Why is DoubleChest a class, not an interface?

Discussion in 'Plugin Development' started by imjake9, Mar 29, 2012.

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

    imjake9

    I guess this is a little nitpicky, but I'm a bit baffled as to why DoubleChest is a class, not an interface, while all the other InventoryHolder objects are interfaces. I've considered submitting a pull request, but I was wondering if there was some kind of reasoning behind it. Does anyone know?
     
  2. Offline

    dillyg10

    Because it implements the chest interface?
     
  3. Offline

    imjake9

    That's the thing, it doesn't. The two are completely incompatible, making it rather difficult to deal with Double Chests. It's a completely separate InventoryHolder.
     
  4. Offline

    Darkman2412

    Code:
    Chest chest = (random chest);
    if(chest.getInventory() instanceof DoubleChestInventory) {
        DoubleChestInventory inv = (DoubleChestInventory)chest.getInventory();
        DoubleChest dchest = inv.getHolder();
    }
    Something like this maybe? Didn't test it :/
     
  5. Offline

    imjake9

    Yeah, that's what you end up having to do right now. Still, it seems awfully silly that you can't cast a DoubleChest to a Chest. I'm planning on submitting a pull request for this if no one objects.

    I have gone through with my plan to modify DoubleChest and submit a pull request. You can find the two pull requests here:
    Bukkit: https://github.com/Bukkit/Bukkit/pull/578
    CraftBukkit: https://github.com/Bukkit/CraftBukkit/pull/743

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

    Michael Briggs

    Jake,

    It's approved at my level :p Though you're right, it would make more sense that way. At least I think so.
     
Thread Status:
Not open for further replies.

Share This Page