PluginPlayerListener cleanup
This commit is contained in:
parent
4b5e4a5e13
commit
d4123d137a
@ -34,25 +34,24 @@ public class PluginPlayerListener implements Listener
|
|||||||
// Find the nearest gate!
|
// Find the nearest gate!
|
||||||
Gate nearestGate = null;
|
Gate nearestGate = null;
|
||||||
Location playerLocation = event.getPlayer().getLocation();
|
Location playerLocation = event.getPlayer().getLocation();
|
||||||
//double shortestDistance = -1;
|
|
||||||
|
|
||||||
for (Gate gate : Gate.getAll())
|
for (Gate gate : Gate.getAll())
|
||||||
{
|
{
|
||||||
if (gate.getFrom() == null || gate.getTo() == null)
|
if (gate.getFrom() == null ||
|
||||||
|
gate.getTo() == null ||
|
||||||
|
gate.isOpen() == false ||
|
||||||
|
!gate.getFrom().getWorld().equals(playerLocation.getWorld()))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (! gate.getFrom().getWorld().equals(playerLocation.getWorld()))
|
|
||||||
continue; // We can only be close to gates in the same world
|
|
||||||
|
|
||||||
|
|
||||||
double distance = GeometryUtil.distanceBetweenLocations(playerLocation, gate.getFrom());
|
double distance = GeometryUtil.distanceBetweenLocations(playerLocation, gate.getFrom());
|
||||||
|
|
||||||
if (distance > Conf.getGateSearchRadius())
|
if (distance > Conf.getGateSearchRadius())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Plugin.log(Level.ALL, "in gate search radius of " + gate.getId());
|
||||||
|
|
||||||
Plugin.log(Level.ALL, "in gate search radius.");
|
|
||||||
for (Integer[] blockXYZ: gate.getGateBlocks())
|
for (Integer[] blockXYZ: gate.getGateBlocks())
|
||||||
{
|
{
|
||||||
if ((blockTo.getX() == blockXYZ[0] || blockToUp.getX() == blockXYZ[0]) &&
|
if ((blockTo.getX() == blockXYZ[0] || blockToUp.getX() == blockXYZ[0]) &&
|
||||||
@ -63,14 +62,9 @@ public class PluginPlayerListener implements Listener
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (shortestDistance == -1 || shortestDistance > distance) {
|
|
||||||
nearestGate = gate;
|
|
||||||
shortestDistance = distance;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nearestGate != null && nearestGate.isOpen())
|
if (nearestGate != null)
|
||||||
{
|
{
|
||||||
checkChunkLoad(nearestGate.getTo().getBlock());
|
checkChunkLoad(nearestGate.getTo().getBlock());
|
||||||
Float newYaw = nearestGate.getFrom().getYaw() - nearestGate.getTo().getYaw() + playerLocation.getYaw();
|
Float newYaw = nearestGate.getFrom().getYaw() - nearestGate.getTo().getYaw() + playerLocation.getYaw();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user