From bc6076a0392bc955d7e680fc6af2398736d1ecae Mon Sep 17 00:00:00 2001 From: noil755 Date: Sat, 30 Nov 2019 11:59:09 -0500 Subject: [PATCH] update formatting of command manager --- .../rigamortis/seppuku/api/module/Module.java | 7 +-- .../gui/hud/component/ArrayListComponent.java | 6 +-- .../impl/management/CommandManager.java | 52 ++++--------------- 3 files changed, 14 insertions(+), 51 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/api/module/Module.java b/src/main/java/me/rigamortis/seppuku/api/module/Module.java index 74a7280..7845a24 100644 --- a/src/main/java/me/rigamortis/seppuku/api/module/Module.java +++ b/src/main/java/me/rigamortis/seppuku/api/module/Module.java @@ -111,18 +111,15 @@ public class Module { if (v.getValue() instanceof Enum) { final Enum val = (Enum) v.getValue(); - final StringBuilder options = new StringBuilder(); - final int size = val.getClass().getEnumConstants().length; for (int i = 0; i < size; i++) { final Enum option = val.getClass().getEnumConstants()[i]; - - options.append(option.name() + ((i == size - 1) ? "" : ", ")); + options.append(option.name().toLowerCase() + ((i == size - 1) ? "" : ", ")); } - msg.appendSibling(new TextComponentString(v.getName() + ChatFormatting.GRAY + " <" + options.toString() + ">" + ChatFormatting.DARK_GRAY + " | " + ChatFormatting.YELLOW + v.getValue()).setStyle(style)); + msg.appendSibling(new TextComponentString(v.getName() + ChatFormatting.GRAY + " <" + options.toString() + ">" + ChatFormatting.DARK_GRAY + " | " + ChatFormatting.YELLOW + val.name().toLowerCase()).setStyle(style)); } } diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ArrayListComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ArrayListComponent.java index 4dae1e0..12d300f 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ArrayListComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ArrayListComponent.java @@ -33,8 +33,8 @@ public final class ArrayListComponent extends DraggableHudComponent { } final Comparator comparator = (first, second) -> { - final String firstName = first.getDisplayName() + (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData() + ChatFormatting.GRAY + "]" : ""); - final String secondName = second.getDisplayName() + (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData() + ChatFormatting.GRAY + "]" : ""); + final String firstName = first.getDisplayName() + (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : ""); + final String secondName = second.getDisplayName() + (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : ""); final float dif = Minecraft.getMinecraft().fontRenderer.getStringWidth(secondName) - Minecraft.getMinecraft().fontRenderer.getStringWidth(firstName); return dif != 0 ? (int) dif : secondName.compareTo(firstName); }; @@ -47,7 +47,7 @@ public final class ArrayListComponent extends DraggableHudComponent { for (Module mod : mods) { if (mod != null && mod.getType() != Module.ModuleType.HIDDEN && mod.isEnabled() && !mod.isHidden()) { - final String name = mod.getDisplayName() + (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData() + ChatFormatting.GRAY + "]" : ""); + final String name = mod.getDisplayName() + (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : ""); final float width = Minecraft.getMinecraft().fontRenderer.getStringWidth(name); diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/CommandManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/CommandManager.java index 04464d8..dd9fd93 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/CommandManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/CommandManager.java @@ -131,24 +131,23 @@ public final class CommandManager { if (split[2].equalsIgnoreCase("true") || split[2].equalsIgnoreCase("false") || split[2].equalsIgnoreCase("1") || split[2].equalsIgnoreCase("0")) { if (split[2].equalsIgnoreCase("1")) { v.setValue(true); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to true"); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to \247atrue"); Seppuku.INSTANCE.getConfigManager().saveAll(); } else if (split[2].equalsIgnoreCase("0")) { v.setValue(false); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to false"); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to \247cfalse"); Seppuku.INSTANCE.getConfigManager().saveAll(); } else { v.setValue(Boolean.parseBoolean(split[2])); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Boolean.parseBoolean(split[2])); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to " + ((Boolean) v.getValue() ? "\247a" : "\247c") + v.getValue()); Seppuku.INSTANCE.getConfigManager().saveAll(); - } } else { Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected true/false"); } } else { v.setValue(!((Boolean) v.getValue())); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + v.getValue()); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to " + ((Boolean) v.getValue() ? "\247a" : "\247c") + v.getValue()); Seppuku.INSTANCE.getConfigManager().saveAll(); } } @@ -159,7 +158,7 @@ public final class CommandManager { return; } v.setValue(split[2]); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + split[2]); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to " + split[2]); Seppuku.INSTANCE.getConfigManager().saveAll(); } @@ -171,7 +170,7 @@ public final class CommandManager { if (v.getValue().getClass() == Float.class) { if (StringUtil.isFloat(split[2])) { v.setValue(Float.parseFloat(split[2])); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Float.parseFloat(split[2])); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247b set to \247b" + Float.parseFloat(split[2])); Seppuku.INSTANCE.getConfigManager().saveAll(); } else { Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected a number"); @@ -180,7 +179,7 @@ public final class CommandManager { if (v.getValue().getClass() == Double.class) { if (StringUtil.isDouble(split[2])) { v.setValue(Double.parseDouble(split[2])); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Double.parseDouble(split[2])); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to \247b" + Double.parseDouble(split[2])); Seppuku.INSTANCE.getConfigManager().saveAll(); } else { Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected a number"); @@ -189,7 +188,7 @@ public final class CommandManager { if (v.getValue().getClass() == Integer.class) { if (StringUtil.isInt(split[2])) { v.setValue(Integer.parseInt(split[2])); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Integer.parseInt(split[2])); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to \247b" + Integer.parseInt(split[2])); Seppuku.INSTANCE.getConfigManager().saveAll(); } else { Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected a number"); @@ -207,41 +206,8 @@ public final class CommandManager { if (op != -1) { v.setEnumValue(split[2]); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + ((Enum) v.getValue()).name()); + Seppuku.INSTANCE.logChat(module.getDisplayName() + " \2477" + v.getName() + "\247f set to \247e" + ((Enum) v.getValue()).name().toLowerCase()); Seppuku.INSTANCE.getConfigManager().saveAll(); - } else if (StringUtil.isInt(split[2])) { - final int mode = Integer.parseInt(split[2]); - - if (mode > v.getValue().getClass().getEnumConstants().length - 1) { - Seppuku.INSTANCE.errorChat("Invalid mode " + "\"" + split[2] + "\""); - StringBuilder sb = new StringBuilder(); - - final int size = v.getValue().getClass().getEnumConstants().length; - for (int i = 0; i < size; i++) { - final Enum option = (Enum) v.getValue().getClass().getEnumConstants()[i]; - sb.append(option.name() + " (" + i + ")" + ((i == size - 1) ? "" : ", ")); - } - - Seppuku.INSTANCE.logChat("Valid Options:"); - Seppuku.INSTANCE.logChat(sb.toString()); - return; - } else if (mode < 0) { - Seppuku.INSTANCE.errorChat("Invalid mode " + "\"" + split[2] + "\""); - StringBuilder sb = new StringBuilder(); - - final int size = v.getValue().getClass().getEnumConstants().length; - for (int i = 0; i < size; i++) { - final Enum option = (Enum) v.getValue().getClass().getEnumConstants()[i]; - sb.append(option.name() + " (" + i + ")" + ((i == size - 1) ? "" : ", ")); - } - - Seppuku.INSTANCE.logChat("Valid Options: " + sb.toString()); - return; - } else { - v.setValue(mode); - Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + ((Enum) v.getValue()).name()); - Seppuku.INSTANCE.getConfigManager().saveAll(); - } } else { Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected a string"); }