Improve and document event system. Deprecate duplicate methods.
This commit is contained in:
parent
7604b4455b
commit
4d5278b079
@ -6,11 +6,8 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class FPlayerJoinEvent extends Event implements Cancellable {
|
public class FPlayerJoinEvent extends FactionPlayerEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
FPlayer fplayer;
|
|
||||||
Faction faction;
|
|
||||||
PlayerJoinReason reason;
|
PlayerJoinReason reason;
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
|
|
||||||
@ -19,31 +16,14 @@ public class FPlayerJoinEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) {
|
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) {
|
||||||
fplayer = fp;
|
super(f, fp);
|
||||||
faction = f;
|
|
||||||
reason = r;
|
reason = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
|
||||||
return fplayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction() {
|
|
||||||
return faction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerJoinReason getReason() {
|
public PlayerJoinReason getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
@ -6,11 +6,9 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class FPlayerLeaveEvent extends Event implements Cancellable {
|
public class FPlayerLeaveEvent extends FactionPlayerEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private PlayerLeaveReason reason;
|
private PlayerLeaveReason reason;
|
||||||
FPlayer FPlayer;
|
|
||||||
Faction Faction;
|
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
|
|
||||||
public enum PlayerLeaveReason {
|
public enum PlayerLeaveReason {
|
||||||
@ -18,31 +16,14 @@ public class FPlayerLeaveEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) {
|
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) {
|
||||||
FPlayer = p;
|
super(f, p);
|
||||||
Faction = f;
|
|
||||||
reason = r;
|
reason = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerLeaveReason getReason() {
|
public PlayerLeaveReason getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
|
||||||
return FPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction() {
|
|
||||||
return Faction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
@ -51,9 +32,9 @@ public class FPlayerLeaveEvent extends Event implements Cancellable {
|
|||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c) {
|
public void setCancelled(boolean c) {
|
||||||
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) {
|
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) {
|
||||||
cancelled = false;
|
cancelled = false; // Don't let them cancel factions disbanding.
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
cancelled = c;
|
cancelled = c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class FactionCreateEvent extends Event implements Cancellable {
|
public class FactionCreateEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private String factionTag;
|
private String factionTag;
|
||||||
|
@ -9,29 +9,14 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class FactionDisbandEvent extends Event implements Cancellable {
|
public class FactionDisbandEvent extends FactionEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled = false;
|
||||||
private String id;
|
|
||||||
private Player sender;
|
private Player sender;
|
||||||
|
|
||||||
public FactionDisbandEvent(Player sender, String factionId) {
|
public FactionDisbandEvent(Player sender, String factionId) {
|
||||||
cancelled = false;
|
super(Factions.i.get(factionId));
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.id = factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction() {
|
|
||||||
return Factions.i.get(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
public FPlayer getFPlayer() {
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class FactionEvent extends Event {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private final Faction faction;
|
||||||
|
|
||||||
|
public FactionEvent(Faction faction) {
|
||||||
|
this.faction = faction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Faction getFaction() {
|
||||||
|
return this.getFaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
|
||||||
|
public class FactionPlayerEvent extends FactionEvent {
|
||||||
|
|
||||||
|
private final FPlayer fPlayer;
|
||||||
|
|
||||||
|
public FactionPlayerEvent(Faction faction, FPlayer fPlayer) {
|
||||||
|
super(faction);
|
||||||
|
this.fPlayer = fPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FPlayer getfPlayer() {
|
||||||
|
return this.fPlayer;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
|
|
||||||
|
|
||||||
public class FactionRelationEvent extends Event {
|
public class FactionRelationEvent extends Event {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Faction fsender;
|
private Faction fsender;
|
||||||
|
@ -7,47 +7,28 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class FactionRenameEvent extends Event implements Cancellable {
|
public class FactionRenameEvent extends FactionPlayerEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled = false;
|
||||||
private FPlayer fplayer;
|
|
||||||
private Faction faction;
|
|
||||||
private String tag;
|
private String tag;
|
||||||
|
|
||||||
public FactionRenameEvent(FPlayer sender, String newTag) {
|
public FactionRenameEvent(FPlayer sender, String newTag) {
|
||||||
fplayer = sender;
|
super(sender.getFaction(), sender);
|
||||||
faction = sender.getFaction();
|
|
||||||
tag = newTag;
|
tag = newTag;
|
||||||
this.cancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction() {
|
|
||||||
return (faction);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
|
||||||
return (fplayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return (fplayer.getPlayer());
|
return getfPlayer().getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getOldFactionTag() {
|
public String getOldFactionTag() {
|
||||||
return (faction.getTag());
|
return getFaction().getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionTag() {
|
public String getFactionTag() {
|
||||||
return (tag);
|
return tag;
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,51 +8,34 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class LandClaimEvent extends Event implements Cancellable {
|
public class LandClaimEvent extends FactionPlayerEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private FLocation location;
|
private FLocation location;
|
||||||
private Faction faction;
|
|
||||||
private FPlayer fplayer;
|
|
||||||
|
|
||||||
public LandClaimEvent(FLocation loc, Faction f, FPlayer p) {
|
public LandClaimEvent(FLocation loc, Faction f, FPlayer p) {
|
||||||
|
super(f, p);
|
||||||
cancelled = false;
|
cancelled = false;
|
||||||
location = loc;
|
location = loc;
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation getLocation() {
|
public FLocation getLocation() {
|
||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction() {
|
@Deprecated
|
||||||
return faction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionId() {
|
public String getFactionId() {
|
||||||
return faction.getId();
|
return getFaction().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getFactionTag() {
|
public String getFactionTag() {
|
||||||
return faction.getTag();
|
return getFaction().getTag();
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
|
||||||
return fplayer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return fplayer.getPlayer();
|
return getfPlayer().getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,42 +6,24 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class LandUnclaimAllEvent extends Event {
|
public class LandUnclaimAllEvent extends FactionPlayerEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private Faction faction;
|
|
||||||
private FPlayer fplayer;
|
|
||||||
|
|
||||||
public LandUnclaimAllEvent(Faction f, FPlayer p) {
|
public LandUnclaimAllEvent(Faction f, FPlayer p) {
|
||||||
faction = f;
|
super(f, p);
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction() {
|
|
||||||
return faction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getFactionId() {
|
public String getFactionId() {
|
||||||
return faction.getId();
|
return getFaction().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getFactionTag() {
|
public String getFactionTag() {
|
||||||
return faction.getTag();
|
return getFaction().getTag();
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
|
||||||
return fplayer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return fplayer.getPlayer();
|
return getfPlayer().getPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,51 +8,34 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class LandUnclaimEvent extends Event implements Cancellable {
|
public class LandUnclaimEvent extends FactionPlayerEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private FLocation location;
|
private FLocation location;
|
||||||
private Faction faction;
|
|
||||||
private FPlayer fplayer;
|
|
||||||
|
|
||||||
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p) {
|
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p) {
|
||||||
|
super(f, p);
|
||||||
cancelled = false;
|
cancelled = false;
|
||||||
location = loc;
|
location = loc;
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation getLocation() {
|
public FLocation getLocation() {
|
||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction() {
|
@Deprecated
|
||||||
return faction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionId() {
|
public String getFactionId() {
|
||||||
return faction.getId();
|
return getFaction().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getFactionTag() {
|
public String getFactionTag() {
|
||||||
return faction.getTag();
|
return getFaction().getTag();
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
|
||||||
return fplayer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return fplayer.getPlayer();
|
return getfPlayer().getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,48 +7,28 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class PowerLossEvent extends FactionPlayerEvent implements Cancellable {
|
||||||
|
|
||||||
public class PowerLossEvent extends Event implements Cancellable {
|
private boolean cancelled = false;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private boolean cancelled;
|
|
||||||
private Faction faction;
|
|
||||||
private FPlayer fplayer;
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public PowerLossEvent(Faction f, FPlayer p) {
|
public PowerLossEvent(Faction f, FPlayer p) {
|
||||||
cancelled = false;
|
super(f, p);
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction() {
|
|
||||||
return faction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getFactionId() {
|
public String getFactionId() {
|
||||||
return faction.getId();
|
return getFaction().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getFactionTag() {
|
public String getFactionTag() {
|
||||||
return faction.getTag();
|
return getFaction().getTag();
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
|
||||||
return fplayer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return fplayer.getPlayer();
|
return getfPlayer().getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
Loading…
Reference in New Issue
Block a user