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 public class FPlayerJoinEvent extends Event implements Cancellable
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
FPlayer fplayer; public static HandlerList getHandlerList() { return handlers; }
Faction faction;
PlayerJoinReason reason; // -------------------------------------------- //
boolean cancelled = false; // FIELDS
public enum PlayerJoinReason // -------------------------------------------- //
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 this.fplayer = fplayer;
} this.faction = faction;
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) this.reason = reason;
{
fplayer = fp;
faction = f;
reason = r;
} }
public FPlayer getFPlayer() public FPlayer getFPlayer()
@ -38,23 +52,14 @@ public class FPlayerJoinEvent extends Event implements Cancellable
{ {
return reason; 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 public class FPlayerLeaveEvent extends Event implements Cancellable
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private PlayerLeaveReason reason; @Override public HandlerList getHandlers() { return handlers; }
FPlayer FPlayer; public static HandlerList getHandlerList() { return handlers; }
Faction Faction;
boolean cancelled = false;
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() // -------------------------------------------- //
{ // FIELDS
return reason; // -------------------------------------------- //
}
public FPlayer getFPlayer() private boolean cancelled;
{ @Override public boolean isCancelled() { return this.cancelled; }
return FPlayer;
}
public Faction getFaction()
{
return Faction;
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override @Override
public void setCancelled(boolean c) public void setCancelled(boolean c)
{ {
@ -68,4 +33,35 @@ public class FPlayerLeaveEvent extends Event implements Cancellable
} }
cancelled = c; 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,19 +11,29 @@ import com.massivecraft.factions.FactionColl;
public class FactionCreateEvent extends Event implements Cancellable public class FactionCreateEvent extends Event implements Cancellable
{ {
private static final HandlerList handlers = new HandlerList(); // -------------------------------------------- //
// REQUIRED EVENT CODE
private String factionTag; // -------------------------------------------- //
private Player sender;
private boolean cancelled;
public FactionCreateEvent(Player sender, String tag) private static final HandlerList handlers = new HandlerList();
{ @Override public HandlerList getHandlers() { return handlers; }
this.factionTag = tag; public static HandlerList getHandlerList() { return handlers; }
this.sender = sender;
this.cancelled = false; // -------------------------------------------- //
} // 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;
public String getFactionTag() { return this.factionTag; }
private Player sender;
public FPlayer getFPlayer() public FPlayer getFPlayer()
{ {
return FPlayerColl.i.get(sender); return FPlayerColl.i.get(sender);
@ -33,31 +43,16 @@ public class FactionCreateEvent extends Event implements Cancellable
{ {
return FactionColl.i.getNextId(); 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 public class FactionDisbandEvent extends Event implements Cancellable
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled; 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 String id;
private Player sender; 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() public Faction getFaction()
{ {
return FactionColl.i.get(id); return FactionColl.i.get(id);
@ -47,18 +45,25 @@ public class FactionDisbandEvent extends Event implements Cancellable
public Player getPlayer() 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;
} }
// -------------------------------------------- //
// ASSORTED
// -------------------------------------------- //
@Override
public void setCancelled(boolean c)
{
cancelled = c;
}
} }

View File

@ -9,48 +9,44 @@ import com.massivecraft.factions.Rel;
public class FactionRelationEvent extends Event public class FactionRelationEvent extends Event
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
// 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; }
private Faction fsender; // -------------------------------------------- //
private Faction ftarget; // CONSTRUCT
private Rel foldrel; // -------------------------------------------- //
private Rel frel;
public FactionRelationEvent(Faction faction, Faction targetFaction, Rel oldRel, Rel newRel)
public FactionRelationEvent(Faction sender, Faction target, Rel oldrel, Rel rel)
{ {
fsender = sender; this.faction = faction;
ftarget = target; this.targetFaction = targetFaction;
foldrel = oldrel; this.oldRel = oldRel;
frel = rel; 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 public class FactionRenameEvent extends Event implements Cancellable
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled; private boolean cancelled;
private FPlayer fplayer; @Override public boolean isCancelled() { return this.cancelled; }
private Faction faction; @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; 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) public FactionRenameEvent(FPlayer sender, String newTag)
{ {
fplayer = sender;
faction = sender.getFaction();
tag = newTag;
this.cancelled = false; 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 public class LandClaimEvent extends Event implements Cancellable
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
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(); }
private boolean cancelled; // -------------------------------------------- //
private FLocation location; // CONSTRUCT
private Faction faction; // -------------------------------------------- //
private FPlayer fplayer;
public LandClaimEvent(FLocation location, Faction faction, FPlayer fplayer)
public LandClaimEvent(FLocation loc, Faction f, FPlayer p)
{ {
cancelled = false; this.cancelled = false;
location = loc; this.location = location;
faction = f; this.faction = faction;
fplayer = p; 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 public class LandUnclaimAllEvent extends Event
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); 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; this.faction = faction;
fplayer = p; 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

@ -10,70 +10,47 @@ import com.massivecraft.factions.FPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class LandUnclaimEvent extends Event implements Cancellable public class LandUnclaimEvent extends Event implements Cancellable
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled; private boolean cancelled;
private FLocation location; @Override public boolean isCancelled() { return this.cancelled; }
private Faction faction; @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; }
private FPlayer fplayer;
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; }
public LandUnclaimEvent(FLocation loc, 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 LandUnclaimEvent(FLocation location, Faction faction, FPlayer fplayer)
{ {
cancelled = false; this.cancelled = false;
location = loc; this.location = location;
faction = f; this.faction = faction;
fplayer = p; 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 public class PowerLossEvent extends Event implements Cancellable
{ {
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean cancelled; private boolean cancelled;
private Faction faction; @Override public boolean isCancelled() { return this.cancelled; }
private FPlayer fplayer; @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; private String message;
public String getMessage() { return this.message; }
public void setMessage(String message) { this.message = message; }
// 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(); }
public PowerLossEvent(Faction f, FPlayer p) // -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public PowerLossEvent(Faction faction, FPlayer fplayer)
{ {
cancelled = false; this.cancelled = false;
faction = f; this.faction = faction;
fplayer = p; this.fplayer = fplayer;
}
@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;
} }
} }