Solved How to use two chest imports together

Discussion in 'Plugin Development' started by PDKnight, Jul 10, 2015.

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

    PDKnight

    Hi there, I'm working on another plugin, but I'm in trouble now. I must import chest as "org.bukkit.block.Chest" (because I want to get its inventory) and then as "org.bukkit.material.Chest" (because I'm setting its data) :( My code:
    Code:java
    1. ((Chest) chest_loc.getBlock().getState()).getInventory().setItem(0, book);
    2. //...
    3. new Location(p.getWorld(), x, y, z)
    4. .getBlock().getState().setData(new Chest(BlockFace.NORTH));

    So how to do it? Please, help me how to fix it :(
     
  2. Offline

    _Error

    What are you exactly trying to do?
     
  3. Offline

    benjfb1

    Set the chest to the material's location after you have set the metadata
     
  4. Offline

    justin_393

    From my understanding he's trying to use Chest as a Material and Block.
    @PDKnight
    Try this.
    When you want to use it as a block, call it with the package, not class I.e
    When you need the block do
    org.bukkit.block.Chest

    I would give better examples, but I'm on my phone, it's hard to code :/
     
  5. Offline

    PDKnight

    @_Error
    @benjfb1 Sorry, but I don't understand :( Can you please show me some code?
    @justin_393 Okay, I'll try it.

    @justin_393 Awesome, it works! Thank you! :D

    Final code:
    Code:java
    1. ((org.bukkit.block.Chest) chest_loc.getBlock().getState()).getInventory().setItem(0, book);
    2. //...
    3. new Location(p.getWorld(), x, y, z)
    4. .getBlock().getState().setData(new Chest(BlockFace.NORTH));


    SOLVED

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

Share This Page