Get PS from Location rather than Entity to minimize the risk for hitting a velocityX NaN bug.

This commit is contained in:
Olof Larsson 2014-11-18 10:00:15 +01:00
parent 7da0b805a1
commit 2240696c98
10 changed files with 22 additions and 19 deletions

View File

@ -41,7 +41,7 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand
@Override @Override
public void perform() public void perform()
{ {
chunk = PS.valueOf(me).getChunk(true); chunk = PS.valueOf(me.getLocation()).getChunk(true);
ta = BoardColl.get().getTerritoryAccessAt(chunk); ta = BoardColl.get().getTerritoryAccessAt(chunk);
hostFaction = ta.getHostFaction(); hostFaction = ta.getHostFaction();

View File

@ -89,7 +89,7 @@ public class CmdFactionsHome extends FactionsCommandHome
} }
Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me)); Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me.getLocation()));
Location locationHere = me.getLocation().clone(); Location locationHere = me.getLocation().clone();
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby

View File

@ -2,6 +2,8 @@ package com.massivecraft.factions.cmd;
import java.util.List; import java.util.List;
import org.bukkit.Location;
import com.massivecraft.factions.Const; import com.massivecraft.factions.Const;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColl;
@ -61,7 +63,8 @@ public class CmdFactionsMap extends FactionsCommand
public void showMap(int width, int height) public void showMap(int width, int height)
{ {
List<String> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(me), me.getLocation().getYaw(), width, height); Location location = me.getLocation();
List<String> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height);
sendMessage(message); sendMessage(message);
} }

View File

