示例#1
0
  /**
   * Handles attribute menu interaction
   *
   * @param event event details
   */
  @EventHandler
  public void onClick(InventoryClickEvent event) {
    // Class selection
    if (InventoryManager.isMatching(event.getInventory(), MENU_KEY)) {
      // Do nothing when clicking outside the inventory
      if (event.getSlot() == -999) {
        return;
      }

      boolean top = event.getRawSlot() < event.getView().getTopInventory().getSize();
      AttributeManager manager = SkillAPI.getAttributeManager();

      // Interact with the skill tree when clicking in the top region
      if (top) {
        if (event.getSlot() < manager.getKeys().size() || event.getCursor() != null) {
          event.setCancelled(true);

          PlayerData data = SkillAPI.getPlayerData((Player) event.getWhoClicked());
          if (event.isRightClick() && SkillAPI.getSettings().isAttributesDowngrade()) {
            data.refundAttribute(manager.getKeys().toArray()[event.getSlot()].toString());
          } else if (event.isLeftClick()) {

            Object[] keys = manager.getKeys().toArray();
            data.upAttribute(keys[event.getSlot()].toString());
          }
          data.openAttributeMenu();
        }
      }

      // Do not allow shift clicking items into the inventory
      else if (event.isShiftClick()) {
        event.setCancelled(true);
      }
    }
  }
	@EventHandler(priority = EventPriority.LOWEST)
	public void onInventoryClickEvent(final InventoryClickEvent event)
	{
		if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
		{
			final IUser user = userMap.getUser((Player)event.getWhoClicked());
			final InventoryHolder invHolder = event.getView().getTopInventory().getHolder();
			if (invHolder != null && invHolder instanceof Player)
			{
				final IUser invOwner = userMap.getUser((Player)invHolder);
				if (user.isInvSee() && (!Permissions.INVSEE_MODIFY.isAuthorized(user) || Permissions.INVSEE_PREVENT_MODIFY.isAuthorized(
										invOwner) || !invOwner.isOnline()))
				{
					event.setCancelled(true);
				}
			}
		}
		if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH)
		{
			final IUser user = userMap.getUser((Player)event.getWhoClicked());
			if (user.isRecipeSee())
			{
				event.setCancelled(true);
			}
		}
	}
示例#3
0
  @Override
  @SuppressWarnings(
      "deprecation") // Player.updateInventory has been deprecated for a while with no alternative
                     // available yet
  public void onClick(final InventoryClickEvent click) {
    final int last = click.getView().getTopInventory().getSize() - 1;

    // cancel shift clicks on items outside of delivery inventory to prevent indirect moving of
    // items into delivery inventory
    if (click.isShiftClick()
        && (click.getCurrentItem().getTypeId() != Material.AIR.getId())
        && (click.getRawSlot() > last)) click.setCancelled(true);

    // cancel clicks with item on cursor in delivery inventory to prevent direct placement of items
    // into delivery inventory
    if ((click.getCursor().getTypeId() != Material.AIR.getId())
        && (click.getRawSlot() >= 0)
        && (click.getRawSlot() <= last)) click.setCancelled(true);

    if (click.isCancelled()) {
      click.setCursor(click.getCursor());
      ((Player) click.getWhoClicked()).updateInventory();
      this.courier.send((Player) click.getWhoClicked(), "withdraw-only");
    }
  }
  @SuppressWarnings("deprecation")
  private void onLobbyInventoryClick(InventoryClickEvent ice, Player player, Game game) {
    Inventory inv = ice.getInventory();
    ItemStack clickedStack = ice.getCurrentItem();

    if (!inv.getTitle().equals(Main._l("lobby.chooseteam"))) {
      ice.setCancelled(true);
      return;
    }

    if (clickedStack == null) {
      ice.setCancelled(true);
      return;
    }

    if (clickedStack.getType() != Material.WOOL) {
      return;
    }

    ice.setCancelled(true);
    Team team = game.getTeamByDyeColor(DyeColor.getByData(clickedStack.getData().getData()));
    if (team == null) {
      return;
    }

    game.playerJoinTeam(player, team);
    player.closeInventory();
  }
 @EventHandler(ignoreCancelled = true)
 public void onPrefsMenuClick(InventoryClickEvent event) {
   Inventory inv = event.getInventory();
   String name = inv.getTitle();
   if (name.equals("§4TARDIS Key Prefs Menu")) {
     Player p = (Player) event.getWhoClicked();
     int slot = event.getRawSlot();
     if (slot >= 0 && slot < 27) {
       switch (slot) {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
         case 10:
         case 12:
         case 14:
         case 16:
           event.setCancelled(true);
           // set display name of key in slot 18
           ItemStack key = inv.getItem(18);
           if (key == null || !key.getType().equals(Material.GOLD_NUGGET) || !key.hasItemMeta()) {
             return;
           }
           // get Display name of selected key
           ItemStack choice = inv.getItem(slot);
           ItemMeta choice_im = choice.getItemMeta();
           String choice_name = choice_im.getDisplayName();
           ItemMeta sonic_im = key.getItemMeta();
           sonic_im.setDisplayName(choice_name);
           key.setItemMeta(sonic_im);
           break;
         case 18:
           break;
         case 26:
           // close
           event.setCancelled(true);
           close(p);
           break;
         default:
           event.setCancelled(true);
           break;
       }
     } else {
       ClickType click = event.getClick();
       if (click.equals(ClickType.SHIFT_RIGHT) || click.equals(ClickType.SHIFT_LEFT)) {
         event.setCancelled(true);
       }
     }
   }
 }
