Upload files to "src/openonyx/commands"

This commit is contained in:
winterflyt committed 2026-11-30 05:42:46 +02:00
1 parent 1014f38838
commit 9b128ab3bb
2 files changed
+160

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
package openonyx.commands;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import openonyx.core.MinecraftAccess;
public abstract class Command implements MinecraftAccess {
private final String[] i;
private final String f;
private final String H;
private final String e;
public String D() {
return this.e;
}
public abstract void L(String[] strings);
public boolean L(String string) {
Command command1 = this;
if (command1.f.equalsIgnoreCase(string)) {
return true;
}
String[] strings = command1.i;
int ix = command1.i.length;
for (int k = j = 0; k < ix; k = ++j) {
if (strings[j].equalsIgnoreCase(string)) {
return true;
}
}
return false;
}
public static void d(String string) {
L(new ChatComponentText(string).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
}
protected Command(String string, String string1, String string2, String... strings) {
this.f = string;
this.e = string1;
this.H = string2;
this.i = strings;
}
public static void L(IChatComponent iChatComponent) {
if (mc.ingameGUI != null) {
mc.ingameGUI
.getChatGUI()
.printChatMessage(
new ChatComponentText("")
.appendSibling(new ChatComponentText("[").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY)))
.appendSibling(new ChatComponentText("onyx").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)))
.appendSibling(new ChatComponentText("] ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY)))
.appendSibling(iChatComponent)
);
}
}
public static void L(String string) {
L(new ChatComponentText(string).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GRAY)));
}
public String[] L() {
return this.i;
}
public String d() {
return this.H;
}
public String L() {
return this.f;
}
}
+81
View File
@@ -0,0 +1,81 @@
package openonyx.commands;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import openonyx.commands.internal.ConfigCommand;
import openonyx.core.OnyxClient;
import org.apache.logging.log4j.Logger;
public class CommandManager {
public ConfigCommand configCommand;
public static final String H = ".";
private final ArrayList<Command> commands;
public boolean L(String string) {
if (string == null) {
return false;
}
if (!(string = string.trim()).startsWith(".")) {
return false;
}
if ((string = string.substring(".".length()).trim()).isEmpty()) {
return false;
}
String[] strings;
String string1 = (strings = string.split("\\s+"))[0];
String[] strings1 = Arrays.copyOfRange(strings, 1, strings.length);
Iterator iterator;
for (Iterator iterator1 = iterator = this.commands.iterator(); iterator1.hasNext(); iterator1 = iterator) {
Command command;
if ((command = (Command)iterator.next()).L(string1)) {
try {
command.L(strings1);
} catch (Exception exception) {
Command.d(new StringBuilder().insert(0, "Command failed: ").append(exception).toString());
Logger logger = OnyxClient.LOGGER;
Object[] objects = new Object[2];
boolean bl = true;
objects[0] = string1;
objects[1] = exception;
logger.error("Command '{}' failed", objects);
}
return true;
}
}
Command.d(new StringBuilder().insert(0, "Unknown command: ").append(string1).toString());
return true;
}
public ArrayList<Command> getCommands() {
return this.commands;
}
public CommandManager() {
CommandManager commandManager1 = this;
commandManager1./* $VF: Unable to resugar constructor */<init>();
commandManager1.configCommand = new ConfigCommand();
commandManager1.commands = new ArrayList<>();
Field[] fields;
int i = (fields = commandManager1.getClass().getDeclaredFields()).length;
int j;
for (int k = j = 0; k < i; k = ++j) {
Field field = fields[j];
if (Command.class.isAssignableFrom(field.getType())) {
try {
commandManager1.commands.add((Command)field.get(commandManager1));
} catch (IllegalAccessException illegalAccessException) {
illegalAccessException.printStackTrace();
}
}
}
}
}