changes towards enabling the hide feature
This commit is contained in:
parent
8e816bb5d2
commit
3fc35e13bc
@ -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,12 +111,11 @@ 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
|
||||
for (Block block : blocks)
|
||||
@ -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
|
||||
//----------------------------------------------//
|
||||
|
@ -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();
|
||||
@ -65,8 +58,7 @@ public class PluginPlayerListener implements Listener
|
||||
{
|
||||
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])
|
||||
)
|
||||
(blockTo.getZ() == blockXYZ[2] || blockToUp.getZ() == blockXYZ[2]))
|
||||
{
|
||||
nearestGate = gate;
|
||||
break;
|
||||
@ -81,10 +73,15 @@ public class PluginPlayerListener implements Listener
|
||||
|
||||
if (nearestGate != null)
|
||||
{
|
||||
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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user