Пример #1
0
 /**
  * Get the slot which the named material sits in.
  *
  * @param inventory inventory to search
  * @param material material to search for
  * @param itemName name of the material to match
  * @return slot of the named-item if it exists in the inventory, -1 otherwise.
  */
 public static Integer getSlotOf(Inventory inventory, Material material, String itemName) {
   HashMap<Integer, ? extends ItemStack> items = inventory.all(material);
   for (Map.Entry<Integer, ? extends ItemStack> inventoryItem : items.entrySet()) {
     if (Items.nameContains(inventoryItem.getValue(), itemName)) {
       return inventoryItem.getKey();
     }
   }
   return -1;
 }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    GamePlayer GamePlayer = FakeboardHandler.getPlayer(player);
    String playerName = GamePlayer.getName();

    if (event.getAction() == Action.RIGHT_CLICK_AIR
        || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      if (player.getItemInHand() != null
          && Items.itemNameContains(player.getItemInHand(), "Select & Edit Loadouts")) {
        event.setCancelled(true);
        // Open the loadout menu for the player
        GameSetupHandler.openLoadoutOptionMenu(player);
      }
    } else if (GameSetupHandler.isGameInProgress()) {
      if (!playerCooldown.isOnCooldown(playerName)) {
        if (GamePlayer.isAfk()) {
          GamePlayer.setAfk(false, false);
        }
        playerCooldown.setOnCooldown(playerName);
      }
    }
  }