@EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (player.getItemInHand().getType() == plugin.getWorldEditSettings().getWandMaterial()) {
      PlayerSettings settings = plugin.getPlayerSettings(player);

      if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
        settings.setFirstPosition(event.getClickedBlock().getLocation());

        if (settings.getSelection() == null) {
          player.sendMessage("First position is set!");
        } else {
          player.sendMessage(
              "First position is set!(" + settings.getSelection().getBlocks().size() + " blocks)");
        }

        event.setCancelled(true);
      } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        settings.setSecondPosition(event.getClickedBlock().getLocation());

        if (settings.getSelection() == null) {
          player.sendMessage("Second position is set!");
        } else {
          player.sendMessage(
              "Second position is set!(" + settings.getSelection().getBlocks().size() + " blocks)");
        }

        event.setCancelled(true);
      }
    }
  }
  public void onPlayerInteract(PlayerInteractEvent pie) {
    if (Action.LEFT_CLICK_BLOCK.equals(pie.getAction())
        || (isValidBlock(pie.getClickedBlock())
            && Action.RIGHT_CLICK_BLOCK.equals(pie.getAction()))) {
      Block clicked = pie.getClickedBlock();
      Block behind = clicked.getRelative(pie.getBlockFace().getOppositeFace());

      SecretDoor door = null;

      if (Material.WOODEN_DOOR.equals(clicked.getType()) && !SecretDoor.isDoubleDoor(clicked)) {
        if (this.plugin.isSecretDoor(SecretDoor.getKeyFromBlock(clicked))) {
          this.plugin.closeDoor(SecretDoor.getKeyFromBlock(clicked));
        } else if (!Material.AIR.equals(behind.getType())) {
          if (SecretDoor.isAdjacentDoor(clicked, pie.getBlockFace()))
            door = new SecretDoor(clicked, behind, SecretDoor.Direction.DOOR_FIRST);
        }

      } else if (Material.WOODEN_DOOR.equals(behind.getType())
          && !SecretDoor.isDoubleDoor(behind)) {
        if (this.plugin.isSecretDoor(SecretDoor.getKeyFromBlock(behind))) {
          this.plugin.closeDoor(SecretDoor.getKeyFromBlock(behind));
        } else if (SecretDoor.isAdjacentDoor(behind, pie.getBlockFace().getOppositeFace()))
          door = new SecretDoor(behind, clicked, SecretDoor.Direction.BLOCK_FIRST);
      }

      if (!(door == null)) {
        plugin.addDoor(door).open();
        pie.getPlayer().sendMessage(ChatColor.RED + "Don't forget to close the door!");
      }
    }
  }
 /**
  * Called when a player clicks on anything.
  *
  * @param event The Interact event.
  */
 @EventHandler
 public void playerInteract(PlayerInteractEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
     if (event.getClickedBlock().getState() instanceof Sign) {
       this.plugin.log(Level.FINER, "Found a Sign!");
       Sign s = (Sign) event.getClickedBlock().getState();
       SignStatus status = this.pd.getSignStatus(s);
       if (status == SignStatus.SignPortal) {
         String destString = this.pd.processSign(s);
         this.takePlayerToDestination(event.getPlayer(), destString);
         event.setCancelled(true);
       } else if (status == SignStatus.Disabled) {
         this.pd.activateSignPortal(event.getPlayer(), ChatColor.RED + "Disabled", s);
         event.setCancelled(true);
       } else if (status == SignStatus.Legacy) {
         this.pd.activateSignPortal(event.getPlayer(), ChatColor.AQUA + "Legacy", s);
         event.setCancelled(true);
       } else if (status == SignStatus.NetherPortalSign) {
         event.setCancelled(true);
       }
     }
   }
 }
  @EventHandler
  public void onPlayerInteractEvent(PlayerInteractEvent event) {
    if (!isEnabled()) return;
    try {
      if (event.hasBlock() && event.getClickedBlock().getType() == Material.SIGN) return;
      if (event.hasItem() && event.useItemInHand() != Event.Result.DENY) {
        ForgePermittor.log(
            "ItemType: " + getValidator().CheckItem(event.getItem()).toString(), true);
        if (!getProtectionManager()
            .CanUseItem(
                event.getPlayer(),
                event.getPlayer().getLocation(),
                getValidator().CheckItem(event.getItem()))) {
          event.setUseItemInHand(Event.Result.DENY);
          event.setUseInteractedBlock(Event.Result.DENY);

          return;
        }
      }
      if (event.hasBlock() && event.useInteractedBlock() != Event.Result.DENY) {
        ForgePermittor.log(
            "BlockType: " + getValidator().CheckBlock(event.getClickedBlock()).toString(), true);
        if (!getProtectionManager()
            .CanUseBlock(
                event.getPlayer(),
                event.getClickedBlock(),
                getValidator().CheckBlock(event.getClickedBlock()))) {
          event.setUseInteractedBlock(Event.Result.DENY);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    if (event.getAction() == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK
        || event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) {
      PlayerEvent playerEvent;
      if (SignUtil.isSign(event.getClickedBlock())) {
        playerEvent =
            new PlayerEvent(
                SignUtil.getSign(event.getClickedBlock()),
                event.getAction() == Action.LEFT_CLICK_BLOCK
                    ? PlayerEvent.Action.LEFT_CLICK
                    : PlayerEvent.Action.RIGHT_CLICK,
                event.getPlayer(),
                event);
      } else {
        playerEvent =
            new PlayerEvent(
                event.getClickedBlock(),
                event.getAction() == Action.LEFT_CLICK_BLOCK
                    ? PlayerEvent.Action.LEFT_CLICK
                    : PlayerEvent.Action.RIGHT_CLICK,
                event.getPlayer(),
                event);
      }
      mechanicsHandler.callPlayerEvent(playerEvent);
    }
  }
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onPlayerInteract(PlayerInteractEvent event) {
   if (event.getClickedBlock() != null
       && event.getClickedBlock().getState() instanceof InventoryHolder) {
     addToCheck(event.getClickedBlock(), event.getClickedBlock().getState());
   }
 }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    int BLWand = getConfig().getInt("blocklog.wand");
    boolean WandEnabled = plugin.users.contains(event.getPlayer().getName());
    if (!event.isCancelled()) {
      if (event.getPlayer().getItemInHand().getTypeId() == BLWand && WandEnabled) {
        if ((event.getAction() == Action.RIGHT_CLICK_BLOCK
                && (!event.getPlayer().getItemInHand().getType().isBlock())
            || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
          Material type = event.getClickedBlock().getType();
          if (type == Material.WOODEN_DOOR
              || type == Material.TRAP_DOOR
              || type == Material.CHEST
              || type == Material.DISPENSER
              || type == Material.STONE_BUTTON
              || type == Material.LEVER)
            getBlockInteractions(
                event.getPlayer(), event.getClickedBlock(), Interaction.getByMaterial(type));
          else getBlockEdits(event.getPlayer(), event.getClickedBlock());

          event.setCancelled(true);
        }
      }
    }
  }
Exemple #8
0
  @EventHandler(priority = EventPriority.HIGH)
  public void protectBlockStates(PlayerInteractEvent event) {
    Material[] blockedItems = {
      Material.NOTE_BLOCK,
      Material.REDSTONE_COMPARATOR_OFF,
      Material.REDSTONE_COMPARATOR_ON,
      Material.DIODE_BLOCK_OFF,
      Material.DIODE_BLOCK_ON,
      Material.FLOWER_POT,
      Material.CAKE_BLOCK,
      Material.DAYLIGHT_DETECTOR,
      Material.DAYLIGHT_DETECTOR_INVERTED
    };
    if (event.getClickedBlock() == null) {
      return;
    }
    Player p = event.getPlayer();
    // System.out.println(event.getClickedBlock().getType());
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
        && Arrays.asList(blockedItems).contains(event.getClickedBlock().getType())) {
      OwnedLand land = OwnedLand.getApplicableLand(event.getClickedBlock().getLocation());
      if (land == null) {
        return;
      }
      if (land.hasPermTo(p, this)) {
        return;
      }

      p.sendMessage(
          ChatColor.RED + getPlugin().getMessageConfig().getString("event.build.blockStateChange"));
      event.setCancelled(true);
    }
  }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerInteract(PlayerInteractEvent e) {
    if (e.getItem() != null
        && e.getItem().getType() == selectionTools
        && e.getClickedBlock() != null
        && e.getPlayer().isOp()) {

      Region v = this.selections.get(e.getPlayer().getName());

      if (v == null) {
        v = new Region(null, null);
        this.selections.put(e.getPlayer().getName(), v);
      }

      Location l = e.getClickedBlock().getLocation();

      if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        v.setEnd(l);
        if (plugin.portalRegionSelectionMessage)
          e.getPlayer().sendMessage("[BungeeSuiteBukkit] Second point set");
      } else if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
        v.setFirst(l);
        if (plugin.portalRegionSelectionMessage)
          e.getPlayer().sendMessage("[BungeeSuiteBukkit] First point set");
      }
    }
  }
 @EventHandler(priority = EventPriority.MONITOR)
 public void onPlayerInteract(PlayerInteractEvent e) {
   ItemStack stack = e.getItem();
   if (e.getPlayer().isOp()) {
     if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
         && stack != null
         && stack.getType().equals(wand)) {
       if (a.get(e.getPlayer().getName()) == null
           || (b.get(e.getPlayer().getName()) != null && a.get(e.getPlayer().getName()) != null)) {
         a.put(e.getPlayer().getName(), e.getClickedBlock().getLocation());
         b.remove(e.getPlayer().getName());
         e.getPlayer()
             .sendMessage(
                 ChatColor.AQUA
                     + "Selected block A: "
                     + e.getClickedBlock().getLocation().toVector().toString());
       } else if (b.get(e.getPlayer().getName()) == null) {
         b.put(e.getPlayer().getName(), e.getClickedBlock().getLocation());
         e.getPlayer()
             .sendMessage(
                 ChatColor.AQUA
                     + "Selected block B: "
                     + e.getClickedBlock().getLocation().toVector().toString());
       }
     }
   }
 }
  private void initCreation(PlayerInteractEvent event, SafeCityPlayer scPlayer, SafeCityZone zone) {
    if (zone == null & scPlayer.getZoneManager().getSubZoneCreationParent() == null) {
      scPlayer.getZoneManager().setIsCreatingZone(true);
      scPlayer
          .getZoneManager()
          .setNewZoneLocation1(context.toThinLocation(event.getClickedBlock().getLocation()));

      // createPrimaryZone(event, scPlayer);
    } else {
      // first click of sub-zone creation
      if (!scPlayer.getZoneManager().isCreatingSubZone()) {
        scPlayer.getZoneManager().setIsCreatingSubZone(true);
        scPlayer.getZoneManager().setSubZoneCreationParent(zone);

        scPlayer.getBukkitPlayer().sendMessage(context.getMessageHandler().Zone_Sub_Creating());

        scPlayer
            .getZoneManager()
            .setNewZoneLocation1(context.toThinLocation(event.getClickedBlock().getLocation()));

        return;
      } else // second click
      {
        createSubZone(scPlayer, event, zone);
      }
    }

    scPlayer.getZoneManager().clearCreationData();
    scPlayer.startCoolDown(2L);
  }
    // Hits a netherrack block
    public void onPlayerInteract(PlayerInteractEvent event) {
      // Do not run if cancelled
      if (event.isCancelled()) {
        return;
      }

      // Only run if netherrack ignition is enabled
      if (igniteNetherrack) {
        // Check to see if player clicked a netherrack block
        if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
          if (event.getClickedBlock().getType() == Material.NETHERRACK) {
            // Ignite this block if Firetouch enabled
            Player player = event.getPlayer();
            PotionEntry buff = getPlugin().BuffList.get(player);

            if (buff != null) {
              if (buff.HasBuff.get(Name) != null && buff.HasBuff.get(Name)) {
                // Ignite block
                BlockIgniteEvent ignite =
                    new BlockIgniteEvent(
                        event.getClickedBlock(), IgniteCause.FLINT_AND_STEEL, player);
                getPlugin().getServer().getPluginManager().callEvent(ignite);
                if (!ignite.isCancelled()) {
                  Block above = event.getClickedBlock().getRelative(0, 1, 0);
                  if (above.isEmpty()) {
                    above.setType(Material.FIRE);
                  }
                }
              }
            }
          }
        }
      }
    }
 @EventHandler
 public void onBlockInteractEvent(PlayerInteractEvent event) {
   if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR))
       || !(event.getAction().equals(Action.RIGHT_CLICK_AIR))) {
     return;
   }
   if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
     if (event.getClickedBlock().getType().equals(Material.SIGN)
         || event.getClickedBlock().getType().equals(Material.SIGN_POST)
         || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
       return;
     }
   }
   Player player = event.getPlayer();
   if (plugin.manager.isPlayerInGame(player)) {
     Game game = plugin.manager.getGame(player);
     if (!(game.mode == ArenaStatus.INGAME)) {
       return;
     }
     if (game.getPlayersGun(player) != null) {
       GunManager gunManager = game.getPlayersGun(player);
       if (gunManager.isGun()) {
         Gun gun = gunManager.getGun(player.getInventory().getHeldItemSlot());
         if (gun.isReloading()) {
           player.getLocation().getWorld().playSound(player.getLocation(), Sound.CLICK, 1, 1);
           return;
         }
         gun.wasShot();
       }
     }
   }
 }
 @EventHandler
 public void onPlayerBlockInteract(PlayerInteractEvent event) {
   if (VAR.config.getBoolean("enableRules")) {
     if (!VAR.pLog
         .getString("players." + event.getPlayer().getName() + ".Has accepted rules")
         .equalsIgnoreCase("true")) {
       if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) return;
       String msg = VAR.config.getString("RulesNotAcceptedMsg");
       msg = ip.replace(msg, event.getPlayer());
       if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("chest")) {
         if (event.getClickedBlock().getTypeId() == 54) {
           event.getPlayer().sendMessage(msg);
           event.setCancelled(true);
           return;
         }
       }
       if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("redstone")) {
         int ID = event.getClickedBlock().getTypeId();
         if (ID == 69 || ID == 70 || ID == 72 || ID == 77) {
           event.getPlayer().sendMessage(msg);
           event.setCancelled(true);
           return;
         }
       }
     }
   }
 }
	@EventHandler(priority = EventPriority.NORMAL)
	public void onPlayerInteract(final PlayerInteractEvent event)
	{
		final IUser user = userMap.getUser(event.getPlayer());
		user.updateActivity(true);
		switch (event.getAction())
		{
		case RIGHT_CLICK_BLOCK:
			if (event.isCancelled())
			{
				return;
			}

			final ISettings settings = ess.getSettings();
			if (settings.getData().getCommands().getHome().isUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
			{
				event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
			}
			break;
		case LEFT_CLICK_AIR:
		case LEFT_CLICK_BLOCK:
			if (user.getData().hasPowerTools() && user.getData().isPowerToolsEnabled())
			{
				if (usePowertools(user))
				{
					event.setCancelled(true);
				}
			}
			break;
		default:
			break;
		}
	}
  /**
   * Event - onBlockRightClick - If a player right clicks a block check their permissions and set a
   * Coordinate.
   */
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) {
      return;
    }

    Player player = event.getPlayer();

    if (player.getItemInHand().getTypeId() == this.plugin.configMV.getInt("setwand", 270)
        && MultiVerse.Permissions.has(player, "multiverse.portal.create")) {
      String[] whitelist = this.plugin.configMV.getString("portalblocks", "").split(",");
      if (whitelist.length > 0 && whitelist[0] != "") {
        for (String element : whitelist) {
          int w = Integer.valueOf(element);
          if (w != event.getClickedBlock().getTypeId()) {
            return;
          }
        }
      }
      Location l = event.getClickedBlock().getLocation();
      if (this.plugin.playerSessions.get(player.getName()).compareLocation2(l)) {
        return;
      }
      this.plugin.playerSessions.get(player.getName()).setLocation2(l);
      player.sendMessage("Position 2 - Set");
    }
  }
