2012-03-27 23:09:23 +02:00
|
|
|
package com.gmail.nossr50.events.party;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.Cancellable;
|
|
|
|
import org.bukkit.event.HandlerList;
|
|
|
|
import org.bukkit.event.player.PlayerEvent;
|
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* Called when a player attempts to join, leave, or change parties.
|
|
|
|
*/
|
2012-03-27 23:09:23 +02:00
|
|
|
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable{
|
|
|
|
|
|
|
|
protected String oldParty;
|
|
|
|
protected String newParty;
|
|
|
|
protected EventReason reason;
|
|
|
|
protected boolean cancelled;
|
|
|
|
|
|
|
|
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
|
|
|
|
super(player);
|
2012-03-28 01:47:20 +02:00
|
|
|
|
|
|
|
if (newParty != null) {
|
|
|
|
newParty = newParty.replace(":", ".");
|
|
|
|
}
|
|
|
|
|
2012-03-27 23:09:23 +02:00
|
|
|
this.oldParty = oldParty;
|
|
|
|
this.newParty = newParty;
|
|
|
|
this.reason = reason;
|
|
|
|
this.cancelled = false;
|
|
|
|
}
|
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* @return The party being left, or null if the player was not in a party
|
|
|
|
*/
|
2012-03-27 23:09:23 +02:00
|
|
|
public String getOldParty() {
|
|
|
|
return oldParty;
|
|
|
|
}
|
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* @return The party being joined, or null if the player is not joining a new party
|
|
|
|
*/
|
2012-03-27 23:09:23 +02:00
|
|
|
public String getNewParty() {
|
|
|
|
return newParty;
|
|
|
|
}
|
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* @return The reason for the event being fired
|
|
|
|
*/
|
2012-03-27 23:09:23 +02:00
|
|
|
public EventReason getReason() {
|
|
|
|
return reason;
|
|
|
|
}
|
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* A list of reasons why the event may have been fired
|
|
|
|
*/
|
|
|
|
public enum EventReason{
|
|
|
|
/**
|
|
|
|
* Joined a party for the first time.
|
|
|
|
*/
|
|
|
|
JOINED_PARTY,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Left a party and did not join a new one.
|
|
|
|
*/
|
|
|
|
LEFT_PARTY,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Was kicked from a party.
|
|
|
|
*/
|
|
|
|
KICKED_FROM_PARTY,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Left one party to join another.
|
|
|
|
*/
|
|
|
|
CHANGED_PARTIES,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Any reason that doesn't fit elsewhere.
|
|
|
|
*/
|
|
|
|
CUSTOM;
|
|
|
|
}
|
|
|
|
|
2012-03-27 23:09:23 +02:00
|
|
|
/** Rest of file is required boilerplate for custom events **/
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public HandlerList getHandlers() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static HandlerList getHandlerList() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Following are required for Cancellable **/
|
|
|
|
@Override
|
|
|
|
public boolean isCancelled() {
|
|
|
|
return cancelled;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setCancelled(boolean cancelled) {
|
|
|
|
this.cancelled = cancelled;
|
|
|
|
}
|
|
|
|
}
|