Created
May 8, 2020 10:17
-
-
Save TheFlash787/451d8af9216fcc4fc84e3e46571fdb56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Listener(beforeModifications = true) | |
public void onPlayerMove(MoveEntityEvent.Position event, @Getter("getTargetEntity") Player player){ | |
if(this.minigame.getPlayers().contains(player)){ | |
if(this.minigame.getStarted()){ | |
if(player.get(Keys.GAME_MODE).get() != GameModes.SPECTATOR){ | |
Vector3d fromPos = event.getFromTransform().getPosition().sub(0, 1.0, 0); | |
Vector3d toPos = event.getToTransform().getPosition().sub(0, 1.0, 0); | |
if(fromPos != toPos){ | |
Location<World> barrierBlockLocation = new Location<>(this.minigame.getWorld(), toPos.sub(0, 1.0, 0)); | |
if(barrierBlockLocation.getBlockType() == BlockTypes.BARRIER){ | |
Location<World> redstoneBlockLocation = barrierBlockLocation.sub(0, 1, 0); | |
barrierBlockLocation.setBlockType(BlockTypes.TNT, BlockChangeFlags.NONE); | |
redstoneBlockLocation.setBlockType(BlockTypes.REDSTONE_BLOCK, BlockChangeFlags.ALL); | |
redstoneBlockLocation.setBlockType(BlockTypes.AIR, BlockChangeFlags.ALL); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment