Saber-Factions/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java

64 lines
1.7 KiB
Java
Raw Normal View History

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;
/**
* Event called when a player regenerate power.
*/
public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable {
private boolean cancelled = false;
2019-11-01 19:15:18 +01:00
private double modified = 0;
public PowerRegenEvent(Faction f, FPlayer p) {
super(f, p);
}
/**
2019-11-01 19:23:41 +01:00
* Get the amount of power this player will regen by default
* @return power amount gained as a Double.
*/
2019-11-01 19:23:41 +01:00
public double getDefaultPowerGained() {
return fPlayer.getMillisPassed() * Conf.powerPerMinute / 60000;
}
2019-11-01 19:15:18 +01:00
/**
* Get the amount of custom power this player will gain. Ignored if less than or equal to 0.
* @return Custom power as a double
*/
public double getCustomPower() {return modified;}
/**
* Get if we will be using the custom power gain instead of default.
* @return If we will process the event custom returned as a Boolean.
*/
public boolean usingCustomPower() {
if (modified > 0) {
return true;
}
return false;
}
/**
* Set the custom power gain for this event.
* @param gain Amount of power to be added to player.
*/
public void setCustomPower(Double gain) {modified = gain;}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean c) {
this.cancelled = c;
}
}