Skip to content

Commit

Permalink
Merge pull request #22 from PixelOutlaw/develop
Browse files Browse the repository at this point in the history
New version to add missing fields and refactor property change event
  • Loading branch information
UltraFaceguy committed Dec 23, 2020
2 parents 1c3309d + d31f16e commit 6825d15
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</parent>

<artifactId>strife</artifactId>
<version>3.3.1</version>
<version>3.3.2</version>
<packaging>jar</packaging>

<name>strife</name>
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/land/face/strife/events/PropertyUpdateEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/land/face/strife/util/StatUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 6825d15

Please sign in to comment.