Factions/src/com/massivecraft/factions/event/EventFactionsMembershipChan...

83 lines
2.1 KiB
Java
Raw Normal View History

2012-03-02 02:16:45 +01:00
package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender;
2012-03-02 02:16:45 +01:00
import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.MPlayer;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction;
2012-03-02 02:16:45 +01:00
2014-06-04 16:47:01 +02:00
public class EventFactionsMembershipChange extends EventFactionsAbstractSender
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
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;
super.setCancelled(cancelled);
2012-03-02 02:16:45 +01:00
}
2013-04-10 09:34:14 +02:00
2014-09-17 13:29:58 +02:00
private final MPlayer mplayer;
public MPlayer getMPlayer() { return this.mplayer; }
2013-04-10 09:34:14 +02:00
2013-04-19 14:08:45 +02:00
private final Faction newFaction;
public Faction getNewFaction() { return this.newFaction; }
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
// -------------------------------------------- //
2014-09-17 13:29:58 +02:00
public EventFactionsMembershipChange(CommandSender sender, MPlayer mplayer, Faction newFaction, MembershipChangeReason reason)
2013-04-10 09:34:14 +02:00
{
super(sender);
2014-09-17 13:29:58 +02:00
this.mplayer = mplayer;
2013-04-19 14:08:45 +02:00
this.newFaction = newFaction;
2013-04-10 09:34:14 +02:00
this.reason = reason;
}
// -------------------------------------------- //
// REASON ENUM
2013-04-10 09:34:14 +02:00
// -------------------------------------------- //
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
2016-10-09 10:59:43 +02:00
JOIN (true),
CREATE (false),
// Leader is not used, but temporarily kept to avoid other plugins crashing
@Deprecated
2016-10-09 10:59:43 +02:00
LEADER (true),
RANK (true),
2013-04-19 14:08:45 +02:00
// Leave
2016-10-09 10:59:43 +02:00
LEAVE (true),
2013-04-19 14:08:45 +02:00
//JOINOTHER (true),
2016-10-09 10:59:43 +02:00
KICK (true),
DISBAND (false),
//RESET (false),
2013-04-19 14:08:45 +02:00
;
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
}
2016-07-30 12:15:24 +02:00
}