示例#6
0
  @EventHandler
  public void onInventoryClick(InventoryClickEvent event) {
    if (event.getInventory().getName() == "Choose a metal") {
      if (event.getRawSlot() <= 8) {
        event.getWhoClicked().getInventory().addItem(new ItemStack(event.getCurrentItem()));

        event.getWhoClicked().closeInventory();
        event.setCancelled(true);
      }
      event.setCancelled(true);
    }
  }
示例#7
0
 @SuppressWarnings("deprecation")
 @EventHandler
 public void click(InventoryClickEvent event) {
   Player player = (Player) event.getView().getPlayer();
   OpenQuestLog oql = getOpenQuestLog(player);
   if (oql == null) return;
   event.setCancelled(true);
   if (event.getView() != oql.getInventoryView()) {
     player.updateInventory();
     return;
   }
   if (event.getCurrentItem() == null) {
     player.updateInventory();
     return;
   }
   Quest sel = oql.getSelected();
   if (sel == null) {
     if (event.getSlot() == 27) {
       oql.setViewingCompleted(!oql.isViewingCompleted());
       oql.update();
     } else {
       int index = (oql.getPage() - 1) * 27 + event.getSlot();
       Quest[] q =
           oql.isViewingCompleted() ? oql.getCurrentCompletedList() : oql.getCurrentQuestList();
       if (index < q.length) {
         oql.setSelected(q[index]);
         oql.update();
       }
     }
   } else if (event.getSlot() == 27) {
     oql.setSelected(null);
     oql.update();
   }
   player.updateInventory();
 }
示例#8
0
 @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
 public void onInventoryClick(InventoryClickEvent e) {
   if (useLocaleInv && e.getView() instanceof LocaleInventory) {
     LocaleInventory inv = (LocaleInventory) e.getView();
     InventoryClickEvent clickEvent =
         new InventoryClickEvent(
             inv.getView(), e.getSlotType(), e.getRawSlot(), e.isRightClick(), e.isShiftClick());
     Bukkit.getServer().getPluginManager().callEvent(clickEvent);
     if (clickEvent.isCancelled()) {
       e.setCancelled(true);
     } else {
       switch (clickEvent.getResult()) {
         case DEFAULT: // Can't really do this with current events
         case ALLOW:
           System.out.println("ok...");
           System.out.println(inv.getView().getItem(e.getRawSlot()));
           inv.getView().setItem(e.getRawSlot(), clickEvent.getCursor());
           System.out.println(inv.getView().getItem(e.getRawSlot()));
           break;
         case DENY:
           break;
       }
     }
     for (LocaleInventory localeInv : localeInventories) {
       if (localeInv != inv) localeInv.reload();
     }
   }
 }
