Use PS instead of FLocation in a few places.
This commit is contained in:
parent
4cc36b8d96
commit
4a63d50cbb
@ -21,7 +21,7 @@ import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.util.AsciiCompass;
|
||||
|
||||
|
||||
public class BoardOld
|
||||
public class BoardOldDepr
|
||||
{
|
||||
private static transient File file = new File(Factions.get().getDataFolder(), "board.json");
|
||||
private static transient HashMap<FLocation, TerritoryAccess> flocationIds = new HashMap<FLocation, TerritoryAccess>();
|
@ -10,6 +10,7 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
/**
|
||||
* Permissions that you (a player) may or may not have in the territory of a certain faction.
|
||||
@ -171,9 +172,10 @@ public enum FPerm
|
||||
{
|
||||
return this.has(testSubject, hostFaction, false);
|
||||
}
|
||||
public boolean has(Object testSubject, FLocation floc, boolean informIfNot)
|
||||
public boolean has(Object testSubject, PS ps, boolean informIfNot)
|
||||
{
|
||||
TerritoryAccess access = BoardOld.getTerritoryAccessAt(floc);
|
||||
TerritoryAccess access = BoardColl.get().getTerritoryAccessAt(ps);
|
||||
|
||||
if (this.isTerritoryPerm())
|
||||
{
|
||||
if (access.subjectHasAccess(testSubject)) return true;
|
||||
@ -196,15 +198,15 @@ public enum FPerm
|
||||
}
|
||||
public boolean has(Object testSubject, Location loc, boolean informIfNot)
|
||||
{
|
||||
FLocation floc = new FLocation(loc);
|
||||
return this.has(testSubject, floc, informIfNot);
|
||||
PS ps = PS.valueOf(loc);
|
||||
return this.has(testSubject, ps, informIfNot);
|
||||
}
|
||||
public boolean has(Object testSubject, Location loc)
|
||||
{
|
||||
return this.has(testSubject, loc, false);
|
||||
}
|
||||
public boolean has(Object testSubject, FLocation floc)
|
||||
public boolean has(Object testSubject, PS ps)
|
||||
{
|
||||
return this.has(testSubject, floc, false);
|
||||
return this.has(testSubject, ps, false);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
|
||||
@ -36,9 +37,12 @@ import com.massivecraft.mcore.util.Txt;
|
||||
public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
{
|
||||
// FIELD: lastStoodAt
|
||||
private transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked?
|
||||
public FLocation getLastStoodAt() { return this.lastStoodAt; }
|
||||
public void setLastStoodAt(FLocation flocation) { this.lastStoodAt = flocation; }
|
||||
// Where did this player stand the last time we checked?
|
||||
// This is a "chunk".
|
||||
// Rename to "currentChunk"?
|
||||
private transient PS lastStoodAt = PS.NULL;
|
||||
public PS getLastStoodAt() { return this.lastStoodAt; }
|
||||
public void setLastStoodAt(PS lastStoodAt) { this.lastStoodAt = lastStoodAt.getChunk(true); }
|
||||
|
||||
// FIELD: factionId
|
||||
private String factionId;
|
||||
@ -101,7 +105,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
public String getAccountId() { return this.getId(); }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Construct
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
// GSON need this noarg constructor.
|
||||
@ -153,7 +157,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Getters And Setters
|
||||
// GETTERS AND SETTERS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public long getLastLoginTime()
|
||||
@ -187,7 +191,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Title, Name, Faction Tag and Chat
|
||||
// TITLE, NAME, FACTION TAG AND CHAT
|
||||
//----------------------------------------------//
|
||||
public String getName()
|
||||
{
|
||||
@ -270,7 +274,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Relation and relation colors
|
||||
// RELATION AND RELATION COLORS
|
||||
// -------------------------------
|
||||
|
||||
@Override
|
||||
@ -299,7 +303,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
|
||||
public Rel getRelationToLocation()
|
||||
{
|
||||
return BoardOld.getFactionAt(new FLocation(this)).getRelationTo(this);
|
||||
// TODO: Use some built in system to get sender
|
||||
return BoardColl.get().getFactionAt(PS.valueOf(this.getPlayer())).getRelationTo(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -309,7 +314,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Health
|
||||
// HEALTH
|
||||
//----------------------------------------------//
|
||||
public void heal(int amnt)
|
||||
{
|
||||
@ -323,7 +328,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
|
||||
|
||||
//----------------------------------------------//
|
||||
// Power
|
||||
// POWER
|
||||
//----------------------------------------------//
|
||||
public double getPower()
|
||||
{
|
||||
@ -416,11 +421,12 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Territory
|
||||
// TERRITORY
|
||||
//----------------------------------------------//
|
||||
public boolean isInOwnTerritory()
|
||||
{
|
||||
return BoardOld.getFactionAt(new FLocation(this)) == this.getFaction();
|
||||
// TODO: Use Mixin to get this PS instead
|
||||
return BoardColl.get().getFactionAt(PS.valueOf(this.getPlayer())) == this.getFaction();
|
||||
}
|
||||
|
||||
/*public boolean isInOthersTerritory()
|
||||
@ -441,7 +447,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
|
||||
public boolean isInEnemyTerritory()
|
||||
{
|
||||
return BoardOld.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.ENEMY;
|
||||
// TODO: Use Mixin to get this PS instead
|
||||
return BoardColl.get().getFactionAt(PS.valueOf(this.getPlayer())).getRelationTo(this) == Rel.ENEMY;
|
||||
}
|
||||
|
||||
public void sendFactionHereMessage()
|
||||
@ -450,7 +457,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
{
|
||||
return;
|
||||
}
|
||||
Faction factionHere = BoardOld.getFactionAt(this.getLastStoodAt());
|
||||
Faction factionHere = BoardColl.get().getFactionAt(this.getLastStoodAt());
|
||||
String msg = Txt.parse("<i>")+" ~ "+factionHere.getTag(this);
|
||||
if (factionHere.getDescription().length() > 0)
|
||||
{
|
||||
@ -460,7 +467,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Actions
|
||||
// ACTIONS
|
||||
// -------------------------------
|
||||
|
||||
public void leave(boolean makePay)
|
||||
@ -536,9 +543,10 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure)
|
||||
{
|
||||
String error = null;
|
||||
FLocation flocation = new FLocation(location);
|
||||
Faction myFaction = getFaction();
|
||||
Faction currentFaction = BoardOld.getFactionAt(flocation);
|
||||
|
||||
PS ps = PS.valueOf(location);
|
||||
Faction myFaction = this.getFaction();
|
||||
Faction currentFaction = BoardColl.get().getFactionAt(ps);
|
||||
int ownedLand = forFaction.getLandRounded();
|
||||
|
||||
if (ConfServer.worldGuardChecking && Worldguard.checkForRegionsInChunk(location))
|
||||
@ -546,7 +554,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||
error = Txt.parse("<b>This land is protected");
|
||||
}
|
||||
else if (ConfServer.worldsNoClaiming.contains(flocation.getWorldName()))
|
||||
else if (ConfServer.worldsNoClaiming.contains(ps.getWorld()))
|
||||
{
|
||||
error = Txt.parse("<b>Sorry, this world has land claiming disabled.");
|
||||
}
|
||||
@ -586,8 +594,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
(
|
||||
ConfServer.claimsMustBeConnected
|
||||
&& ! this.hasAdminMode()
|
||||
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
|
||||
&& !BoardOld.isConnectedLocation(flocation, myFaction)
|
||||
&& myFaction.getLandRoundedInWorld(ps.getWorld()) > 0
|
||||
&& !BoardColl.get().isConnectedPs(ps, myFaction)
|
||||
&& (!ConfServer.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())
|
||||
)
|
||||
{
|
||||
@ -603,7 +611,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
// TODO more messages WARN current faction most importantly
|
||||
error = Txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this));
|
||||
}
|
||||
else if ( ! BoardOld.isBorderLocation(flocation))
|
||||
else if ( ! BoardColl.get().isBorderPs(ps))
|
||||
{
|
||||
error = Txt.parse("<b>You must start claiming land at the border of the territory.");
|
||||
}
|
||||
@ -621,8 +629,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
// notifyFailure is false if called by auto-claim; no need to notify on every failure for it
|
||||
// return value is false on failure, true on success
|
||||
|
||||
FLocation flocation = new FLocation(location);
|
||||
Faction currentFaction = BoardOld.getFactionAt(flocation);
|
||||
PS flocation = PS.valueOf(location).getChunk(true);
|
||||
Faction currentFaction = BoardColl.get().getFactionAt(flocation);
|
||||
|
||||
int ownedLand = forFaction.getLandRounded();
|
||||
|
||||
@ -637,7 +645,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
{
|
||||
cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
||||
|
||||
if (ConfServer.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !BoardOld.isConnectedLocation(flocation, forFaction))
|
||||
if (ConfServer.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorld()) > 0 && !BoardColl.get().isConnectedPs(flocation, forFaction))
|
||||
cost += ConfServer.econClaimUnconnectedFee;
|
||||
|
||||
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts && this.hasFaction())
|
||||
@ -667,17 +675,17 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
fp.msg("<h>%s<i> claimed land for <h>%s<i> from <h>%s<i>.", this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
|
||||
}
|
||||
|
||||
BoardOld.setFactionAt(forFaction, flocation);
|
||||
BoardColl.get().setFactionAt(flocation, forFaction);
|
||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
||||
|
||||
if (ConfServer.logLandClaims)
|
||||
Factions.get().log(this.getName()+" claimed land at ("+flocation.getCoordString()+") for the faction: "+forFaction.getTag());
|
||||
Factions.get().log(this.getName()+" claimed land at ("+flocation.getChunkX()+","+flocation.getChunkZ()+") for the faction: "+forFaction.getTag());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Persistance
|
||||
// PERSISTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.factions.zcore.persist.Entity;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
|
||||
@ -74,7 +75,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
public void confirmValidHome()
|
||||
{
|
||||
if (!ConfServer.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && BoardOld.getFactionAt(new FLocation(this.home.getLocation())) == this))
|
||||
if (!ConfServer.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && BoardColl.get().getFactionAt(PS.valueOf(this.home.getLocation())) == this))
|
||||
return;
|
||||
|
||||
msg("<b>Your faction home has been un-set since it is no longer in your territory.");
|
||||
@ -348,13 +349,14 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
return (int) Math.round(this.getPowerMax());
|
||||
}
|
||||
|
||||
public int getLandRounded() {
|
||||
return BoardOld.getFactionCoordCount(this);
|
||||
// TODO: Why "rounded"? Rename to getLandCount? or getChunkCount?
|
||||
public int getLandRounded()
|
||||
{
|
||||
return BoardColl.get().getCount(this);
|
||||
}
|
||||
|
||||
public int getLandRoundedInWorld(String worldName)
|
||||
{
|
||||
return BoardOld.getFactionCoordCountInWorld(this, worldName);
|
||||
return BoardColl.get().get(worldName).getCount(this);
|
||||
}
|
||||
|
||||
public boolean hasLandInflation()
|
||||
@ -548,7 +550,8 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
|
||||
// Clean the board
|
||||
BoardOld.clean();
|
||||
// TODO: Use events for this instead
|
||||
BoardColl.get().clean();
|
||||
|
||||
// Clean the fplayers
|
||||
FPlayerColl.i.clean();
|
||||
|
@ -188,7 +188,7 @@ public class FactionColl extends EntityCollection<Faction>
|
||||
if ( ! this.exists(id))
|
||||
{
|
||||
Factions.get().log(Level.WARNING, "Non existing factionId "+id+" requested! Issuing cleaning!");
|
||||
BoardOld.clean();
|
||||
BoardColl.get().clean();
|
||||
FPlayerColl.i.clean();
|
||||
}
|
||||
|
||||
|
@ -78,12 +78,10 @@ public class Factions extends MPlugin
|
||||
// Load Server Config
|
||||
ConfServer.get().load();
|
||||
|
||||
this.loadSuccessful = false;
|
||||
|
||||
// Load Conf from disk
|
||||
FPlayerColl.i.loadFromDisc();
|
||||
FactionColl.i.loadFromDisc();
|
||||
BoardOld.load();
|
||||
BoardColl.get().init();
|
||||
|
||||
// Add Base Commands
|
||||
this.cmdAutoHelp = new CmdFactionsAutoHelp();
|
||||
@ -125,7 +123,6 @@ public class Factions extends MPlugin
|
||||
getServer().getPluginManager().registerEvents(this.blockListener, this);
|
||||
|
||||
postEnable();
|
||||
this.loadSuccessful = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,11 +144,6 @@ public class Factions extends MPlugin
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
// only save data if plugin actually completely loaded successfully
|
||||
if (this.loadSuccessful)
|
||||
{
|
||||
BoardOld.save();
|
||||
}
|
||||
EssentialsFeatures.unhookChat();
|
||||
if (AutoLeaveTask != null)
|
||||
{
|
||||
@ -195,12 +187,6 @@ public class Factions extends MPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAutoSave()
|
||||
{
|
||||
BoardOld.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split)
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.TerritoryAccess;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
|
||||
@ -36,9 +36,9 @@ public class CmdFactionsAccess extends FCommand
|
||||
{
|
||||
String type = this.argAsString(0);
|
||||
type = (type == null) ? "" : type.toLowerCase();
|
||||
FLocation loc = new FLocation(me.getLocation());
|
||||
PS loc = PS.valueOf(me);
|
||||
|
||||
TerritoryAccess territory = BoardOld.getTerritoryAccessAt(loc);
|
||||
TerritoryAccess territory = BoardColl.get().getTerritoryAccessAt(loc);
|
||||
Faction locFaction = territory.getHostFaction();
|
||||
boolean accessAny = Perm.ACCESS_ANY.has(sender, false);
|
||||
|
||||
|
@ -7,16 +7,16 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.integration.EssentialsFeatures;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.util.SmokeUtil;
|
||||
|
||||
|
||||
@ -75,7 +75,8 @@ public class CmdFactionsHome extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
Faction faction = BoardOld.getFactionAt(new FLocation(me.getLocation()));
|
||||
|
||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(me));
|
||||
Location loc = me.getLocation().clone();
|
||||
|
||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
|
||||
public class CmdFactionsMap extends FCommand
|
||||
@ -61,7 +61,7 @@ public class CmdFactionsMap extends FCommand
|
||||
|
||||
public void showMap()
|
||||
{
|
||||
sendMessage(BoardOld.getMap(myFaction, new FLocation(fme), fme.getPlayer().getLocation().getYaw()));
|
||||
sendMessage(BoardColl.get().getMap(myFaction, PS.valueOf(me), fme.getPlayer().getLocation().getYaw()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.FactionColl;
|
||||
import com.massivecraft.factions.Factions;
|
||||
@ -34,12 +33,7 @@ public class CmdFactionsReload extends FCommand
|
||||
|
||||
String fileName;
|
||||
|
||||
if (file.startsWith("b"))
|
||||
{
|
||||
BoardOld.load();
|
||||
fileName = "board.json";
|
||||
}
|
||||
else if (file.startsWith("f"))
|
||||
if (file.startsWith("f"))
|
||||
{
|
||||
FactionColl.i.loadFromDisc();
|
||||
fileName = "factions.json";
|
||||
@ -54,7 +48,6 @@ public class CmdFactionsReload extends FCommand
|
||||
fileName = "all";
|
||||
FPlayerColl.i.loadFromDisc();
|
||||
FactionColl.i.loadFromDisc();
|
||||
BoardOld.load();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.FactionColl;
|
||||
import com.massivecraft.factions.Perm;
|
||||
@ -31,7 +30,6 @@ public class CmdFactionsSaveAll extends FCommand
|
||||
{
|
||||
FPlayerColl.i.saveToDisc();
|
||||
FactionColl.i.saveToDisc();
|
||||
BoardOld.save();
|
||||
msg("<i>Factions saved to disk!");
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
public class CmdFactionsSethome extends FCommand
|
||||
{
|
||||
@ -47,7 +47,7 @@ public class CmdFactionsSethome extends FCommand
|
||||
&&
|
||||
ConfServer.homesMustBeInClaimedTerritory
|
||||
&&
|
||||
BoardOld.getFactionAt(new FLocation(me)) != faction
|
||||
BoardColl.get().getFactionAt(PS.valueOf(me)) != faction
|
||||
)
|
||||
{
|
||||
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
||||
|
@ -2,16 +2,16 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.event.LandUnclaimEvent;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
public class CmdFactionsUnclaim extends FCommand
|
||||
{
|
||||
@ -35,12 +35,12 @@ public class CmdFactionsUnclaim extends FCommand
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
FLocation flocation = new FLocation(fme);
|
||||
Faction otherFaction = BoardOld.getFactionAt(flocation);
|
||||
PS chunk = PS.valueOf(me).getChunk(true);
|
||||
Faction otherFaction = BoardColl.get().getFactionAt(chunk);
|
||||
|
||||
if ( ! FPerm.TERRITORY.has(sender, otherFaction, true)) return;
|
||||
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(chunk, otherFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
if(unclaimEvent.isCancelled()) return;
|
||||
|
||||
@ -59,12 +59,14 @@ public class CmdFactionsUnclaim extends FCommand
|
||||
}
|
||||
}
|
||||
|
||||
BoardOld.removeAt(flocation);
|
||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
||||
BoardColl.get().removeAt(chunk);
|
||||
SpoutFeatures.updateTerritoryDisplayLoc(chunk);
|
||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||
|
||||
if (ConfServer.logLandUnclaims)
|
||||
Factions.get().log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
|
||||
{
|
||||
Factions.get().log(fme.getName()+" unclaimed land at ("+chunk.getChunkX()+","+chunk.getChunkZ()+") from the faction: "+otherFaction.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
@ -46,15 +46,17 @@ public class CmdFactionsUnclaimall extends FCommand
|
||||
}
|
||||
|
||||
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
|
||||
// this event cannot be cancelled
|
||||
|
||||
BoardOld.unclaimAll(myFaction.getId());
|
||||
BoardColl.get().removeAll(myFaction);
|
||||
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
||||
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
||||
|
||||
if (ConfServer.logLandUnclaims)
|
||||
{
|
||||
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,10 @@ import org.bukkit.event.Cancellable;
|
||||
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 com.massivecraft.mcore.ps.PS;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LandClaimEvent extends Event implements Cancellable
|
||||
@ -27,8 +28,8 @@ public class LandClaimEvent extends Event implements Cancellable
|
||||
@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 PS chunk;
|
||||
public PS getChunk() { return this.chunk; }
|
||||
|
||||
private final Faction faction;
|
||||
public Faction getFaction() { return this.faction; }
|
||||
@ -45,10 +46,10 @@ public class LandClaimEvent extends Event implements Cancellable
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public LandClaimEvent(FLocation location, Faction faction, FPlayer fplayer)
|
||||
public LandClaimEvent(PS chunk, Faction faction, FPlayer fplayer)
|
||||
{
|
||||
this.cancelled = false;
|
||||
this.location = location;
|
||||
this.chunk = chunk.getChunk(true);
|
||||
this.faction = faction;
|
||||
this.fplayer = fplayer;
|
||||
}
|
||||
|
@ -4,9 +4,10 @@ import org.bukkit.event.Cancellable;
|
||||
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 com.massivecraft.mcore.ps.PS;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LandUnclaimEvent extends Event implements Cancellable
|
||||
@ -27,8 +28,8 @@ public class LandUnclaimEvent extends Event implements Cancellable
|
||||
@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 PS chunk;
|
||||
public PS getChunk() { return this.chunk; }
|
||||
|
||||
private final Faction faction;
|
||||
public Faction getFaction() { return this.faction; }
|
||||
@ -45,10 +46,10 @@ public class LandUnclaimEvent extends Event implements Cancellable
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public LandUnclaimEvent(FLocation location, Faction faction, FPlayer fplayer)
|
||||
public LandUnclaimEvent(PS chunk, Faction faction, FPlayer fplayer)
|
||||
{
|
||||
this.cancelled = false;
|
||||
this.location = location;
|
||||
this.chunk = chunk.getChunk(true);
|
||||
this.faction = faction;
|
||||
this.fplayer = fplayer;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -14,7 +13,6 @@ import org.bukkit.block.BlockState;
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.lwc.LWCPlugin;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
@ -38,11 +36,18 @@ public class LWCFeatures
|
||||
return ConfServer.lwcIntegration && lwc != null;
|
||||
}
|
||||
|
||||
public static void clearOtherChests(FLocation flocation, Faction faction)
|
||||
public static void clearOtherChests(PS ps, Faction faction)
|
||||
{
|
||||
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
||||
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
||||
Chunk chunk = location.getChunk();
|
||||
Chunk chunk = null;
|
||||
try
|
||||
{
|
||||
chunk = ps.asBukkitChunk(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState[] blocks = chunk.getTileEntities();
|
||||
List<Block> chests = new LinkedList<Block>();
|
||||
|
||||
|
@ -8,7 +8,6 @@ import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Factions;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -17,6 +16,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.util.HealthBarUtil;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
@ -246,7 +246,7 @@ public class SpoutFeatures
|
||||
// -------------------------------------------- //
|
||||
|
||||
// update displayed current territory for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
||||
public static void updateTerritoryDisplayLoc(FLocation fLoc)
|
||||
public static void updateTerritoryDisplayLoc(PS chunk)
|
||||
{
|
||||
if ( ! isEnabled()) return;
|
||||
|
||||
@ -254,10 +254,14 @@ public class SpoutFeatures
|
||||
|
||||
for (FPlayer player : players)
|
||||
{
|
||||
if (fLoc == null)
|
||||
if (chunk == null)
|
||||
{
|
||||
mainListener.updateTerritoryDisplay(player, false);
|
||||
else if (player.getLastStoodAt().equals(fLoc))
|
||||
}
|
||||
else if (player.getLastStoodAt().equals(chunk))
|
||||
{
|
||||
mainListener.updateTerritoryDisplay(player, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,15 +273,17 @@ public class SpoutFeatures
|
||||
}
|
||||
|
||||
// update access info for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
||||
public static void updateAccessInfoLoc(FLocation fLoc)
|
||||
public static void updateAccessInfoLoc(PS chunk)
|
||||
{
|
||||
if ( ! isEnabled()) return;
|
||||
|
||||
chunk = chunk.getChunk(true);
|
||||
|
||||
Set<FPlayer> players = FPlayerColl.i.getOnline();
|
||||
|
||||
for (FPlayer player : players)
|
||||
{
|
||||
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
|
||||
if (chunk == null || player.getLastStoodAt().equals(chunk))
|
||||
mainListener.updateAccessInfo(player);
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.TerritoryAccess;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
@ -72,9 +72,9 @@ public class SpoutMainListener implements Listener
|
||||
if (!sPlayer.isSpoutCraftEnabled() || (ConfServer.spoutTerritoryDisplaySize <= 0 && ! ConfServer.spoutTerritoryNoticeShow))
|
||||
return false;
|
||||
|
||||
FLocation here = player.getLastStoodAt();
|
||||
PS here = player.getLastStoodAt();
|
||||
|
||||
doAccessInfo(player, sPlayer, here);
|
||||
this.doAccessInfo(player, sPlayer, here);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -89,8 +89,8 @@ public class SpoutMainListener implements Listener
|
||||
|
||||
private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify)
|
||||
{
|
||||
FLocation here = player.getLastStoodAt();
|
||||
Faction factionHere = BoardOld.getFactionAt(here);
|
||||
PS here = player.getLastStoodAt();
|
||||
Faction factionHere = BoardColl.get().getFactionAt(here);
|
||||
String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
|
||||
|
||||
// ----------------------
|
||||
@ -156,7 +156,7 @@ public class SpoutMainListener implements Listener
|
||||
|
||||
private static final Color accessGrantedColor = new Color(0.2f, 1.0f, 0.2f);
|
||||
private static final Color accessDeniedColor = new Color(1.0f, 0.2f, 0.2f);
|
||||
private void doAccessInfo(FPlayer player, SpoutPlayer sPlayer, FLocation here)
|
||||
private void doAccessInfo(FPlayer player, SpoutPlayer sPlayer, PS here)
|
||||
{
|
||||
if (ConfServer.spoutTerritoryDisplayPosition <= 0 || ConfServer.spoutTerritoryDisplaySize <= 0 || ! ConfServer.spoutTerritoryAccessShow) return;
|
||||
|
||||
@ -177,7 +177,7 @@ public class SpoutMainListener implements Listener
|
||||
}
|
||||
|
||||
String msg = "";
|
||||
TerritoryAccess access = BoardOld.getTerritoryAccessAt(here);
|
||||
TerritoryAccess access = BoardColl.get().getTerritoryAccessAt(here);
|
||||
|
||||
if ( ! access.isDefault())
|
||||
{
|
||||
|
@ -3,52 +3,74 @@ package com.massivecraft.factions.listeners;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
|
||||
public class FactionsBlockListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockSpread(BlockSpreadEvent event)
|
||||
public void blockFireSpread(Block block, Cancellable cancellable)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (event.getSource().getTypeId() != 51) return; // Must be Fire
|
||||
Faction faction = BoardOld.getFactionAt(event.getBlock());
|
||||
if (faction.getFlag(FFlag.FIRESPREAD) == false)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
// If the faction at the block has firespread disabled ...
|
||||
PS ps = PS.valueOf(block);
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
if (faction.getFlag(FFlag.FIRESPREAD)) return;
|
||||
|
||||
// then cancel the event.
|
||||
cancellable.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockBurn(BlockBurnEvent event)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockFireSpread(BlockIgniteEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
Faction faction = BoardOld.getFactionAt(event.getBlock());
|
||||
if (faction.getFlag(FFlag.FIRESPREAD) == false)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
// If fire is spreading ...
|
||||
if (event.getCause() != IgniteCause.SPREAD && event.getCause() != IgniteCause.LAVA) return;
|
||||
|
||||
// ... consider blocking it.
|
||||
blockFireSpread(event.getBlock(), event);
|
||||
}
|
||||
|
||||
// TODO: Is use of this event deprecated?
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockFireSpread(BlockSpreadEvent event)
|
||||
{
|
||||
// If fire is spreading ...
|
||||
if (event.getNewState().getTypeId() != 51) return;
|
||||
|
||||
// ... consider blocking it.
|
||||
blockFireSpread(event.getBlock(), event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockFireSpread(BlockBurnEvent event)
|
||||
{
|
||||
// If a block is burning ...
|
||||
|
||||
// ... consider blocking it.
|
||||
blockFireSpread(event.getBlock(), event);
|
||||
}
|
||||
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Block block, String action, boolean justCheck)
|
||||
{
|
||||
return playerCanBuildDestroyBlock(player, block.getLocation(), action, justCheck);
|
||||
@ -62,8 +84,8 @@ public class FactionsBlockListener implements Listener
|
||||
FPlayer me = FPlayerColl.i.get(name);
|
||||
if (me.hasAdminMode()) return true;
|
||||
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction factionHere = BoardOld.getFactionAt(loc);
|
||||
PS ps = PS.valueOf(location);
|
||||
Faction factionHere = BoardColl.get().getFactionAt(ps);
|
||||
|
||||
if ( ! FPerm.BUILD.has(me, location) && FPerm.PAINBUILD.has(me, location))
|
||||
{
|
||||
@ -75,7 +97,7 @@ public class FactionsBlockListener implements Listener
|
||||
return true;
|
||||
}
|
||||
|
||||
return FPerm.BUILD.has(me, loc, true);
|
||||
return FPerm.BUILD.has(me, ps, true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -117,13 +139,13 @@ public class FactionsBlockListener implements Listener
|
||||
if (event.isCancelled()) return;
|
||||
if ( ! ConfServer.pistonProtectionThroughDenyBuild) return;
|
||||
|
||||
Faction pistonFaction = BoardOld.getFactionAt(new FLocation(event.getBlock()));
|
||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||
|
||||
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
|
||||
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
||||
|
||||
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
|
||||
Faction targetFaction = BoardOld.getFactionAt(new FLocation(targetBlock));
|
||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
|
||||
if (targetFaction == pistonFaction) return;
|
||||
|
||||
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
||||
@ -150,10 +172,10 @@ public class FactionsBlockListener implements Listener
|
||||
// if potentially retracted block is just air/water/lava, no worries
|
||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
||||
|
||||
Faction pistonFaction = BoardOld.getFactionAt(new FLocation(event.getBlock()));
|
||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||
|
||||
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
|
||||
Faction targetFaction = BoardOld.getFactionAt(new FLocation(targetLoc));
|
||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetLoc));
|
||||
if (targetFaction == pistonFaction) return;
|
||||
|
||||
if ( ! FPerm.BUILD.has(pistonFaction, targetLoc))
|
||||
|
@ -3,7 +3,6 @@ package com.massivecraft.factions.listeners;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@ -38,16 +37,16 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Const;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.event.PowerLossEvent;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
|
||||
public class FactionsEntityListener implements Listener
|
||||
@ -61,7 +60,8 @@ public class FactionsEntityListener implements Listener
|
||||
|
||||
Player player = (Player) entity;
|
||||
FPlayer fplayer = FPlayerColl.i.get(player);
|
||||
Faction faction = BoardOld.getFactionAt(new FLocation(player.getLocation()));
|
||||
|
||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player));
|
||||
|
||||
PowerLossEvent powerLossEvent = new PowerLossEvent(faction,fplayer);
|
||||
// Check for no power loss conditions
|
||||
@ -117,27 +117,24 @@ public class FactionsEntityListener implements Listener
|
||||
}*/
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Block block = iter.next();
|
||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(block));
|
||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false) iter.remove();
|
||||
}
|
||||
|
||||
Set<FLocation> explosionLocs = new HashSet<FLocation>();
|
||||
for (Block block : event.blockList())
|
||||
if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).getFlag(FFlag.EXPLOSIONS) == false)
|
||||
{
|
||||
explosionLocs.add(new FLocation(block));
|
||||
}
|
||||
for (FLocation loc : explosionLocs)
|
||||
{
|
||||
Faction faction = BoardOld.getFactionAt(loc);
|
||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false)
|
||||
{
|
||||
// faction has explosions disabled
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but...
|
||||
// this optional change below provides workaround for waterwalling providing perfect protection,
|
||||
// and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots
|
||||
@ -231,7 +228,7 @@ public class FactionsEntityListener implements Listener
|
||||
|
||||
Location defenderLoc = defender.getPlayer().getLocation();
|
||||
|
||||
Faction defLocFaction = BoardOld.getFactionAt(new FLocation(defenderLoc));
|
||||
Faction defLocFaction = BoardColl.get().getFactionAt(PS.valueOf(defenderLoc));
|
||||
|
||||
// for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source
|
||||
if (damager instanceof Projectile)
|
||||
@ -272,7 +269,7 @@ public class FactionsEntityListener implements Listener
|
||||
return false;
|
||||
}
|
||||
|
||||
Faction locFaction = BoardOld.getFactionAt(new FLocation(attacker));
|
||||
Faction locFaction = BoardColl.get().getFactionAt(PS.valueOf(damager));
|
||||
|
||||
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
|
||||
if (locFaction.getFlag(FFlag.PVP) == false)
|
||||
@ -350,8 +347,8 @@ public class FactionsEntityListener implements Listener
|
||||
if (event.isCancelled()) return;
|
||||
if (event.getLocation() == null) return;
|
||||
|
||||
FLocation floc = new FLocation(event.getLocation());
|
||||
Faction faction = BoardOld.getFactionAt(floc);
|
||||
PS ps = PS.valueOf(event.getLocation());
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
|
||||
if (faction.getFlag(FFlag.MONSTERS)) return;
|
||||
if ( ! Const.ENTITY_TYPES_MONSTERS.contains(event.getEntityType())) return;
|
||||
@ -373,8 +370,8 @@ public class FactionsEntityListener implements Listener
|
||||
|
||||
if ( ! Const.ENTITY_TYPES_MONSTERS.contains(event.getEntity().getType())) return;
|
||||
|
||||
FLocation floc = new FLocation(target.getLocation());
|
||||
Faction faction = BoardOld.getFactionAt(floc);
|
||||
PS ps = PS.valueOf(target.getLocation());
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
|
||||
if (faction.getFlag(FFlag.MONSTERS)) return;
|
||||
|
||||
@ -388,7 +385,7 @@ public class FactionsEntityListener implements Listener
|
||||
|
||||
if (event.getCause() == RemoveCause.EXPLOSION)
|
||||
{
|
||||
Faction faction = BoardOld.getFactionAt(new FLocation(event.getEntity().getLocation()));
|
||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(event.getEntity()));
|
||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false)
|
||||
{ // faction has explosions disabled
|
||||
event.setCancelled(true);
|
||||
@ -434,8 +431,8 @@ public class FactionsEntityListener implements Listener
|
||||
// for now, only interested in Enderman and Wither boss tomfoolery
|
||||
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) return;
|
||||
|
||||
FLocation floc = new FLocation(event.getBlock());
|
||||
Faction faction = BoardOld.getFactionAt(floc);
|
||||
PS ps = PS.valueOf(event.getBlock());
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
|
||||
if (entity instanceof Enderman)
|
||||
{
|
||||
|
@ -24,11 +24,10 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
|
||||
import com.massivecraft.factions.BoardOld;
|
||||
import com.massivecraft.factions.BoardColl;
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Const;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
@ -36,6 +35,7 @@ import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.TerritoryAccess;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
|
||||
public class FactionsPlayerListener implements Listener
|
||||
@ -49,10 +49,13 @@ public class FactionsPlayerListener implements Listener
|
||||
// Update the lastLoginTime for this fplayer
|
||||
me.setLastLoginTime(System.currentTimeMillis());
|
||||
|
||||
// Store player's current FLocation and notify them where they are
|
||||
me.setLastStoodAt(new FLocation(event.getPlayer().getLocation()));
|
||||
// Store player's current Chunk and notify them where they are
|
||||
me.setLastStoodAt(PS.valueOf(event.getPlayer()));
|
||||
|
||||
if ( ! SpoutFeatures.updateTerritoryDisplay(me))
|
||||
{
|
||||
me.sendFactionHereMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -88,25 +91,25 @@ public class FactionsPlayerListener implements Listener
|
||||
FPlayer me = FPlayerColl.i.get(player);
|
||||
|
||||
// Did we change coord?
|
||||
FLocation from = me.getLastStoodAt();
|
||||
FLocation to = new FLocation(event.getTo());
|
||||
PS from = me.getLastStoodAt();
|
||||
PS to = PS.valueOf(event.getTo()).getChunk(true);
|
||||
|
||||
if (from.equals(to)) return;
|
||||
|
||||
// Yes we did change coord (:
|
||||
|
||||
me.setLastStoodAt(to);
|
||||
TerritoryAccess access = BoardOld.getTerritoryAccessAt(to);
|
||||
TerritoryAccess access = BoardColl.get().getTerritoryAccessAt(to);
|
||||
|
||||
// Did we change "host"(faction)?
|
||||
boolean changedFaction = (BoardOld.getFactionAt(from) != access.getHostFaction());
|
||||
boolean changedFaction = (BoardColl.get().getFactionAt(from) != access.getHostFaction());
|
||||
|
||||
// let Spout handle most of this if it's available
|
||||
boolean handledBySpout = changedFaction && SpoutFeatures.updateTerritoryDisplay(me);
|
||||
|
||||
if (me.isMapAutoUpdating())
|
||||
{
|
||||
me.sendMessage(BoardOld.getMap(me.getFaction(), to, player.getLocation().getYaw()));
|
||||
me.sendMessage(BoardColl.get().getMap(me.getFaction(), to, player.getLocation().getYaw()));
|
||||
}
|
||||
else if (changedFaction && ! handledBySpout)
|
||||
{
|
||||
@ -303,7 +306,7 @@ public class FactionsPlayerListener implements Listener
|
||||
}
|
||||
|
||||
Rel rel = me.getRelationToLocation();
|
||||
if (BoardOld.getFactionAt(me.getLastStoodAt()).isNone()) return;
|
||||
if (BoardColl.get().getFactionAt(me.getLastStoodAt()).isNone()) return;
|
||||
|
||||
if (rel == Rel.NEUTRAL && isCommandInList(fullCmd, ConfServer.territoryNeutralDenyCommands))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user