Upload files to "src/openonyx/history"
This commit is contained in:
1 parent
b8d038597f
commit
51cb99e2b8
5 files changed
+331
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
package openonyx.history;
|
||||||
|
|
||||||
|
public interface DisplayNamed {
|
||||||
|
String getDisplayName();
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<M extends ModeOption> extends SettingValue<M> {
|
||||||
|
private final List<M> modes;
|
||||||
|
|
||||||
|
public ModeSetting<M> describe(String string) {
|
||||||
|
super.describe(string);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <O> ModeSetting<M> visibleWhen(SettingValue<O> settingValue, Predicate<O> predicate) {
|
||||||
|
super.visibleWhen(settingValue, predicate);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModeSetting<M> onChange(Consumer<M> 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<M> visibleWhen(SettingValue<Boolean> settingValue) {
|
||||||
|
super.visibleWhen(settingValue);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<M> getModes() {
|
||||||
|
return this.modes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Setting> 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<M> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package openonyx.history;
|
||||||
|
|
||||||
|
public class NoneMode extends ModeOption {
|
||||||
|
public NoneMode() {
|
||||||
|
super("None");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user