From d31f16e43ec26ff3076970e00d811079b375ea6f Mon Sep 17 00:00:00 2001 From: UltraFaceguy Date: Wed, 23 Dec 2020 18:12:48 -0500 Subject: [PATCH] New version to add missing fields and refactor property change event --- pom.xml | 2 +- .../face/strife/events/PropertyUpdateEvent.java | 17 ++++++++++++----- .../java/land/face/strife/util/StatUtil.java | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 90900150..54e57463 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ strife - 3.3.1 + 3.3.2 jar strife diff --git a/src/main/java/land/face/strife/events/PropertyUpdateEvent.java b/src/main/java/land/face/strife/events/PropertyUpdateEvent.java index dc40b8b8..73e13dbf 100644 --- a/src/main/java/land/face/strife/events/PropertyUpdateEvent.java +++ b/src/main/java/land/face/strife/events/PropertyUpdateEvent.java @@ -22,6 +22,7 @@ */ package land.face.strife.events; +import land.face.strife.data.StrifeMob; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -33,18 +34,24 @@ public static HandlerList getHandlerList() { return HANDLER_LIST; } - private final String id; + private final StrifeMob mob; + private final String propertyId; private final float baseValue; private float appliedValue; - public PropertyUpdateEvent(String id, float baseValue) { - this.id = id; + public PropertyUpdateEvent(StrifeMob mob, String propertyId, float baseValue) { + this.mob = mob; + this.propertyId = propertyId; this.baseValue = baseValue; appliedValue = baseValue; } - public String getId() { - return id; + public StrifeMob getMob() { + return mob; + } + + public String getPropertyId() { + return propertyId; } public float getBaseValue() { diff --git a/src/main/java/land/face/strife/util/StatUtil.java b/src/main/java/land/face/strife/util/StatUtil.java index 080c1e4c..675d76a9 100644 --- a/src/main/java/land/face/strife/util/StatUtil.java +++ b/src/main/java/land/face/strife/util/StatUtil.java @@ -35,14 +35,14 @@ public static float getBarrierRegen(StrifeMob ae) { public static float getHealth(StrifeMob ae) { float amount = ae.getStat(StrifeStat.HEALTH) * (1 + ae.getStat(StrifeStat.HEALTH_MULT) / 100); - PropertyUpdateEvent event = new PropertyUpdateEvent("life", amount); + PropertyUpdateEvent event = new PropertyUpdateEvent(ae, "life", amount); Bukkit.getPluginManager().callEvent(event); return event.getAppliedValue(); } public static float getMaximumEnergy(StrifeMob ae) { float amount = ae.getStat(StrifeStat.ENERGY) * (1 + ae.getStat(StrifeStat.ENERGY_MULT) / 100); - PropertyUpdateEvent event = new PropertyUpdateEvent("energy", amount); + PropertyUpdateEvent event = new PropertyUpdateEvent(ae, "energy", amount); Bukkit.getPluginManager().callEvent(event); return event.getAppliedValue(); }