1.17.x how to permanently store a variable to a player

Discussion in 'Spigot Plugin Development' started by mason-walker, Jun 25, 2021.

  1. I want to be able to permanently store a variable to a player, and use it later, but I also want to be able to change it. I also want this variable to be set to 0 whenever a new player joins, but not whenever they join, how can I do this?
     
  2. What have you tried?
     
  3. nothing, I am new to this
     
  4. my guy... you can't "permanently" store a variable, variable is a thing that's stored in the RAM, where nothing is permant, you might wanna use YAML files or databases, but variable ain't possible.
     
  5. ok, how can I store it in a Database for any player?
     
    • Agree Agree x 4
    • Winner Winner x 1
    • Informative Informative x 1
  6. Its really frustrating when people suggest databases or yaml files all the time when the PersistentDataContainer is a perfect solution for this
     
  7. What is that?
     
  8. There are many usecases where yaml or dbs are required over PDCs. They are not an end-all be-all solution.
     
  9. That's why I said "for this" and not "all the time". This thread is about storing a variable for the Player object, and the PDC is the perfect interface for this.