A player specific variable that can only have only one instance

Discussion in 'Spigot Plugin Development' started by Peraction, Aug 19, 2017.

  1. I'm trying to create an "active skills" variable for a player, which I think I know how to do with a HashMap containing the UUID and a set.

    It would be instantiated when the player sets their skills in a GUI, and only deleted if the player deletes their skills in the GUI. What strategies should I implement to make sure that the player cannot have two active skill lists? I could definitely check for an already existing skill list when deleting and setting the GUI, but I am wondering if there is a more robust solution, like perhaps an automatic deletion of existing instances whenever this variable is created for a player.
  2. Code (Java):
    if(hashMap.containsKey(player.getUniqueId()) { // player has already a skill if so
      // then add the new skill
    please be more practical show us your code.
  3. Try using Metadata
    Code (Text):
    yourPlayer.setMetadata("nameOfMetadata", new FixedMetadataValue(yourPlugin, skills));