Solved Changing Inventory Names

Discussion in 'Spigot Plugin Development' started by Hunky524, May 25, 2016.

  1. I just have a quick question and I'm not sure if it is possible. Is there a way to change the name of custom made inventories after they have been made? I'm not trying to change the name of the inventories for anvils or chests, just the names of custom inventories like GUIs after the inventory has been created with an initial name.
     
  2. MiniDigger

    Supporter

    don't think so since the name gets send to the client if you open the inventory. maybe you could try reopening it but that will most likly cause the mouse position to reset
     
  3. You could use a variable like
    Code (Text):
    Bukkit.createInventory(null, 27, name);
         
        public void setInentoryName(String name) {
            this.name = name;
        }
    no idea if that would work.
     
    • Optimistic Optimistic x 1
  4. MiniDigger

    Supporter

    lel, variables don't replicate over the network ^^
    you are not dealing with an advanced game engine here, you are dealing with minecraft ^^
     
    • Agree Agree x 1
  5. It is possible but you would have to reopen the inventory
     
  6. Strings are immutable anyway, it doesn't matter how advanced the engine behind it can be, that code will never be able to change the inventories name :p
     
  7. MiniDigger

    Supporter

    there is no advanced game engine in java anyways :p
     
    • Funny Funny x 1
  8. The only way I've really thought how to do it is by recreating the inventory and just duplicate all the contents over, but that's not exactly what I had in mind.

    It's not a big issue for me I was just wondering if it is possible.
     
  9. MiniDigger

    Supporter

    the client can't update the title of an open inventory, just another limitation the game has to offer. you don't even need to copy the content, just use reflection to change the title and open the inv again
     
  10. I've decided it's not worth the hassle for what I need to do. Thanks for all your help though :)

    For anyone wondering how do to this, you can either re-create the inventory and copy all the items or use reflection.
     
  11. Even advanced game engines do not randomly send stuff over a network when a local variable that is not checked anywhere changes.