aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/LowHealthNotifications.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker/features/LowHealthNotifications.java')
-rw-r--r--src/main/java/me/Danker/features/LowHealthNotifications.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/features/LowHealthNotifications.java b/src/main/java/me/Danker/features/LowHealthNotifications.java
new file mode 100644
index 0000000..0bf2898
--- /dev/null
+++ b/src/main/java/me/Danker/features/LowHealthNotifications.java
@@ -0,0 +1,36 @@
+package me.Danker.features;
+
+import me.Danker.DankersSkyblockMod;
+import me.Danker.commands.ToggleCommand;
+import me.Danker.handlers.ScoreboardHandler;
+import me.Danker.utils.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+
+import java.util.List;
+
+public class LowHealthNotifications {
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.START) return;
+
+ World world = Minecraft.getMinecraft().theWorld;
+ if (DankersSkyblockMod.tickAmount % 2 == 0) {
+ if (ToggleCommand.lowHealthNotifyToggled && Utils.inDungeons && world != null) {
+ List<String> scoreboard = ScoreboardHandler.getSidebarLines();
+ for (String score : scoreboard) {
+ if (score.endsWith("❤") && score.matches(".* §c\\d.*")) {
+ String name = score.substring(score.indexOf(" ") + 1);
+ Utils.createTitle(EnumChatFormatting.RED + "LOW HEALTH!\n" + name, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+}