From 7a1ce39633f13123d6380e122ba0a62bf1d5a3c6 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 27 May 2018 11:19:41 -0400 Subject: [PATCH] Remove actor death event, use despawn event instead --- .../net/runelite/api/events/ActorDeath.java | 40 ------------------- .../net/runelite/client/callback/Hooks.java | 7 ---- .../specialcounter/SpecialCounterPlugin.java | 8 ++-- 3 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 runelite-api/src/main/java/net/runelite/api/events/ActorDeath.java diff --git a/runelite-api/src/main/java/net/runelite/api/events/ActorDeath.java b/runelite-api/src/main/java/net/runelite/api/events/ActorDeath.java deleted file mode 100644 index 3c2493ec5a..0000000000 --- a/runelite-api/src/main/java/net/runelite/api/events/ActorDeath.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.api.events; - -import lombok.Data; -import net.runelite.api.Actor; - -/** - * An event where the {@link Actor} has died. - */ -@Data -public class ActorDeath -{ - /** - * The player or NPC who died. - */ - private Actor actor; -} diff --git a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java index ac08796bd9..57fedba6a4 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java @@ -56,7 +56,6 @@ import net.runelite.api.RenderOverview; import net.runelite.api.TextureProvider; import net.runelite.api.WorldMapManager; import net.runelite.api.coords.LocalPoint; -import net.runelite.api.events.ActorDeath; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameTick; @@ -456,12 +455,6 @@ public class Hooks public static void onSetCombatInfo(Actor actor, int combatInfoId, int gameCycle, int var3, int var4, int healthRatio, int health) { - if (healthRatio == 0) - { - ActorDeath death = new ActorDeath(); - death.setActor(actor); - eventBus.post(death); - } } public static void postItemComposition(ItemComposition itemComposition) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java index 419cf71e7a..29404ac58a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java @@ -37,9 +37,9 @@ import net.runelite.api.NPC; import net.runelite.api.Player; import net.runelite.api.Skill; import net.runelite.api.VarPlayer; -import net.runelite.api.events.ActorDeath; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; +import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.VarbitChanged; import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.Plugin; @@ -162,11 +162,11 @@ public class SpecialCounterPlugin extends Plugin } @Subscribe - public void onActorDeath(ActorDeath death) + public void onNpcDespawn(NpcDespawned npcDespawned) { - Actor actor = death.getActor(); + NPC actor = npcDespawned.getNpc(); - if (actor instanceof NPC && ((NPC) actor).getId() == interactedNpcId) + if (actor.getHealthRatio() == 0 && actor.getId() == interactedNpcId) { removeCounters(); }