diff options
| author | Yasin <a.piri@hotmail.de> | 2024-05-08 00:07:04 +0200 |
|---|---|---|
| committer | Yasin <a.piri@hotmail.de> | 2024-05-08 00:07:04 +0200 |
| commit | 15bf2503e0147aeb06ebae2922ecede237983d5c (patch) | |
| tree | 827bb279c18a6394959008a661290c94d3d0e7a7 /src/main/java/de/hysky/skyblocker/utils | |
| parent | 9807bacfb9b2d7ef6a84e158ec21efea343128a7 (diff) | |
| download | Skyblocker-15bf2503e0147aeb06ebae2922ecede237983d5c.tar.gz Skyblocker-15bf2503e0147aeb06ebae2922ecede237983d5c.tar.bz2 Skyblocker-15bf2503e0147aeb06ebae2922ecede237983d5c.zip | |
debloat SkyblockerConfig.java + translate change
removed text.autoconfig. prefix
new way is skyblocker.option.
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils')
4 files changed, 62 insertions, 59 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/chat/ChatFilterResult.java b/src/main/java/de/hysky/skyblocker/utils/chat/ChatFilterResult.java index 5a94682a..48ba9dad 100644 --- a/src/main/java/de/hysky/skyblocker/utils/chat/ChatFilterResult.java +++ b/src/main/java/de/hysky/skyblocker/utils/chat/ChatFilterResult.java @@ -13,6 +13,6 @@ public enum ChatFilterResult { @Override public String toString() { - return I18n.translate("text.autoconfig.skyblocker.option.messages.chatFilterResult." + name()); + return I18n.translate("skyblocker.option.messages.chatFilterResult." + name()); } } diff --git a/src/main/java/de/hysky/skyblocker/utils/discord/DiscordRPCManager.java b/src/main/java/de/hysky/skyblocker/utils/discord/DiscordRPCManager.java index b2104fdc..fb2006c4 100644 --- a/src/main/java/de/hysky/skyblocker/utils/discord/DiscordRPCManager.java +++ b/src/main/java/de/hysky/skyblocker/utils/discord/DiscordRPCManager.java @@ -2,6 +2,7 @@ package de.hysky.skyblocker.utils.discord; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.config.configs.MiscConfig; import de.hysky.skyblocker.events.SkyblockEvents; import de.hysky.skyblocker.utils.Utils; import meteordevelopment.discordipc.DiscordIPC; @@ -34,15 +35,15 @@ public class DiscordRPCManager { } /** - * Checks the {@link de.hysky.skyblocker.config.SkyblockerConfig.RichPresence#customMessage custom message}, updates {@link #cycleCount} if enabled, and updates rich presence. + * Checks the {@link MiscConfig.RichPresence#customMessage custom message}, updates {@link #cycleCount} if enabled, and updates rich presence. */ public static void updateDataAndPresence() { // If the custom message is empty, discord will keep the last message, this is can serve as a default if the user doesn't want a custom message - if (SkyblockerConfigManager.get().richPresence.customMessage.isEmpty()) { - SkyblockerConfigManager.get().richPresence.customMessage = "Playing Skyblock"; + if (SkyblockerConfigManager.get().misc.richPresence.customMessage.isEmpty()) { + SkyblockerConfigManager.get().misc.richPresence.customMessage = "Playing Skyblock"; SkyblockerConfigManager.save(); } - if (SkyblockerConfigManager.get().richPresence.cycleMode) cycleCount = (cycleCount + 1) % 3; + if (SkyblockerConfigManager.get().misc.richPresence.cycleMode) cycleCount = (cycleCount + 1) % 3; initAndUpdatePresence(); } @@ -58,21 +59,21 @@ public class DiscordRPCManager { * <p> * When the {@link #updateTask previous update} does not exist or {@link CompletableFuture#isDone() has completed}: * <p> - * Connects to discord if {@link de.hysky.skyblocker.config.SkyblockerConfig.RichPresence#enableRichPresence rich presence is enabled}, + * Connects to discord if {@link MiscConfig.RichPresence#enableRichPresence rich presence is enabled}, * the player {@link Utils#isOnSkyblock() is on Skyblock}, and {@link DiscordIPC#isConnected() discord is not already connected}. - * Updates the presence if {@link de.hysky.skyblocker.config.SkyblockerConfig.RichPresence#enableRichPresence rich presence is enabled} + * Updates the presence if {@link MiscConfig.RichPresence#enableRichPresence rich presence is enabled} * and the player {@link Utils#isOnSkyblock() is on Skyblock}. - * Stops the connection if {@link de.hysky.skyblocker.config.SkyblockerConfig.RichPresence#enableRichPresence rich presence is disabled} + * Stops the connection if {@link MiscConfig.RichPresence#enableRichPresence rich presence is disabled} * or the player {@link Utils#isOnSkyblock() is not on Skyblock} and {@link DiscordIPC#isConnected() discord is connected}. * Saves the update task in {@link #updateTask} * * @param initialization whether this is the first time the presence is being updates. If {@code true}, a message will be logged - * if {@link de.hysky.skyblocker.config.SkyblockerConfig.RichPresence#enableRichPresence rich presence is disabled}. + * if {@link MiscConfig.RichPresence#enableRichPresence rich presence is disabled}. */ private static void initAndUpdatePresence(boolean initialization) { if (updateTask == null || updateTask.isDone()) { updateTask = CompletableFuture.runAsync(() -> { - if (SkyblockerConfigManager.get().richPresence.enableRichPresence && Utils.isOnSkyblock()) { + if (SkyblockerConfigManager.get().misc.richPresence.enableRichPresence && Utils.isOnSkyblock()) { if (!DiscordIPC.isConnected()) { if (DiscordIPC.start(934607927837356052L, null)) { LOGGER.info("[Skyblocker] Discord RPC connected successfully"); @@ -98,20 +99,20 @@ public class DiscordRPCManager { RichPresence presence = new RichPresence(); presence.setLargeImage("skyblocker-default", null); presence.setStart(startTimeStamp); - presence.setDetails(SkyblockerConfigManager.get().richPresence.customMessage); + presence.setDetails(SkyblockerConfigManager.get().misc.richPresence.customMessage); presence.setState(getInfo()); return presence; } public static String getInfo() { String info = null; - if (!SkyblockerConfigManager.get().richPresence.cycleMode) { - switch (SkyblockerConfigManager.get().richPresence.info) { + if (!SkyblockerConfigManager.get().misc.richPresence.cycleMode) { + switch (SkyblockerConfigManager.get().misc.richPresence.info) { case BITS -> info = "Bits: " + DECIMAL_FORMAT.format(Utils.getBits()); case PURSE -> info = "Purse: " + DECIMAL_FORMAT.format(Utils.getPurse()); case LOCATION -> info = Utils.getIslandArea(); } - } else if (SkyblockerConfigManager.get().richPresence.cycleMode) { + } else if (SkyblockerConfigManager.get().misc.richPresence.cycleMode) { switch (cycleCount) { case 0 -> info = "Bits: " + DECIMAL_FORMAT.format(Utils.getBits()); case 1 -> info = "Purse: " + DECIMAL_FORMAT.format(Utils.getPurse()); diff --git a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java index a115bb2b..7a2ea60a 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java @@ -2,6 +2,7 @@ package de.hysky.skyblocker.utils.render.title; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.config.configs.UiAndVisualsConfig; import de.hysky.skyblocker.events.HudRenderEvents; import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; @@ -82,7 +83,7 @@ public class TitleContainer { } private static void render(DrawContext context, float tickDelta) { - render(context, titles, SkyblockerConfigManager.get().general.titleContainer.x, SkyblockerConfigManager.get().general.titleContainer.y, tickDelta); + render(context, titles, SkyblockerConfigManager.get().uiAndVisuals.titleContainer.x, SkyblockerConfigManager.get().uiAndVisuals.titleContainer.y, tickDelta); } protected static void render(DrawContext context, Set<Title> titles, int xPos, int yPos, float tickDelta) { @@ -90,11 +91,11 @@ public class TitleContainer { TextRenderer textRenderer = client.textRenderer; // Calculate Scale to use - float scale = 3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F); + float scale = 3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F); // Grab direction and alignment values - SkyblockerConfig.Direction direction = SkyblockerConfigManager.get().general.titleContainer.direction; - SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + UiAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; // x/y refer to the starting position for the text // y always starts at yPos float x = 0; @@ -106,8 +107,8 @@ public class TitleContainer { width += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == SkyblockerConfig.Alignment.MIDDLE) { - if (direction == SkyblockerConfig.Direction.HORIZONTAL) { + if (alignment == UiAndVisualsConfig.Alignment.MIDDLE) { + if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { //If middle aligned horizontally, start the xPosition at half of the width to the left. x = xPos - (width / 2); } else { @@ -115,7 +116,7 @@ public class TitleContainer { x = xPos; } } - if (alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) { + if (alignment == UiAndVisualsConfig.Alignment.LEFT || alignment == UiAndVisualsConfig.Alignment.RIGHT) { //If left or right aligned, start at xPos, we will shift each text later x = xPos; } @@ -124,14 +125,14 @@ public class TitleContainer { //Calculate which x the text should use float xToUse; - if (direction == SkyblockerConfig.Direction.HORIZONTAL) { - xToUse = alignment == SkyblockerConfig.Alignment.RIGHT ? + if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { + xToUse = alignment == UiAndVisualsConfig.Alignment.RIGHT ? x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side. x; } else { - xToUse = alignment == SkyblockerConfig.Alignment.MIDDLE ? + xToUse = alignment == UiAndVisualsConfig.Alignment.MIDDLE ? x - (textRenderer.getWidth(title.getText()) * scale) / 2 : //if middle aligned we need the text position to be aligned in the middle. - alignment == SkyblockerConfig.Alignment.RIGHT ? + alignment == UiAndVisualsConfig.Alignment.RIGHT ? x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side. x; } @@ -156,13 +157,13 @@ public class TitleContainer { context.getMatrices().pop(); //Calculate the x and y positions for the next title - if (direction == SkyblockerConfig.Direction.HORIZONTAL) { - if (alignment == SkyblockerConfig.Alignment.MIDDLE || alignment == SkyblockerConfig.Alignment.LEFT) { + if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { + if (alignment == UiAndVisualsConfig.Alignment.MIDDLE || alignment == UiAndVisualsConfig.Alignment.LEFT) { //Move to the right if middle or left aligned x += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == SkyblockerConfig.Alignment.RIGHT) { + if (alignment == UiAndVisualsConfig.Alignment.RIGHT) { //Move to the left if right aligned x -= textRenderer.getWidth(title.getText()) * scale + 10; } diff --git a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java index cc80f74c..6a66faad 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java @@ -2,6 +2,7 @@ package de.hysky.skyblocker.utils.render.title; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.config.configs.UiAndVisualsConfig; import de.hysky.skyblocker.utils.render.RenderHelper; import dev.isxander.yacl3.api.ConfigCategory; import dev.isxander.yacl3.api.Option; @@ -23,8 +24,8 @@ public class TitleContainerConfigScreen extends Screen { private final Title example1 = new Title(Text.literal("Test1").formatted(Formatting.RED)); private final Title example2 = new Title(Text.literal("Test23").formatted(Formatting.AQUA)); private final Title example3 = new Title(Text.literal("Testing1234").formatted(Formatting.DARK_GREEN)); - private float hudX = SkyblockerConfigManager.get().general.titleContainer.x; - private float hudY = SkyblockerConfigManager.get().general.titleContainer.y; + private float hudX = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.x; + private float hudY = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.y; private final Screen parent; private boolean changedScale; @@ -42,8 +43,8 @@ public class TitleContainerConfigScreen extends Screen { super.render(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta); TitleContainer.render(context, Set.of(example1, example2, example3), (int) hudX, (int) hudY, delta); - SkyblockerConfig.Direction direction = SkyblockerConfigManager.get().general.titleContainer.direction; - SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + UiAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; context.drawCenteredTextWithShadow(textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, textRenderer.fontHeight * 2, Color.WHITE.getRGB()); context.drawCenteredTextWithShadow(textRenderer, "Press R to change Direction: " + direction, width / 2, textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB()); context.drawCenteredTextWithShadow(textRenderer, "Press +/- to change Scale", width / 2, textRenderer.fontHeight * 4 + 10, Color.WHITE.getRGB()); @@ -62,7 +63,7 @@ public class TitleContainerConfigScreen extends Screen { } private Pair<Vector2f, Vector2f> getSelectionBoundingBox() { - SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; float midWidth = getSelectionWidth() / 2F; float x1 = 0; @@ -87,15 +88,15 @@ public class TitleContainerConfigScreen extends Screen { } private float getSelectionHeight() { - float scale = (3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfigManager.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? + float scale = (3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F)); + return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UiAndVisualsConfig.Direction.HORIZONTAL ? (textRenderer.fontHeight * scale) : (textRenderer.fontHeight + 10F) * 3F * scale; } private float getSelectionWidth() { - float scale = (3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfigManager.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? + float scale = (3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F)); + return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UiAndVisualsConfig.Direction.HORIZONTAL ? (textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale : textRenderer.getWidth("Testing1234") * scale; } @@ -104,7 +105,7 @@ public class TitleContainerConfigScreen extends Screen { public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { float midWidth = getSelectionWidth() / 2; float midHeight = getSelectionHeight() / 2; - var alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + var alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; Pair<Vector2f, Vector2f> boundingBox = getSelectionBoundingBox(); float x1 = boundingBox.getLeft().getX(); @@ -135,34 +136,34 @@ public class TitleContainerConfigScreen extends Screen { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW.GLFW_KEY_Q) { - SkyblockerConfig.Alignment current = SkyblockerConfigManager.get().general.titleContainer.alignment; - SkyblockerConfigManager.get().general.titleContainer.alignment = switch (current) { - case LEFT -> SkyblockerConfig.Alignment.MIDDLE; - case MIDDLE -> SkyblockerConfig.Alignment.RIGHT; - case RIGHT -> SkyblockerConfig.Alignment.LEFT; + UiAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment = switch (current) { + case LEFT -> UiAndVisualsConfig.Alignment.MIDDLE; + case MIDDLE -> UiAndVisualsConfig.Alignment.RIGHT; + case RIGHT -> UiAndVisualsConfig.Alignment.LEFT; }; } if (keyCode == GLFW.GLFW_KEY_E) { - SkyblockerConfig.Alignment current = SkyblockerConfigManager.get().general.titleContainer.alignment; - SkyblockerConfigManager.get().general.titleContainer.alignment = switch (current) { - case LEFT -> SkyblockerConfig.Alignment.RIGHT; - case MIDDLE -> SkyblockerConfig.Alignment.LEFT; - case RIGHT -> SkyblockerConfig.Alignment.MIDDLE; + UiAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment = switch (current) { + case LEFT -> UiAndVisualsConfig.Alignment.RIGHT; + case MIDDLE -> UiAndVisualsConfig.Alignment.LEFT; + case RIGHT -> UiAndVisualsConfig.Alignment.MIDDLE; }; } if (keyCode == GLFW.GLFW_KEY_R) { - SkyblockerConfig.Direction current = SkyblockerConfigManager.get().general.titleContainer.direction; - SkyblockerConfigManager.get().general.titleContainer.direction = switch (current) { - case HORIZONTAL -> SkyblockerConfig.Direction.VERTICAL; - case VERTICAL -> SkyblockerConfig.Direction.HORIZONTAL; + UiAndVisualsConfig.Direction current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction = switch (current) { + case HORIZONTAL -> UiAndVisualsConfig.Direction.VERTICAL; + case VERTICAL -> UiAndVisualsConfig.Direction.HORIZONTAL; }; } if (keyCode == GLFW.GLFW_KEY_EQUAL) { - SkyblockerConfigManager.get().general.titleContainer.titleContainerScale += 10; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale += 10; changedScale = true; } if (keyCode == GLFW.GLFW_KEY_MINUS) { - SkyblockerConfigManager.get().general.titleContainer.titleContainerScale -= 10; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale -= 10; changedScale = true; } return super.keyPressed(keyCode, scanCode, modifiers); @@ -171,15 +172,15 @@ public class TitleContainerConfigScreen extends Screen { @Override public void close() { - SkyblockerConfigManager.get().general.titleContainer.x = (int) hudX; - SkyblockerConfigManager.get().general.titleContainer.y = (int) hudY; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.x = (int) hudX; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.y = (int) hudY; //TODO Come up with a better, less hacky solution for this in the future (: if (parent instanceof YACLScreen yaclScreen) { - ConfigCategory category = yaclScreen.config.categories().stream().filter(cat -> cat.name().getString().equals(I18n.translate("text.autoconfig.skyblocker.category.general"))).findFirst().orElseThrow(); - OptionGroup group = category.groups().stream().filter(grp -> grp.name().getString().equals(I18n.translate("text.autoconfig.skyblocker.option.general.titleContainer"))).findFirst().orElseThrow(); + ConfigCategory category = yaclScreen.config.categories().stream().filter(cat -> cat.name().getString().equals(I18n.translate("skyblocker.category.general"))).findFirst().orElseThrow(); + OptionGroup group = category.groups().stream().filter(grp -> grp.name().getString().equals(I18n.translate("skyblocker.option.general.titleContainer"))).findFirst().orElseThrow(); - Option<?> scaleOpt = group.options().get(0); + Option<?> scaleOpt = group.options().getFirst(); // Refresh the value in the config with the bound value if (changedScale) scaleOpt.forgetPendingValue(); |
