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

43 lines
1.1 KiB
Java
Raw Normal View History

package com.massivecraft.factions.event;
2014-04-04 20:55:21 +02:00
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import org.bukkit.event.Cancellable;
public class FPlayerLeaveEvent extends FactionPlayerEvent implements Cancellable {
2014-04-04 20:55:21 +02:00
private PlayerLeaveReason reason;
boolean cancelled = false;
public enum PlayerLeaveReason {
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
}
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) {
super(f, p);
2014-07-01 22:10:18 +02:00
reason = r;
2014-04-04 20:55:21 +02:00
}
2014-07-09 21:01:53 +02:00
/**
* Get the reason the player left the faction.
*
* @return reason player left the faction.
*/
2014-04-04 20:55:21 +02:00
public PlayerLeaveReason getReason() {
return reason;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean c) {
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) {
cancelled = false; // Don't let them cancel factions disbanding.
} else {
2014-07-09 21:01:53 +02:00
cancelled = c;
}
2014-04-04 20:55:21 +02:00
}
}