@EventHandler(priority = EventPriority.MONITOR) public void onPlayerMove(PlayerMoveEvent event) { BlockPlatform platform = windwalkers.get(event.getPlayer().getName()); if (platform != null) { Player player = event.getPlayer(); if (isExpired(player)) { turnOff(player); } else { if (falling.contains(player)) { if (event.getTo().getY() < event.getFrom().getY()) { falling.remove(player); } else { return; } } if (!player.isSneaking()) { Block block = event.getTo().subtract(0, 1, 0).getBlock(); boolean moved = platform.isMoved(block, false); if (moved) { platform.movePlatform(block, true); addUse(player); chargeUseCost(player); } } } } }
@Override protected void turnOff() { for (BlockPlatform platform : windwalkers.values()) { platform.destroyPlatform(); } windwalkers.clear(); unregisterListener(); }
@Override public void turnOffBuff(Player player) { BlockPlatform platform = windwalkers.get(player.getName()); if (platform != null) { platform.destroyPlatform(); windwalkers.remove(player.getName()); unregisterListener(); } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { if (windwalkers.size() > 0 && event.getBlock().getType() == platformBlock) { for (BlockPlatform platform : windwalkers.values()) { if (platform.blockInPlatform(event.getBlock())) { event.setCancelled(true); break; } } } }