示例#9
0
 /**
  * Cancel players from removing, picking the hat in their inventory.
  *
  * @param EVENT
  */
 @EventHandler
 public void cancelHatClick(final InventoryClickEvent EVENT) {
   if (EVENT.getCurrentItem() != null
       && EVENT.getCurrentItem().hasItemMeta()
       && EVENT.getCurrentItem().getItemMeta().hasDisplayName()
       && EVENT.getCurrentItem().getItemMeta().getDisplayName().equals("§8§oHat")) {
     EVENT.setCancelled(true);
     EVENT.setResult(Event.Result.DENY);
     EVENT.getWhoClicked().closeInventory();
     Bukkit.getScheduler()
         .runTaskLaterAsynchronously(
             Core.getPlugin(),
             new Runnable() {
               @Override
               public void run() {
                 for (ItemStack itemStack : EVENT.getWhoClicked().getInventory().getContents()) {
                   if (itemStack != null
                       && itemStack.hasItemMeta()
                       && itemStack.getItemMeta().hasDisplayName()
                       && itemStack.getItemMeta().getDisplayName().equals("§8§oHat")
                       && itemStack != EVENT.getWhoClicked().getInventory().getHelmet())
                     EVENT.getWhoClicked().getInventory().remove(itemStack);
                 }
               }
             },
             1);
   }
 }
示例#10
0
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onInventoryClick(InventoryClickEvent e) {
    Player player = (Player) e.getWhoClicked();
    Inventory inventory = e.getInventory();
    ItemStack currentItem = e.getCurrentItem();

    if (ArenaManager.getInstance().getArena(player) == null) {
      return;
    }

    Plot plot = ArenaManager.getInstance().getArena(player).getPlot(player);

    if (!inventory.getName().equals(ChatColor.GREEN + "Options menu")) {
      return;
    }
    if (currentItem.getType() != Material.HARD_CLAY) {
      return;
    }
    if (!currentItem.hasItemMeta()) {
      return;
    }
    if (!currentItem.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Floor block")) {
      return;
    }

    for (Block block : plot.getFloor().getAllBlocks()) {
      block.setType(e.getCursor().getType());
      block.setData(e.getCursor().getData().getData());
    }

    e.setCancelled(true);
  }
示例#11
0
  @EventHandler
  public void onInventoryClick(InventoryClickEvent e) {
    Player player = (Player) e.getWhoClicked();
    Inventory inventory = e.getInventory();
    ItemStack currentItem = e.getCurrentItem();

    if (ArenaManager.getInstance().getArena(player) == null) {
      return;
    }

    Plot plot = ArenaManager.getInstance().getArena(player).getPlot(player);

    if (!inventory.getName().equals(ChatColor.GREEN + "Particles")) {
      return;
    }
    if (currentItem.getType() != Material.LAVA_BUCKET) {
      return;
    }
    if (!currentItem.hasItemMeta()) {
      return;
    }
    if (!currentItem.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Lava drip")) {
      return;
    }

    plot.addParticle(new Particle(player.getLocation(), ParticleType.LAVA_DRIP));
    e.setCancelled(true);
  }
