Class QuitPlayerMemory

java.lang.Object
de.marcely.bedwars.api.arena.QuitPlayerMemory
All Implemented Interfaces:
Metadatable

public class QuitPlayerMemory extends Object implements Metadatable
Gets constructed whenever a player leaves a running match.

Used to keep track of all prior players who already have left. Also used to store data for a player's rejoin capability.

  • Constructor Details

    • QuitPlayerMemory

      public QuitPlayerMemory(OfflinePlayer player, Team team, boolean rejoinPermitted, Instant lastJoinTime, Instant quitTime, Duration playTime, boolean bypassTraps, Inventory playerPrivateInventory, @Nullable @Nullable BukkitTask soloRejoinTask, int shopResourcesSpentAmount)
      Constructs a QuitPlayerMemory instance.

      The constructor may change without prior notice in future versions.

      Parameters:
      player - The player who quit
      team - The team the player belongs to
      rejoinPermitted - true whether the player is allowed to rejoin
      lastJoinTime - The time the player last joined
      quitTime - The time the player quit
      playTime - The total play time of the player
      bypassTraps - whether the player can bypass traps
      playerPrivateInventory - The private inventory of the player
      soloRejoinTask - The task that will eliminate the players team if he leaves the team empty. null if there were other players on the team still
      shopResourcesSpentAmount - The amount of resources the player has spent in the shop
    • QuitPlayerMemory

      public QuitPlayerMemory(UUID uuid, String username, Team team, boolean rejoinPermitted, Instant lastJoinTime, Instant quitTime, Duration playTime, boolean bypassTraps, Inventory playerPrivateInventory, @Nullable @Nullable BukkitTask soloRejoinTask, int shopResourcesSpentAmount)
      Constructs a QuitPlayerMemory instance.

      The constructor may change without prior notice in future versions.

      Parameters:
      uuid - The uuid of the player who quit
      username - The name of the player who quit
      team - The team the player belongs to
      rejoinPermitted - true whether the player is allowed to rejoin
      lastJoinTime - The time the player last joined
      quitTime - The time the player quit
      playTime - The total play time of the player
      bypassTraps - whether the player can bypass traps
      playerPrivateInventory - The private inventory of the player
      soloRejoinTask - The task that will eliminate the players team if he leaves the team empty. null if there were other players on the team still
      shopResourcesSpentAmount - The amount of resources the player has spent in the shop
  • Method Details

    • getUniqueId

      public UUID getUniqueId()
      Returns the uuid (OfflinePlayer.getUniqueId()) of the player.
      Returns:
      The uniqueId of the player
    • getUsername

      public String getUsername()
      Returns the name (OfflinePlayer.getName()) of the player.
      Returns:
      The username of the player
    • getTeam

      public Team getTeam()
      Returns the team to which he belongs to.
      Returns:
      The team of the player
    • setTeam

      public void setTeam(Team team)
      Set the team to which the player belongs to.
      Parameters:
      team - The new team of the player
    • isRejoinPermitted

      public boolean isRejoinPermitted()
      Returns if the player is able to rejoin the match.

      A player may not be permitted if e.g. his team's elimination was the cause for him to quit.

      Returns:
      if the player can rejoin
    • setRejoinPermitted

      public void setRejoinPermitted(boolean rejoinPermitted)
      Set if the player is able to rejoin the match.

      A player may not be permitted if e.g. his team's elimination was the cause for him to quit.

      Parameters:
      rejoinPermitted - if the player can rejoin
    • getBypassTraps

      public boolean getBypassTraps()
      Set if the player is able to bypass traps.
      Returns:
      if the player can bypass traps
    • setBypassTraps

      public void setBypassTraps(boolean bypassTraps)
      Set if the player is able to bypass traps.
      Parameters:
      bypassTraps - if the player can bypass traps
    • getLastJoinTime

      public Instant getLastJoinTime()
      Returns the time when the player has the last (re)joined the match.
      Returns:
      The previous time the player joined the arena
    • setLastJoinTime

      public void setLastJoinTime(Instant time)
      Set the time when the player has the last time (re)joined the match
      Parameters:
      time - The new previous time the player joined the arena
    • getQuitTime

      public Instant getQuitTime()
      Returns the time when the player has quit the arena.
      Returns:
      The time the player decided to leave the match
    • setQuitTime

      public void setQuitTime(Instant time)
      Set the time when the player has the last time quit the arena.
      Parameters:
      time - The new time the player decided to leave the match
    • getPlayTime

      public Duration getPlayTime()
      Returns the duration that the player has been within the match.

      The returned value may not match getQuitTime() minus getLastJoinTime() as the player may rejoined multiple times.

      Returns:
      The play time of the player
    • setPlayTime

      public void setPlayTime(Duration playTime)
      Set the total play time the player has been within the match.
      Parameters:
      playTime - The new play time
    • getKillHistory

      public List<PlayerKillPlayerRecord> getKillHistory()
      Returns a list containing all the corresponding player kill records of the player.

      It is safe to modify the entries of the List.

      Contains all the kills the player has made so far in the current match.

      Returns:
      A list storing the kill records of the player
    • getBuyGroupLevels

      public Map<BuyGroup,Integer> getBuyGroupLevels()
      Returns a map containing all the corresponding buy-group levels of the player. Not all existing buy-groups may be present.

      It is safe to modify the entries of the Map.

      Returns:
      A map storing the buy-groups of the player
    • getPlayerPrivateInventory

      public Inventory getPlayerPrivateInventory()
      Returns the players private inventory, used for ender chests in some configurations.

      It is safe to modify the contents of the Inventory.

      Returns:
      The private inventory belong to the player
    • getOneTimePurchaseBoughtItems

      public Set<ShopItem> getOneTimePurchaseBoughtItems()
      Returns all ShopItems the player has bought which have ShopItem.isOneTimePurchase() set to true.

      It is safe to modify the entries of the Set.

      Returns:
      All one-time-purchase items that have been bought
    • getSoloRejoinTask

      @Nullable public @Nullable BukkitTask getSoloRejoinTask()
      Returns the task used to eliminate a team if no players rejoin in the configured time.

      If you dont want this team to be eliminated if the player does not rejoin, simply cancel this task.

      Returns:
      The task that will eliminate the players team if he leaves the team empty. null if there were other players on the team still
    • setSoloRejoinTask

      public void setSoloRejoinTask(@Nullable @Nullable BukkitTask task)
      Set the task used to eliminate a team if no players rejoin in the configured time.

      Note: This doesn't cancel the current task if it exists. Make sure to cancel it before setting a new one.

      Parameters:
      task - The task that will eliminate the players team if he leaves the team empty. null if there were other players on the team still
    • getGameStats

      public Map<String,Number> getGameStats()
      Returns the internal map that represents the game stats of the player.

      Note that they won't be added to the actual stats thereafter. They only exist for representiation purposes.

      Returns:
      The game stats of the player
      See Also:
    • getShopResourcesSpentAmount

      public int getShopResourcesSpentAmount()
      Returns the amount of resources the player has spent in the shop.

      This number is used for the DefaultPlayerAchievement.SPEND_200_RESOURCES achievement.

      Returns:
      The amount of resources the player has spent
    • setShopResourcesSpentAmount

      public void setShopResourcesSpentAmount(int amount)
      Set the amount of resources the player has spent in the shop.

      This number is used for the DefaultPlayerAchievement.SPEND_200_RESOURCES achievement.

      Parameters:
      amount - The new amount of resources the player has spent
    • getMetadata

      public List<MetadataValue> getMetadata(String key)
      Specified by:
      getMetadata in interface Metadatable
    • hasMetadata

      public boolean hasMetadata(String key)
      Specified by:
      hasMetadata in interface Metadatable
    • removeMetadata

      public void removeMetadata(String key, Plugin plugin)
      Specified by:
      removeMetadata in interface Metadatable
    • setMetadata

      public void setMetadata(String key, MetadataValue value)
      Specified by:
      setMetadata in interface Metadatable
    • constructMidgame

      public static QuitPlayerMemory constructMidgame(Player player, Team team)
      Constructs a fresh, empty QuitPlayerMemory instance for a player.

      This may be e.g. used to make a player (who hasn't played prior in the match) join an already running match.

      Parameters:
      player - The player to construct the memory for
      team - The team the player belongs to
      Returns:
      The constructed memory