Clicking item item in custom inventory

Discussion in 'Plugin Development' started by Jam40e123, Apr 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Jam40e123

    Hello,
    I am trying to develop a plugin. This is what I am trying to do:
    When they click a feather named speed 2 in a custom inventory it will set something in their Player YML and close the custom inventory.
    Although. When they click it in a custom inventory it lets them remove the item from the bar and when they go their actual inventory and click the feather the whole thing works fine. It closes and sets something in their Player YML.

    Here is the code: http://pastebin.com/miU0gb5K

    Cheers,

    Jam40e
     
  2. Offline

    valon750

    Jam40e123

    Basically you need to cancel the event :)
     
  3. Offline

    Gecco1234

    Why does he need to cancel the click event?
     
  4. Offline

    valon750

    Gecco1234

    It essentially undoes the action, so that the item will return to the bar, leaving the cursor empty.
     
  5. Offline

    Gecco1234

    He wants it to close the bar when they click it though.
     
  6. Offline

    valon750

    Gecco1234

    You're able to cancel an event and close the inventory, it's not as if they cancel each other out.
     
  7. Offline

    Onlineids

    Code:java
    1. @EventHandler
    2. public void onClick(InventoryClickEvent e){
    3. if(e.getInventory().getName().equals("Your inv name")){
    4. if(e.getCurrentItem().equals("Your item")){
    5. e.setCancelled(true);
    6. e.getWhoClicked().closeInventory();
    7. }
    8. }
    9. }
     
  8. Offline

    Gecco1234

    event.getCurrentItem().getItemMeta().getDisplayName().equals("Your Item")){
    Thats for display name

    Oh ok that works but anyone can still drag stuff out from the bar. And will only work if you click in actual inventory, it does not fix that problem.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page