changes towards enabling the hide feature

This commit is contained in:
Tobias Ottenweller 2012-03-11 18:47:31 +01:00
parent 8e816bb5d2
commit 3fc35e13bc
2 changed files with 33 additions and 19 deletions

View File

@ -28,6 +28,7 @@ public class Gate
private transient String id;
private Location from;
private Location to;
private boolean isHidden = false;
private Integer[][] gateBlocks;
@ -110,11 +111,10 @@ public class Gate
public boolean open()
{
Set<Block> blocks = FloodUtil.getGateFrameBlocks(from.getBlock());
setGateBlocks(blocks);
if (blocks == null)
return false;
// Uncomment lines below to have the old Portal open functionality back.
// This is not to do an effect
// It is to stop portal blocks from destroying themself as they cant rely on non created blocks :P
@ -124,6 +124,7 @@ public class Gate
for (Block block : blocks)
block.setType(Material.PORTAL);
return true;
}
@ -143,6 +144,22 @@ public class Gate
}
//----------------------------------------------//
// isHidden Setter and Getter
//----------------------------------------------//
public void setHidden(boolean isHidden)
{
this.isHidden = isHidden;
}
public boolean isHidden()
{
return this.isHidden;
}
//----------------------------------------------//
// Persistance and entity management
//----------------------------------------------//

View File

@ -32,13 +32,6 @@ public class PluginPlayerListener implements Listener
Block blockTo = event.getTo().getBlock();
Block blockToUp = blockTo.getRelative(BlockFace.UP);
// Check if player is standing inside a portal
if (blockTo.getType() != Material.PORTAL && blockToUp.getType() != Material.PORTAL)
return;
// Ok so a player walks into a portal block
// Find the nearest gate!
Gate nearestGate = null;
Location playerLocation = event.getPlayer().getLocation();
@ -46,11 +39,11 @@ public class PluginPlayerListener implements Listener
for (Gate gate : Gate.getAll())
{
if ( gate.getFrom() == null || gate.getTo() == null)
if (gate.getFrom() == null || gate.getTo() == null)
continue;
if ( ! gate.getFrom().getWorld().equals(playerLocation.getWorld()))
if (! gate.getFrom().getWorld().equals(playerLocation.getWorld()))
continue; // We can only be close to gates in the same world
@ -60,17 +53,16 @@ public class PluginPlayerListener implements Listener
continue;
Plugin.log(Level.ALL, "in gate search radius.");
Plugin.log(Level.ALL, "in gate search radius.");
for (Integer[] blockXYZ: gate.getGateBlocks())
{
if ( (blockTo.getX() == blockXYZ[0] || blockToUp.getX() == blockXYZ[0]) &&
(blockTo.getY() == blockXYZ[1] || blockToUp.getY() == blockXYZ[1]) &&
(blockTo.getZ() == blockXYZ[2] || blockToUp.getZ() == blockXYZ[2])
)
if ((blockTo.getX() == blockXYZ[0] || blockToUp.getX() == blockXYZ[0]) &&
(blockTo.getY() == blockXYZ[1] || blockToUp.getY() == blockXYZ[1]) &&
(blockTo.getZ() == blockXYZ[2] || blockToUp.getZ() == blockXYZ[2]))
{
nearestGate = gate;
break;
}
}
}
/*if (shortestDistance == -1 || shortestDistance > distance) {
@ -81,10 +73,15 @@ public class PluginPlayerListener implements Listener
if (nearestGate != null)
{
checkChunkLoad(nearestGate.getTo().getBlock());
if (nearestGate.isHidden() == false)
{
// Check if player is standing inside portal blocks
if (blockTo.getType() != Material.PORTAL && blockToUp.getType() != Material.PORTAL)
return;
}
checkChunkLoad(nearestGate.getTo().getBlock());
Float newYaw = nearestGate.getFrom().getYaw() - nearestGate.getTo().getYaw() + playerLocation.getYaw();
Location teleportToLocation = new Location( nearestGate.getTo().getWorld(),
nearestGate.getTo().getX(),
nearestGate.getTo().getY(),