示例#12
0
  @EventHandler
  public void onInterfaceInteract(InventoryClickEvent event) {
    if (event.getView() != this) return;

    ItemStack itemClicked = event.getCurrentItem();
    if (itemClicked == null || itemClicked.getType() == Material.AIR) return;

    event.setCancelled(true);

    // If not right or left-click.
    if (!(event.getClick() == ClickType.RIGHT || event.getClick() == ClickType.LEFT)) return;

    if (this.ACCEPT_OBJECT.equals(itemClicked)) {
      onAcceptPressed();
      return;
    }

    if (this.BACK_OBJECT.equals(itemClicked)) {
      if (onBackPressed()) scheduleCloseOfInventory();
      return;
    }

    int rawSlot = event.getRawSlot();
    int slotNumber = event.getSlot();
    boolean usedTopInv = rawSlot < getTopInventory().getSize();

    if (usedTopInv) onSelectionItemPressed(slotNumber, itemClicked);
    else onControlItemPressed(slotNumber, itemClicked);
  }
 @EventHandler(priority = EventPriority.MONITOR)
 void onInventoryClick(InventoryClickEvent event) {
   if ((event.getInventory().getTitle().equals(this.name))
       && (event.getWhoClicked().getName().equals(this.player.getName()))) {
     event.setCancelled(true);
     int slot = event.getRawSlot();
     if ((slot >= 0) && (slot < this.size) && (this.optionNames[slot] != null)) {
       Plugin plugin = this.plugin;
       OptionClickEvent e =
           new OptionClickEvent((Player) event.getWhoClicked(), slot, this.optionNames[slot]);
       this.handler.onOptionClick(e);
       if (e.willClose()) {
         final Player p = (Player) event.getWhoClicked();
         Bukkit.getScheduler()
             .scheduleSyncDelayedTask(
                 plugin,
                 new Runnable() {
                   public void run() {
                     p.closeInventory();
                   }
                 },
                 1L);
       }
       if (e.willDestroy()) {
         destroy();
       }
     }
   }
 }
 @Override
 protected void onInventoryClick(InventoryClickEvent event, Player player) {
   event.setCancelled(true);
   final int slot = event.getRawSlot();
   if (slot >= 0 && slot <= 7) {
     // handle changing sell stack size
     ItemStack item = event.getCurrentItem();
     if (item != null && item.getType() != Material.AIR) {
       int amount = item.getAmount();
       amount = this.getNewAmountAfterEditorClick(event, amount);
       if (amount <= 0) amount = 1;
       if (amount > item.getMaxStackSize()) amount = item.getMaxStackSize();
       item.setAmount(amount);
     }
   } else if ((slot >= 9 && slot <= 16) || (slot >= 18 && slot <= 25)) {
     if (((TradingPlayerShopkeeper) shopkeeper).clickedItem != null) {
       // placing item
       final Inventory inventory = event.getInventory();
       Bukkit.getScheduler()
           .runTaskLater(
               ShopkeepersPlugin.getInstance(),
               new Runnable() {
                 public void run() {
                   inventory.setItem(slot, ((TradingPlayerShopkeeper) shopkeeper).clickedItem);
                   ((TradingPlayerShopkeeper) shopkeeper).clickedItem = null;
                 }
               },
               1);
     } else {
       // changing stack size
       ItemStack item = event.getCurrentItem();
       if (item != null && item.getType() != Material.AIR) {
         int amount = item.getAmount();
         amount = this.getNewAmountAfterEditorClick(event, amount);
         if (amount <= 0) {
           event.getInventory().setItem(slot, null);
         } else {
           if (amount > item.getMaxStackSize()) amount = item.getMaxStackSize();
           item.setAmount(amount);
         }
       }
     }
   } else if (slot >= 27) {
     // clicking in player inventory
     if (event.isShiftClick() || !event.isLeftClick()) {
       return;
     }
     ItemStack cursor = event.getCursor();
     if (cursor != null && cursor.getType() != Material.AIR) {
       return;
     }
     ItemStack current = event.getCurrentItem();
     if (current != null && current.getType() != Material.AIR) {
       ((TradingPlayerShopkeeper) shopkeeper).clickedItem = current.clone();
       ((TradingPlayerShopkeeper) shopkeeper).clickedItem.setAmount(1);
     }
   } else {
     super.onInventoryClick(event, player);
   }
 }
