Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void interactEvent(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- boolean nearStand = false;
- if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
- && event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK)
- && event.hasItem()
- && event.getItem().getType().equals(Material.IRON_BARDING)
- && event.getItem().getItemMeta().getLore().contains("Створює турель")) {
- if (!player.getGameMode().equals(GameMode.CREATIVE)) {
- if (player.getInventory().getItemInMainHand().getAmount() > 1) {
- player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
- } else {
- player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
- }
- }
- Block block = event.getClickedBlock();
- Location location = block.getLocation();
- Collection<Entity> near = block.getLocation().add(0, 1, 0).getWorld().getNearbyEntities(block.getLocation(), 2, 2, 2);
- for (Entity st : near) {
- if (st instanceof ArmorStand && st.getName().startsWith("Турель")) {
- nearStand = true;
- }
- }
- if (!nearStand) {
- Turret turret = new Turret(player, location);
- runTurret(turret, player);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement