From 8d4a4cf3333a749e4ee6e466d42972040f16b0ad Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 7 Feb 2022 11:09:41 -0500 Subject: [PATCH] Dungeon Score Logger Name --- README.md | 36 +++- gradle.properties | 2 +- .../skyblockmod/SkyblockMod.java | 8 +- .../skyblockmod/dungeons/DungeonMap.java | 3 +- .../skyblockmod/dungeons/DungeonScore.java | 26 +++ .../skyblockmod/dungeons/LividColor.java | 3 +- .../skyblockmod/dungeons/Reparty.java | 94 +++++----- .../mixins/ChatHudListenerMixin.java | 10 +- .../skyblockmod/mixins/ScreenMixin.java | 161 +++++++++++++++--- .../skyblockmod/util/Config.java | 40 ++++- .../kevinthegreat/skyblockmod/util/Util.java | 5 +- src/main/resources/fabric.mod.json | 4 +- 12 files changed, 299 insertions(+), 93 deletions(-) create mode 100644 src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonScore.java diff --git a/README.md b/README.md index 84e81b9..0c5351f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Skyblock Mod Fabric -Helpful features for Hypixel Skyblock ([Fabric](https://fabricmc.net/) 1.17.1) +Helpful features for Hypixel Skyblock ([Fabric](https://fabricmc.net/) 1.17+) ##Features @@ -12,26 +12,46 @@ Notifies you to reel in ###Dungeon ####Configurable dungeon map + +- /sbm map: show current state (on or off) +- /sbm map on/off: turn dungeon map on or off +- /sbm map scale: show current scale - /sbm map scale \[number] -- /sbm map scale -> show current scale +- /sbm map offset: show current offset - /sbm map offset \[number] \[number] -- /sbm map offset -> show current offset + + +####Dungeon Score + +- send 300 score in chat +- /sbm score: show current state (on or off) +- /sbm score on/off: turn dungeon score on or off +- /sbm score \[message before] "\[score]" \[message after] +- Ex: /sbm score \[score] score: 300 score ####Livid color + - send livid color in chat +- /sbm livid: show current state (on or off) +- /sbm livid on/off: turn livid color on or off - /sbm livid \[message before] "\[color]" \[message after] -- Ex: /sbm livid \[color] is sus -> red is sus +- Ex: /sbm livid \[color] is sus: red is sus ###Party + - /pa \[Player\] -> /p accept \[Player\] - /pv -> /p leave - /pd -> /p disband ####Reparty + - /pr, /rp -> Reparty: disbands the party and invites everyone back - Auto join reparty +- /sbm reparty: show current state (on or off) +- /sbm reparty on/off: turn reparty on or off ###Warp + - /sk, /sky -> /skyblock - /i -> /is - /h, /hu -> /hub @@ -63,6 +83,7 @@ Notifies you to reel in - /howl -> /warp howl ###Chat + - /ca -> /chat all - /cp -> /chat party - /cg -> /chat guild @@ -70,13 +91,18 @@ Notifies you to reel in - /cc -> /chat coop ###Message + - /m \[player\] -> /msg \[Player\] ###Visit + - /v \[Player\] -> /visit \[Player\] - /vp, /visit p -> /visit portalhub ###Misc -- /sbm reload -> reload config file +- /sbm reload: reload config file +- Useful when you accidentally override something + +Configuration file is in minecraft run directory Configuration will be printed to the log if writing to the configuration file fails. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c5133e6..19e9c12 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.12.2 # Mod Properties - mod_version = 1.0.0 + mod_version = 1.5.0 maven_group = com.kevinthegreat.skyblockmod archives_base_name = SkyblockMod diff --git a/src/main/java/com/kevinthegreat/skyblockmod/SkyblockMod.java b/src/main/java/com/kevinthegreat/skyblockmod/SkyblockMod.java index 30860ec..f7dd62d 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/SkyblockMod.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/SkyblockMod.java @@ -1,25 +1,29 @@ package com.kevinthegreat.skyblockmod; import com.kevinthegreat.skyblockmod.dungeons.DungeonMap; +import com.kevinthegreat.skyblockmod.dungeons.DungeonScore; import com.kevinthegreat.skyblockmod.dungeons.LividColor; import com.kevinthegreat.skyblockmod.dungeons.Reparty; import com.kevinthegreat.skyblockmod.util.Config; import com.kevinthegreat.skyblockmod.util.Message; import com.kevinthegreat.skyblockmod.util.Util; import net.fabricmc.api.ModInitializer; -import org.apache.logging.log4j.LogManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SkyblockMod implements ModInitializer { public static final String MOD_ID = "skyblockmod"; public static final String MOD_NAME = "SkyblockMod"; public static SkyblockMod skyblockMod; + public final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); public int tick = 0; public final Config config = new Config(); public final Message message = new Message(); public final Util util = new Util(); + public final DungeonScore dungeonScore = new DungeonScore(); public final DungeonMap dungeonMap = new DungeonMap(); public final Fishing fishing = new Fishing(); public final LividColor lividColor = new LividColor(); @@ -30,7 +34,7 @@ public class SkyblockMod implements ModInitializer { public void onInitialize() { skyblockMod = this; config.load(); - LogManager.getLogger().info(MOD_NAME + " initialized."); + LOGGER.info(MOD_NAME + " initialized."); } public void tick() { diff --git a/src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonMap.java b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonMap.java index 9e254cc..67ee0a5 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonMap.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonMap.java @@ -11,13 +11,14 @@ //from skyfabric public class DungeonMap { + public boolean on = true; public float mapScale = 1; public int mapOffsetx = 0; public int mapOffsety = 0; public DungeonMap() { HudRenderCallback.EVENT.register((matrixStack, tickDelta) -> { - if (SkyblockMod.skyblockMod.util.catacombs) { + if (on && SkyblockMod.skyblockMod.util.catacombs) { MinecraftClient minecraftClient = MinecraftClient.getInstance(); if (minecraftClient == null || minecraftClient.player == null || minecraftClient.world == null) { return; diff --git a/src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonScore.java b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonScore.java new file mode 100644 index 0000000..8cdb479 --- /dev/null +++ b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/DungeonScore.java @@ -0,0 +1,26 @@ +package com.kevinthegreat.skyblockmod.dungeons; + +import com.kevinthegreat.skyblockmod.SkyblockMod; + +public class DungeonScore { + public boolean on270 = true; + public String text270 = "270 score"; + private long last270 = 0; + public boolean on300 = true; + public String text300 = "300 score"; + private long last300 = 0; + + public boolean onChatMessage(String message) { + if (on270 && SkyblockMod.skyblockMod.util.catacombs && (message.endsWith("Skytils > 270 score") || message.endsWith("270 Score Reached!")) && last270 + 2000 < System.currentTimeMillis()) { + SkyblockMod.skyblockMod.message.sendMessage(text270); + last270 = System.currentTimeMillis(); + return true; + } + if (on300 && SkyblockMod.skyblockMod.util.catacombs && (message.endsWith("Skytils > 300 score") || message.endsWith("300 Score Reached!")) && last300 + 2000 < System.currentTimeMillis()) { + SkyblockMod.skyblockMod.message.sendMessage(text300); + last300 = System.currentTimeMillis(); + return true; + } + return false; + } +} diff --git a/src/main/java/com/kevinthegreat/skyblockmod/dungeons/LividColor.java b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/LividColor.java index bc85017..b8d1656 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/dungeons/LividColor.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/LividColor.java @@ -7,6 +7,7 @@ import net.minecraft.util.math.BlockPos; public class LividColor { + public boolean on = true; public String[] text = {"", ""}; private int ticks = 0; @@ -15,7 +16,7 @@ public void start() { } public void tick() { - if (SkyblockMod.skyblockMod.util.catacombs && MinecraftClient.getInstance().world != null) { + if (on && SkyblockMod.skyblockMod.util.catacombs && MinecraftClient.getInstance().world != null) { if (ticks == 1) { SkyblockMod.skyblockMod.message.sendMessage(text[0] + "red" + text[1]); ticks = 0; diff --git a/src/main/java/com/kevinthegreat/skyblockmod/dungeons/Reparty.java b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/Reparty.java index 4548713..132060d 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/dungeons/Reparty.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/dungeons/Reparty.java @@ -8,6 +8,7 @@ import java.util.List; public class Reparty { + public boolean on = true; private boolean reparty = false; private int memberCount = 0; private final List members = new ArrayList<>(); @@ -17,54 +18,63 @@ public void start(){ reparty = true; } - public void onChatMessage(String message) { - if (reparty) { - if (message.startsWith("Party Members (")) { - memberCount = Integer.parseInt(message.substring(15, message.length() - 1)) - 1; - if (memberCount == 0) { - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("The Party is empty.")); - reparty = false; - } - } else if (message.startsWith("Party Leader")) { - String[] messageContents = message.split(" "); - MinecraftClient minecraftClient = MinecraftClient.getInstance(); - assert minecraftClient.player != null; - if (!messageContents[2].equals(minecraftClient.player.getEntityName()) && !messageContents[3].equals(minecraftClient.player.getEntityName())) { - minecraftClient.inGameHud.getChatHud().addMessage(Text.of("You are not the party leader.")); + public boolean onChatMessage(String message) { + if(on && SkyblockMod.skyblockMod.util.hypixel) { + if (reparty) { + if (message.startsWith("Party Members (")) { + memberCount = Integer.parseInt(message.substring(15, message.length() - 1)) - 1; + if (memberCount == 0) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("The Party is empty.")); + reparty = false; + } + return true; + } else if (message.startsWith("Party Leader")) { + String[] messageContents = message.split(" "); + MinecraftClient minecraftClient = MinecraftClient.getInstance(); + assert minecraftClient.player != null; + if (!messageContents[2].equals(minecraftClient.player.getEntityName()) && !messageContents[3].equals(minecraftClient.player.getEntityName())) { + minecraftClient.inGameHud.getChatHud().addMessage(Text.of("You are not the party leader.")); + reparty = false; + } + return true; + } else if (message.startsWith("Party M")) { + String[] messageContents = message.split(" "); + for (int i = 2; i < messageContents.length - 1; i++) { + if (!messageContents[i].contains("[") && !messageContents[i].contains("●")) { + members.add(messageContents[i]); + i++; + } + } + if (members.size() == memberCount) { + SkyblockMod.skyblockMod.message.queueMessage("/p disband", 4); + for (String player : members) { + SkyblockMod.skyblockMod.message.queueMessage("/p invite " + player, 6); + } + members.clear(); + reparty = false; + } + return true; + } else if (message.startsWith("You are not currently in a party.")) { reparty = false; + return true; } - } else if (message.startsWith("Party M")) { + } else if (message.endsWith("has disbanded the party!")) { String[] messageContents = message.split(" "); - for (int i = 2; i < messageContents.length - 1; i++) { - if (!messageContents[i].contains("[") && !messageContents[i].contains("●")) { - members.add(messageContents[i]); - i++; - } + if (messageContents[0].contains("[")) { + leader = messageContents[1]; + } else { + leader = messageContents[0]; } - if (members.size() == memberCount) { - SkyblockMod.skyblockMod.message.queueMessage("/p disband", 4); - for (String player : members) { - SkyblockMod.skyblockMod.message.queueMessage("/p invite " + player, 6); - } - members.clear(); - reparty = false; + return true; + } else if (!leader.isEmpty() && message.contains(leader + " has invited you to join their party!")) { + assert MinecraftClient.getInstance().player != null; + if (!leader.equals(MinecraftClient.getInstance().player.getEntityName())) { + SkyblockMod.skyblockMod.message.sendMessage("/p accept " + leader); + leader = ""; } - } else if (message.startsWith("You are not currently in a party.")) { - reparty = false; - } - } else if (message.endsWith("has disbanded the party!")) { - String[] messageContents = message.split(" "); - if (messageContents[0].contains("[")) { - leader = messageContents[1]; - } else { - leader = messageContents[0]; - } - } else if (!leader.isEmpty() && message.contains(leader + " has invited you to join their party!")) { - assert MinecraftClient.getInstance().player != null; - if (!leader.equals(MinecraftClient.getInstance().player.getEntityName())) { - SkyblockMod.skyblockMod.message.sendMessage("/p accept " + leader); - leader = ""; + return true; } } + return false; } } diff --git a/src/main/java/com/kevinthegreat/skyblockmod/mixins/ChatHudListenerMixin.java b/src/main/java/com/kevinthegreat/skyblockmod/mixins/ChatHudListenerMixin.java index cad94f4..a3a6009 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/mixins/ChatHudListenerMixin.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/mixins/ChatHudListenerMixin.java @@ -16,9 +16,15 @@ public class ChatHudListenerMixin { @Inject(method = "onChatMessage(Lnet/minecraft/network/MessageType;Lnet/minecraft/text/Text;Ljava/util/UUID;)V", at = @At(value = "HEAD")) private void onChatMessage(MessageType messageType, Text text, UUID sender, CallbackInfo ci) { String message = text.getString(); - if(message.equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")){ + if(SkyblockMod.skyblockMod.lividColor.on && message.equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")){ SkyblockMod.skyblockMod.lividColor.start(); + return; + } + if(SkyblockMod.skyblockMod.reparty.onChatMessage(message)){ + return; + } + if(SkyblockMod.skyblockMod.dungeonScore.onChatMessage(message)){ + return; } - SkyblockMod.skyblockMod.reparty.onChatMessage(message); } } diff --git a/src/main/java/com/kevinthegreat/skyblockmod/mixins/ScreenMixin.java b/src/main/java/com/kevinthegreat/skyblockmod/mixins/ScreenMixin.java index 03938f0..82a0a9e 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/mixins/ScreenMixin.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/mixins/ScreenMixin.java @@ -37,37 +37,144 @@ private void processMessage(String message, boolean toHud, CallbackInfo ci) { if (message.startsWith("/")) { String[] messageArgs = message.split(" "); if (messageArgs[0].equals("/sbm") && messageArgs.length >= 2) { - if (messageArgs[1].equals("reload")) { - SkyblockMod.skyblockMod.config.load(); - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Reloaded config file.")); - } else if (messageArgs[1].equals("livid")) { - if (messageArgs.length == 2) { - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Livid color text: " + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1])); - } else { - SkyblockMod.skyblockMod.lividColor.text = Arrays.copyOf(message.substring(11).split("\\[color]"), 2); - if (SkyblockMod.skyblockMod.lividColor.text[0] == null) { - SkyblockMod.skyblockMod.lividColor.text[0] = ""; + switch (messageArgs[1]) { + case "reload" -> { + SkyblockMod.skyblockMod.config.load(); + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Reloaded config file.")); + } + case "save" -> { + SkyblockMod.skyblockMod.config.save(); + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Saved config file.")); + } + case "livid" -> { + if (messageArgs.length == 2) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of((SkyblockMod.skyblockMod.lividColor.on ? "Livid color is on: " : "Livid color is off: ") + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1])); + } else { + switch (messageArgs[2]) { + case "on", "true" -> { + SkyblockMod.skyblockMod.lividColor.on = true; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Livid color turned on")); + } + case "off", "false" -> { + SkyblockMod.skyblockMod.lividColor.on = false; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Livid color turned off")); + } + default -> { + SkyblockMod.skyblockMod.lividColor.text = Arrays.copyOf(message.substring(11).split("\\[color]"), 2); + if (SkyblockMod.skyblockMod.lividColor.text[0] == null) { + SkyblockMod.skyblockMod.lividColor.text[0] = ""; + } + if (SkyblockMod.skyblockMod.lividColor.text[1] == null) { + SkyblockMod.skyblockMod.lividColor.text[1] = ""; + } + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Livid color text set to: " + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1])); + } + } } - if (SkyblockMod.skyblockMod.lividColor.text[1] == null) { - SkyblockMod.skyblockMod.lividColor.text[1] = ""; + } + case "map" -> { + if (messageArgs.length == 2) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map is " + (SkyblockMod.skyblockMod.dungeonMap.on ? "on" : "off"))); + } else { + switch (messageArgs[2]) { + case "on", "true" -> { + SkyblockMod.skyblockMod.dungeonMap.on = true; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon map turned on")); + } + case "off", "false" -> { + SkyblockMod.skyblockMod.dungeonMap.on = false; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon map turned off")); + } + case "scale" -> { + try { + SkyblockMod.skyblockMod.dungeonMap.mapScale = Float.parseFloat(messageArgs[3]); + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map size set to: " + messageArgs[3])); + } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map size: " + SkyblockMod.skyblockMod.dungeonMap.mapScale)); + } + } + case "offset" -> { + try { + SkyblockMod.skyblockMod.dungeonMap.mapOffsetx = Integer.parseInt(messageArgs[3]); + SkyblockMod.skyblockMod.dungeonMap.mapOffsety = Integer.parseInt(messageArgs[4]); + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map offset set to: " + messageArgs[3] + ", " + messageArgs[4])); + } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map offset: " + SkyblockMod.skyblockMod.dungeonMap.mapOffsetx + ", " + SkyblockMod.skyblockMod.dungeonMap.mapOffsety)); + } + } + default -> MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map is " + (SkyblockMod.skyblockMod.dungeonMap.on ? "on" : "off"))); + } } - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Livid color text set to: " + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1])); } - } else if (messageArgs[1].equals("map") && messageArgs.length >= 3) { - if (messageArgs[2].equals("scale")) { - try { - SkyblockMod.skyblockMod.dungeonMap.mapScale = Float.parseFloat(messageArgs[3]); - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map size set to: " + messageArgs[3])); - } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map size: " + SkyblockMod.skyblockMod.dungeonMap.mapScale)); + case "reparty" -> { + if (messageArgs.length == 2) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Reparty is " + (SkyblockMod.skyblockMod.reparty.on ? "on" : "off"))); + } else { + switch (messageArgs[2]) { + case "on", "true" -> { + SkyblockMod.skyblockMod.reparty.on = true; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Reparty turned on")); + } + case "off", "false" -> { + SkyblockMod.skyblockMod.reparty.on = false; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Reparty turned off")); + } + default -> MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Reparty is " + (SkyblockMod.skyblockMod.reparty.on ? "on" : "off"))); + } } - } else if (messageArgs[2].equals("offset")) { - try { - SkyblockMod.skyblockMod.dungeonMap.mapOffsetx = Integer.parseInt(messageArgs[3]); - SkyblockMod.skyblockMod.dungeonMap.mapOffsety = Integer.parseInt(messageArgs[4]); - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map offset set to: " + messageArgs[3] + ", " + messageArgs[4])); - } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Map offset: " + SkyblockMod.skyblockMod.dungeonMap.mapOffsetx + ", " + SkyblockMod.skyblockMod.dungeonMap.mapOffsety)); + } + case "score" -> { + if (messageArgs.length == 2) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("/sbm score [270 or 300] [on, off, or message]")); + } else { + switch (messageArgs[2]) { + case "270" -> { + if (messageArgs.length == 3) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of((SkyblockMod.skyblockMod.dungeonScore.on270 ? "Dungeon score 270 is on: " : "Dungeon score 270 is off: ") + SkyblockMod.skyblockMod.dungeonScore.text270)); + } else { + switch (messageArgs[3]) { + case "on", "true" -> { + SkyblockMod.skyblockMod.dungeonScore.on270 = true; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon score 270 turned on")); + } + case "off", "false" -> { + SkyblockMod.skyblockMod.dungeonScore.on270 = false; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon score 270 turned off")); + } + default -> { + SkyblockMod.skyblockMod.dungeonScore.text270 = message.substring(15); + if (SkyblockMod.skyblockMod.dungeonScore.text270.isEmpty()) { + SkyblockMod.skyblockMod.dungeonScore.text270 = "270 score"; + } + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon score 270 text set to: " + SkyblockMod.skyblockMod.dungeonScore.text270)); + } + } + } + } + case "300" -> { + if (messageArgs.length == 3) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of((SkyblockMod.skyblockMod.dungeonScore.on300 ? "Dungeon score 300 is on: " : "Dungeon score 300 is off: ") + SkyblockMod.skyblockMod.dungeonScore.text300)); + } else { + switch (messageArgs[3]) { + case "on", "true" -> { + SkyblockMod.skyblockMod.dungeonScore.on300 = true; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon score 300 turned on")); + } + case "off", "false" -> { + SkyblockMod.skyblockMod.dungeonScore.on300 = false; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon score 300 turned off")); + } + default -> { + SkyblockMod.skyblockMod.dungeonScore.text300 = message.substring(15); + if (SkyblockMod.skyblockMod.dungeonScore.text300.isEmpty()) { + SkyblockMod.skyblockMod.dungeonScore.text300 = "300 score"; + } + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.of("Dungeon score 300 text set to: " + SkyblockMod.skyblockMod.dungeonScore.text300)); + } + } + } + } + } } } } diff --git a/src/main/java/com/kevinthegreat/skyblockmod/util/Config.java b/src/main/java/com/kevinthegreat/skyblockmod/util/Config.java index e64eedd..7838e46 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/util/Config.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/util/Config.java @@ -2,8 +2,8 @@ import com.kevinthegreat.skyblockmod.dungeons.DungeonMap; import com.kevinthegreat.skyblockmod.SkyblockMod; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import com.kevinthegreat.skyblockmod.dungeons.DungeonScore; +import org.slf4j.Logger; import java.io.*; import java.util.Arrays; @@ -19,9 +19,12 @@ public void load() { String[] args = line.split(":"); try { switch (args[0]) { + case "map" -> dungeonMap.on = Boolean.parseBoolean(args[1]); case "mapScale" -> dungeonMap.mapScale = Float.parseFloat(args[1]); case "mapOffsetX" -> dungeonMap.mapOffsetx = Integer.parseInt(args[1]); case "mapOffsetY" -> dungeonMap.mapOffsety = Integer.parseInt(args[1]); + case "reparty" -> SkyblockMod.skyblockMod.reparty.on = Boolean.parseBoolean(args[1]); + case "lividColor" -> SkyblockMod.skyblockMod.lividColor.on = Boolean.parseBoolean(args[1]); case "lividColorText" -> { SkyblockMod.skyblockMod.lividColor.text = Arrays.copyOf(args[1].split("\\[color]"), 2); if (SkyblockMod.skyblockMod.lividColor.text[0] == null) { @@ -31,36 +34,55 @@ public void load() { SkyblockMod.skyblockMod.lividColor.text[1] = ""; } } + case "score270" -> SkyblockMod.skyblockMod.dungeonScore.on270 = Boolean.parseBoolean(args[1]); + case "score270Text" -> SkyblockMod.skyblockMod.dungeonScore.text270 = args[1]; + case "score300" -> SkyblockMod.skyblockMod.dungeonScore.on300 = Boolean.parseBoolean(args[1]); + case "score300Text" -> SkyblockMod.skyblockMod.dungeonScore.text300 = args[1]; } } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { - LogManager.getLogger().error("Unable to parse configuration \"" + args[0] + "\"."); + SkyblockMod.skyblockMod.LOGGER.error("Unable to parse configuration \"" + args[0] + "\"."); } line = reader.readLine(); } reader.close(); } catch (FileNotFoundException e) { - LogManager.getLogger().info("Configuration file not found."); + SkyblockMod.skyblockMod.LOGGER.info("Configuration file not found."); } catch (IOException e) { - LogManager.getLogger().error("Failed to read configuration file."); + SkyblockMod.skyblockMod.LOGGER.error("Error while reading configuration file."); } } public void save() { DungeonMap dungeonMap = SkyblockMod.skyblockMod.dungeonMap; + DungeonScore dungeonScore = SkyblockMod.skyblockMod.dungeonScore; try { PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(SkyblockMod.MOD_ID + ".txt"))); + writer.println("lividColor:" + SkyblockMod.skyblockMod.lividColor.on); + writer.println("lividColorText:" + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1]); + writer.println("map:" + dungeonMap.on); writer.println("mapScale:" + dungeonMap.mapScale); writer.println("mapOffsetX:" + dungeonMap.mapOffsetx); writer.println("mapOffsetY:" + dungeonMap.mapOffsety); - writer.println("lividColorText:" + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1]); + writer.println("reparty:" + SkyblockMod.skyblockMod.reparty.on); + writer.println("score270:" + dungeonScore.on270); + writer.println("score270Text:" + dungeonScore.text270); + writer.println("score300:" + dungeonScore.on300); + writer.println("score300Text:" + dungeonScore.text300); writer.close(); } catch (IOException e) { - Logger logger = LogManager.getLogger(); - logger.error("Failed to write configuration file. Logging configuration."); + Logger logger = SkyblockMod.skyblockMod.LOGGER; + logger.error("Error while writing configuration file. Logging configuration."); + logger.info("lividColor:" + SkyblockMod.skyblockMod.lividColor.on); + logger.info("lividColorText:" + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1]); + logger.info("map:" + dungeonMap.on); logger.info("mapScale:" + dungeonMap.mapScale); logger.info("mapOffsetX:" + dungeonMap.mapOffsetx); logger.info("mapOffsetY:" + dungeonMap.mapOffsety); - logger.info("lividColorText:" + SkyblockMod.skyblockMod.lividColor.text[0] + "[color]" + SkyblockMod.skyblockMod.lividColor.text[1]); + logger.info("reparty:" + SkyblockMod.skyblockMod.reparty.on); + logger.info("score270:" + dungeonScore.on270); + logger.info("score270Text:" + dungeonScore.text270); + logger.info("score300:" + dungeonScore.on300); + logger.info("score300Text:" + dungeonScore.text300); } } } \ No newline at end of file diff --git a/src/main/java/com/kevinthegreat/skyblockmod/util/Util.java b/src/main/java/com/kevinthegreat/skyblockmod/util/Util.java index 770a327..b22591e 100644 --- a/src/main/java/com/kevinthegreat/skyblockmod/util/Util.java +++ b/src/main/java/com/kevinthegreat/skyblockmod/util/Util.java @@ -16,8 +16,10 @@ //from skyblocker / skyfabric public class Util { + public boolean hypixel = false; public boolean skyblock = false; public boolean catacombs = false; + public boolean crystalHollows = false; public void check() { MinecraftClient minecraftClient = MinecraftClient.getInstance(); @@ -54,10 +56,11 @@ public void check() { Collections.reverse(list); String scoreboardString = list.toString(); if (list.get(list.size() - 1).equals("www.hypixel.net")) { + hypixel = true; if (list.get(0).contains("SKYBLOCK")) { skyblock = true; catacombs = scoreboardString.contains("The Catacombs"); -// crystalHollows = scoreboardString.contains("Precursor Remnants") || scoreboardString.contains("Khazad-dûm") || scoreboardString.contains("Jungle") || scoreboardString.contains("Mithril Deposits") || scoreboardString.contains("Goblin Holdout") || scoreboardString.contains("Goblin Queen's Den") || scoreboardString.contains("Lost Precursor City") || scoreboardString.contains("Crystal Nucleus") || scoreboardString.contains("Crystal Hollows") || scoreboardString.contains("Magma Fields") || scoreboardString.contains("Fairy Grotto") || scoreboardString.contains("Dragon's Lair"); + crystalHollows = scoreboardString.contains("Precursor Remnants") || scoreboardString.contains("Khazad-dûm") || scoreboardString.contains("Jungle") || scoreboardString.contains("Mithril Deposits") || scoreboardString.contains("Goblin Holdout") || scoreboardString.contains("Goblin Queen's Den") || scoreboardString.contains("Lost Precursor City") || scoreboardString.contains("Crystal Nucleus") || scoreboardString.contains("Crystal Hollows") || scoreboardString.contains("Magma Fields") || scoreboardString.contains("Fairy Grotto") || scoreboardString.contains("Dragon's Lair"); } else { skyblock = false; catacombs = false; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index da37b2c..aeea3b7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, - "id": "fabrictils", + "id": "skyblockmod", "version": "${version}", "name": "", @@ -28,7 +28,7 @@ "depends": { "fabricloader": ">=0.11.3", "fabric": "*", - "minecraft": "1.17.x", + "minecraft": ["1.17.x","1.18.x"], "java": ">=16" }, "suggests": {