Fix the water not being replaced bug

This commit is contained in:
Sam 2017-04-24 21:26:00 +01:00 committed by cnr
parent fd31706333
commit 0bbd0659a0
2 changed files with 522 additions and 180 deletions

View File

@ -21,6 +21,8 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public abstract class CustomBridgeAnimation extends BridgeAnimation
{
@ -198,7 +200,18 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation
_maxDistance = dist;
}
_restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE);
int toSet = Material.AIR.getId();
for (Block surround : getNextBlocks(block))
{
if (surround.getType() == Material.WATER || surround.getType() == Material.STATIONARY_WATER)
{
toSet = Material.STATIONARY_WATER.getId();
break;
}
}
_restore.add(block, toSet, (byte) 0, Integer.MAX_VALUE);
_bridgeBlocks.put(block.getLocation(), dist);
}
}
@ -248,4 +261,16 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation
return builder.toString();
}
private List<Block> getNextBlocks(Block block)
{
List<Block> blocks = new ArrayList<>(4);
blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.WEST));
return blocks;
}
}