HealthBarUpdated event made immutable and additional documentation

This commit is contained in:
Irmuun
2021-03-05 18:06:29 -08:00
parent 00d7f27d0a
commit 9066b670d6
2 changed files with 9 additions and 7 deletions

View File

@@ -24,22 +24,26 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data; import lombok.Value;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Hitsplat; import net.runelite.api.Hitsplat;
/** /**
* An event called when an {@link Actor} health bar is updated from a {@link Hitsplat}. * An event called when an {@link Actor} health bar is updated from a {@link Hitsplat}.
* <p>
* This event is called when the health bar first appears and when the client gets new information
* about the health bar of the actor. It does not fire when the health bar disappears.
* The event will still fire even if the health ratio did not change for example from a 0 hitsplat.
*/ */
@Data @Value
public class HealthBarUpdated public class HealthBarUpdated
{ {
/** /**
* The actor the hitsplat was applied to. * The actor the hitsplat was applied to.
*/ */
private Actor actor; Actor actor;
/** /**
* The updated health ratio. * The updated health ratio.
*/ */
private int healthRatio; int healthRatio;
} }

View File

@@ -270,9 +270,7 @@ public abstract class RSActorMixin implements RSActor
this.setDead(true); this.setDead(true);
} }
final HealthBarUpdated event = new HealthBarUpdated(); final HealthBarUpdated event = new HealthBarUpdated(this, healthRatio);
event.setActor(this);
event.setHealthRatio(healthRatio);
client.getCallbacks().post(event); client.getCallbacks().post(event);
} }