diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index fd16466c..ac2305f2 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -281,6 +281,10 @@ public interface FPlayer extends EconomyParticipator { int getPowerMinRounded(); + long getMillisPassed(); + + long getLastPowerUpdateTime(); + void updatePower(); void losePowerFromBeingOffline(); diff --git a/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java b/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java index 45a5b19b..df277804 100644 --- a/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java +++ b/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.event; +import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import org.bukkit.entity.Player; @@ -68,6 +69,12 @@ public class PowerLossEvent extends FactionPlayerEvent implements Cancellable { this.message = message; } + /** + * Gets the damage to a players individual power + * @return power lost as a Double. + */ + public Double getPowerLost() {return Conf.powerPerDeath;} + @Override public boolean isCancelled() { return cancelled; diff --git a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java index b9a7ec2c..9d3291d5 100644 --- a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java +++ b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java @@ -1,7 +1,10 @@ package com.massivecraft.factions.event; +import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.zcore.persist.MemoryFPlayer; +import com.massivecraft.factions.zcore.persist.MemoryFPlayers; import org.bukkit.event.Cancellable; /** @@ -15,6 +18,14 @@ public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable { super(f, p); } + /** + * Get the amount of power this player will regen + * @return power amount gained as a Double. + */ + public Double getPowerGained() { + return fPlayer.getMillisPassed() * Conf.powerPerMinute / 60000; + } + @Override public boolean isCancelled() { return cancelled; diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index d6fdd073..1877ef92 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -49,6 +49,7 @@ public abstract class MemoryFPlayer implements FPlayer { protected double power; protected double powerBoost; protected long lastPowerUpdateTime; + protected long millisPassed; protected long lastLoginTime; protected ChatMode chatMode; protected boolean ignoreAllianceChat = false; @@ -599,6 +600,12 @@ public abstract class MemoryFPlayer implements FPlayer { public int getPowerMinRounded() { return (int) Math.round(this.getPowerMin()); } + public long getMillisPassed() { + return this.millisPassed; + } + public long getLastPowerUpdateTime() { + return this.millisPassed; + } public void updatePower() { if (this.isOffline()) { @@ -611,7 +618,7 @@ public abstract class MemoryFPlayer implements FPlayer { } long now = System.currentTimeMillis(); - long millisPassed = now - this.lastPowerUpdateTime; + this.millisPassed = now - this.lastPowerUpdateTime; this.lastPowerUpdateTime = now; Player thisPlayer = this.getPlayer();