Skip to content

Commit 9e5dc13

Browse files
committed
change config from record to class with default fields
1 parent 5879822 commit 9e5dc13

4 files changed

Lines changed: 12 additions & 19 deletions

File tree

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
package org.lime.velocircon;
22

3-
public record RconConfig(
4-
boolean enable,
5-
String host,
6-
int port,
7-
String password,
8-
boolean colors
9-
) {
10-
public static final RconConfig DEFAULT = new RconConfig(
11-
false,
12-
"0.0.0.0",
13-
25575,
14-
"PASSWORD",
15-
true);
3+
public class RconConfig {
4+
public boolean enable = false;
5+
public String host = "0.0.0.0";
6+
public int port = 25575;
7+
public String password = "PASSWORD";
8+
public boolean colors = true;
169
}

src/main/java/org/lime/velocircon/RconService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public RconService(Object plugin, ProxyServer server, ConfigLoader<RconConfig> c
4444

4545
public CompletableFuture<Void> reloadConfig() throws IOException {
4646
RconConfig config = configLoader.load();
47-
InetSocketAddress address = new InetSocketAddress(config.host(), config.port());
47+
InetSocketAddress address = new InetSocketAddress(config.host, config.port);
4848

4949
return disable()
5050
.handle((disabled, e) -> {
51-
if (!config.enable())
51+
if (!config.enable)
5252
return CompletableFuture.completedFuture((Void)null);
53-
this.password = config.password();
53+
this.password = config.password;
5454
return this.binder.bind(address, config)
5555
.handle((channel, ex) -> {
5656
if (channel != null)

src/main/java/org/lime/velocircon/Velocircon.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Velocircon(
4040
this.dataFolder = dataFolder;
4141
this.metricsFactory = metricsFactory;
4242

43-
this.rconService = new RconService(this, proxy, ConfigLoader.create(dataFolder, "rcon", RconConfig.DEFAULT), logger);
43+
this.rconService = new RconService(this, proxy, ConfigLoader.create(dataFolder, "rcon", new RconConfig()), logger);
4444
}
4545

4646
@Subscribe

src/main/java/org/lime/velocircon/server/RconConnectionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ private void handlePacket(ChannelHandlerContext ctx, int requestId, int requestT
9090
result = Component.text("Error executing: " + payload + " (" + ex.getMessage() + ")")
9191
.color(NamedTextColor.RED);
9292
}
93-
String postfix = config.colors()
93+
String postfix = config.colors
9494
? LegacyComponentSerializer.SECTION_CHAR + "r"
9595
: "";
96-
ComponentEncoder<Component, String> encoder = config.colors()
96+
ComponentEncoder<Component, String> encoder = config.colors
9797
? LegacyComponentSerializer.legacySection()
9898
: PlainTextComponentSerializer.plainText();
9999
sendResponse(ctx, requestId, PacketType.COMMAND_RESPONSE, encoder.serialize(result) + postfix);

0 commit comments

Comments
 (0)