Event cleanup pass 1.

This commit is contained in:
Olof Larsson 2013-04-10 09:34:14 +02:00
parent 363a63bf3a
commit 27cee7d6f7
10 changed files with 349 additions and 452 deletions

View File

@ -9,21 +9,35 @@ import com.massivecraft.factions.Faction;
public class FPlayerJoinEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
FPlayer fplayer;
Faction faction;
PlayerJoinReason reason;
boolean cancelled = false;
public enum PlayerJoinReason
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private FPlayer fplayer;
private Faction faction;
private PlayerJoinReason reason;
private boolean cancelled = false;
@Override public boolean isCancelled() { return this.cancelled; }
@Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FPlayerJoinEvent(FPlayer fplayer, Faction faction, PlayerJoinReason reason)
{
CREATE, LEADER, COMMAND
}
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r)
{
fplayer = fp;
faction = f;
reason = r;
this.fplayer = fplayer;
this.faction = faction;
this.reason = reason;
}
public FPlayer getFPlayer()
@ -38,23 +52,14 @@ public class FPlayerJoinEvent extends Event implements Cancellable
{
return reason;
}
public HandlerList getHandlers()
// -------------------------------------------- //
// INTERNAL ENUM
// -------------------------------------------- //
public enum PlayerJoinReason
{
return handlers;
CREATE, LEADER, COMMAND
}
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override
public void setCancelled(boolean c)
{
cancelled = c;
}
}

View File

