moved toggle sit keybind logic to Logic.java

This commit is contained in:
Oth3r 2024-09-29 11:36:18 -05:00
commit 9fd0ee1d6a
2 changed files with 36 additions and 27 deletions

View file

@ -45,33 +45,7 @@ public class Events {
private static void loopLogic(ClientPlayerEntity player) {
while (toggle_key.wasPressed()) {
if (Data.isInGame()) {
// todo move to logic.java
if (Data.isSupportedServer()) {
// get the sitting config
SittingConfig config = FileData.getSittingConfig();
// toggle the setting
config.setEnabled(!config.getEnabled());
// set the sitting config to the new value
FileData.setSittingConfig(config);
// save the changes to the file
config.save();
// send the changes to the server
Utl.sendSettingsPackets();
// get the message settings
String messageKey = "msg.sit_toggle."+(config.getEnabled()?"on":"off");
Formatting messageColor = config.getEnabled()?Formatting.GREEN:Formatting.RED;
// send the player the actionbar message
player.sendMessage(Utl.lang("msg.sit_toggle",
Utl.lang(messageKey).formatted(messageColor)), true);
} else {
// unsupported server message if not in a Sit! server
player.sendMessage(Utl.lang("msg.unsupported")
.formatted(Formatting.RED), true);
}
player.sendMessage(Logic.toggleSiting(), true);
}
}