Making A Player Specific Inventory?

Discussion in 'Plugin Development' started by TheCakeMaster, Oct 11, 2014.

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

    TheCakeMaster

    So I want to make an inventory act kind of like a enderchest, meaning the player can change the inventory, but for other players it will stay the same, or what they have changed it to. I want to use this to make an unlockable gadget menu, but I just don't know how to do this. I created my inventory's like this:
    Code:java
    1.  
    2. public static Inventory test = Bukkit.createInventory(null, 27, "testMenu");
    3.  

    And assigned items to it with this:
    Code:java
    1.  
    2. createDisplay(Material.PAPER, test, 0, "This is a name","This is a lore", (short) 0);
    3.  

    with this method:
    Code:java
    1.  
    2. public static void createDisplay(Material mat, Inventory inv, int Slot, String name, String lore, short durability) {
    3. ItemStack item = new ItemStack(mat);
    4. ItemMeta meta = item.getItemMeta();
    5. meta.setDisplayName(name);
    6. meta.setLore(Arrays.asList(lore));
    7. item.setItemMeta(meta);
    8. item.setDurability(durability);
    9. inv.setItem(Slot, item);
    10. }
    11.  

    Any help would be much appreciated!
     
  2. Offline

    pookeythekid

  3. Offline

    TheCakeMaster

    I just want to know how to make the inventory player specific, like an enderchest.
     
  4. Offline

    Code0

    TheCakeMaster Well, if you'd want to save the items, a configuration file is what you're looking for. Each time they either type the command or click an item to open the enderchest-like inventory, you need to load the items from the config file.
     
  5. Offline

    pookeythekid

    What Code0 said. Never tried this before, but perhaps you could try setting "inv.toString()" into the config file, see what that gives you. Then you can play around from there.
     
    Code0 likes this.
  6. Offline

    Code0

    Yea, like the concept of that idea. As long as no one fools around with the file, Bukkit's Inventory Class shouldn't have any problem reading the text and re-creating an inventory.
     
  7. Offline

    TheCakeMaster

    Code0 likes this.
  8. Offline

    Code0

    No problem. And remember, if it's solved, mark it as that by selecting the appropriate prefix in the title edit menu.
     
Thread Status:
Not open for further replies.

Share This Page