Class PlayerData

java.lang.Object
me.fami6xx.rpuniverse.core.misc.PlayerData

public class PlayerData extends Object
This class is used to store player data. You can extend and add fields to this class, but be aware that the added fields might not be saved depending on the selected Data Handler.

It is serialized and deserialized by the selected Data Handler.

To ignore a field from being serialized, use the transient keyword.

  • Constructor Details

    • PlayerData

      public PlayerData(org.bukkit.entity.Player bindedPlayer)
    • PlayerData

      public PlayerData(org.bukkit.OfflinePlayer bindedOfflinePlayer)
    • PlayerData

      public PlayerData(String playerUUID)
  • Method Details

    • addJob

      public void addJob(Job job)
      Adds a job to the player's list of jobs.

      This method does not check if the player is at maximum amount of jobs.

      Parameters:
      job - The job to be added.
    • removeJob

      public void removeJob(Job job)
      Removes a job from the player's list of jobs.
      Parameters:
      job - The job to be removed.
    • setSelectedPlayerJob

      public void setSelectedPlayerJob(Job job)
      Sets the selected player job.
      Parameters:
      job - The job to be set as the selected player job.
    • getSelectedPlayerJob

      public Job getSelectedPlayerJob()
      Retrieves the selected player job.
      Returns:
      the selected player job
    • getPlayerJobs

      public List<Job> getPlayerJobs()
      Retrieves the list of jobs for the player data.

      This method returns a new ArrayList to prevent the original list from being modified.

      Returns:
      the list of jobs for the player data
    • setPlayerMode

      public void setPlayerMode(PlayerMode playerMode)
      Sets the player mode.
      Parameters:
      playerMode - The player mode to be set.
    • increaseTimeOnline

      public void increaseTimeOnline()
      Increase time online by 1 second
    • getTimeOnline

      public int getTimeOnline()
      Retrieves the time online for the player data in seconds.
      Returns:
      the time online of the player data
    • getPlayerMode

      public PlayerMode getPlayerMode()
      Retrieves the player mode for the player data.
      Returns:
      the player mode of the player data
    • getTag

      public String getTag()
      Retrieves the tag for the player data.
      Returns:
      the tag of the player data
    • setTag

      public void setTag(String tag)
      Sets the tag for the player data.
      Parameters:
      tag - The tag to be set.
    • isTagVisible

      public boolean isTagVisible()
      Retrieves the visibility of the tag for the player data.
      Returns:
      the visibility of the tag of the player data
    • getCurrentTagHologram

      @Nullable public famiHologram getCurrentTagHologram()
      Retrieves the hologram for the tag of the player data.
      Returns:
      the hologram of the tag of the player data
    • setCurrentTagHologram

      public void setCurrentTagHologram(famiHologram currentTagHologram)
      Sets the hologram for the tag of the player data.
      Parameters:
      currentTagHologram - The hologram to be set.
    • prepareForSave

      public void prepareForSave()
      Prepares the player data for saving.

      If the bindedPlayer field is not null, it retrieves the name of the player and assigns it to playerName.

      If the bindedOfflinePlayer field is not null, it retrieves the name of the offline player and assigns it to playerName.

      It retrieves the UUID of the player data as a String and assigns it to playerUUID.

      If the selectedPlayerJob field is not null, it retrieves the name of the job and assigns it to selectedJobName.

      Initializes playerJobNames as an empty ArrayList.

      For each job in playerJobs, it retrieves the name of the job and adds it to playerJobNames.

    • loadAfterSave

      public void loadAfterSave()
      Loads the player data after it has been saved.

      If the bindedPlayer field is not null, it retrieves the player object using the playerUUID and assigns it to bindedPlayer.

      If the bindedOfflinePlayer field is not null, it retrieves the offline player object using the playerUUID and assigns it to bindedOfflinePlayer.

      If the selectedJobName field is not null, it retrieves the job object using the selectedJobName and assigns it to selectedPlayerJob.

      Initializes playerJobs as an empty ArrayList.

      For each jobName in playerJobNames, it retrieves the job object using the jobName and adds it to playerJobs.

    • getDataUUID

      public UUID getDataUUID()
      Retrieves the UUID of the player data.
      Returns:
      the UUID of the player data
    • getPlayerUUID

      public UUID getPlayerUUID()
      Retrieves the UUID of the player data.
      Returns:
      the UUID of the player data
    • shouldDisplayJob

      public boolean shouldDisplayJob(Job job)
      Determines whether a job should be displayed to a player in a boss menu.
      Parameters:
      job - The job to check for display.
      Returns:
      True if the job should be displayed, false otherwise.
    • shouldDisplayWorkingStep

      public boolean shouldDisplayWorkingStep(Job job, int neededPermissionLevel)
      Determines whether a working step should be displayed to a player.
      Parameters:
      job - The job to check for display.
      neededPermissionLevel - The minimum permission level needed to display the working step.
      Returns:
      true if the working step should be displayed, false otherwise.
    • hasPermissionForEditingJobs

      public boolean hasPermissionForEditingJobs()
      Checks if the player has permission to edit jobs.
      Returns:
      true if the player has permission to edit jobs, false otherwise.
    • hasPermissionForCreatingJobs

      public boolean hasPermissionForCreatingJobs()
      Checks if the player has permission to create jobs.
      Returns:
      true if the player has permission to create jobs, false otherwise.
    • canBeAddedToJob

      public boolean canBeAddedToJob()
      Determines whether the player can be added to a job.
      Returns:
      true if the player can be added to a job, false otherwise.
    • canBeAddedToJob

      public boolean canBeAddedToJob(Job job)
      Determines whether the player can be added to the given job.
      Parameters:
      job - The job to check for add-ability.
      Returns:
      True if the player can be added to the job, false otherwise.
    • updatePlayer

      public void updatePlayer(org.bukkit.entity.Player player)
      Updates the player bound to this PlayerData instance.
      Parameters:
      player - The player to be updated.
    • updatePlayer

      public void updatePlayer(org.bukkit.OfflinePlayer player)
      Updates the player bound to this PlayerData instance.
      Parameters:
      player - The player to be updated.
    • getBindedPlayer

      @Nullable public org.bukkit.entity.Player getBindedPlayer()
      Retrieves the player object that is currently bound to this PlayerData instance.
      Returns:
      the player object that is currently bound, or null if no player is bound.
    • getBindedOfflinePlayer

      @Nullable public org.bukkit.OfflinePlayer getBindedOfflinePlayer()
      Returns the OfflinePlayer object that is currently bound to this PlayerData instance.
      Returns:
      the OfflinePlayer object that is currently bound, or null if no OfflinePlayer is bound.
    • getFoodLevel

      public int getFoodLevel()
      Gets the player's food level
      Returns:
      the player's food level (Higher is better)
    • setFoodLevel

      public void setFoodLevel(int foodLevel)
      Sets the player's food level
      Parameters:
      foodLevel - the player's food level (Higher is better)
    • getWaterLevel

      public int getWaterLevel()
      Gets the player's water level
      Returns:
      the player's water level (Higher is better)
    • setWaterLevel

      public void setWaterLevel(int waterLevel)
      Sets the player's water level
      Parameters:
      waterLevel - the player's water level (Higher is better)
    • getPoopLevel

      public int getPoopLevel()
      Gets the player's poop level
      Returns:
      the player's poop level (Lower is better)
    • setPoopLevel

      public void setPoopLevel(int poopLevel)
      Sets the player's poop level
      Parameters:
      poopLevel - the player's poop level (Lower is better)
    • getPeeLevel

      public int getPeeLevel()
      Gets the player's pee level
      Returns:
      the player's pee level (Lower is better)
    • setPeeLevel

      public void setPeeLevel(int peeLevel)
      Sets the player's pee level
      Parameters:
      peeLevel - the player's pee level (Lower is better)
    • canOpenLock

      public boolean canOpenLock(Lock lock)
      Determines if the player can open a specified lock.
      Parameters:
      lock - The lock to check against.
      Returns:
      true if the player can open the lock, false otherwise.