How to Make a null ItemStack

Discussion in 'Plugin Development' started by Danelli, Dec 10, 2013.

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

    Danelli

    So I need to make the result null if a condition is true for the PrepareItemCraftEvent without it throwing an error. Does anyone know how I could do this?

    Let's just say if the player if the player is not an op they cannot craft tnt:

    Code:java
    1. @EventHandler
    2. public void Repairs(PrepareItemCraftEvent e){
    3. if (((Player)e.getViewers().get(0)).isOp)
    4. if (e.getInventory().getResult().getType()==(Material.TNT))
    5. e.setResult(new ItemStack(nothing)); //Fill in the blank please
    6. }
     
  2. Offline

    Warreo

    I believe you can just do something like this:
    Code:java
    1. e.setResult(null);
     
  3. Offline

    The_Doctor_123

    Material.AIR?
     
  4. Offline

    Danelli

    Doesn't work. It will throw a NullPointerException. Is there a way I could suppress the error?
     
Thread Status:
Not open for further replies.

Share This Page