check if the item is null / air from InventoryClickEvent

Discussion in 'Spigot Plugin Development' started by Artist, Jun 6, 2018.

  1. Hello! I need to know how to check if the item is null or air from inventoryClickEvent?

    Best regards,
    Pandu :coffee:
     
    • Like Like x 1
  2. Well, get the item and check if it is null or air? What's your problem?


    Sent from my iPhone using Tapatalk
     
  3. Can you send some example code? Please? Would really appreciate that!

    Best regards,
    Pandu
     
    • Like Like x 1
  4. Look at the Java docs, show code that you've tried, if you understand Java this is easy.


    Sent from my iPhone using Tapatalk
     
    • Agree Agree x 1
  5. Code (Java):

    // eventhandler
    /* public etc.*/ (InventoryClickEvent event) {
    if (event.getcurrentitem == null) {
    // your item is null
    // maby return;
    }
    if (event.getcurrentitem.gettype == material.air) {
    // your item is air.
    }

    }
     
     
    • Agree Agree x 2