Remove actor death event, use despawn event instead

This commit is contained in:
Adam
2018-05-27 11:19:41 -04:00
parent 4d4d5fd180
commit 7a1ce39633
3 changed files with 4 additions and 51 deletions

View File

@@ -1,40 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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;
}

View File

@@ -56,7 +56,6 @@ import net.runelite.api.RenderOverview;
import net.runelite.api.TextureProvider; import net.runelite.api.TextureProvider;
import net.runelite.api.WorldMapManager; import net.runelite.api.WorldMapManager;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.events.ActorDeath;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.FocusChanged; import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.GameTick; 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) 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) public static void postItemComposition(ItemComposition itemComposition)

View File

@@ -37,9 +37,9 @@ import net.runelite.api.NPC;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import net.runelite.api.VarPlayer; import net.runelite.api.VarPlayer;
import net.runelite.api.events.ActorDeath;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -162,11 +162,11 @@ public class SpecialCounterPlugin extends Plugin
} }
@Subscribe @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(); removeCounters();
} }