Advertisement
Cool_boy21

Untitled

May 11th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. @EventHandler
  2. public void interactEvent(PlayerInteractEvent event) {
  3. Player player = event.getPlayer();
  4. boolean nearStand = false;
  5. if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
  6. && event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK)
  7. && event.hasItem()
  8. && event.getItem().getType().equals(Material.IRON_BARDING)
  9. && event.getItem().getItemMeta().getLore().contains("Створює турель")) {
  10. if (!player.getGameMode().equals(GameMode.CREATIVE)) {
  11. if (player.getInventory().getItemInMainHand().getAmount() > 1) {
  12. player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
  13. } else {
  14. player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
  15. }
  16. }
  17. Block block = event.getClickedBlock();
  18. Location location = block.getLocation();
  19. Collection<Entity> near = block.getLocation().add(0, 1, 0).getWorld().getNearbyEntities(block.getLocation(), 2, 2, 2);
  20. for (Entity st : near) {
  21. if (st instanceof ArmorStand && st.getName().startsWith("Турель")) {
  22. nearStand = true;
  23. }
  24. }
  25. if (!nearStand) {
  26. Turret turret = new Turret(player, location);
  27. runTurret(turret, player);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement