higher priority

This commit is contained in:
Leijurv 2018-09-17 10:38:37 -07:00
parent b3654492be
commit 043dd80e28
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -69,6 +69,59 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
} }
msg = msg.substring(1); msg = msg.substring(1);
} }
List<Settings.Setting<Boolean>> toggleable = Baritone.settings().getAllValuesByType(Boolean.class);
for (Settings.Setting<Boolean> setting : toggleable) {
if (msg.equalsIgnoreCase(setting.getName())) {
setting.value ^= true;
event.cancel();
logDirect("Toggled " + setting.getName() + " to " + setting.value);
return;
}
}
if (msg.equals("baritone") || msg.equals("settings")) {
for (Settings.Setting<?> setting : Baritone.settings().allSettings) {
logDirect(setting.toString());
}
event.cancel();
return;
}
if (msg.contains(" ")) {
String[] data = msg.split(" ");
if (data.length == 2) {
Settings.Setting setting = Baritone.settings().byLowerName.get(data[0]);
if (setting != null) {
try {
if (setting.value.getClass() == Long.class) {
setting.value = Long.parseLong(data[1]);
}
if (setting.value.getClass() == Integer.class) {
setting.value = Integer.parseInt(data[1]);
}
if (setting.value.getClass() == Double.class) {
setting.value = Double.parseDouble(data[1]);
}
if (setting.value.getClass() == Float.class) {
setting.value = Float.parseFloat(data[1]);
}
} catch (NumberFormatException e) {
logDirect("Unable to parse " + data[1]);
event.cancel();
return;
}
logDirect(setting.toString());
event.cancel();
return;
}
}
}
if (Baritone.settings().byLowerName.containsKey(msg)) {
Settings.Setting<?> setting = Baritone.settings().byLowerName.get(msg);
logDirect(setting.toString());
event.cancel();
return;
}
if (msg.startsWith("goal")) { if (msg.startsWith("goal")) {
event.cancel(); event.cancel();
String[] params = msg.substring(4).trim().split(" "); String[] params = msg.substring(4).trim().split(" ");
@ -369,56 +422,5 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
event.cancel(); event.cancel();
return; return;
} }
List<Settings.Setting<Boolean>> toggleable = Baritone.settings().getAllValuesByType(Boolean.class);
for (Settings.Setting<Boolean> setting : toggleable) {
if (msg.equalsIgnoreCase(setting.getName())) {
setting.value ^= true;
event.cancel();
logDirect("Toggled " + setting.getName() + " to " + setting.value);
return;
}
}
if (msg.equals("baritone") || msg.equals("settings")) {
for (Settings.Setting<?> setting : Baritone.settings().allSettings) {
logDirect(setting.toString());
}
event.cancel();
return;
}
if (msg.contains(" ")) {
String[] data = msg.split(" ");
if (data.length == 2) {
Settings.Setting setting = Baritone.settings().byLowerName.get(data[0]);
if (setting != null) {
try {
if (setting.value.getClass() == Long.class) {
setting.value = Long.parseLong(data[1]);
}
if (setting.value.getClass() == Integer.class) {
setting.value = Integer.parseInt(data[1]);
}
if (setting.value.getClass() == Double.class) {
setting.value = Double.parseDouble(data[1]);
}
if (setting.value.getClass() == Float.class) {
setting.value = Float.parseFloat(data[1]);
}
} catch (NumberFormatException e) {
logDirect("Unable to parse " + data[1]);
event.cancel();
return;
}
logDirect(setting.toString());
event.cancel();
return;
}
}
}
if (Baritone.settings().byLowerName.containsKey(msg)) {
Settings.Setting<?> setting = Baritone.settings().byLowerName.get(msg);
logDirect(setting.toString());
event.cancel();
return;
}
} }
} }