Updated Faction Event System -- Land Events
Changes: ---------- * changed internal storage of faction from String Id to Faction for LandClaimEvent and LandUnclaimEvent * added getFactionId(), getFactionTag(), getPlayer() to LandClaimEvent * added getFactionId(), getFactionTag(), getFPlayer(), getPlayer() to LandUnclaimEvent * removed LandUnclaimEvent from unclaimAll() in Board.java * created LandUnclaimAllEvent (uncancellable) and hooked into cmdUnclaimall Notes: -------- * LandUnclaimAllEvent currently only returns calling faction and fplayer information. Location data is unavailable as it is determined in Board.java's unclaimAll(). Realistically this should be enough information for anyone hooking this event to determine what is being altered. On branch CustomFactionEvents modified: src/com/massivecraft/factions/Board.java modified: src/com/massivecraft/factions/FPlayer.java modified: src/com/massivecraft/factions/cmd/CmdUnclaim.java modified: src/com/massivecraft/factions/cmd/CmdUnclaimall.java modified: src/com/massivecraft/factions/event/LandClaimEvent.java new file: src/com/massivecraft/factions/event/LandUnclaimAllEvent.java modified: src/com/massivecraft/factions/event/LandUnclaimEvent.java
This commit is contained in:
parent
88bdadcb2b
commit
9314b4e298
@ -9,13 +9,11 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.massivecraft.factions.event.LandUnclaimEvent;
|
|
||||||
import com.massivecraft.factions.integration.LWCFeatures;
|
import com.massivecraft.factions.integration.LWCFeatures;
|
||||||
import com.massivecraft.factions.iface.RelationParticipator;
|
import com.massivecraft.factions.iface.RelationParticipator;
|
||||||
import com.massivecraft.factions.util.AsciiCompass;
|
import com.massivecraft.factions.util.AsciiCompass;
|
||||||
@ -83,10 +81,6 @@ public class Board
|
|||||||
{
|
{
|
||||||
Entry<FLocation, String> entry = iter.next();
|
Entry<FLocation, String> entry = iter.next();
|
||||||
if (entry.getValue().equals(factionId))
|
if (entry.getValue().equals(factionId))
|
||||||
{
|
|
||||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(entry.getKey(), entry.getValue());
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
|
||||||
if(!unclaimEvent.isCancelled())
|
|
||||||
{
|
{
|
||||||
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
||||||
LWCFeatures.clearAllChests(entry.getKey());
|
LWCFeatures.clearAllChests(entry.getKey());
|
||||||
@ -95,7 +89,6 @@ public class Board
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Is this coord NOT completely surrounded by coords claimed by the same faction?
|
// Is this coord NOT completely surrounded by coords claimed by the same faction?
|
||||||
// Simpler: Is there any nearby coord with a faction other than the faction here?
|
// Simpler: Is there any nearby coord with a faction other than the faction here?
|
||||||
|
@ -664,7 +664,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction.getId(), this.getId());
|
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(claimEvent);
|
Bukkit.getServer().getPluginManager().callEvent(claimEvent);
|
||||||
if(claimEvent.isCancelled()) return false;
|
if(claimEvent.isCancelled()) return false;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class CmdUnclaim extends FCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction.getId());
|
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||||
if(unclaimEvent.isCancelled()) return;
|
if(unclaimEvent.isCancelled()) return;
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.Board;
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.event.LandUnclaimAllEvent;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
@ -42,6 +45,10 @@ public class CmdUnclaimall extends FCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
|
||||||
|
// this event cannot be cancelled
|
||||||
|
|
||||||
Board.unclaimAll(myFaction.getId());
|
Board.unclaimAll(myFaction.getId());
|
||||||
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
||||||
|
@ -5,10 +5,9 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class LandClaimEvent extends Event implements Cancellable
|
public class LandClaimEvent extends Event implements Cancellable
|
||||||
{
|
{
|
||||||
@ -16,14 +15,15 @@ public class LandClaimEvent extends Event implements Cancellable
|
|||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private FLocation location;
|
private FLocation location;
|
||||||
private String factionId, playerId;
|
private Faction faction;
|
||||||
|
private FPlayer fplayer;
|
||||||
|
|
||||||
public LandClaimEvent(FLocation loc, String fid, String pid)
|
public LandClaimEvent(FLocation loc, Faction f, FPlayer p)
|
||||||
{
|
{
|
||||||
cancelled = false;
|
cancelled = false;
|
||||||
location = loc;
|
location = loc;
|
||||||
this.factionId = fid;
|
faction = f;
|
||||||
this.playerId = pid;
|
fplayer = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers()
|
||||||
@ -36,11 +36,6 @@ public class LandClaimEvent extends Event implements Cancellable
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
|
||||||
{
|
|
||||||
return FPlayers.i.get(playerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FLocation getLocation()
|
public FLocation getLocation()
|
||||||
{
|
{
|
||||||
return this.location;
|
return this.location;
|
||||||
@ -48,7 +43,27 @@ public class LandClaimEvent extends Event implements Cancellable
|
|||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction()
|
||||||
{
|
{
|
||||||
return Factions.i.get(factionId);
|
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
|
@Override
|
||||||
|
68
src/com/massivecraft/factions/event/LandUnclaimAllEvent.java
Executable file
68
src/com/massivecraft/factions/event/LandUnclaimAllEvent.java
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
//import com.massivecraft.factions.FLocation;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class LandUnclaimAllEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
// Location is commented out because there is no clean way to hook currently.
|
||||||
|
// faction and fplayer should be enough to filter needed information.
|
||||||
|
// private FLocation[] location;
|
||||||
|
private Faction faction;
|
||||||
|
private FPlayer fplayer;
|
||||||
|
|
||||||
|
public LandUnclaimAllEvent(Faction f, FPlayer p)
|
||||||
|
{
|
||||||
|
faction = f;
|
||||||
|
fplayer = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -6,21 +6,24 @@ import org.bukkit.event.HandlerList;
|
|||||||
|
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class LandUnclaimEvent extends Event implements Cancellable
|
public class LandUnclaimEvent extends Event implements Cancellable
|
||||||
{
|
{
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private String factionId;
|
|
||||||
private FLocation location;
|
private FLocation location;
|
||||||
|
private Faction faction;
|
||||||
|
private FPlayer fplayer;
|
||||||
|
|
||||||
public LandUnclaimEvent(FLocation loc, String id)
|
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p)
|
||||||
{
|
{
|
||||||
cancelled = false;
|
cancelled = false;
|
||||||
location = loc;
|
location = loc;
|
||||||
factionId = id;
|
faction = f;
|
||||||
|
fplayer = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers()
|
||||||
@ -33,16 +36,36 @@ public class LandUnclaimEvent extends Event implements Cancellable
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
|
||||||
{
|
|
||||||
return Factions.i.get(factionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FLocation getLocation()
|
public FLocation getLocation()
|
||||||
{
|
{
|
||||||
return this.location;
|
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
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user