示例#15
0
  @EventHandler
  public void onInventoryClick(InventoryClickEvent e) {
    Player player = (Player) e.getWhoClicked();
    Inventory inventory = e.getInventory();
    ItemStack currentItem = e.getCurrentItem();

    if (ArenaManager.getInstance().getArena(player) == null) {
      return;
    }

    Plot plot = ArenaManager.getInstance().getArena(player).getPlot(player);

    if (!inventory.getName().equals(ChatColor.GREEN + "Time selection")) {
      return;
    }
    if (currentItem.getType() != Material.WATCH) {
      return;
    }
    if (!currentItem.hasItemMeta()) {
      return;
    }
    if (!currentItem.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "2 AM")) {
      return;
    }

    plot.setTime(Time.AM2);
    e.setCancelled(true);
  }
 public static void onInventoryClick(InventoryClickEvent e) {
   if (!(e.getWhoClicked() instanceof Player)) return;
   Player p = (Player) e.getWhoClicked();
   if (gunBuilder.get(p) == true) {
     if (gunBuilderStep.get(p) >= 7) {
       e.setCancelled(true);
     }
   }
 }
示例#17
0
  @ClickHandler(
      status = {tNpcStatus.SELL_AMOUNTS},
      inventory = InventoryType.TRADER)
  public void sellAmountsItems(InventoryClickEvent e) {
    e.setCancelled(true);
    // check permission
    if (!perms.has(player, "dtl.trader.sell")) return;

    int slot = e.getSlot();
    if (stock.isUiSlot(slot)) return;

    if (checkItemAmount(slot)) {
      if (handleClick(e.getRawSlot())) {
        if (!inventoryHasPlace(slot)) {
          // send message
          locale.sendMessage(player, "trader-transaction-failed-inventory");
        } else if (!sellTransaction(slot)) {
          // send message
          locale.sendMessage(player, "trader-transaction-failed-player-money");
        } else {
          addToInventory(slot);

          // send message
          locale.sendMessage(
              player,
              "trader-transaction-success",
              "trader",
              getNPC().getName(),
              "player",
              player.getName(),
              "action",
              "#bought",
              "item",
              getSelectedItem().getName(),
              "amount",
              String.valueOf(getSelectedItem().getAmount()),
              "price",
              String.format("%.2f", stock.parsePrice(getSelectedItem(), slot)).replace(',', '.'));

          // update inventory - lore
          updatePlayerInventory();
        }
      } else {
        // informations about the item some1 wants to buy
        locale.sendMessage(
            player,
            "trader-transaction-item",
            "item",
            getSelectedItem().getName(),
            "amount",
            String.valueOf(getSelectedItem().getAmount()),
            "price",
            String.format("%.2f", stock.parsePrice(getSelectedItem(), slot)).replace(',', '.'));
      }
    }
  }
示例#18
0
  @EventHandler
  public void InvClickEvent(InventoryClickEvent event) {
    ItemStack selectedItem = event.getCurrentItem();
    Player p = (Player) event.getWhoClicked();
    Inventory inv = event.getInventory();

    if (!inv.getName().equals(ChatColor.GREEN + "" + ChatColor.BOLD + "PLACE ITEMS BELOW")) {
      return;
    }

    if (selectedItem == null) {
      return;
    }
    if (selectedItem.getType().equals(Material.AIR)) {
      return;
    }

    if (selectedItem.getType().equals(Material.NETHER_FENCE)
        && selectedItem
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.GRAY + "" + ChatColor.BOLD + "<--")) {
      event.setCancelled(true);
    }

    if (selectedItem.getType().equals(Material.STAINED_GLASS_PANE)) {
      if (selectedItem
          .getItemMeta()
          .getDisplayName()
          .equals(ChatColor.GREEN + "" + ChatColor.BOLD + "ACCEPT TRADE")) {
        event.setCancelled(true);
        tradeCountdown.put(event.getWhoClicked().getUniqueId(), 6);
        if (event
            .getInventory()
            .getItem(41)
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.GREEN + "" + ChatColor.BOLD + "TRADE ACCEPTED")) {
          tradeCountdown.put(event.getWhoClicked().getUniqueId(), 6);
        }
      }
    }
  }
 @EventHandler
 public void onClick(InventoryClickEvent e) {
   if (e.getInventory() == null) return;
   if (e.getCurrentItem() == null) return;
   if (e.getCurrentItem().getType().equals(Material.AIR)) return;
   if (e.getInventory().getTitle() == null) return;
   if (e.getInventory().getTitle().equals(INV_TITLE)) {
     e.setCancelled(true);
     e.getWhoClicked().openInventory(e.getInventory());
   }
 }