@ -9,55 +9,20 @@ import com.massivecraft.factions.Faction;
public class FPlayerLeaveEvent extends Event implements Cancellable
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
private PlayerLeaveReason reason;
FPlayer FPlayer;
Faction Faction;
boolean cancelled = false;
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
public enum PlayerLeaveReason
{
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
}
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r)
{
FPlayer = p;
Faction = f;
reason = r;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public PlayerLeaveReason getReason()
{
return reason;
}
public FPlayer getFPlayer()
{
return FPlayer;
}
public Faction getFaction()
{
return Faction;
}
@Override
public boolean isCancelled()
{
return cancelled;
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled;
@Override public boolean isCancelled() { return this.cancelled; }
@Override
public void setCancelled(boolean c)
{
@ -68,4 +33,35 @@ public class FPlayerLeaveEvent extends Event implements Cancellable
}
cancelled = c;
}
private final PlayerLeaveReason reason;
public PlayerLeaveReason getReason() { return this.reason; }
private final FPlayer fplayer;
public FPlayer getFPlayer() { return this.fplayer; }
private final Faction faction;
public Faction getFaction() { return this.faction; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FPlayerLeaveEvent(FPlayer fplayer, Faction faction, PlayerLeaveReason reason)
{
this.cancelled = false;
this.fplayer = fplayer;
this.faction = faction;
this.reason = reason;
}
// -------------------------------------------- //
// INTERNAL ENUM
// -------------------------------------------- //
public enum PlayerLeaveReason
{
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
}
}

View File

@ -11,18 +11,28 @@ import com.massivecraft.factions.FactionColl;
public class FactionCreateEvent extends Event implements Cancellable
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled;
@Override public boolean isCancelled() { return this.cancelled; }
@Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
// TODO: Could the fields be reorganized to achieve symmetry?
private String factionTag;
private Player sender;
private boolean cancelled;
public String getFactionTag() { return this.factionTag; }
public FactionCreateEvent(Player sender, String tag)
{
this.factionTag = tag;
this.sender = sender;
this.cancelled = false;
}
private Player sender;
public FPlayer getFPlayer()
{
@ -34,30 +44,15 @@ public class FactionCreateEvent extends Event implements Cancellable
return FactionColl.i.getNextId();
}
public String getFactionTag()
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionCreateEvent(Player sender, String tag)
{
return factionTag;
this.cancelled = false;
this.factionTag = tag;
this.sender = sender;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override
public void setCancelled(boolean c)
{
this.cancelled = c;
}
}

View File

@ -12,29 +12,27 @@ import com.massivecraft.factions.FactionColl;
public class FactionDisbandEvent extends Event implements Cancellable
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled;
@Override public boolean isCancelled() { return this.cancelled; }
@Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
// TODO: Could the fields be reorganized to achieve symmetry?
private String id;
private Player sender;
public FactionDisbandEvent(Player sender, String factionId)
{
cancelled = false;
this.sender = sender;
this.id = factionId;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Faction getFaction()
{
return FactionColl.i.get(id);
@ -47,18 +45,25 @@ public class FactionDisbandEvent extends Event implements Cancellable
public Player getPlayer()
{
return sender;
return this.sender;
}
@Override
public boolean isCancelled()
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionDisbandEvent(Player sender, String factionId)
{
return cancelled;
this.cancelled = false;
this.sender = sender;
this.id = factionId;
}
@Override
public void setCancelled(boolean c)
{
cancelled = c;
}
// -------------------------------------------- //
// ASSORTED
// -------------------------------------------- //
}

View File

@ -9,48 +9,44 @@ import com.massivecraft.factions.Rel;
public class FactionRelationEvent extends Event
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
private Faction fsender;
private Faction ftarget;
private Rel foldrel;
private Rel frel;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public FactionRelationEvent(Faction sender, Faction target, Rel oldrel, Rel rel)
// TODO: Should this one be informative only?
// TODO: How about making it Cancellable?
// TODO: How about making the target relation non-final?
private final Faction faction;
public Faction getFaction() { return this.faction; }
private final Faction targetFaction;
public Faction getTargetFaction() { return this.targetFaction; }
private final Rel oldRel;
public Rel getOldRel() { return this.oldRel; }
private final Rel newRel;
public Rel getNewRel() { return this.newRel; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionRelationEvent(Faction faction, Faction targetFaction, Rel oldRel, Rel newRel)
{
fsender = sender;
ftarget = target;
foldrel = oldrel;
frel = rel;
this.faction = faction;
this.targetFaction = targetFaction;
this.oldRel = oldRel;
this.newRel = newRel;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Rel getOldRelation()
{
return foldrel;
}
public Rel getRelation()
{
return frel;
}
public Faction getFaction()
{
return fsender;
}
public Faction getTargetFaction()
{
return ftarget;
}
}

View File

@ -10,65 +10,51 @@ import com.massivecraft.factions.Faction;
public class FactionRenameEvent extends Event implements Cancellable
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled;
private FPlayer fplayer;
private Faction faction;
@Override public boolean isCancelled() { return this.cancelled; }
@Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
private final FPlayer fplayer;
public FPlayer getFPlayer() { return this.fplayer; }
private final Faction faction;
public Faction getFaction() { return this.faction; }
private String tag;
// TODO: fix these
public Player getPlayer() { return this.fplayer.getPlayer(); }
public String getOldFactionTag() { return this.faction.getTag(); }
public String getFactionTag() { return this.tag; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionRenameEvent(FPlayer sender, String newTag)
{
fplayer = sender;
faction = sender.getFaction();
tag = newTag;
this.cancelled = false;
this.fplayer = sender;
this.faction = sender.getFaction(); // TODO: Players can only rename their own faction? A field and constructor rewrite is probably pending for this class...
this.tag = newTag;
}
public Faction getFaction()
{
return(faction);
}
public FPlayer getFPlayer()
{
return(fplayer);
}
public Player getPlayer()
{
return(fplayer.getPlayer());
}
public String getOldFactionTag()
{
return(faction.getTag());
}
public String getFactionTag()
{
return(tag);
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override
public void setCancelled(boolean c)
{
this.cancelled = c;
}
}

View File

@ -11,70 +11,46 @@ import org.bukkit.entity.Player;
public class LandClaimEvent extends Event implements Cancellable
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
private boolean cancelled;
private FLocation location;
private Faction faction;
private FPlayer fplayer;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public LandClaimEvent(FLocation loc, Faction f, FPlayer p)
private boolean cancelled = false;
@Override public boolean isCancelled() { return this.cancelled; }
@Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
private final FLocation location;
public FLocation getLocation() { return this.location; }
private final Faction faction;
public Faction getFaction() { return this.faction; }
private final FPlayer fplayer;
public FPlayer getFPlayer() { return this.fplayer; }
// TODO: These methods seem redundant? Why were they added? Can I remove them?
public String getFactionId() { return faction.getId(); }
public String getFactionTag() { return this.faction.getTag(); }
public Player getPlayer() { return this.fplayer.getPlayer(); }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public LandClaimEvent(FLocation location, Faction faction, FPlayer fplayer)
{
cancelled = false;
location = loc;
faction = f;
fplayer = p;
this.cancelled = false;
this.location = location;
this.faction = faction;
this.fplayer = fplayer;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public FLocation getLocation()
{
return this.location;
}
public Faction getFaction()
{
return faction;
}
public String getFactionId()
{
return faction.getId();
}
public String getFactionTag()
{
return faction.getTag();
}
public FPlayer getFPlayer()
{
return fplayer;
}
public Player getPlayer()
{
return fplayer.getPlayer();
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override
public void setCancelled(boolean c)
{
this.cancelled = c;
}
}

View File

@ -9,49 +9,37 @@ import org.bukkit.entity.Player;
public class LandUnclaimAllEvent extends Event
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
private Faction faction;
private FPlayer fplayer;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public LandUnclaimAllEvent(Faction f, FPlayer p)
private final Faction faction;
public Faction getFaction() { return this.faction; }
private final FPlayer fplayer;
public FPlayer getFPlayer() { return this.fplayer; }
// TODO: These methods seem redundant? Why were they added? Can I remove them?
public String getFactionId() { return this.faction.getId(); }
public String getFactionTag() { return this.faction.getTag(); }
public Player getPlayer() { return this.fplayer.getPlayer(); }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public LandUnclaimAllEvent(Faction faction, FPlayer fplayer)
{
faction = f;
fplayer = p;
this.faction = faction;
this.fplayer = fplayer;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Faction getFaction()
{
return faction;
}
public String getFactionId()
{
return faction.getId();
}
public String getFactionTag()
{
return faction.getTag();
}
public FPlayer getFPlayer()
{
return fplayer;
}
public Player getPlayer()
{
return fplayer.getPlayer();
}
}

View File

@ -11,69 +11,46 @@ import org.bukkit.entity.Player;
public class LandUnclaimEvent extends Event implements Cancellable
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled;
private FLocation location;
private Faction faction;
private FPlayer fplayer;
@Override public boolean isCancelled() { return this.cancelled; }
@Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p)
private final FLocation location;
public FLocation getLocation() { return this.location; }
private final Faction faction;
public Faction getFaction() { return this.faction; }
private final FPlayer fplayer;
public FPlayer getFPlayer() { return this.fplayer; }
// TODO: These methods seem redundant? Why were they added? Can I remove them?
public String getFactionId() { return this.faction.getId(); }
public String getFactionTag() { return this.faction.getTag(); }
public Player getPlayer() { return this.fplayer.getPlayer(); }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public LandUnclaimEvent(FLocation location, Faction faction, FPlayer fplayer)
{
cancelled = false;
location = loc;
faction = f;
fplayer = p;
this.cancelled = false;
this.location = location;
this.faction = faction;
this.fplayer = fplayer;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public FLocation getLocation()
{
return this.location;
}
public Faction getFaction()
{
return faction;
}
public String getFactionId()
{
return faction.getId();
}
public String getFactionTag()
{
return faction.getTag();
}
public FPlayer getFPlayer()
{
return fplayer;
}
public Player getPlayer()
{
return fplayer.getPlayer();
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override
public void setCancelled(boolean c) {
cancelled = c;
}
}

View File

@ -12,74 +12,47 @@ import org.bukkit.entity.Player;
public class PowerLossEvent extends Event implements Cancellable
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled;
private Faction faction;
private FPlayer fplayer;
@Override public boolean isCancelled() { return this.cancelled; }
@Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
private final Faction faction;
public Faction getFaction() { return this.faction; }
private final FPlayer fplayer;
public FPlayer getFPlayer() { return this.fplayer; }
// TODO: Should message really be set here? Or should it be sent by the plugin that cancells directly?
private String message;
public String getMessage() { return this.message; }
public void setMessage(String message) { this.message = message; }
public PowerLossEvent(Faction f, FPlayer p)
// TODO: These methods seem redundant? Why were they added? Can I remove them?
public String getFactionId() { return this.faction.getId(); }
public String getFactionTag() { return this.faction.getTag(); }
public Player getPlayer() { return this.fplayer.getPlayer(); }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public PowerLossEvent(Faction faction, FPlayer fplayer)
{
cancelled = false;
faction = f;
fplayer = p;
}
@Override
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Faction getFaction()
{
return faction;
}
public String getFactionId()
{
return faction.getId();
}
public String getFactionTag()
{
return faction.getTag();
}
public FPlayer getFPlayer()
{
return fplayer;
}
public Player getPlayer()
{
return fplayer.getPlayer();
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override
public void setCancelled(boolean c)
{
this.cancelled = c;
this.cancelled = false;
this.faction = faction;
this.fplayer = fplayer;
}
}