[SOLVED] Inventories - per player

Discussion in 'Spigot Plugin Development' started by AdrianPMC, Jun 21, 2015.

  1. hi,

    I have spent over 2 hours searching for this answer on Google and I haven't found anything so if you tell me to search it up, trust me I already have... So I don't have any code to show I'm just trying to figure out how to make an inventory per player for example, someone makes a let's say leather from rabbit hide, and I make them have a custom texture pack that makes the leather look like a backpack, I want that piece of leather to have its own inventory so not based on the players UUID or anything like that I want it to be its own inventory that can be passed to other players in game but the inventory stays the same... I'm not sure if that makes complete sense but I'm trying my best, and this means that the player can make as many backpacks as they want because they will all have a different inventory, basically to sum it up I'm trying to make an inventory per the specific item so an inventory that is unique to only that item :) any help would be appreciated
  2. sothatsit


    I think your best bet would be to attach an id in the items lore or name which you can use to identify it by. If you really need, you can also make this so the player can't see the id by converting it to chat colours and appending the chat colours to a line in the lore or name.

    - "&7Right click to open the backpack! &1&2&3&4&5&6&7"
    (ID is the mass of chat colours)

    You can then use this to identify the backpack. Just convert the number to hexadecimal and then put an & in front of each character. Then to retrieve it again use subString(First character index) and get rid of all & symbols. Then just convert it back to decimal.
  3. I get everything you have said apart from where the hell I get an ID that is unique to that item only
  4. sothatsit


    Just create a counter.
    Code (Text):
    private counter = 0;

    public int getNewId() {
        return counter++;
    Then just use getNextId to get an id when a backpack is made. You would also have to store this counter in the config and reload it on startup.
    • Like Like x 1
  5. Thank you so much