From 51cb99e2b8b692b3b5cf868e4ff8bb0baa9c5354 Mon Sep 17 00:00:00 2001 From: winterflyt <36+winterflyt@noreply.skidsolutions.xyz> Date: Mon, 30 Nov 2026 06:00:23 +0200 Subject: [PATCH] Upload files to "src/openonyx/history" --- src/openonyx/history/DisplayNamed.java | 5 + src/openonyx/history/ModeOption.java | 35 ++++ src/openonyx/history/ModeSetting.java | 230 +++++++++++++++++++++++++ src/openonyx/history/NoneMode.java | 7 + src/openonyx/history/Range.java | 54 ++++++ 5 files changed, 331 insertions(+) create mode 100644 src/openonyx/history/DisplayNamed.java create mode 100644 src/openonyx/history/ModeOption.java create mode 100644 src/openonyx/history/ModeSetting.java create mode 100644 src/openonyx/history/NoneMode.java create mode 100644 src/openonyx/history/Range.java diff --git a/src/openonyx/history/DisplayNamed.java b/src/openonyx/history/DisplayNamed.java new file mode 100644 index 0000000..3da4f88 --- /dev/null +++ b/src/openonyx/history/DisplayNamed.java @@ -0,0 +1,5 @@ +package openonyx.history; + +public interface DisplayNamed { + String getDisplayName(); +} diff --git a/src/openonyx/history/ModeOption.java b/src/openonyx/history/ModeOption.java new file mode 100644 index 0000000..4e2c09f --- /dev/null +++ b/src/openonyx/history/ModeOption.java @@ -0,0 +1,35 @@ +package openonyx.history; + +import java.util.function.BooleanSupplier; + +public class ModeOption extends SettingGroup { + private transient ModeSetting modeSetting; + + public ModeOption describe(String string) { + super.describe(string); + return this; + } + + public boolean isSelected() { + return this.modeSetting != null && this.modeSetting.getValue() == this; + } + + void setOwner(ModeSetting modeSetting) { + this.modeSetting = modeSettingx; + } + + protected ModeOption(String string) { + super(string); + } + + public void select() { + if (this.modeSetting != null) { + this.modeSetting.select(this); + } + } + + public ModeOption visibleWhen(BooleanSupplier booleanSupplier) { + super.visibleWhen(booleanSupplier); + return this; + } +} diff --git a/src/openonyx/history/ModeSetting.java b/src/openonyx/history/ModeSetting.java new file mode 100644 index 0000000..c2f47f5 --- /dev/null +++ b/src/openonyx/history/ModeSetting.java @@ -0,0 +1,230 @@ +package openonyx.history; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.util.Iterator; +import java.util.List; +import java.util.function.BooleanSupplier; +import java.util.function.Consumer; +import java.util.function.Predicate; +import openonyx.core.OnyxClient; +import openonyx.features.Module; +import org.apache.logging.log4j.Logger; + +public class ModeSetting extends SettingValue { + private final List modes; + + public ModeSetting describe(String string) { + super.describe(string); + return this; + } + + public ModeSetting visibleWhen(SettingValue settingValue, Predicate predicate) { + super.visibleWhen(settingValue, predicate); + return this; + } + + public ModeSetting onChange(Consumer consumer) { + super.onChange(consumer); + return this; + } + + public M getMode() { + return this.getValue(); + } + + public void select(ModeOption modeOption) { + ModeSetting modeSetting1 = this; + Iterator iterator = modeSetting1.modes.iterator(); + + while (iterator.hasNext()) { + ModeOption modeOption1; + if ((modeOption1 = (ModeOption)iterator.next()) == modeOption) { + modeSetting1.setMode(modeOption1); + return; + } + } + } + + @Override + public JsonElement toJson() { + ModeSetting modeSetting1 = this; + JsonObject jsonObject1; + (jsonObject1 = new JsonObject()).addProperty("mode", ((ModeOption)modeSetting1.getValue()).getName()); + JsonObject jsonObject = new JsonObject(); + Iterator iterator; + Iterator iterator1 = iterator = modeSetting1.modes.iterator(); + + while (iterator1.hasNext()) { + ModeOption modeOption; + if (!(modeOption = (ModeOption)iterator.next()).hasVisibilityCondition()) { + iterator1 = iterator; + } else { + jsonObject.add(modeOption.getName(), modeOption.toJson()); + iterator1 = iterator; + } + } + + jsonObject1.add("modes", jsonObject); + return jsonObject1; + } + + public ModeSetting visibleWhen(SettingValue settingValue) { + super.visibleWhen(settingValue); + return this; + } + + public List getModes() { + return this.modes; + } + + @Override + public List getSettings() { + return List.copyOf(this.modes); + } + + public boolean is(M modeOption) { + return this.getValue() == modeOption; + } + + @Override + public void fromJson(JsonElement jsonObject) { + ModeSetting modeSetting1 = this; + if (jsonObject.isJsonPrimitive() && jsonObject.getAsJsonPrimitive().isString()) { + modeSetting1.setModeByName(jsonObject.getAsString()); + } else if (jsonObject.isJsonObject()) { + JsonElement jsonElement1; + if ((jsonElement1 = (jsonObject = jsonObject.getAsJsonObject()).get("modes")) != null && jsonElement1.isJsonObject()) { + JsonObject jsonObject1 = jsonElement1.getAsJsonObject(); + Iterator iterator = modeSetting1.modes.iterator(); + + label49: + while (true) { + Iterator iterator1 = iterator; + + while (true) { + if (!iterator1.hasNext()) { + break label49; + } + + ModeOption modeOption; + if (!(modeOption = (ModeOption)iterator.next()).hasVisibilityCondition()) { + iterator1 = iterator; + } else { + JsonElement jsonElement; + if ((jsonElement = jsonObject1.get(modeOption.getName())) == null) { + break; + } + + if (!jsonElement.isJsonNull()) { + try { + modeOption.fromJson(jsonElement); + } catch (RuntimeException runtimeException) { + Logger logger = OnyxClient.LOGGER; + Object[] objects = new Object[2]; + boolean bl = true; + objects[0] = modeOption.getPath(); + objects[1] = runtimeException; + logger.warn("Failed to load mode '{}'", objects); + } + break; + } + + iterator1 = iterator; + } + } + } + } + + JsonElement jsonElement2; + if ((jsonElement2 = jsonObject.get("mode")) != null && jsonElement2.isJsonPrimitive() && jsonElement2.getAsJsonPrimitive().isString()) { + modeSetting1.setModeByName(jsonElement2.getAsString()); + } + } + } + + public void setModeByName(String string) { + ModeSetting modeSetting1 = this; + string = normalize(string); + Iterator iterator = modeSetting1.modes.iterator(); + + while (iterator.hasNext()) { + ModeOption modeOption; + if (normalize((modeOption = (ModeOption)iterator.next()).getName()).equals(string)) { + modeSetting1.setMode(modeOption); + return; + } + } + } + + @Override + public void setActive(boolean bl) { + ModeSetting modeSetting1 = this; + + for (Iterator iterator1 = iterator = modeSetting1.modes.iterator(); iterator1.hasNext(); iterator1 = iterator) { + ModeOption modeOption; + (modeOption = (ModeOption)iterator.next()).setActive(bl && modeOption == modeSetting1.getValue()); + } + } + + public ModeSetting visibleWhen(BooleanSupplier booleanSupplier) { + super.visibleWhen(booleanSupplier); + return this; + } + + @Override + public void attach(Module module, Setting setting) { + super.attach(module, setting); + Iterator iterator; + Iterator iterator1 = iterator = this.modes.iterator(); + + while (iterator1.hasNext()) { + ModeOption modeOption = (ModeOption)iterator.next(); + iterator1 = iterator; + modeOption.setOwner(this); + modeOption.attach(module, this); + } + } + + @SafeVarargs + public ModeSetting(String string, M modeOption, M... modeOptions) { + super(string, (M)modeOption); + this.modes = List.of((M[])modeOptions); + if (!this.modes.contains(modeOption)) { + throw new IllegalArgumentException( + new StringBuilder().insert(0, "Default mode '").append(modeOption.getName()).append("' is not part of '").append(string).append("'").toString() + ); + } + } + + public void setMode(M modeOption) { + ModeSetting modeSetting1 = this; + ModeOption modeOption1 = (ModeOption)modeSetting1.getValue(); + modeSetting1.setValue(modeOption); + if (modeSetting1.getValue() != modeOption1) { + modeSetting1.notifyChanged(); + } + } + + private static String normalize(String string) { + String string1 = string; + if (string1 == null) { + return ""; + } + + StringBuilder stringBuilder = new StringBuilder(string1.length()); + + for (int j = i = 0; j < string1.length(); j = ++i) { + char c; + if (Character.isLetterOrDigit(c = string1.charAt(i))) { + stringBuilder.append(Character.toLowerCase(c)); + } + } + + return stringBuilder.toString(); + } + + public boolean is(String string) { + return this.getValue().getName().equals(string); + } +} diff --git a/src/openonyx/history/NoneMode.java b/src/openonyx/history/NoneMode.java new file mode 100644 index 0000000..28fd3e1 --- /dev/null +++ b/src/openonyx/history/NoneMode.java @@ -0,0 +1,7 @@ +package openonyx.history; + +public class NoneMode extends ModeOption { + public NoneMode() { + super("None"); + } +} diff --git a/src/openonyx/history/Range.java b/src/openonyx/history/Range.java new file mode 100644 index 0000000..1ffbe74 --- /dev/null +++ b/src/openonyx/history/Range.java @@ -0,0 +1,54 @@ +package openonyx.history; + +public record Range(double min, double max) { + public Range(double d, double e) { + if (min > max) { + double f = min; + min = max; + max = f; + } + + this.min = min; + this.max = max; + } + + public static String decrypt(String string) { + String string1 = string; + int n = (4 ^ 5) << 3 ^ 2; + String string2; + int p = (string2 = string1).length(); + char[] e = new char[p]; + boolean bl = true; + int j; + int o = j = p - 1; + char[] c = e; + byte b = 99; + byte d = 100; + int k = o; + int i = n; + + while (k >= 0) { + int l = j; + int m = string2.charAt(j); + j--; + c[l] = (char)(m ^ i); + if (j < 0) { + break; + } + + m = j--; + c[m] = (char)(string2.charAt(m) ^ b); + k = j; + } + + return new String(c); + } + + public boolean L(double d) { + return d >= this.min && d <= this.max; + } + + public double d() { + return this.max - this.min; + } +}