Change name of an Inventory?

Discussion in 'Plugin Development' started by soshimee, Jan 15, 2021.

  1. Offline

    soshimee

    I can't find an answer, they all talk about changing name of an open Inventory, but I just want to change it while it's closed, to just refresh the name that is stored as data in a YAML file.
     
  2. Offline

    ForbiddenSoul

    As far as I know you can only set the inventory's name when it is created. If it is vanilla created you are stuck with the vanilla name, if you are creating the inventory you can always specify the name in Bukkit.getServer().createInventory();

    I tried this, but it does not seem to actually overwrite anything:
    Code:Java
    1. ItemStack[] originalContents = oldInventory.getContents();
    2. Inventory inventory = Bukkit.createInventory(oldInventory.getHolder(), oldInventory.getType(), "Custom Name");
    3. inventory.setContents(originalContents);


    If you just need to be able to identify it in your config.yml you should just be able to specify the key you store it under to be the custom name you want...
     

Share This Page