2012-03-02 02:16:45 +01:00
|
|
|
package com.massivecraft.factions.event;
|
|
|
|
|
2013-04-19 12:27:39 +02:00
|
|
|
import org.bukkit.command.CommandSender;
|
2012-03-02 02:16:45 +01:00
|
|
|
import org.bukkit.event.HandlerList;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.Faction;
|
|
|
|
|
2013-04-19 14:08:45 +02:00
|
|
|
public class FactionsEventMembershipChange extends FactionsEventAbstractSender
|
2012-03-02 02:16:45 +01:00
|
|
|
{
|
2013-04-10 09:34:14 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// REQUIRED EVENT CODE
|
|
|
|
// -------------------------------------------- //
|
2012-03-02 02:16:45 +01:00
|
|
|
|
2013-04-10 09:34:14 +02:00
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
@Override public HandlerList getHandlers() { return handlers; }
|
|
|
|
public static HandlerList getHandlerList() { return handlers; }
|
2012-03-02 02:16:45 +01:00
|
|
|
|
2013-04-10 09:34:14 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// FIELDS
|
|
|
|
// -------------------------------------------- //
|
2012-03-02 02:16:45 +01:00
|
|
|
|
|
|
|
@Override
|
2013-04-19 12:27:39 +02:00
|
|
|
public void setCancelled(boolean cancelled)
|
2012-03-02 02:16:45 +01:00
|
|
|
{
|
2013-04-19 14:08:45 +02:00
|
|
|
if (!this.reason.isCancellable()) cancelled = false;
|
2013-04-19 12:27:39 +02:00
|
|
|
super.setCancelled(cancelled);
|
2012-03-02 02:16:45 +01:00
|
|
|
}
|
2013-04-10 09:34:14 +02:00
|
|
|
|
|
|
|
private final FPlayer fplayer;
|
|
|
|
public FPlayer getFPlayer() { return this.fplayer; }
|
|
|
|
|
2013-04-19 14:08:45 +02:00
|
|
|
private final Faction newFaction;
|
|
|
|
public Faction getNewFaction() { return this.newFaction; }
|
2013-04-19 12:27:39 +02:00
|
|
|
|
2013-04-19 14:08:45 +02:00
|
|
|
private final MembershipChangeReason reason;
|
|
|
|
public MembershipChangeReason getReason() { return this.reason; }
|
2013-04-10 09:34:14 +02:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-19 14:08:45 +02:00
|
|
|
public FactionsEventMembershipChange(CommandSender sender, FPlayer fplayer, Faction newFaction, MembershipChangeReason reason)
|
2013-04-10 09:34:14 +02:00
|
|
|
{
|
2013-04-19 12:27:39 +02:00
|
|
|
super(sender);
|
2013-04-10 09:34:14 +02:00
|
|
|
this.fplayer = fplayer;
|
2013-04-19 14:08:45 +02:00
|
|
|
this.newFaction = newFaction;
|
2013-04-10 09:34:14 +02:00
|
|
|
this.reason = reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// INTERNAL ENUM
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-19 14:08:45 +02:00
|
|
|
public enum MembershipChangeReason
|
2013-04-10 09:34:14 +02:00
|
|
|
{
|
2013-04-19 14:08:45 +02:00
|
|
|
// Join
|
|
|
|
JOIN (true),
|
|
|
|
CREATE (false),
|
|
|
|
LEADER (true),
|
|
|
|
|
|
|
|
// Leave
|
|
|
|
LEAVE (true),
|
|
|
|
//JOINOTHER (true),
|
|
|
|
KICK (true),
|
|
|
|
DISBAND (false),
|
|
|
|
//RESET (false),
|
|
|
|
;
|
|
|
|
|
|
|
|
private final boolean cancellable;
|
|
|
|
public boolean isCancellable() { return this.cancellable; }
|
|
|
|
|
|
|
|
private MembershipChangeReason(boolean cancellable)
|
|
|
|
{
|
|
|
|
this.cancellable = cancellable;
|
|
|
|
}
|
2013-04-10 09:34:14 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 02:16:45 +01:00
|
|
|
}
|