@ -37,7 +37,7 @@ public class CmdFactionsSeeChunkOld extends FactionsCommand
{ {
// Args // Args
World world = me.getWorld(); World world = me.getWorld();
PS chunk = PS.valueOf(me).getChunk(true); PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
int chunkX = chunk.getChunkX(); int chunkX = chunk.getChunkX();
int chunkZ = chunk.getChunkZ(); int chunkZ = chunk.getChunkZ();

View File

@ -57,7 +57,7 @@ public class CmdFactionsSetAuto extends FactionsCommand
msg("<i>Now auto-setting <h>%s<i> land.", newFaction.describeTo(msender)); msg("<i>Now auto-setting <h>%s<i> land.", newFaction.describeTo(msender));
// Chunks // Chunks
final PS chunk = PS.valueOf(me).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
Set<PS> chunks = Collections.singleton(chunk); Set<PS> chunks = Collections.singleton(chunk);
// Apply / Inform // Apply / Inform

View File

@ -37,7 +37,7 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius
public Set<PS> getChunks() public Set<PS> getChunks()
{ {
// Common Startup // Common Startup
final PS chunk = PS.valueOf(me).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = new LinkedHashSet<PS>(); final Set<PS> chunks = new LinkedHashSet<PS>();
chunks.add(chunk); // The center should come first for pretty messages chunks.add(chunk); // The center should come first for pretty messages

View File

@ -41,7 +41,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple
public Set<PS> getChunks() public Set<PS> getChunks()
{ {
// Common Startup // Common Startup
final PS chunk = PS.valueOf(me).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = new LinkedHashSet<PS>(); final Set<PS> chunks = new LinkedHashSet<PS>();
// What faction (aka color) resides there? // What faction (aka color) resides there?

View File

@ -32,7 +32,7 @@ public class CmdFactionsSetOne extends CmdFactionsSetXSimple
@Override @Override
public Set<PS> getChunks() public Set<PS> getChunks()
{ {
final PS chunk = PS.valueOf(me).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = Collections.singleton(chunk); final Set<PS> chunks = Collections.singleton(chunk);
return chunks; return chunks;
} }

View File

@ -37,7 +37,7 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius
public Set<PS> getChunks() public Set<PS> getChunks()
{ {
// Common Startup // Common Startup
final PS chunk = PS.valueOf(me).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = new LinkedHashSet<PS>(); final Set<PS> chunks = new LinkedHashSet<PS>();
chunks.add(chunk); // The center should come first for pretty messages chunks.add(chunk); // The center should come first for pretty messages

View File

@ -728,7 +728,7 @@ public class EngineMain extends EngineAbstract
MPlayer mplayer = MPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
// ... and powerloss can happen here ... // ... and powerloss can happen here ...
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player)); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player.getLocation()));
if (!faction.getFlag(MFlag.getFlagPowerloss())) if (!faction.getFlag(MFlag.getFlagPowerloss()))
{ {
@ -829,7 +829,7 @@ public class EngineMain extends EngineAbstract
if (eattacker != null && eattacker.equals(edefender)) return true; if (eattacker != null && eattacker.equals(edefender)) return true;
// ... gather defender PS and faction information ... // ... gather defender PS and faction information ...
PS defenderPs = PS.valueOf(defender); PS defenderPs = PS.valueOf(defender.getLocation());
Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs); Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs);
// ... PVP flag may cause a damage block ... // ... PVP flag may cause a damage block ...
@ -863,7 +863,7 @@ public class EngineMain extends EngineAbstract
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true; if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true;
// ... gather attacker PS and faction information ... // ... gather attacker PS and faction information ...
PS attackerPs = PS.valueOf(attacker); PS attackerPs = PS.valueOf(attacker.getLocation());
Faction attackerPsFaction = BoardColl.get().getFactionAt(attackerPs); Faction attackerPsFaction = BoardColl.get().getFactionAt(attackerPs);
// ... PVP flag may cause a damage block ... // ... PVP flag may cause a damage block ...
@ -1017,7 +1017,7 @@ public class EngineMain extends EngineAbstract
} }
// ... if there is a faction at the players location ... // ... if there is a faction at the players location ...
PS ps = PS.valueOf(player).getChunk(true); PS ps = PS.valueOf(player.getLocation()).getChunk(true);
Faction factionAtPs = BoardColl.get().getFactionAt(ps); Faction factionAtPs = BoardColl.get().getFactionAt(ps);
if (factionAtPs.isNone()) return; // TODO: An NPE can arise here? Why? if (factionAtPs.isNone()) return; // TODO: An NPE can arise here? Why?
@ -1093,7 +1093,7 @@ public class EngineMain extends EngineAbstract
if (target == null) return; if (target == null) return;
// ... at a place where monsters are forbidden ... // ... at a place where monsters are forbidden ...
PS ps = PS.valueOf(target); PS ps = PS.valueOf(target.getLocation());
Faction faction = BoardColl.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getFlagMonsters())) return; if (faction.getFlag(MFlag.getFlagMonsters())) return;
@ -1120,7 +1120,7 @@ public class EngineMain extends EngineAbstract
Entity entity = event.getEntity(); Entity entity = event.getEntity();
// ... and the faction there has explosions disabled ... // ... and the faction there has explosions disabled ...
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(entity)); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(entity.getLocation()));
if (faction.isExplosionsAllowed()) return; if (faction.isExplosionsAllowed()) return;
// ... then cancel. // ... then cancel.
@ -1286,7 +1286,7 @@ public class EngineMain extends EngineAbstract
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(HangingPlaceEvent event) public void blockBuild(HangingPlaceEvent event)
{ {
if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getEntity()), true)) return; if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getEntity().getLocation()), true)) return;
event.setCancelled(true); event.setCancelled(true);
} }
@ -1300,7 +1300,7 @@ public class EngineMain extends EngineAbstract
Entity breaker = entityEvent.getRemover(); Entity breaker = entityEvent.getRemover();
if (! (breaker instanceof Player)) return; if (! (breaker instanceof Player)) return;
if ( ! canPlayerBuildAt(breaker, PS.valueOf(event.getEntity()), true)) if ( ! canPlayerBuildAt(breaker, PS.valueOf(event.getEntity().getLocation()), true))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -1320,7 +1320,7 @@ public class EngineMain extends EngineAbstract
Player player = (Player)edamager; Player player = (Player)edamager;
// ... and the player can't build there ... // ... and the player can't build there ...
if (canPlayerBuildAt(player, PS.valueOf(itemFrame), true)) return; if (canPlayerBuildAt(player, PS.valueOf(itemFrame.getLocation()), true)) return;
// ... then cancel the event. // ... then cancel the event.
event.setCancelled(true); event.setCancelled(true);
@ -1493,7 +1493,7 @@ public class EngineMain extends EngineAbstract
MPlayer me = MPlayer.get(player); MPlayer me = MPlayer.get(player);
if (me.isUsingAdminMode()) return true; if (me.isUsingAdminMode()) return true;
PS ps = PS.valueOf(entity); PS ps = PS.valueOf(entity.getLocation());
EntityType type = entity.getType(); EntityType type = entity.getType();
if (MConf.get().entityTypesContainer.contains(type) && ! MPerm.getPermContainer().has(me, ps, verboose)) return false; if (MConf.get().entityTypesContainer.contains(type) && ! MPerm.getPermContainer().has(me, ps, verboose)) return false;