示例#20
0
 @EventHandler
 public void onAnvil(InventoryClickEvent e) {
   if (e.getRawSlot() == 2
       && e.getWhoClicked() instanceof Player
       && e.getInventory().getType() == InventoryType.ANVIL) {
     if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null) {
       e.setCancelled(true);
       Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true);
     }
   }
 }
示例#21
0
 /**
  * Cancel players from removing, picking the item in their inventory.
  *
  * @param event
  */
 @EventHandler(priority = EventPriority.LOWEST)
 public void cancelMove(InventoryClickEvent event) {
   Player player = (Player) event.getWhoClicked();
   if (player == getPlayer()) {
     if (event.getClick() == ClickType.SHIFT_LEFT
         || event.getClick() == ClickType.SHIFT_RIGHT
         || event.getClick() == ClickType.NUMBER_KEY
         || event.getClick() == ClickType.UNKNOWN) {
       event.setCancelled(true);
       player.updateInventory();
       return;
     }
     if (event.getCurrentItem() != null) {
       if (event.getCurrentItem().equals(itemStack)) {
         event.setCancelled(true);
         player.updateInventory();
         return;
       }
     }
   }
 }
示例#22
0
  @EventHandler(priority = EventPriority.LOW)
  public void onInventoryClick(InventoryClickEvent event) {
    if (event.getWhoClicked() instanceof Player == false) {
      event.setCancelled(true);
      return;
    }

    Player player = (Player) event.getWhoClicked();
    Client client = Client.getClient(player);

    if ((client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning())
        && event.getInventory().getType() != InventoryType.PLAYER) {
      event.setCancelled(true);
      return;
    }

    if (!client.isObserver()) {
      /*Map map = Rixor.getRotation().getSlot().getMap();
       */
    }
  }
示例#23
0
 @ClickHandler(
     status = {
       tNpcStatus.SELL,
       tNpcStatus.BUY,
       tNpcStatus.SELL_AMOUNTS,
       tNpcStatus.MANAGE_BUY,
       tNpcStatus.MANAGE_SELL
     },
     shift = true,
     inventory = InventoryType.PLAYER)
 public void botShift(InventoryClickEvent e) {
   if (e.isShiftClick()) e.setCancelled(true);
 }
  @EventHandler
  public void onInventoryClickEvent(InventoryClickEvent e) {
    Entity entity = e.getWhoClicked();

    if (entity instanceof Player) {
      Player p = (Player) entity;

      if (Commands.tmpArmor.containsKey(
          p)) { // Don't let them throw away out armor if we're storing theirs!
        e.setCancelled(true);
      }
    }
  }
示例#25
0
 @EventHandler(priority = EventPriority.HIGHEST)
 private void preventArmor(InventoryClickEvent evt) {
   // plugin.getLogger().info(evt.getView().getType().getDefaultTitle());
   if (evt.getView().getType() == InventoryType.CRAFTING) {
     // plugin.getLogger().info("inventory click " + evt.getSlot());
     if (evt.getSlot() == 39
         || evt.getSlot() == 38
         || evt.getSlot() == 37
         || evt.getSlot() == 36) {
       evt.setCancelled(true);
     }
   }
 }
