From f402027fcef81254125385aee2b7794ade0cb8fc Mon Sep 17 00:00:00 2001 From: Farhan Ahmad Date: Thu, 25 Apr 2019 14:38:19 +0100 Subject: [PATCH 1/2] Added olm cripple timer overlay --- .../OlmCrippleTimerOverlay.java | 65 ++++++++++++++ .../OlmCrippleTimerPlugin.java | 90 +++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerOverlay.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerOverlay.java new file mode 100644 index 0000000000..949c8be23b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerOverlay.java @@ -0,0 +1,65 @@ +package net.runelite.client.plugins.olmcrippletimer; + + +import java.awt.*; +import java.util.*; +import java.util.List; +import javax.inject.Inject; +import net.runelite.api.*; +import net.runelite.api.Point; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.coords.WorldArea; +import net.runelite.api.coords.WorldPoint; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.OverlayUtil; + + +public class OlmCrippleTimerOverlay extends Overlay { + + + private final Client client; + private final OlmCrippleTimerPlugin plugin; + + @Inject + private OlmCrippleTimerOverlay(Client client, OlmCrippleTimerPlugin plugin){ + this.client = client; + this.plugin = plugin; + setPosition(OverlayPosition.DYNAMIC); + setPriority(OverlayPriority.HIGH); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + @Override + public Dimension render(Graphics2D graphics) { + if(plugin.isHandCripple()){ + int tick = plugin.getTimer(); + NPC olmHand = plugin.getHand(); + final String tickStr = String.valueOf(tick); + Point canvasPoint = olmHand.getCanvasTextLocation(graphics, tickStr, 50); + renderTextLocation(graphics, tickStr, 12 , Font.BOLD, Color.GRAY, canvasPoint); + } + + + return null; + } + //this is just copy pasted btw + private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint) + { + graphics.setFont(new Font("Arial", fontStyle, fontSize)); + if (canvasPoint != null) + { + final Point canvasCenterPoint = new Point( + canvasPoint.getX(), + canvasPoint.getY()); + final Point canvasCenterPoint_shadow = new Point( + canvasPoint.getX() + 1, + canvasPoint.getY() + 1) ; + OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK); + OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, txtString, fontColor); + } + } + +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java new file mode 100644 index 0000000000..3bd63e7575 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java @@ -0,0 +1,90 @@ +package net.runelite.client.plugins.olmcrippletimer; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.NpcID; +import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.NpcDespawned; +import net.runelite.api.events.NpcSpawned; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginType; +import net.runelite.client.ui.overlay.OverlayManager; + +import javax.inject.Inject; + +@PluginDescriptor( + name="Olm Cripple Timer", + description = "Shows a timer over the olm hand cripple", + tags = {"cox", "raid", "clench", "melee", "hand"}, + type = PluginType.PVM +) + +public class OlmCrippleTimerPlugin extends Plugin{ + + private static final String OLM_HAND_CRIPPLE = "The Great Olm\'s left claw clenches to protect itself temporarily."; + @Inject + private Client client; + @Getter(AccessLevel.PACKAGE) + private boolean HandCripple; + @Getter(AccessLevel.PACKAGE) + private int timer = 45; + @Getter(AccessLevel.PACKAGE) + private NPC hand; + @Inject + private OverlayManager overlayManager; + @Inject + private OlmCrippleTimerOverlay olmCrippleTimerOverlay; + + @Override + protected void startUp() throws Exception { + overlayManager.add(olmCrippleTimerOverlay); + } + @Override + protected void shutDown() throws Exception { + overlayManager.remove(olmCrippleTimerOverlay); + HandCripple = false; + timer = 45; + hand = null; + + } + @Subscribe + public void onChatMessage(ChatMessage event) + { + + String message = event.getMessage(); + if(message.startsWith(OLM_HAND_CRIPPLE)){ + HandCripple = true; + timer = 45; + } + } + @Subscribe + public void onNpcDespawned(NpcDespawned npcdespawned){ + if(npcdespawned.getNpc().getId() == NpcID.GREAT_OLM_RIGHT_CLAW_7553 || npcdespawned.getNpc().getId() == NpcID.GREAT_OLM_RIGHT_CLAW){ + HandCripple = false; + } + } + @Subscribe + public void onNpcSpawned(NpcSpawned npcSpawned) + { + if(npcSpawned.getNpc().getId() == NpcID.GREAT_OLM_LEFT_CLAW_7555 || npcSpawned.getNpc().getId() == NpcID.GREAT_OLM_LEFT_CLAW){ + hand = npcSpawned.getNpc(); + } + } + @Subscribe + public void onGameTick(GameTick event) + { + if(HandCripple) { + timer--; + if (timer <= 0) { + HandCripple = false; + timer = 45; + } + } + } +} \ No newline at end of file From a1b710e57860a52ecb817078a66013f16adc400e Mon Sep 17 00:00:00 2001 From: gazivodag <43923017+gazivodag@users.noreply.github.com> Date: Thu, 25 Apr 2019 09:42:02 -0400 Subject: [PATCH 2/2] Update OlmCrippleTimerPlugin.java --- .../client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java index 3bd63e7575..4e51224624 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/olmcrippletimer/OlmCrippleTimerPlugin.java @@ -19,7 +19,7 @@ import net.runelite.client.ui.overlay.OverlayManager; import javax.inject.Inject; @PluginDescriptor( - name="Olm Cripple Timer", + name="Olm Cripple Timer", description = "Shows a timer over the olm hand cripple", tags = {"cox", "raid", "clench", "melee", "hand"}, type = PluginType.PVM @@ -87,4 +87,4 @@ public class OlmCrippleTimerPlugin extends Plugin{ } } } -} \ No newline at end of file +}