updated patrickfreed's custom event system
Patrick's Custom Event System Changes: ---------------------------------------- * FPlayerLeaveEvent now fires for all faction players in cmdDisband() * FPlayerLeaveEvent removed from cmdJoin() * FPlayerJoinEvent now only fires when the faction is different in cmdLeade * Added FactionRenameEvent, firing on cmdTag() * Added FactionRelationEvent, firing on FRelationCommand extensions * Fixed FPlayerJoinEvent to fire after tag is set in cmdCreate() * Added getFactionId() to FactionCreateEvent TODO: ------- * cmdLeader() might need a FPlayerLeaveEvent for the same reason it needs a FPlayerJoinEvent? On branch CustomFactionEvents modified: src/com/massivecraft/factions/cmd/CmdCreate.java modified: src/com/massivecraft/factions/cmd/CmdDisband.java modified: src/com/massivecraft/factions/cmd/CmdJoin.java modified: src/com/massivecraft/factions/cmd/CmdKick.java modified: src/com/massivecraft/factions/cmd/CmdLeader.java modified: src/com/massivecraft/factions/cmd/CmdTag.java modified: src/com/massivecraft/factions/cmd/FRelationCommand.java modified: src/com/massivecraft/factions/event/FPlayerLeaveEvent.java modified: src/com/massivecraft/factions/event/FactionCreateEvent.java new file: src/com/massivecraft/factions/event/FactionRelationEvent.java new file: src/com/massivecraft/factions/event/FactionRenameEvent.java modified: src/com/massivecraft/factions/event/LandClaimEvent.java
This commit is contained in:
@ -15,7 +15,7 @@ public class FPlayerLeaveEvent extends Event implements Cancellable
|
||||
Faction Faction;
|
||||
boolean cancelled = false;
|
||||
|
||||
public enum PlayerLeaveReason
|
||||
public enum PlayerLeaveReason
|
||||
{
|
||||
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Factions;
|
||||
|
||||
public class FactionCreateEvent extends Event implements Cancellable
|
||||
{
|
||||
@ -16,7 +17,7 @@ public class FactionCreateEvent extends Event implements Cancellable
|
||||
private Player sender;
|
||||
private boolean cancelled;
|
||||
|
||||
public FactionCreateEvent(String tag, Player sender)
|
||||
public FactionCreateEvent(Player sender, String tag)
|
||||
{
|
||||
this.factionTag = tag;
|
||||
this.sender = sender;
|
||||
@ -28,11 +29,16 @@ public class FactionCreateEvent extends Event implements Cancellable
|
||||
return FPlayers.i.get(sender);
|
||||
}
|
||||
|
||||
public String getFactionId()
|
||||
{
|
||||
return Factions.i.getNextId();
|
||||
}
|
||||
|
||||
public String getFactionTag()
|
||||
{
|
||||
return factionTag;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
|
@ -0,0 +1,56 @@
|
||||
package com.massivecraft.factions.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.Faction;
|
||||
|
||||
|
||||
public class FactionRelationEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Faction fsender;
|
||||
private Faction ftarget;
|
||||
private Rel foldrel;
|
||||
private Rel frel;
|
||||
|
||||
public FactionRelationEvent(Faction sender, Faction target, Rel oldrel, Rel rel)
|
||||
{
|
||||
fsender = sender;
|
||||
ftarget = target;
|
||||
foldrel = oldrel;
|
||||
frel = rel;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
73
src/com/massivecraft/factions/event/FactionRenameEvent.java
Normal file
73
src/com/massivecraft/factions/event/FactionRenameEvent.java
Normal file
@ -0,0 +1,73 @@
|
||||
package com.massivecraft.factions.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
|
||||
public class FactionRenameEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private boolean cancelled;
|
||||
private FPlayer fplayer;
|
||||
private Faction faction;
|
||||
private String tag;
|
||||
|
||||
public FactionRenameEvent(FPlayer sender, String newTag)
|
||||
{
|
||||
fplayer = sender;
|
||||
faction = sender.getFaction();
|
||||
tag = newTag;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -18,12 +18,12 @@ public class LandClaimEvent extends Event implements Cancellable
|
||||
private FLocation location;
|
||||
private String factionId, playerId;
|
||||
|
||||
public LandClaimEvent(FLocation loc, String id, String pid)
|
||||
public LandClaimEvent(FLocation loc, String fid, String pid)
|
||||
{
|
||||
cancelled = false;
|
||||
location = loc;
|
||||
factionId = id;
|
||||
playerId = pid;
|
||||
this.factionId = fid;
|
||||
this.playerId = pid;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
|
Reference in New Issue
Block a user