Solved Inventory Help!

Discussion in 'Plugin Development' started by MoeMix, Feb 9, 2014.

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

    MoeMix

    So I want to get the chest's inventory and add some items into it....however, the last line of code is spitting out errors! Can someone help out?
    Code:java
    1. if(kills.get(killer.getName()) == 3){
    2. Location chestlocation = new Location(killer.getWorld(), killer.getLocation().getX(), killer.getLocation().getY() + 2, killer.getLocation().getZ());
    3. chestlocation.getBlock().setType(Material.CHEST);
    4. Chest chest = (Chest) chestlocation.getBlock().getState();
    5. chest.getInventory().addItem(new ItemStack(Material.ANVIL));
     
  2. Offline

    adam753

    Can you post the error?
     
  3. Offline

    MoeMix

    adam753 http://pastebin.com/kLKZvyM8

    Can anyone figure this out? I've literally been struggling for hours..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    xTrollxDudex

    MoeMix
    The block isn't a chest
     
  5. Offline

    MoeMix

    xTrollxDudex
    The block has to be a chest i set it as a chest in line 3...
     
  6. Offline

    xTrollxDudex

    MoeMix
    Did you hotswap jars and the previous one didn't get the state before casting?
     
  7. Offline

    MoeMix

    xTrollxDudex
    Lol, I don't understand what you mean by hostwarp jars um could you explain a bit more?
     
  8. Offline

    xTrollxDudex

    MoeMix
    It means that the server was still running when you compiled it to the folder. At least make sure that thej ar is updated.
     
  9. Offline

    MoeMix

    xTrollxDudex
    yeah it is updated. I made sure I stopped the server, delete the old jar, and export the new one.
     
  10. Offline

    xTrollxDudex

    MoeMix
    Dang! I didn't read the stacktrace correctly. You have the wrong import, you need to cast to org.bukkit.block.Chest. NOT org.bukkit.material.Chest.
     
    MoeMix likes this.
  11. Offline

    MoeMix

Thread Status:
Not open for further replies.

Share This Page