diff options
author | Yasin <LifeIsAParadox@users.noreply.github.com> | 2024-05-09 22:28:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 22:28:47 +0200 |
commit | 21253c3b4e37ce07198a6e736a2b8a403d9661af (patch) | |
tree | 6cf569e6c1be5a1fa622115a4a422ddbd3d43d58 /src/main/java/de/hysky/skyblocker/utils | |
parent | 4a4234d7c9d4f038d4fa418fb15ef24ce3fcc501 (diff) | |
parent | 14302bb348aff30c33a27f43a8b6c017f2fb829e (diff) | |
download | Skyblocker-21253c3b4e37ce07198a6e736a2b8a403d9661af.tar.gz Skyblocker-21253c3b4e37ce07198a6e736a2b8a403d9661af.tar.bz2 Skyblocker-21253c3b4e37ce07198a6e736a2b8a403d9661af.zip |
Merge pull request #697 from LifeIsAParadox/ultimate-config-reconfiguration
Ultimate config reconfiguration
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils')
5 files changed, 64 insertions, 62 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index dc13b61d..70dbdac6 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -224,7 +224,7 @@ public class Utils { if (!isOnHypixel) { isOnHypixel = true; } - if (fabricLoader.isDevelopmentEnvironment() || sidebar.get(0).contains("SKYBLOCK") || sidebar.get(0).contains("SKIBLOCK")) { + if (fabricLoader.isDevelopmentEnvironment() || sidebar.getFirst().contains("SKYBLOCK") || sidebar.getFirst().contains("SKIBLOCK")) { if (!isOnSkyblock) { if (!isInjected) { isInjected = true; 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..5c2bfe53 100644 --- a/src/main/java/de/hysky/skyblocker/utils/chat/ChatFilterResult.java +++ b/src/main/java/de/hysky/skyblocker/utils/chat/ChatFilterResult.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.utils.chat; import net.minecraft.client.resource.language.I18n; + public enum ChatFilterResult { // Skip this one / no action PASS, @@ -13,6 +14,6 @@ public enum ChatFilterResult { @Override public String toString() { - return I18n.translate("text.autoconfig.skyblocker.option.messages.chatFilterResult." + name()); + return I18n.translate("skyblocker.config.chat.filter.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..c21485e2 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 @@ -1,7 +1,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 +82,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 +90,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 +106,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 +115,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 +124,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 +156,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..a8fbbea8 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 @@ -1,7 +1,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 +23,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 +42,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 +62,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 +87,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 +104,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 +135,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 +171,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.config.uiAndVisuals"))).findFirst().orElseThrow(); + OptionGroup group = category.groups().stream().filter(grp -> grp.name().getString().equals(I18n.translate("skyblocker.config.uiAndVisuals.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(); |