I may just be being really dumb.. or something.

Discussion in 'Plugin Development' started by madyoda, Mar 4, 2014.

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

    madyoda

    Hi

    I currently have this piece of code;
    Code:java
    1. public static Inventory parkour = Bukkit.createInventory(null, 9, ChatColor.DARK_RED +""+ ChatColor.BOLD + "YodaGames BETA | PvP Kit!");
    2. static {
    3. //Inventory stuff here
    4. }


    The "null" part of createInventory is the player, and it appears the[parkour] inventory is shared between players. How would I go about making this inventory 1 per player?

    Sorry if it's something simple, knowing my knowledge I should know this but I guess I can't figure it out :p

    Tom
     
  2. Offline

    Garris0n

    Create one for each player instead of just using one...also why is all of that static?
     
  3. Offline

    Alshain01

    Well, your storing it in a single variable. You need a collection, like a HashMap and you will have to loop through and create one for all players and store it in that hashmap using the player UUID as a key.
     
  4. Offline

    Garris0n

    The player name would work fine as a key.
     
  5. Offline

    madyoda



    Thank you. I have no idea why it's all static.
     
  6. Offline

    Alshain01

    Unless he wants to serialize it and write it to a file.
     
  7. Offline

    Garris0n

    I was assuming based on what he posted that he had no plans to do that.
     
Thread Status:
Not open for further replies.

Share This Page