From 642d762b231498c54e7690b207e7919e9f374e2d Mon Sep 17 00:00:00 2001 From: Dominika Date: Wed, 9 Dec 2020 13:45:16 -0500 Subject: [PATCH] [refactor] Auto-format and cleanup `kami` module Signed-off-by: Dominika --- .../zeroeightsix/kami/gui/kami/KamiGUI.java | 64 ++--- .../gui/kami/component/ActiveModules.java | 2 +- .../kami/theme/kami/KamiActiveModulesUI.java | 20 +- .../gui/kami/theme/kami/KamiEnumButtonUI.java | 6 +- .../kami/gui/kami/theme/kami/KamiPotionUi.kt | 4 +- .../kami/theme/kami/KamiUnboundSliderUI.java | 6 +- .../gui/kami/theme/kami/RootButtonUI.java | 6 +- .../kami/theme/kami/RootCheckButtonUI.java | 8 +- .../zeroeightsix/kami/gui/mc/KamiGuiChat.kt | 2 +- .../kami/gui/mc/KamiGuiDisconnected.kt | 2 +- .../kami/gui/mc/KamiGuiStealButton.kt | 2 +- .../me/zeroeightsix/kami/gui/rgui/GUI.java | 4 +- .../gui/rgui/component/AbstractComponent.java | 4 +- .../gui/rgui/component/AlignedComponent.java | 2 +- .../kami/gui/rgui/component/Component.java | 92 +++--- .../rgui/component/container/Container.java | 18 +- .../rgui/component/container/use/Frame.java | 5 +- .../component/container/use/Scrollpane.java | 8 +- .../rgui/component/listen/KeyListener.java | 6 +- .../rgui/component/listen/MouseListener.java | 16 +- .../rgui/component/listen/RenderListener.java | 4 +- .../rgui/component/listen/UpdateListener.java | 4 +- .../gui/rgui/component/use/InputField.java | 8 +- .../kami/gui/rgui/layout/Layout.java | 2 +- .../kami/gui/rgui/poof/IPoof.java | 6 +- .../kami/gui/rgui/poof/use/FramePoof.java | 2 +- .../kami/gui/rgui/poof/use/Poof.java | 8 +- .../gui/rgui/render/AbstractComponentUI.java | 2 +- .../gui/rgui/render/util/Framebuffer.java | 12 +- .../java/me/zeroeightsix/kami/util/Bind.kt | 8 +- .../me/zeroeightsix/kami/util/BlockUtils.kt | 58 ++-- .../me/zeroeightsix/kami/util/ConfigUtils.kt | 28 +- .../kami/util/EnchantmentUtils.kt | 2 +- .../zeroeightsix/kami/util/InfoCalculator.kt | 2 +- .../zeroeightsix/kami/util/InventoryUtils.kt | 22 +- .../java/me/zeroeightsix/kami/util/Quad.kt | 8 +- .../kami/util/combat/CrystalUtils.kt | 18 +- .../kami/util/combat/SurroundUtils.kt | 18 +- .../zeroeightsix/kami/util/event/Listener.kt | 6 +- .../kami/util/graphics/GlStateUtils.kt | 2 +- .../kami/util/graphics/KamiTessellator.kt | 18 +- .../kami/util/graphics/font/FontGlyphs.kt | 64 ++--- .../util/graphics/font/KamiFontRenderer.kt | 10 +- .../kami/util/graphics/font/TextComponent.kt | 2 +- .../me/zeroeightsix/kami/util/math/Vec2d.kt | 2 +- .../me/zeroeightsix/kami/util/math/Vec2f.kt | 2 +- .../kami/util/math/VectorUtils.kt | 10 +- .../kami/util/text/MessageDetectionHelper.kt | 12 +- .../kami/util/text/MessageSendHelper.kt | 2 +- .../kami/util/text/SpamFilters.kt | 261 +++++++++--------- 50 files changed, 439 insertions(+), 441 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/KamiGUI.java b/src/main/java/me/zeroeightsix/kami/gui/kami/KamiGUI.java index 2fe46dc36..75df975e8 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/KamiGUI.java +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/KamiGUI.java @@ -82,7 +82,7 @@ public class KamiGUI extends GUI { public static > Map sortByValue(Map map) { List> list = - new LinkedList<>(map.entrySet()); + new LinkedList<>(map.entrySet()); list.sort(Map.Entry.comparingByValue()); Map result = new LinkedHashMap<>(); @@ -435,21 +435,21 @@ public class KamiGUI extends GUI { return; } final Map entityCounts = entityList.stream() - .filter(Objects::nonNull) - .filter(e -> !(e instanceof EntityPlayer)) - .collect(Collectors.groupingBy(KamiGUI::getEntityName, - Collectors.reducing(0, ent -> { - if (ent instanceof EntityItem) - return ((EntityItem) ent).getItem().getCount(); - return 1; - }, Integer::sum) - )); + .filter(Objects::nonNull) + .filter(e -> !(e instanceof EntityPlayer)) + .collect(Collectors.groupingBy(KamiGUI::getEntityName, + Collectors.reducing(0, ent -> { + if (ent instanceof EntityItem) + return ((EntityItem) ent).getItem().getCount(); + return 1; + }, Integer::sum) + )); entityLabel.setText(""); entityCounts.entrySet().stream() - .sorted(Map.Entry.comparingByValue()) - .map(entry -> TextFormatting.GRAY + entry.getKey() + " " + TextFormatting.DARK_GRAY + "x" + entry.getValue()) - .forEach(entityLabel::addLine); + .sorted(Map.Entry.comparingByValue()) + .map(entry -> TextFormatting.GRAY + entry.getKey() + " " + TextFormatting.DARK_GRAY + "x" + entry.getValue()) + .forEach(entityLabel::addLine); //entityLabel.getParent().setHeight(entityLabel.getLines().length * (entityLabel.getTheme().getFontRenderer().getFontHeight()+1) + 3); } @@ -463,7 +463,7 @@ public class KamiGUI extends GUI { /* * Coordinates */ - Frame coords = new Frame(getTheme(), new Stretcherlayout(1), "Coordinates"); + Frame coords = new Frame(getTheme(), new Stretcherlayout(1), "Coordinates"); coords.setCloseable(false); coords.setPinnable(true); Label coordsLabel = new Label(""); @@ -489,26 +489,26 @@ public class KamiGUI extends GUI { /* The 7 and f in the string formatter is the color */ String colouredSeparator = TextFormatting.GRAY + " |" + TextFormatting.RESET; String ow = String.format(" (%s%,d%s, %s%,d%s, %s%,d%s)", - TextFormatting.WHITE, - posX, - TextFormatting.GRAY, - TextFormatting.WHITE, - posY, - TextFormatting.GRAY, - TextFormatting.WHITE, - posZ, - TextFormatting.GRAY + TextFormatting.WHITE, + posX, + TextFormatting.GRAY, + TextFormatting.WHITE, + posY, + TextFormatting.GRAY, + TextFormatting.WHITE, + posZ, + TextFormatting.GRAY ); String nether = String.format(" (%s%,d%s, %s%,d%s, %s%,d%s)", - TextFormatting.WHITE, - hposX, - TextFormatting.GRAY, - TextFormatting.WHITE, - posY, - TextFormatting.GRAY, - TextFormatting.WHITE, - hposZ, - TextFormatting.GRAY + TextFormatting.WHITE, + hposX, + TextFormatting.GRAY, + TextFormatting.WHITE, + posY, + TextFormatting.GRAY, + TextFormatting.WHITE, + hposZ, + TextFormatting.GRAY ); coordsLabel.setText(""); coordsLabel.addLine(ow); diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/component/ActiveModules.java b/src/main/java/me/zeroeightsix/kami/gui/kami/component/ActiveModules.java index 49fe5df0d..d91f6f8ee 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/component/ActiveModules.java +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/component/ActiveModules.java @@ -29,4 +29,4 @@ public class ActiveModules extends Label { } }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiActiveModulesUI.java b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiActiveModulesUI.java index 8cd023a39..c71516103 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiActiveModulesUI.java +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiActiveModulesUI.java @@ -25,19 +25,19 @@ import static me.zeroeightsix.kami.util.color.ColorConverter.toF; public class KamiActiveModulesUI extends AbstractComponentUI { final ColorGradient transRights = new ColorGradient( - new Pair<>(0f, new ColorHolder(91, 207, 250)), new Pair<>(19.9999999999f, new ColorHolder(91, 207, 250)), - new Pair<>(20f, new ColorHolder(245, 170, 185)), new Pair<>(39.9999999999f, new ColorHolder(245, 170, 185)), - new Pair<>(40f, new ColorHolder(255, 255, 255)), new Pair<>(59.9999999999f, new ColorHolder(255, 255, 255)), - new Pair<>(60f, new ColorHolder(245, 170, 185)), new Pair<>(79.9999999999f, new ColorHolder(245, 170, 185)), - new Pair<>(80f, new ColorHolder(91, 207, 250)), new Pair<>(100f, new ColorHolder(91, 207, 250)) + new Pair<>(0f, new ColorHolder(91, 207, 250)), new Pair<>(19.9999999999f, new ColorHolder(91, 207, 250)), + new Pair<>(20f, new ColorHolder(245, 170, 185)), new Pair<>(39.9999999999f, new ColorHolder(245, 170, 185)), + new Pair<>(40f, new ColorHolder(255, 255, 255)), new Pair<>(59.9999999999f, new ColorHolder(255, 255, 255)), + new Pair<>(60f, new ColorHolder(245, 170, 185)), new Pair<>(79.9999999999f, new ColorHolder(245, 170, 185)), + new Pair<>(80f, new ColorHolder(91, 207, 250)), new Pair<>(100f, new ColorHolder(91, 207, 250)) ); @Override public void renderComponent(me.zeroeightsix.kami.gui.kami.component.ActiveModules component) { List modules = ModuleManager.getModules().stream() - .filter(module -> module.isEnabled() && (ActiveModules.INSTANCE.getHidden().getValue() || module.isOnArray())) - .sorted(Comparator.comparing(module -> FontRenderAdapter.INSTANCE.getStringWidth(module.getName().getValue() + (module.getHudInfo() == null ? "" : module.getHudInfo() + " ")) * (component.sort_up ? -1 : 1))) - .collect(Collectors.toList()); + .filter(module -> module.isEnabled() && (ActiveModules.INSTANCE.getHidden().getValue() || module.isOnArray())) + .sorted(Comparator.comparing(module -> FontRenderAdapter.INSTANCE.getStringWidth(module.getName().getValue() + (module.getHudInfo() == null ? "" : module.getHudInfo() + " ")) * (component.sort_up ? -1 : 1))) + .collect(Collectors.toList()); int y = 2; @@ -92,8 +92,8 @@ public class KamiActiveModulesUI extends AbstractComponentUI { } ColorHolder color = new ColorHolder( - component.isHovered() ? GuiC.buttonHoveredN.color : - component.isPressed() ? GuiC.buttonPressed.color : - GuiC.buttonHoveredT.color); + component.isHovered() ? GuiC.buttonHoveredN.color : + component.isPressed() ? GuiC.buttonPressed.color : + GuiC.buttonHoveredT.color); int parts = component.getModes().length; double step = component.getWidth() / (double) parts; diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiPotionUi.kt b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiPotionUi.kt index 3e9435101..8a875d7cd 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiPotionUi.kt +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiPotionUi.kt @@ -55,8 +55,8 @@ class KamiPotionUi : AbstractComponentUI() { * Formats name and time based on UI alignment */ fun formattedName(right: Boolean) = - if (right) "${TextFormatting.GRAY}${formattedTimeLeft()}${TextFormatting.RESET} ${formattedName()}" - else "${formattedName()} ${TextFormatting.GRAY}${formattedTimeLeft()}" + if (right) "${TextFormatting.GRAY}${formattedTimeLeft()}${TextFormatting.RESET} ${formattedName()}" + else "${formattedName()} ${TextFormatting.GRAY}${formattedTimeLeft()}" /** * (min:secs) diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiUnboundSliderUI.java b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiUnboundSliderUI.java index 14b191857..7570354be 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiUnboundSliderUI.java +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/KamiUnboundSliderUI.java @@ -16,9 +16,9 @@ public class KamiUnboundSliderUI extends AbstractComponentUI { String s = component.getText() + ": " + component.getValue(); ColorHolder color = new ColorHolder( - component.isHovered() ? KamiGuiColors.GuiC.buttonHoveredN.color : - component.isPressed() ? KamiGuiColors.GuiC.buttonPressed.color : - KamiGuiColors.GuiC.buttonHoveredT.color); + component.isHovered() ? KamiGuiColors.GuiC.buttonHoveredN.color : + component.isPressed() ? KamiGuiColors.GuiC.buttonPressed.color : + KamiGuiColors.GuiC.buttonHoveredT.color); FontRenderAdapter.INSTANCE.drawString(s, component.getWidth() / 2f - FontRenderAdapter.INSTANCE.getStringWidth(s) / 2f, 1f, false, color); } diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootButtonUI.java b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootButtonUI.java index c861e8a62..758abc471 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootButtonUI.java +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootButtonUI.java @@ -21,9 +21,9 @@ public class RootButtonUI extends AbstractComponentUI