From 8b78e680240a20d1b44c03f6bbcbb42b36a02827 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Wed, 25 Nov 2020 22:55:50 -0500 Subject: Add low health alerts --- README.md | 3 ++- src/main/java/me/Danker/TheMod.java | 15 ++++++++++++++- src/main/java/me/Danker/commands/DHelpCommand.java | 2 +- src/main/java/me/Danker/commands/ToggleCommand.java | 13 ++++++++++--- src/main/java/me/Danker/gui/DankerGui.java | 7 +++++++ src/main/java/me/Danker/handlers/ConfigHandler.java | 2 ++ 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ca46bc2..e02bbb8 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,14 @@ Discord Server: https://discord.gg/QsEkNQS - Show total skill xp instead of progress to next level - Show time until century cakes run out - Mythological event (Diana) tracker +- Low health alert in dungeons - API commands - Update checker ## Commands - /dhelp - Returns this message in-game. - /dsm - Opens the GUI for Danker's Skyblock Mod. -- /toggle - Toggles features. /toggle list returns values of every toggle. +- /toggle - Toggles features. /toggle list returns values of every toggle. - /setkey - Sets API key. - /getkey - Returns key set with /setkey and copies it to your clipboard. - /loot [winter/spooky/f(1-7)/session] - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead. diff --git a/src/main/java/me/Danker/TheMod.java b/src/main/java/me/Danker/TheMod.java index 7c821fd..55ec20e 100644 --- a/src/main/java/me/Danker/TheMod.java +++ b/src/main/java/me/Danker/TheMod.java @@ -2519,7 +2519,7 @@ public class TheMod // Checks 5 times per second if (tickAmount % 4 == 0) { - if (ToggleCommand.blazeToggled && Utils.inDungeons && world != null) { + if (ToggleCommand.blazeToggled && Utils.inDungeons && world != null) { List entities = world.getLoadedEntityList(); int highestHealth = 0; highestBlaze = null; @@ -2563,6 +2563,19 @@ public class TheMod } } + // Checks 10 times per second + if (tickAmount % 2 == 0) { + if (ToggleCommand.lowHealthNotifyToggled && Utils.inDungeons && world != null) { + List scoreboard = ScoreboardHandler.getSidebarLines(); + for (String score : scoreboard) { + if (score.endsWith("❤") && score.matches(".*§c\\d.*")) { + Utils.createTitle(EnumChatFormatting.RED + "LOW HEALTH!", 1); + break; + } + } + } + } + if (titleTimer >= 0) { if (titleTimer == 0) { showTitle = false; diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index e900c57..9d9bb51 100644 --- a/src/main/java/me/Danker/commands/DHelpCommand.java +++ b/src/main/java/me/Danker/commands/DHelpCommand.java @@ -34,7 +34,7 @@ public class DHelpCommand extends CommandBase { EnumChatFormatting.GOLD + " Commands, " + EnumChatFormatting.GREEN + " Keybinds.\n" + EnumChatFormatting.GOLD + " /dhelp" + EnumChatFormatting.AQUA + " - Returns this message.\n" + EnumChatFormatting.GOLD + " /dsm" + EnumChatFormatting.AQUA + " - Opens the GUI for Danker's Skyblock Mod.\n" + - EnumChatFormatting.GOLD + " /toggle " + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" + + EnumChatFormatting.GOLD + " /toggle " + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" + EnumChatFormatting.GOLD + " /setkey " + EnumChatFormatting.AQUA + " - Sets API key.\n" + EnumChatFormatting.GOLD + " /getkey" + EnumChatFormatting.AQUA + " - Returns key set with /setkey and copies it to your clipboard.\n" + EnumChatFormatting.GOLD + " /loot [winter/festival/spooky/f(1-7)/session]" + EnumChatFormatting.AQUA + " - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead.\n" + diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 0aba64b..6e85d58 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -33,6 +33,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean midasStaffMessages; public static boolean healMessages; public static boolean cakeTimerToggled; + public static boolean lowHealthNotifyToggled; public static boolean lividSolverToggled; // Puzzle Solvers public static boolean threeManToggled; @@ -50,7 +51,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public String getCommandUsage(ICommandSender arg0) { return "/" + getCommandName() + " "; } @@ -66,8 +67,8 @@ public class ToggleCommand extends CommandBase implements ICommand { "splitfishing", "chatmaddox", "spiritbearalerts", "aotd", "lividdagger", "sceptremessages", "petcolors", "dungeontimer", "golemalerts", "expertiselore", "skill50display", "outlinetext", "midasstaffmessages", - "healmessages", "caketimer", "lividsolver", "threemanpuzzle", "oruopuzzle", - "blazepuzzle", "creeperpuzzle", "waterpuzzle", "list"); + "healmessages", "caketimer", "lowhealthnotify", "lividsolver", "threemanpuzzle", + "oruopuzzle", "blazepuzzle", "creeperpuzzle", "waterpuzzle", "list"); } return null; } @@ -183,6 +184,11 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "CakeTimer", cakeTimerToggled); player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Cake timer has been set to " + TheMod.SECONDARY_COLOUR + cakeTimerToggled + TheMod.MAIN_COLOUR + ".")); break; + case "lowhealthnotify": + lowHealthNotifyToggled = !lowHealthNotifyToggled; + ConfigHandler.writeBooleanConfig("toggles", "LowHealthNotify", lowHealthNotifyToggled); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Low health notify has been set to " + TheMod.SECONDARY_COLOUR + lowHealthNotifyToggled + TheMod.MAIN_COLOUR + ".")); + break; case "lividsolver": lividSolverToggled = !lividSolverToggled; ConfigHandler.writeBooleanConfig("toggles", "LividSolver", lividSolverToggled); @@ -234,6 +240,7 @@ public class ToggleCommand extends CommandBase implements ICommand { TheMod.TYPE_COLOUR + " Midas Staff messages: " + TheMod.VALUE_COLOUR + midasStaffMessages + "\n" + TheMod.TYPE_COLOUR + " Heal messages: " + TheMod.VALUE_COLOUR + healMessages + "\n" + TheMod.TYPE_COLOUR + " Cake timer: " + TheMod.VALUE_COLOUR + cakeTimerToggled + "\n" + + TheMod.TYPE_COLOUR + " Low health notify: " + TheMod.VALUE_COLOUR + lowHealthNotifyToggled + "\n" + TheMod.TYPE_COLOUR + " Livid solver: " + TheMod.VALUE_COLOUR + lividSolverToggled + "\n" + TheMod.TYPE_COLOUR + " Three man puzzle solver: " + TheMod.VALUE_COLOUR + threeManToggled + "\n" + TheMod.TYPE_COLOUR + " Oruo trivia solver: " + TheMod.VALUE_COLOUR + oruoToggled + "\n" + diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index 205dc8b..f086e25 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -49,6 +49,7 @@ public class DankerGui extends GuiScreen { private GuiButton midasStaffMessages; private GuiButton healMessages; private GuiButton cakeTimer; + private GuiButton lowHealthNotify; private GuiButton lividSolver; public DankerGui(int page) { @@ -104,6 +105,7 @@ public class DankerGui extends GuiScreen { lividSolver = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Find Correct Livid: " + Utils.getColouredBoolean(ToggleCommand.lividSolverToggled)); golemAlerts = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Alert When Golem Spawns: " + Utils.getColouredBoolean(ToggleCommand.golemAlertToggled)); rngesusAlert = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "RNGesus Alerts: " + Utils.getColouredBoolean(ToggleCommand.rngesusAlerts)); + lowHealthNotify = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Low Health Notifications: " + Utils.getColouredBoolean(ToggleCommand.lowHealthNotifyToggled)); if (page == 1) { this.buttonList.add(changeDisplay); @@ -139,6 +141,7 @@ public class DankerGui extends GuiScreen { this.buttonList.add(lividSolver); this.buttonList.add(golemAlerts); this.buttonList.add(rngesusAlert); + this.buttonList.add(lowHealthNotify); this.buttonList.add(backPage); } @@ -268,6 +271,10 @@ public class DankerGui extends GuiScreen { ToggleCommand.healMessages = !ToggleCommand.healMessages; ConfigHandler.writeBooleanConfig("toggles", "HealMessages", ToggleCommand.healMessages); healMessages.displayString = "Heal Messages: " + Utils.getColouredBoolean(ToggleCommand.healMessages); + } else if (button == lowHealthNotify) { + ToggleCommand.lowHealthNotifyToggled = !ToggleCommand.lowHealthNotifyToggled; + ConfigHandler.writeBooleanConfig("toggles", "LowHealthNotify", ToggleCommand.lowHealthNotifyToggled); + lowHealthNotify.displayString = "Low Health Notifications: " + Utils.getColouredBoolean(ToggleCommand.lowHealthNotifyToggled); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 8cfc9bf..c5ede0c 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -193,6 +193,7 @@ public class ConfigHandler { if (!hasKey("toggles", "MidasStaffMessages")) writeBooleanConfig("toggles", "MidasStaffMessages", true); if (!hasKey("toggles", "HealMessages")) writeBooleanConfig("toggles", "HealMessages", true); if (!hasKey("toggles", "CakeTimer")) writeBooleanConfig("toggles", "CakeTimer", false); + if (!hasKey("toggles", "LowHealthNotify")) writeBooleanConfig("toggles", "LowHealthNotify", false); if (!hasKey("toggles", "LividSolver")) writeBooleanConfig("toggles", "LividSolver", false); // Puzzle Solvers if (!hasKey("toggles", "ThreeManPuzzle")) writeBooleanConfig("toggles", "ThreeManPuzzle", false); @@ -425,6 +426,7 @@ public class ConfigHandler { ToggleCommand.midasStaffMessages = getBoolean("toggles", "MidasStaffMessages"); ToggleCommand.healMessages = getBoolean("toggles", "HealMessages"); ToggleCommand.cakeTimerToggled = getBoolean("toggles", "CakeTimer"); + ToggleCommand.lowHealthNotifyToggled = getBoolean("toggles", "LowHealthNotify"); ToggleCommand.lividSolverToggled = getBoolean("toggles", "LividSolver"); // Puzzle Solvers ToggleCommand.threeManToggled = getBoolean("toggles", "ThreeManPuzzle"); -- cgit