From 6b97bdadd7f01189cde01b2c33c06dad0bb4c9c8 Mon Sep 17 00:00:00 2001 From: Nicholas Ingram <34698287+Nicholas-Ingram@users.noreply.github.com> Date: Sat, 14 Oct 2023 19:15:52 -0500 Subject: [PATCH] Added the ability to end a session when the player enters a Player Owned House. This is a configurable option. --- src/main/java/com/killsperhour/KphConfig.java | 16 ++++++++++---- src/main/java/com/killsperhour/KphPlugin.java | 22 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/killsperhour/KphConfig.java b/src/main/java/com/killsperhour/KphConfig.java index 7d104e3..5f23410 100644 --- a/src/main/java/com/killsperhour/KphConfig.java +++ b/src/main/java/com/killsperhour/KphConfig.java @@ -254,9 +254,17 @@ enum BottomGoalOverlay ) default boolean printKphInChat() { return false; } + @ConfigItem( + position = 5, + keyName = "PoH Ends Session", + name = "PoH Ends Session", + description = "Automatically ends the current session when the player enters the PoH", + section = generalSettings + ) + default boolean endSessionPoH() { return false; } @ConfigItem( - position = 5, + position = 6, keyName = "Session Timeout", name = "Session Timeout", description = "Set the session timeout time in minutes (set to 0 for no timeout time)", @@ -276,7 +284,7 @@ enum KphMethod } @ConfigItem( - position = 6, + position = 7, keyName = "KPH Calc Method", name = "KPH Calc", description = "Allows you to choose the method KPH calculated via", @@ -291,7 +299,7 @@ enum LootDisplay } @ConfigItem( - position = 7, + position = 8, keyName = "Loot Display", name = "Loot Display", description = "Allows you to choose the method KPH calculated via", @@ -308,7 +316,7 @@ enum DksSelector } @ConfigItem( - position = 8, + position = 9, keyName = "Dagannoth Selector", name = "Dagannoth Selector", description = "Allows you to select which Dagannoth King the plugin will track", diff --git a/src/main/java/com/killsperhour/KphPlugin.java b/src/main/java/com/killsperhour/KphPlugin.java index bd27bcc..f6fda05 100644 --- a/src/main/java/com/killsperhour/KphPlugin.java +++ b/src/main/java/com/killsperhour/KphPlugin.java @@ -28,10 +28,7 @@ import lombok.Getter; import lombok.Setter; import net.runelite.api.*; -import net.runelite.api.events.ChatMessage; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.HitsplatApplied; +import net.runelite.api.events.*; import net.runelite.client.callback.ClientThread; import net.runelite.client.chat.ChatCommandManager; import net.runelite.client.chat.ChatMessageManager; @@ -144,6 +141,8 @@ public class KphPlugin extends Plugin private int firstKillTime; private int attkCount; + private final int pohPortalId = ObjectID.PORTAL_4525; + private final int[] cmRegions = {13138, 13137, 13139, 13141, 13136, 13145, 13393, 13394, 13140, 13395, 13397}; private final int[] regGauntletRegion = {7512}; private final int[] cGauntletRegion = {7768}; @@ -574,8 +573,19 @@ public void onGameTick(GameTick gameTick) } - - + @Subscribe + public void onGameObjectSpawned(GameObjectSpawned event) + { + // Retrieve the spawned object + final GameObject gameObject = event.getGameObject(); + // Try and see if the PoH exit portal is found (id PORTAL_4525) if it is that means the player is in a PoH + if (gameObject.getId() == pohPortalId) + { + // The player is in a PoH. Check to see if they want to end session when in PoH + if (config.endSessionPoH()) + sessionEnd(); + } + } public boolean timesAreNotNull() {