Solved Renaming an existing inventory

Discussion in 'Plugin Help/Development/Requests' started by BizarrePlatinum, Jun 7, 2015.

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


    I am creating an inventory with .createInventory(), and want to change the inventories name based on the custom name being stored in a hashmap when a command is executed. Is this possible? There doesn't seem to be a method to do this, so if it's possible, how would I do it?
  2. Offline


  3. Offline


    @BizarrePlatinum Server#createInventory(InventoryHolder, int, String) Just create a new inventory, then set the contents to be the same as the old inventory (via getContents() and setContents()).
  4. Offline


    @pie_flavor my problem is that I need to be able to access the inventory from other methods.
  5. Offline

    I Al Istannen

    @BizarrePlatinum How do you pass it on? Is it a static one? Do you have a getter?
    I don't know of a method to change the name either, so - except sb knows a method - replacing would be your only choice.
  6. Offline


    Just curious, do you know basic Java? If not I advise you write a few CLI programs before diving into plugin development, that's the best way to go.

    I don't exactly understand your question, but I believe you can solve the problem by placing both the HashMap and inventory in a class instead (with private set as the visibility) of putting them in a method. This will allow you to use them in many methods.

    Let me know of anything else you need.
  7. Offline


    @wxwsk8er of course I don't know basic java...

    I've tried creating a new inventory when the event I am using fires
    doublePreview = Bukkit.getServer().createInventory(null, 54, ChestPreview.customName.get(c.getLocation()));
    , which will work for the naming part, but it appears that this:
    if(inv == singlePreview || inv == doublePreview) {
    will no longer cancel (InventoryClickEvent).
  8. Offline

    I Al Istannen

    @BizarrePlatinum Maybe use "equals" instead. "==" compares the object in the memory. I have no clue what the variables represent though. Some code would be nice.
  9. Offline


Thread Status:
Not open for further replies.

Share This Page