Change Inventory Type or Title

Discussion in 'Plugin Development' started by Goblom, Dec 25, 2013.

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

    Goblom

    I want to create a Dispenser Menu but i am unable to change the title of the menu since
    Code:java
    1. Bukkit.createInventory(player, InventoryType.DISPENSER);
    doesn't allow me to set the Title.... and
    Code:java
    1. Bukkit.createInventory(player, 9, title);
    doesn't allow me to set the type...

    Code:java
    1. /**
    2.  * This also doesnt work (but i really wish it did)
    3.  */
    4. Inventory inv = Bukkit.createInventory(player, InventoryType.DISPENSER);
    5.  
    6. /**
    7.  * These methods do not exist
    8.  */
    9. inv.setTitle(title);
    10. inv.setType(InventoryType);
    11.  


    This can probably be done via Reflection (but i don't know how to use Reflection)
     
  2. Offline

    Garris0n

    The different inventory types are different classes, you can't just "change" them. The title can probably be changed somewhere but it's more trouble than it's worth and easier to create a new inventory.
     
  3. Offline

    WhatAaCow

    You can't. You can only create a new inventory
    Code:java
    1. Inventory newInventory = Bukkit.createInventory(owner, 9, "Inventory Name")); //owner can be "null" or a player
    2. newInventory.setContents(copyInventory.getContents(); //copyInventory is the inventory you want to change / copy
     
  4. Offline

    Goblom

    The title is private & final so it cannot be changed once created. The type is private. The type is not a separate class because Inventory.getType() will return an InventoryType not a separate class ;)
     
Thread Status:
Not open for further replies.

Share This Page