示例#26
0
  @EventHandler
  public void onInventroyClick(InventoryClickEvent event) {
    if (!ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("Offical MD Links"))
      ;
    return;

    Player player = (Player) event.getWhoClicked();
    event.setCancelled(true);

    if (event.getCurrentItem() == null
        || event.getCurrentItem().getType() == Material.AIR
        || !event.getCurrentItem().hasItemMeta()) {
      player.closeInventory();
      return;
    }

    switch (event.getCurrentItem().getType()) {
      case BEACON:
        player.closeInventory();
        player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/");
        break;

      case ANVIL:
        player.closeInventory();
        player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/");
        break;

      case MINECART:
        player.closeInventory();
        player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/");
        break;

      case DIAMOND:
        player.closeInventory();
        player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/");
        break;

      case WOOL:
        player.closeInventory();
        player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/");
        break;

      case COMPASS:
        player.closeInventory();
        player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/");
        break;
      default:
        player.closeInventory();
        break;
    }
  }
 @EventHandler
 public void onArmorSlot(InventoryClickEvent e) {
   if (e.getSlotType().equals(InventoryType.SlotType.ARMOR)) {
     HumanEntity entity = (HumanEntity) e.getWhoClicked();
     Player player = (Player) entity;
     String pn = player.getName();
     String kit = Main.getKit().get(pn);
     if (kit.equalsIgnoreCase("hidden")) {
       e.setCancelled(true);
     }
     return;
   }
   return;
 }
 @EventHandler(ignoreCancelled = true)
 public void onFurnaceInsert(final InventoryClickEvent event) {
   if (event.getInventory().getType() != InventoryType.FURNACE) {
     return;
   }
   if (event.getRawSlot() == 0 && event.getCursor().getType() != Material.AIR) {
     if (!validateSmeltingIngredient(event.getCursor())) {
       event.setCancelled(true);
     }
   } else if (event.getRawSlot() >= event.getView().getTopInventory().getSize()) {
     if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
       if (!validateSmeltingIngredient(event.getCurrentItem())
           && !STBUtil.isFuel(event.getCurrentItem().getType())) {
         event.setCancelled(true);
         int newSlot = findNewSlot(event);
         if (newSlot >= 0) {
           event.getWhoClicked().getInventory().setItem(newSlot, event.getCurrentItem());
           event.setCurrentItem(null);
         }
       }
     }
   } else if (event.getRawSlot() == 2
       && SensibleToolbox.getItemRegistry().isSTBItem(event.getCurrentItem())) {
     // work around CB bug where shift-clicking custom items out of furnace seems
     // to cause a de-sync, leaving phantom items in the furnace
     Bukkit.getScheduler()
         .runTask(
             plugin,
             new Runnable() {
               @Override
               public void run() {
                 STBUtil.forceInventoryRefresh(event.getInventory());
               }
             });
   }
 }
示例#29
0
 @SuppressWarnings("deprecation")
 @EventHandler(priority = EventPriority.LOWEST)
 public void onFurnaceInsert(InventoryClickEvent e) {
   if (e.getInventory().getType() == InventoryType.FURNACE
       && e.getCursor() != null
       && (e.getRawSlot() == 0 || e.getSlot() == 1)) {
     if (!e.isShiftClick()) {
       ItemStack item = e.getCurrentItem();
       e.setCurrentItem(e.getCursor());
       e.setCursor(item);
       e.setCancelled(true);
       PlayerInventory.update((Player) e.getWhoClicked());
     }
   }
 }
示例#30
0
 @EventHandler
 public void onInventoryClick(InventoryClickEvent event) {
   Inventory inventory = event.getInventory();
   if (inventory.getName().equals(i.getName())) {
     event.setCancelled(true);
     Player player = (Player) event.getWhoClicked();
     ItemStack stack = event.getCurrentItem();
     if (stack == null || !stack.hasItemMeta()) return;
     if (stack.getItemMeta().getDisplayName().equals("Une pomme g閚iale !")) {
       player.closeInventory();
       player.sendMessage(
           "Bravo, tu viens de cliquer sur " + stack.getItemMeta().getDisplayName() + " !");
       player.addPotionEffect(PotionEffectType.FIRE_RESISTANCE.createEffect(Integer.MAX_VALUE, 2));
     }
   }
 }