2018-11-20 20:51:07 +01:00
|
|
|
package com.massivecraft.factions.event;
|
|
|
|
|
2019-11-01 10:52:42 +01:00
|
|
|
import com.massivecraft.factions.Conf;
|
2018-11-20 20:51:07 +01:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.Faction;
|
2019-11-01 10:52:42 +01:00
|
|
|
import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
|
|
|
|
import com.massivecraft.factions.zcore.persist.MemoryFPlayers;
|
2019-02-11 05:57:45 +01:00
|
|
|
import org.bukkit.event.Cancellable;
|
2018-11-20 20:51:07 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Event called when a player regenerate power.
|
|
|
|
*/
|
|
|
|
public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable {
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
private boolean cancelled = false;
|
2019-11-01 19:15:18 +01:00
|
|
|
private double modified = 0;
|
2018-11-20 20:51:07 +01:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public PowerRegenEvent(Faction f, FPlayer p) {
|
|
|
|
super(f, p);
|
|
|
|
}
|
2018-11-20 20:51:07 +01:00
|
|
|
|
2019-11-01 10:52:42 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
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;}
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public boolean isCancelled() {
|
|
|
|
return cancelled;
|
|
|
|
}
|
2018-11-20 20:51:07 +01:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public void setCancelled(boolean c) {
|
|
|
|
this.cancelled = c;
|
|
|
|
}
|
2018-11-20 20:51:07 +01:00
|
|
|
|
|
|
|
}
|