Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheFlash787/451d8af9216fcc4fc84e3e46571fdb56 to your computer and use it in GitHub Desktop.
Save TheFlash787/451d8af9216fcc4fc84e3e46571fdb56 to your computer and use it in GitHub Desktop.
@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