aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java337
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Optional.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/BooleanParser.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/gui/OneUIScreen.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java12
9 files changed, 264 insertions, 134 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
index 7ec5ee5..0f50a33 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
@@ -1,14 +1,14 @@
package cc.polyfrost.oneconfig.utils;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
-import gg.essential.universal.UResolution;
+import cc.polyfrost.oneconfig.libs.universal.UResolution;
import org.lwjgl.input.Mouse;
/**
* Various utility methods for input.
* <p>
* All values returned from this class are not scaled to Minecraft's GUI scale.
- * For scaled values, see {@link gg.essential.universal.UMouse}.
+ * For scaled values, see {@link cc.polyfrost.oneconfig.libs.universal.UMouse}.
* </p>
*/
public final class InputUtils {
@@ -78,7 +78,7 @@ public final class InputUtils {
* Gets the current mouse X position.
* <p>
* All values returned from this class are not scaled to Minecraft's GUI scale.
- * For scaled values, see {@link gg.essential.universal.UMouse}.
+ * For scaled values, see {@link cc.polyfrost.oneconfig.libs.universal.UMouse}.
* </p>
*
* @return the current mouse X position
@@ -92,7 +92,7 @@ public final class InputUtils {
* Gets the current mouse Y position.
* <p>
* All values returned from this class are not scaled to Minecraft's GUI scale.
- * For scaled values, see {@link gg.essential.universal.UMouse}.
+ * For scaled values, see {@link cc.polyfrost.oneconfig.libs.universal.UMouse}.
* </p>
*
* @return the current mouse Y position
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java
index 5578e1e..b99d096 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java
@@ -1,7 +1,7 @@
package cc.polyfrost.oneconfig.utils;
import com.google.gson.JsonElement;
-import gg.essential.universal.UDesktop;
+import cc.polyfrost.oneconfig.libs.universal.UDesktop;
import org.apache.commons.io.IOUtils;
import java.io.*;
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
index 6cda00c..b51ee85 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
@@ -3,7 +3,7 @@ package cc.polyfrost.oneconfig.utils;
import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.Stage;
import cc.polyfrost.oneconfig.events.event.TickEvent;
-import me.kbrewster.eventbus.Subscribe;
+import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
/**
* Schedules a Runnable to be called after a certain amount of ticks.
@@ -13,7 +13,7 @@ public class TickDelay {
private int delay;
public TickDelay(Runnable functionName, int ticks) {
- EventManager.getEventManager().register(this);
+ EventManager.INSTANCE.register(this);
delay = ticks;
function = functionName;
}
@@ -24,7 +24,7 @@ public class TickDelay {
// Delay expired
if (delay < 1) {
function.run();
- EventManager.getEventManager().unregister(this);
+ EventManager.INSTANCE.unregister(this);
}
delay--;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java
index 32bbf5d..004f427 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java
@@ -1,15 +1,17 @@
package cc.polyfrost.oneconfig.utils.commands;
-import cc.polyfrost.oneconfig.utils.commands.annotations.Command;
-import cc.polyfrost.oneconfig.utils.commands.annotations.Greedy;
-import cc.polyfrost.oneconfig.utils.commands.annotations.Main;
-import cc.polyfrost.oneconfig.utils.commands.annotations.SubCommand;
+import cc.polyfrost.oneconfig.utils.commands.annotations.*;
import cc.polyfrost.oneconfig.utils.commands.arguments.*;
-import gg.essential.universal.ChatColor;
-import gg.essential.universal.UChat;
+import cc.polyfrost.oneconfig.libs.universal.ChatColor;
+import cc.polyfrost.oneconfig.libs.universal.UChat;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
+import net.minecraft.util.BlockPos;
import net.minecraftforge.client.ClientCommandHandler;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.ImmutableTriple;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.commons.lang3.tuple.Triple;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -25,19 +27,20 @@ import java.util.*;
public class CommandManager {
public static final CommandManager INSTANCE = new CommandManager();
private static final String NOT_FOUND_TEXT = "Command not found! Type /@ROOT_COMMAND@ help for help.";
+ private static final String TOO_MANY_PARAMETERS = "There were too many / little parameters for this command! Type /@ROOT_COMMAND@ help for help.";
private static final String METHOD_RUN_ERROR = "Error while running @ROOT_COMMAND@ method! Please report this to the developer.";
private final HashMap<Class<?>, ArgumentParser<?>> parsers = new HashMap<>();
private CommandManager() {
addParser(new StringParser());
addParser(new IntegerParser());
- addParser(new IntegerParser(), int.class);
+ addParser(new IntegerParser(), Integer.TYPE);
addParser(new DoubleParser());
- addParser(new DoubleParser(), double.class);
+ addParser(new DoubleParser(), Double.TYPE);
addParser(new FloatParser());
- addParser(new FloatParser(), float.class);
+ addParser(new FloatParser(), Float.TYPE);
addParser(new BooleanParser());
- addParser(new BooleanParser(), boolean.class);
+ addParser(new BooleanParser(), Boolean.TYPE);
}
/**
@@ -89,62 +92,7 @@ public class CommandManager {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if (args.length == 0) {
- if (!root.invokers.isEmpty()) {
- try {
- root.invokers.get(0).method.invoke(null);
- } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException |
- ExceptionInInitializerError e) {
- e.printStackTrace();
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
- }
- }
- } else {
- if (annotation.helpCommand() && args[0].equalsIgnoreCase("help")) {
- //UChat.chat(sendHelpCommand(root));
- } else {
- List<InternalCommand.InternalCommandInvoker> commands = new ArrayList<>();
- int depth = 0;
- for (InternalCommand command : root.children) {
- int newDepth = loopThroughCommands(commands, 0, command, args, true);
- if (newDepth != -1) {
- depth = newDepth;
- break;
- }
- }
- System.out.println(depth);
- System.out.println(commands);
- if (commands.isEmpty()) {
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + NOT_FOUND_TEXT.replace("@ROOT_COMMAND@", annotation.value()));
- } else {
- List<CustomError> errors = new ArrayList<>();
- for (InternalCommand.InternalCommandInvoker invoker : commands) {
- try {
- List<Object> params = getParametersForInvoker(invoker, depth, args);
- if (params.size() == 1) {
- Object first = params.get(0);
- if (first instanceof CustomError) {
- errors.add((CustomError) first);
- continue;
- }
- }
- invoker.method.invoke(null, params.toArray());
- return;
- } catch (Exception e) {
- e.printStackTrace();
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
- return;
- }
- }
- if (!errors.isEmpty()) {
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + "Multiple errors occurred:");
- for (CustomError error : errors) {
- UChat.chat(" " + ChatColor.RED + ChatColor.BOLD + error.message);
- }
- }
- }
- }
- }
+ handleCommand(root, annotation, args);
}
@Override
@@ -152,36 +100,157 @@ public class CommandManager {
return -1;
}
- /*/
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
- List<InternalCommand.InternalCommandInvoker> commands = new ArrayList<>();
- int depth = 0;
- for (InternalCommand command : root.children) {
- int newDepth = loopThroughCommands(commands, 0, command, args, false);
- if (newDepth != -1) {
- depth = newDepth;
- break;
+ return handleTabCompletion(root, annotation, args);
+ }
+ });
+ }
+ }
+
+ private void handleCommand(InternalCommand root, Command annotation, String[] args) {
+ if (args.length == 0) {
+ if (!root.invokers.isEmpty()) {
+ try {
+ root.invokers.get(0).method.invoke(null);
+ } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException |
+ ExceptionInInitializerError e) {
+ e.printStackTrace();
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
+ }
+ }
+ } else {
+ if (annotation.helpCommand() && args[0].equalsIgnoreCase("help")) {
+ UChat.chat(sendHelpCommand(root));
+ } else {
+ List<InternalCommand.InternalCommandInvoker> commands = new ArrayList<>();
+ int depth = 0;
+ for (InternalCommand command : root.children) {
+ int newDepth = loopThroughCommands(commands, 0, command, args);
+ if (newDepth != -1) {
+ depth = newDepth;
+ break;
+ }
+ }
+ if (commands.isEmpty()) {
+ if (depth == -2) {
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + TOO_MANY_PARAMETERS.replace("@ROOT_COMMAND@", annotation.value()));
+ } else {
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + NOT_FOUND_TEXT.replace("@ROOT_COMMAND@", annotation.value()));
+ }
+ } else {
+ List<CustomError> errors = new ArrayList<>();
+ for (InternalCommand.InternalCommandInvoker invoker : commands) {
+ try {
+ List<Object> params = getParametersForInvoker(invoker, depth, args);
+ if (params.size() == 1) {
+ Object first = params.get(0);
+ if (first instanceof CustomError) {
+ errors.add((CustomError) first);
+ continue;
+ }
+ }
+ invoker.method.invoke(null, params.toArray());
+ return;
+ } catch (Exception e) {
+ e.printStackTrace();
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
+ return;
+ }
+ }
+ //noinspection ConstantConditions
+ if (!errors.isEmpty()) {
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + "Multiple errors occurred:");
+ for (CustomError error : errors) {
+ UChat.chat(" " + ChatColor.RED + ChatColor.BOLD + error.message);
}
}
- System.out.println(depth);
- System.out.println(commands);
- if (!commands.isEmpty()) {
- for (InternalCommand.InternalCommandInvoker invoker : commands) {
- try {
- List<Object> params = getParametersForInvoker(invoker, depth, args);
- invoker.method.invoke(null, params.toArray());
- return;
- } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+ private List<String> handleTabCompletion(InternalCommand root, Command annotation, String[] args) {
+ try {
+ Set<Pair<InternalCommand.InternalCommandInvoker, Integer>> commands = new HashSet<>();
+ for (InternalCommand command : root.children) {
+ loopThroughCommandsTab(commands, 0, command, args);
+ }
+ if (!commands.isEmpty() || annotation.helpCommand()) {
+ List<Triple<InternalCommand.InternalCommandInvoker, Integer, Integer>> validCommands = new ArrayList<>(); // command, depth, and all processed params
+ for (Pair<InternalCommand.InternalCommandInvoker, Integer> pair : commands) {
+ InternalCommand.InternalCommandInvoker invoker = pair.getLeft();
+ int depth = pair.getRight();
+ int currentParam = 0;
+ boolean failed = false;
+ while (args.length - depth > 1) {
+ Parameter param = invoker.method.getParameters()[currentParam];
+ if (param.isAnnotationPresent(Greedy.class) && currentParam + 1 != invoker.parameterTypes.length) {
+ failed = true;
+ break;
+ }
+ ArgumentParser<?> parser = parsers.get(param.getType());
+ if (parser == null) {
+ failed = true;
+ break;
+ }
+ try {
+ Arguments arguments = new Arguments(Arrays.copyOfRange(args, depth, args.length), param.isAnnotationPresent(Greedy.class));
+ if (parser.parse(arguments) != null) {
+ depth += arguments.getPosition();
+ currentParam++;
+ } else {
+ failed = true;
+ break;
}
+ } catch (Exception e) {
+ failed = true;
+ break;
}
}
+ if (!failed) {
+ validCommands.add(new ImmutableTriple<>(pair.getLeft(), depth, currentParam));
+ }
}
+ if (!validCommands.isEmpty() || annotation.helpCommand()) {
+ Set<String> completions = new HashSet<>();
+ for (Triple<InternalCommand.InternalCommandInvoker, Integer, Integer> valid : validCommands) {
+ if (valid.getMiddle() == args.length) {
+ completions.add(valid.getLeft().name);
+ completions.addAll(Arrays.asList(valid.getLeft().aliases));
+ continue;
+ }
+ if (valid.getRight() + 1 > valid.getLeft().parameterTypes.length) continue;
+ Parameter param = valid.getLeft().method.getParameters()[valid.getRight()];
+ if (param.isAnnotationPresent(Greedy.class) && valid.getRight() + 1 != valid.getLeft().parameterTypes.length) {
+ continue;
+ }
+ ArgumentParser<?> parser = parsers.get(param.getType());
+ if (parser == null) {
+ continue;
+ }
+ try {
+ Arguments arguments = new Arguments(Arrays.copyOfRange(args, valid.getMiddle(), args.length), param.isAnnotationPresent(Greedy.class));
+ List<String> possibleCompletions = parser.complete(arguments, param);
+ if (possibleCompletions != null) {
+ completions.addAll(possibleCompletions);
+ }
+ } catch (Exception ignored) {
+
+ }
+ }
+ if (args.length == 1 && annotation.helpCommand()) {
+ if ("help".startsWith(args[0].toLowerCase(Locale.ENGLISH))) {
+ completions.add("help");
+ }
+ }
+ return new ArrayList<>(completions);
+ }
+ }
+ } catch (Exception ignored) {
- */
- });
}
+ return null;
}
private List<Object> getParametersForInvoker(InternalCommand.InternalCommandInvoker invoker, int depth, String[] args) {
@@ -190,7 +259,7 @@ public class CommandManager {
int currentParam = 0;
while (processed < args.length) {
Parameter param = invoker.method.getParameters()[currentParam];
- if (param.isAnnotationPresent(Greedy.class) && currentParam + 1 != invoker.method.getParameterCount()) {
+ if (param.isAnnotationPresent(Greedy.class) && currentParam + 1 != invoker.parameterTypes.length) {
return Collections.singletonList(new CustomError("Parsing failed: Greedy parameter must be the last one."));
}
ArgumentParser<?> parser = parsers.get(param.getType());
@@ -218,36 +287,98 @@ public class CommandManager {
return parameters;
}
- private int loopThroughCommands(List<InternalCommand.InternalCommandInvoker> commands, int depth, InternalCommand command, String[] args, boolean checkParams) {
+ private int loopThroughCommands(List<InternalCommand.InternalCommandInvoker> commands, int depth, InternalCommand command, String[] args) {
int nextDepth = depth + 1;
- if (command.isEqual(args[depth])) {
+ boolean thatOneSpecialError = false;
+ if (command.isValid(args[depth], false)) {
for (InternalCommand child : command.children) {
- if (args.length > nextDepth && child.isEqual(args[nextDepth])) {
- int result = loopThroughCommands(commands, nextDepth, child, args, checkParams);
- if (result != -1) {
+ if (args.length > nextDepth && child.isValid(args[nextDepth], false)) {
+ int result = loopThroughCommands(commands, nextDepth, child, args);
+ if (result > -1) {
return result;
+ } else if (result == -2) {
+ thatOneSpecialError = true;
}
}
}
boolean added = false;
for (InternalCommand.InternalCommandInvoker invoker : command.invokers) {
- if (!checkParams || args.length - nextDepth == invoker.method.getParameterCount()) {
+ if (args.length - nextDepth == invoker.parameterTypes.length) {
commands.add(invoker);
added = true;
+ } else {
+ thatOneSpecialError = true;
}
}
if (added) {
return nextDepth;
}
- } else {
- for (InternalCommand child : command.children) {
- int childDepth = loopThroughCommands(commands, nextDepth, child, args, checkParams);
- if (childDepth != -1) {
- return childDepth;
+ }
+ return thatOneSpecialError ? -2 : -1;
+ }
+
+ private void loopThroughCommandsTab(Set<Pair<InternalCommand.InternalCommandInvoker, Integer>> commands, int depth, InternalCommand command, String[] args) {
+ int nextDepth = depth + 1;
+ if (command.isValid(args[depth], args.length == nextDepth)) {
+ if (args.length != nextDepth) {
+ for (InternalCommand child : command.children) {
+ if (child.isValid(args[nextDepth], args.length == nextDepth + 1)) {
+ loopThroughCommandsTab(commands, nextDepth, child, args);
+ }
}
}
+ for (InternalCommand.InternalCommandInvoker invoker : command.invokers) {
+ commands.add(new ImmutablePair<>(invoker, nextDepth));
+ }
+ }
+ }
+
+ //TODO: someone make the help command actually look nice lmao
+ private String sendHelpCommand(InternalCommand root) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(ChatColor.GOLD).append("Help for ").append(ChatColor.BOLD).append(root.name).append(ChatColor.RESET).append(ChatColor.GOLD).append(":\n");
+ if (!root.description.isEmpty()) {
+ builder.append("\n").append(ChatColor.GOLD).append("Description: ").append(ChatColor.BOLD).append(root.description);
+ }
+ for (InternalCommand command : root.children) {
+ runThroughCommandsHelp(root.name, command, builder);
+ }
+ builder.append("\n").append(ChatColor.GOLD).append("Aliases: ").append(ChatColor.BOLD);
+ int index = 0;
+ for (String alias : root.aliases) {
+ ++index;
+ builder.append(alias).append(index < root.aliases.length ? ", " : "");
+ }
+ builder.append("\n");
+ return builder.toString();
+ }
+
+ private void runThroughCommandsHelp(String append, InternalCommand command, StringBuilder builder) {
+ if (!command.invokers.isEmpty()) {
+ Class<?> declaringClass = command.invokers.get(0).method.getDeclaringClass();
+ if (declaringClass.isAnnotationPresent(SubCommand.class)) {
+ String description = declaringClass.getAnnotation(SubCommand.class).description();
+ if (!description.isEmpty()) {
+ builder.append("\n").append(ChatColor.GOLD).append("Description: ").append(ChatColor.BOLD).append(description);
+ }
+ }
+ }
+ for (InternalCommand.InternalCommandInvoker invoker : command.invokers) {
+ builder.append("\n").append(ChatColor.GOLD).append("/").append(append).append(" ").append(command.name);
+ for (Parameter parameter : invoker.method.getParameters()) {
+ String name = parameter.getName();
+ if (parameter.isAnnotationPresent(Name.class)) {
+ name = parameter.getAnnotation(Name.class).value();
+ }
+ builder.append(" <").append(name).append(">");
+ }
+ if (!command.description.trim().isEmpty()) {
+ builder.append(": ").append(ChatColor.BOLD).append(command.description);
+ }
+ }
+ for (InternalCommand subCommand : command.children) {
+ runThroughCommandsHelp(append + " " + command.name, subCommand, builder);
}
- return -1;
}
private void addToInvokers(Class<?>[] classes, InternalCommand parent) {
@@ -289,12 +420,15 @@ public class CommandManager {
this.parent = parent;
}
- public boolean isEqual(String name) {
- if (this.name.equals(name)) {
+ public boolean isValid(String name, boolean tabCompletion) {
+ String lowerCaseName = this.name.toLowerCase(Locale.ENGLISH);
+ String lowerCaseOtherName = name.toLowerCase(Locale.ENGLISH);
+ if (!tabCompletion ? lowerCaseName.equals(lowerCaseOtherName) : lowerCaseName.startsWith(lowerCaseOtherName)) {
return true;
} else {
for (String alias : aliases) {
- if (alias.equals(name)) {
+ String lowerCaseAlias = alias.toLowerCase(Locale.ENGLISH);
+ if (!tabCompletion ? lowerCaseAlias.equals(lowerCaseOtherName) : lowerCaseAlias.startsWith(lowerCaseOtherName)) {
return true;
}
}
@@ -345,3 +479,4 @@ public class CommandManager {
}
}
}
+
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Optional.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Optional.java
deleted file mode 100644
index 4dbe8b5..0000000
--- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Optional.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package cc.polyfrost.oneconfig.utils.commands.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.PARAMETER})
-public @interface Optional {
-
-}
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/BooleanParser.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/BooleanParser.java
index 7411cbe..ede83fb 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/BooleanParser.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/BooleanParser.java
@@ -13,7 +13,14 @@ public class BooleanParser extends ArgumentParser<Boolean> {
@Override
public @Nullable Boolean parse(Arguments arguments) {
- return Boolean.parseBoolean(arguments.poll());
+ String next = arguments.poll();
+ if (next.equalsIgnoreCase("true")) {
+ return true;
+ } else if (next.equalsIgnoreCase("false")) {
+ return false;
+ } else {
+ return null;
+ }
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java
index c80814f..d7b3bea 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java
@@ -4,9 +4,9 @@ import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.RenderEvent;
import cc.polyfrost.oneconfig.events.event.Stage;
import cc.polyfrost.oneconfig.utils.TickDelay;
-import gg.essential.universal.UMinecraft;
-import gg.essential.universal.UScreen;
-import me.kbrewster.eventbus.Subscribe;
+import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
+import cc.polyfrost.oneconfig.libs.universal.UScreen;
+import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import net.minecraft.client.gui.GuiScreen;
/**
@@ -17,7 +17,7 @@ public final class GuiUtils {
private static long deltaTime = 17L;
static {
- EventManager.getEventManager().register(new GuiUtils());
+ EventManager.INSTANCE.register(new GuiUtils());
}
/**
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/gui/OneUIScreen.java b/src/main/java/cc/polyfrost/oneconfig/utils/gui/OneUIScreen.java
index c06f6f3..7459224 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/gui/OneUIScreen.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/gui/OneUIScreen.java
@@ -2,8 +2,8 @@ package cc.polyfrost.oneconfig.utils.gui;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.utils.InputUtils;
-import gg.essential.universal.UMatrixStack;
-import gg.essential.universal.UScreen;
+import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
+import cc.polyfrost.oneconfig.libs.universal.UScreen;
import net.minecraft.client.gui.GuiScreen;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Mouse;
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java
index 36dc46c..df5211b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java
@@ -8,11 +8,11 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import gg.essential.universal.UChat;
-import gg.essential.universal.UMinecraft;
-import gg.essential.universal.wrappers.UPlayer;
-import gg.essential.universal.wrappers.message.UTextComponent;
-import me.kbrewster.eventbus.Subscribe;
+import cc.polyfrost.oneconfig.libs.universal.UChat;
+import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
+import cc.polyfrost.oneconfig.libs.universal.wrappers.UPlayer;
+import cc.polyfrost.oneconfig.libs.universal.wrappers.message.UTextComponent;
+import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
@@ -123,7 +123,7 @@ public class HypixelUtils {
previousLocraw = parsed;
inGame = true; // If your gamemode does not return "lobby", boolean inGame is true.
}
- EventManager.getEventManager().post(new LocrawEvent(locraw));
+ EventManager.INSTANCE.post(new LocrawEvent(locraw));
event.isCancelled = true;
}
} catch (Exception ex) {