Skip to content

Commit

Permalink
merge via autoConfig and version commands
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Dec 14, 2024
1 parent 946df9e commit ce72e3b
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/main/java/com/zenith/command/impl/ViaVersionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CommandUsage commandUsage() {
asList(
"zenithToServer on/off",
"zenithToServer disableOn2b2t on/off",
"zenithToServer autoConfig on/off",
"zenithToServer version auto",
"zenithToServer version <MC version>",
"playerToZenith on/off"
)
Expand All @@ -45,7 +45,7 @@ public LiteralArgumentBuilder<CommandContext> register() {
CONFIG.client.viaversion.enabled = getToggle(c, "toggle");
c.getSource().getEmbed()
.title("Zenith To Server ViaVersion " + toggleStrCaps(CONFIG.client.viaversion.enabled));
return 1;
return OK;
}))
.then(literal("disableOn2b2t")
.then(argument("toggle", toggle()).executes(c -> {
Expand All @@ -59,30 +59,36 @@ public LiteralArgumentBuilder<CommandContext> register() {
CONFIG.client.viaversion.autoProtocolVersion = getToggle(c, "toggle");
c.getSource().getEmbed()
.title("Zenith To Server ViaVersion AutoConfig " + toggleStrCaps(CONFIG.client.viaversion.autoProtocolVersion));
return 1;
return OK;
})))
.then(literal("version")
.then(argument("version", wordWithChars()).executes(c -> {
final String version = StringArgumentType.getString(c, "version");
ProtocolVersion closest = ProtocolVersion.getClosest(version);
if (closest == null) {
c.getSource().getEmbed()
.title("Invalid Version!")
.description("Please select a valid version. Example: 1.19.4")
.errorColor();
if ("auto".equalsIgnoreCase(version)) {
CONFIG.client.viaversion.autoProtocolVersion = true;
} else {
CONFIG.client.viaversion.protocolVersion = closest.getVersion();
c.getSource().getEmbed()
.title("Zenith To Server ViaVersion Version Updated!");
ProtocolVersion closest = ProtocolVersion.getClosest(version);
if (closest == null) {
c.getSource().getEmbed()
.title("Invalid Version!")
.description("Please select a valid version. Example: 1.19.4")
.errorColor();
return OK;
} else {
CONFIG.client.viaversion.protocolVersion = closest.getVersion();
CONFIG.client.viaversion.autoProtocolVersion = false;
}
}
return 1;
c.getSource().getEmbed()
.title("Zenith To Server ViaVersion Version Updated!");
return OK;
}))))
.then(literal("playerToZenith")
.then(argument("toggle", toggle()).executes(c -> {
CONFIG.server.viaversion.enabled = getToggle(c, "toggle");
c.getSource().getEmbed()
.title("Player To Zenith ViaVersion " + toggleStrCaps(CONFIG.server.viaversion.enabled));
return 1;
return OK;
})));
}

Expand All @@ -91,8 +97,9 @@ public void postPopulate(final Embed embedBuilder) {
embedBuilder
.addField("Zenith To Server ViaVersion", toggleStr(CONFIG.client.viaversion.enabled), false)
.addField("Zenith To Server Disable On 2b2t", toggleStr(CONFIG.client.viaversion.disableOn2b2t), false)
.addField("Zenith To Server AutoConfig", toggleStr(CONFIG.client.viaversion.autoProtocolVersion), false)
.addField("Zenith To Server Version", ProtocolVersion.getProtocol(CONFIG.client.viaversion.protocolVersion).getName(), false)
.addField("Zenith To Server Version", CONFIG.client.viaversion.autoProtocolVersion
? "Auto (" + ProtocolVersion.getProtocol(CONFIG.client.viaversion.protocolVersion).getName() + ")"
: ProtocolVersion.getProtocol(CONFIG.client.viaversion.protocolVersion).getName(), false)
.addField("Player To Zenith ViaVersion", toggleStr(CONFIG.server.viaversion.enabled), false)
.primaryColor();
}}

0 comments on commit ce72e3b

Please sign in to comment.