Furnace Inventory cast Error

Discussion in 'Plugin Development' started by Pik0, Oct 24, 2014.

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

    Pik0

    Hello guys. I have a little strange problem. Here is my code:
    Code:java
    1. if(event.getInventory() instanceof FurnaceInventory) {
    2.  
    3.  
    4. FurnaceInventory inv = (FurnaceInventory) event.getInventory();
    5.  


    inv is null i dont know why D:
     
  2. Offline

    mine-care

    What event is this called in? Can we see the error? Can we see some more code plz? Ty
     
  3. Offline

    lucaazalim

    mine-care He has already said, when cast Inventory to FurnaceInventory, returns null, I'm having the same problem.
     
  4. Offline

    WesJD

    mine-care likes this.
  5. Offline

    Pik0

    WesJD
    Code:
    Caused by: java.lang.NullPointerException
        at me.hungergames.kits.Metalurgico.execute(Metalurgico.java:150) ~[?:?]
    Line 150:
    Code:java
    1. Bukkit.broadcastMessage("" + event.getCurrentItem().getType().name() + " " + inv.getSmelting().getType().name());

    The error is the inv being null, i have dubugged before with:
    Code:java
    1. Bukkit.broadcastMessage("" + (inv = null));

    which returned me "true"...
     
  6. Offline

    fireblast709

    Pik0 you assign inv to null and print it (might be a typo). Anyway, your actual null is either event.getCurrentItem() or inv.getSmelting().
     
  7. Offline

    Pik0

    fireblast709 i know that inv.getSmelting() will return null, because inv is null as i checked before. The question is, why is the inv null when i check if it is an instance and it returns true, and when i cast it it returns null..
     
  8. Offline

    fireblast709

    Pik0 post the full code
     
Thread Status:
Not open for further replies.

Share This Page