Solved Private player variables

Discussion in 'Plugin Development' started by thepicdeath100, Jan 3, 2018.

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


    I'm fairly new to plugin coding and how it works, I was wondering how to make player specific variables. For an example: if you want to track how much blocks that one player broke.
  2. Offline


    Here is the easiest way to do this:
    1. Create a Hashmap. The keys will be UUIDs, and the value will be an Integer. This represents how may blocks (the integer) a player (the uuid) has broken.
    2. On BlockBreakEvent
    3. If a block is broken, create an integer. Set this to 0.
    4. Check to see if the player's UUID is in the map. If so, set the integer above to the number from the map.
    5. Then, add the (integer+1) to the map. Doing this will increase the number by 1, signifying that a block has been broken.
    6. When you want to check how many blocks a player has broken, get the integer from the hashmap.
    BTW: Are you new to Java programming, or do you have some background in writing programs, but are new to just Bukkit? If the former, or if you do not understand any of the steps above, I recommend you spend some time learning Java before working on bukkit. Tutorials can be found here, if you do not have any currently:
  3. Offline


    Thank you, and yes im new to the java code as well.
  4. @thepicdeath100 Please mark this code as SOLVED if you feel that no more help is needed. If you don't know how to use HashMap-s, feel free to ask!
  5. Offline


    @Xydez Lol my bad, but yes can I get help with HashMap(s)?
  6. Offline


  7. Offline


Thread Status:
Not open for further replies.

Share This Page