@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onClick(PlayerInteractEntityEvent event) { Player player = event.getPlayer(); Entity entity = event.getRightClicked(); if (entity == null) { return; } if (entity.getType() != EntityType.ITEM_FRAME && entity.getType() != EntityType.ARMOR_STAND) { return; } if (entity.getType() == EntityType.ITEM_FRAME) { if (!AllowAction.allowAction(entity.getLocation(), player, FlagManager.ITEMFRAME)) { event.setCancelled(true); } } else { if (!AllowAction.allowAction(entity.getLocation(), player, FlagManager.ARMORSTAND)) { event.setCancelled(true); } } }
private void interact(Player player, Block block, PlayerInteractEvent event) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { return; } Flag flag = getFlag(block.getType()); if (flag == null) { return; } if (!AllowAction.allowAction(block.getLocation(), player, flag)) { event.setCancelled(true); } else { } }
private void pressure(Player player, Block block, PlayerInteractEvent event) { if (event.getAction() != Action.PHYSICAL) { return; } Material mat = block.getType(); if (mat == Material.SOIL || mat == Material.SOUL_SAND) { if (!AllowAction.allowAction(block.getLocation(), player, FlagManager.TRAMPLE)) { event.setCancelled(true); return; } return; } if (block.getType() != Material.STONE_PLATE && block.getType() != Material.WOOD_PLATE && block.getType() != Material.GOLD_PLATE && block.getType() != Material.IRON_PLATE) { return; } if (!AllowAction.allowAction(block.getLocation(), player, FlagManager.PRESSUREPLATE)) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.LOWEST) public void onEntityInteract(EntityInteractEvent event) { Block block = event.getBlock(); Material mat = block.getType(); Entity entity = event.getEntity(); if ((entity.getType() == EntityType.FALLING_BLOCK) || !(mat == Material.SOIL || mat == Material.SOUL_SAND)) { return; } if (!AllowAction.allowAction(block.getLocation(), FlagManager.TRAMPLE)) { event.setCancelled(true); } }
private void armorStand(Player player, Block block, Cancellable cancellable) { if (!AllowAction.allowAction(block.getLocation(), player, FlagManager.ARMORSTAND)) { cancellable.setCancelled(true); } }