Exemple #17
0
  // handle sign click
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onSignClick(PlayerInteractEvent e) {
    if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    if (!(e.getClickedBlock().getState() instanceof Sign)) {
      return;
    }
    Sign sign = (Sign) e.getClickedBlock().getState();
    Player player = e.getPlayer();
    if (sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[TNTRun]")) {
      if (!player.hasPermission("tntrun.game")) {
        player.sendMessage("You don't have permission to do this");
        e.setCancelled(true);
        return;
      }

      if (sign.getLine(1).equalsIgnoreCase("[join]") && sign.getLine(2) != null) {
        joinsign.handleClick(e);
      } else if (sign.getLine(1).equalsIgnoreCase("[leave]")) {
        leavesign.handleClick(e);
      } else if (sign.getLine(1).equalsIgnoreCase("[vote]")) {
        votesign.handleClick(e);
      }
    }
  }
Exemple #18
0
  @Override
  public boolean onInteract(PlayerInteractEvent e, int level) {
    if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.COBBLESTONE) {
      e.getClickedBlock().setType(Material.STONE);

      return true;
    }
    return false;
  }
  @EventHandler
  public void onClick(PlayerInteractEvent e) {
    if (e.getPlayer().getItemInHand() != null
        && e.getPlayer().getItemInHand().getType() == Material.STICK
        && e.getPlayer()
            .getItemInHand()
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.GOLD + "Outil de Parcelles")) {
      Action ac = e.getAction();
      if (ac != Action.LEFT_CLICK_BLOCK && ac != Action.RIGHT_CLICK_BLOCK) return;

      Player j = e.getPlayer();

      Ville v = pl.v().citizenOf(j.getName());
      if (v == null) {
        j.sendMessage(pl.TAG + ChatColor.RED + "Vous ne disposez pas de ville.");
        return;
      } else if (!v.canBuild(j.getName())) {
        j.sendMessage(
            pl.TAG + ChatColor.RED + "Vous n'êtes pas adjoint ou maire dans votre ville.");
        return;
      }
      if (!e.getClickedBlock().getWorld().getName().equals("world")) {
        e.getPlayer()
            .sendMessage(pl.TAG + ChatColor.RED + "Cet outil ne peut pas être utilisé ici.");
        return;
      }

      if (pl.v().villeParChunk(e.getClickedBlock().getChunk()) != v) {
        e.getPlayer().sendMessage(pl.TAG + ChatColor.RED + "Vous n'êtes pas dans votre ville.");
        return;
      }

      if (ac == Action.LEFT_CLICK_BLOCK) {
        pl.p.setPoint(0, e.getPlayer().getName(), e.getClickedBlock().getLocation());
        e.getPlayer().sendMessage(pl.TAG + ChatColor.LIGHT_PURPLE + "Premier bloc sélectionné.");
      } else if (ac == Action.RIGHT_CLICK_BLOCK) {
        pl.p.setPoint(1, e.getPlayer().getName(), e.getClickedBlock().getLocation());
        e.getPlayer().sendMessage(pl.TAG + ChatColor.LIGHT_PURPLE + "Second bloc sélectionné.");
      }
      return;
    }

    Block clicked = e.getClickedBlock();
    if (clicked == null) return;

    if (!clicked.getWorld().getName().equals("world")) return;

    if (!pl.v().canInteractEnv(e.getPlayer(), clicked)) {
      e.getPlayer()
          .sendMessage(pl.TAG + ChatColor.DARK_RED + "Vous ne pouvez pas intéragir avec ceci.");
      e.setCancelled(true);
    }
  }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
      return;
    }
    if (event.getClickedBlock() == null || event.getClickedBlock().getType() == Material.AIR) {
      return;
    }

    if (!context.isValidWorld(event.getPlayer().getWorld().getName())) return;

    SafeCityPlayer scPlayer = context.getPlayer(event.getPlayer());

    if (scPlayer.getCoolDownState()) {
      return;
    }
    if (scPlayer.getZoneManager().isResizing()) {
      return;
    }

    boolean hasTool = false;
    if (scPlayer.getBukkitPlayer().getItemInHand().getType() == SafeCityTool.ZoneTool.material()) {
      hasTool = true;
    }
    if (scPlayer.getBukkitPlayer().getItemInHand().getType()
        == SafeCityTool.ZoneTool3d.material()) {
      hasTool = true;
    }
    if (!hasTool) {
      return;
    }

    World blockWorld = event.getClickedBlock().getWorld();
    Location blockLocation = event.getClickedBlock().getLocation();
    ThinLocation blockThinLocation = context.toThinLocation(blockLocation);

    // does a zone already exist here?
    SafeCityZone zone = context.getZone(blockThinLocation, blockWorld);
    SafeCitySubZone subZone = context.getSubZone(blockThinLocation, blockWorld);

    // if clicked a corner, ignore (resizing)
    if (zone != null && zone.isCornerLocation(blockThinLocation, blockWorld, false)) {
      return;
    }
    if (subZone != null && subZone.isCornerLocation(blockThinLocation, blockWorld, true)) {
      return;
    }

    // check if player has permission
    if (!this.checkPermission(event, scPlayer, zone, subZone)) {
      return;
    }

    initCreation(event, scPlayer, zone);
  }
 public void select(Player player, PlayerInteractEvent event) {
   User user = UManager.getUser(player.getUniqueId());
   if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
     player.sendMessage("F");
     SelectionManager.SelectFirstPosition(user, event.getClickedBlock().getLocation());
   } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
     player.sendMessage("S");
     SelectionManager.SelectSecondPosition(user, event.getClickedBlock().getLocation());
   }
   event.setCancelled(true);
 }
  @EventHandler
  public void onClick(PlayerInteractEvent ev) {
    if (ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
      String item = pl.bs.check(ev.getClickedBlock());

      if (item != null && item.equalsIgnoreCase(id)) {
        ev.setCancelled(true);
        openInventory(ev.getPlayer(), ev.getClickedBlock().getLocation());
      }
    }
  }
Exemple #23
0
 public void onPlayerInteract(PlayerInteractEvent event) {
   Block b = event.getClickedBlock();
   Player p = event.getPlayer();
   Action a = event.getAction();
   // Handle field building tool operations
   if (p.getItemInHand().getTypeId() == 276) {
     Builder fb = plugin.getBattlefieldManager().getBuilder(p);
     if (fb != null) {
       if (fb.getTool() != null) {
         Tool tool = fb.getTool();
         switch (a) {
           case RIGHT_CLICK_BLOCK:
             tool.rightClick(b);
             break;
           case LEFT_CLICK_BLOCK:
             tool.leftClick(b);
             break;
           case RIGHT_CLICK_AIR:
             tool.rightClick();
             break;
           case LEFT_CLICK_AIR:
             tool.leftClick();
             break;
           default:
             break;
         }
       }
     }
   }
   TeamMember m = plugin.getBattlefieldManager().getPlayer(p);
   if (m != null) {
     Battlefield field = m.getTeam().getField();
     // Handle sign clicks
     if (b != null) {
       if (b.getState() instanceof Sign) {
         Sign sign = (Sign) b.getState();
         String line = sign.getLine(0);
         if (line.equals("[Options]")) {
           BattlefieldSign bs = field.getSign(b);
           if (bs != null) {
             if (field.isActive())
               Format.sendMessage(m, "You cannot change settings during a game.");
             else if (a == Action.LEFT_CLICK_BLOCK) bs.executeOption(m);
             else if (a == Action.RIGHT_CLICK_BLOCK) bs.cycleOption(m);
           }
         }
       }
     }
     if (field.isActive())
       field.getGametype().getListener().onClick(m, event.getClickedBlock(), event.getAction());
   }
 }
 @EventHandler
 public void onPlayerInteract(PlayerInteractEvent event) {
   if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
     if (event.getClickedBlock().getType() == Material.BOOKSHELF) {
       if (!event.getPlayer().isSneaking()) {
         if (plugin.getBookshelfInventory(event.getClickedBlock()) == null) {
           plugin.createBookshelfInventory(event.getClickedBlock());
         }
         event.getPlayer().openInventory(plugin.getBookshelfInventory(event.getClickedBlock()));
         event.setCancelled(true);
       }
     }
   }
 }
  @EventHandler
  public void onPlayerMonkeyBomb(PlayerInteractEvent event) {
    if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR))
        || !(event.getAction().equals(Action.RIGHT_CLICK_AIR))) {
      return;
    }
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
      if (event.getClickedBlock().getType().equals(Material.SIGN)
          || event.getClickedBlock().getType().equals(Material.SIGN_POST)
          || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
        return;
      }
    }
    final Player player = event.getPlayer();
    if (plugin.manager.isPlayerInGame(player)) {
      Game game = plugin.manager.getGame(player);
      if (!(game.mode == ArenaStatus.INGAME)) {
        return;
      }
      if (player.getItemInHand().getType().equals(Material.MAGMA_CREAM)) {
        player.getInventory().removeItem(new ItemStack(Material.MAGMA_CREAM, 1));
        final Item item =
            player
                .getWorld()
                .dropItemNaturally(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM));
        // Location Iloc = item.getLocation();
        item.setVelocity(player.getLocation().getDirection().multiply(1));
        item.setPickupDelay(1000);
        /*for(Entity e: game.spawnManager.mobs)
        {

        }*/
        Bukkit.getScheduler()
            .scheduleSyncDelayedTask(
                plugin,
                new Runnable() {
                  @Override
                  public void run() {
                    Location loc = item.getLocation();
                    player
                        .getWorld()
                        .createExplosion(loc.getX(), loc.getY(), loc.getZ(), 4.0F, false, false);
                    item.remove();
                  }
                },
                140);
      }
    }
  }
 /**
  * Record the right clicking a sign.
  *
  * @param event
  */
 @EventHandler
 public void onPlayerInteract(PlayerInteractEvent event) {
   if (this.plugin.getDisabled().contains(event.getPlayer().getName())) return;
   if (!event.getPlayer().hasPermission("signfix.enable")) return;
   if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
   if (!event.getClickedBlock().getType().equals(Material.SIGN)
       && !event.getClickedBlock().getType().equals(Material.SIGN_POST)
       && !event.getClickedBlock().getType().equals(Material.WALL_SIGN)) return;
   this.plugin
       .getClicked()
       .put(event.getPlayer().getName(), (Sign) event.getClickedBlock().getState());
   event
       .getPlayer()
       .sendMessage(ChatColor.AQUA.toString() + "[SignFix] Selected the sign you've hit.");
 }
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onClickBeacon(PlayerInteractEvent event) {
    if (!RedstonePvP.config.isFeatureEnabled(RedstoneFeature.BEACON_DROPS)) {
      return;
    }
    Player ply = event.getPlayer();
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    if (event.getClickedBlock() == null) {
      return;
    }
    if (!(event.getClickedBlock().getState() instanceof Beacon)) {
      if (this.beaconSetters.contains(ply.getName())) {
        ply.sendMessage(this.config.getMessage("not-beacon"));
        this.beaconSetters.remove(ply.getName());
      }
      return;
    }
    Beacon beacon = (Beacon) event.getClickedBlock().getState();
    if (this.beaconSetters.contains(ply.getName())) {
      event.setCancelled(true);
      if (!this.config.isDropBeacon(beacon)) {
        this.config.setBeacon(beacon);
        ply.sendMessage(this.config.getMessage("beacon-set"));
      } else {
        ply.sendMessage(this.config.getMessage("already-set"));
      }
      this.beaconSetters.remove(ply.getName());

      return;
    }
    if (this.config.isDropBeacon(beacon)) {
      event.setCancelled(true);
      if (!this.canRun) {
        ply.sendMessage(this.config.getMessage("wait"));
        return;
      }
      if (Bukkit.getOnlinePlayers().length
          < this.config.getPlayerAmount()) // <-- you get an error ingame?
      {
        ply.sendMessage(this.config.getMessage("not-enough-players"));
        return;
      }
      runBeaconDrops(beacon);
    }
  }
  /* (non-Javadoc)
   * @see org.bukkit.event.player.PlayerListener#onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent)
   */
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    Block clicked = event.getClickedBlock();
    Player player = event.getPlayer();

    if (clicked != null
        && (clicked.getType() == Material.STONE_BUTTON || clicked.getType() == Material.LEVER)) {
      if (!this.ButtonLeverHit(player, clicked, null)) {
        event.setCancelled(true);
      }
    } else if (clicked != null && clicked.getType() == Material.WALL_SIGN) {
      Stargate stargate = StargateManager.getGateFromBlock(clicked);

      if (stargate != null) {
        if (WXPermissions.checkWXPermissions(player, stargate, PermissionType.SIGN)) {
          if (stargate.TryClickTeleportSign(clicked)) {
            String target = "";
            if (stargate.SignTarget != null) {
              target = stargate.SignTarget.Name;
            }
            player.sendMessage("Dialer set to: " + target);
          }
        } else {
          player.sendMessage(ConfigManager.output_strings.get(StringTypes.PERMISSION_NO));
          event.setCancelled(true);
        }
      }
    }
  }
	@EventHandler(priority = EventPriority.HIGHEST)
	public void onPlayerInteract(PlayerInteractEvent e) {
		SpleefPlayer player = HeavySpleef.getInstance().getSpleefPlayer(e.getPlayer());
		Block block = e.getClickedBlock();

		if (player == null)
			return;
		if (block == null)
			return;
		if (!player.isActive())
			return;
		if (e.getAction() != Action.LEFT_CLICK_BLOCK)
			return;

		Game game = player.getGame();
		if (!game.canSpleef(player, block.getLocation()))
			return;

		if (game.getFlag(FlagType.BOWSPLEEF) || game.getFlag(FlagType.SPLEGG))
			return;

		if (game.getFlag(FlagType.BLOCKBREAKEFFECT)) {
			block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
		}

		block.setType(Material.AIR);
		player.addBrokenBlock(block);
	}
  @EventHandler
  public void onPlayerClickTool(PlayerInteractEvent event) {
    Location location = null;

    try {
      Block clicked = event.getClickedBlock();

      if ((clicked != null) && (event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
        Block relative = clicked.getRelative(event.getBlockFace());
        location = relative.getLocation();
      } else {
        BlockIterator iterator = new BlockIterator(event.getPlayer(), 16);
        Block target = null;

        while (iterator.hasNext()) {
          Block block = iterator.next();
          if (block.getType() != Material.AIR) {
            target = iterator.next();
            break;
          }
        }

        if (target != null) location = target.getLocation();
      }
    } catch (Exception e) {

    }

    if (setBlock(event.getPlayer(), event.getPlayer().getItemInHand(), location)) {
      event.setCancelled(true);
    }
  }