Class TeamManager

java.lang.Object
com.booksaw.betterTeams.team.TeamManager
Direct Known Subclasses:
SQLStorageManager, YamlStorageManager

public abstract class TeamManager extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final HashMap<UUID,Team>
    A list of all teams
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Used to create a new teamManager
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    addChestClaim(Team team, org.bukkit.Location loc)
     
    createNewTeam(String name, org.bukkit.entity.Player owner)
    This method is used to create a new team with the specified name
    abstract TeamStorage
    Called when a new team is made
    abstract TeamStorage
    Called when a team needs a storage manager to manage all information, this is called for preexisting teams
    protected abstract void
    Used when a team is disbanded, can be used to remove it from any team trackers
    void
    this can be overritten if any code needs to be run when onDisable is called
    void
    Used to disband a team
    org.bukkit.Location
    getClaimingLocation(org.bukkit.block.Block block)
    Used to get the claiming location, will check both parts of a double chest, it is assumed that the provided block is known to be a chest
    getClaimingTeam(org.bukkit.block.Block block)
    Used to get the claiming team of a chest, will check both parts of a double chest, it is assumed that the provided block is known to be a chest
    getClaimingTeam(org.bukkit.Location location)
    Used to get the team which has claimed the provided chest, will return null if that location is not claimed
    abstract UUID
    getClaimingTeamUUID(org.bukkit.Location location)
    Used to get the UUID of the team which has claimed the provided chest, will return null if that location is not claimed
    abstract List<String>
     
    Used to get an clone of the loaded team list.
    @Nullable Team
    getTeam(@Nullable String name)
    Used to get the team by it's display name or a player within it
    @Nullable Team
    getTeam(@Nullable UUID uuid)
    Used to get the team with the provided ID
    @Nullable Team
    getTeam(@Nullable org.bukkit.OfflinePlayer player)
    Used to find the team that a specified player is in, this is the highest time complexity search to find a team (O(n^2)) so only use when the other provided methods are not possible
    @Nullable Team
    getTeamByName(@NotNull String name)
    Used to get the team by its team name
    abstract UUID
    Used to get the team uuid from the team name
    abstract UUID
    getTeamUUID(org.bukkit.OfflinePlayer player)
    Used to get the uuid of the team that the specified player is in
    abstract boolean
    isInTeam(org.bukkit.OfflinePlayer player)
    Used to check if the specified player is in a team
    boolean
    isLoaded(UUID teamUUID)
     
    boolean
    If chat is being logged to the console
    abstract boolean
    isTeam(@Nullable String name)
    Used to check if a team exists with that name
    abstract boolean
    isTeam(@Nullable UUID uuid)
    Used to check if a team exists with that uuid
    abstract void
    Used to load the stored values into the storage manager
    abstract void
    Called when a player joins a team, this can be used to track the players location
    abstract void
    Called when a player leaves a team
    abstract void
    Used to reset the balance of all teams
    boolean
    purgeTeams(boolean money, boolean score)
    Used to reset all teams scores to 0
    abstract void
    Used to reset the score of all teams
    abstract void
    Can be called by a config option if the server is having difficulties.
    protected abstract void
    registerNewTeam(Team team, org.bukkit.entity.Player player)
    Called when a new team is registered, this can be used to register it in any full team trackers The team file will be fully prepared with the members within the team
    abstract void
    removeChestclaim(org.bukkit.Location loc)
     
    abstract void
    Used to store and save the updated hologram details
    abstract String[]
    This method is used to sort all the team names into an array ranking from highest to lowest
    abstract String[]
    Used to sort all members from largest to smallest by number of members
    abstract String[]
    This method is used to sort all the teams into an array ranking from highest score to lowest
    abstract void
    teamNameChange(Team team, String newName)
    Called when a team changes its name as this will effect the getTeam(String teamName) method

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • loadedTeams

      protected final HashMap<UUID,Team> loadedTeams
      A list of all teams
  • Constructor Details

    • TeamManager

      protected TeamManager()
      Used to create a new teamManager
  • Method Details

    • getLoadedTeamListClone

      public Map<UUID,Team> getLoadedTeamListClone()
      Used to get an clone of the loaded team list. The team objects are not cloned, just the hashmap to avoid concurrent modification
      Returns:
      A clone of the team list
    • getTeam

      @Nullable @Contract(pure=true, value="null -> null") public @Nullable Team getTeam(@Nullable @Nullable UUID uuid)
      Used to get the team with the provided ID
      Parameters:
      uuid - the ID of the team
      Returns:
      the team with that ID [null - the team does not exist]
    • getTeam

      @Nullable @Contract(pure=true, value="null -> null") public @Nullable Team getTeam(@Nullable @Nullable String name)
      Used to get the team by it's display name or a player within it
      Parameters:
      name - the display name of the team or an online player within the team
      Returns:
      the team which matches the data[null - no team could be found]
    • getTeam

      @Nullable @Contract(pure=true, value="null -> null") public @Nullable Team getTeam(@Nullable @Nullable org.bukkit.OfflinePlayer player)
      Used to find the team that a specified player is in, this is the highest time complexity search to find a team (O(n^2)) so only use when the other provided methods are not possible
      Parameters:
      player - the player which is in a team
      Returns:
      the team they are in [null - they are not in a team]
    • getTeamByName

      @Nullable public @Nullable Team getTeamByName(@NotNull @NotNull String name)
      Used to get the team by its team name
      Parameters:
      name - The name of the team
      Returns:
      The team with that display name [null - no team with that name could be found]
    • createNewTeam

      public Team createNewTeam(String name, org.bukkit.entity.Player owner)
      This method is used to create a new team with the specified name

      Checks are not carried out to ensure that the name is available, so that should be done before this method is called

      Parameters:
      name - the name of the new team
      owner - the owner of the new team (the player who ran /team create)
      Returns:
      The created team
    • getClaimingTeam

      public Team getClaimingTeam(org.bukkit.Location location)
      Used to get the team which has claimed the provided chest, will return null if that location is not claimed
      Parameters:
      location - the location of the chest - must already be normalised
      Returns:
      The team which has claimed that chest
    • getClaimingTeamUUID

      public abstract UUID getClaimingTeamUUID(org.bukkit.Location location)
      Used to get the UUID of the team which has claimed the provided chest, will return null if that location is not claimed
      Parameters:
      location - The location of the chest - must already be normalised
      Returns:
      the team which has claimed that chest
    • getClaimingTeam

      public Team getClaimingTeam(org.bukkit.block.Block block)
      Used to get the claiming team of a chest, will check both parts of a double chest, it is assumed that the provided block is known to be a chest
      Parameters:
      block - The block being checked
      Returns:
      The team which has claimed that block
    • getClaimingLocation

      public org.bukkit.Location getClaimingLocation(org.bukkit.block.Block block)
      Used to get the claiming location, will check both parts of a double chest, it is assumed that the provided block is known to be a chest
      Parameters:
      block - Part of the chest
      Returns:
      The location of the claim
    • purgeTeams

      public boolean purgeTeams(boolean money, boolean score)
      Used to reset all teams scores to 0
      Returns:
      If the teams were purged or not
    • isTeam

      @Contract(pure=true, value="null -> false") public abstract boolean isTeam(@Nullable @Nullable UUID uuid)
      Used to check if a team exists with that uuid
      Parameters:
      uuid - the UUID to check
      Returns:
      If a team exists with that uuid
    • isTeam

      @Contract(pure=true, value="null -> false") public abstract boolean isTeam(@Nullable @Nullable String name)
      Used to check if a team exists with that name
      Parameters:
      name - the name to check
      Returns:
      If a team exists with that name
    • isInTeam

      public abstract boolean isInTeam(org.bukkit.OfflinePlayer player)
      Used to check if the specified player is in a team
      Parameters:
      player - The player to check
      Returns:
      If they are in a team
    • getTeamUUID

      public abstract UUID getTeamUUID(org.bukkit.OfflinePlayer player)
      Used to get the uuid of the team that the specified player is in
      Parameters:
      player - the plyaer to check for
      Returns:
      The team uuid
    • getTeamUUID

      public abstract UUID getTeamUUID(String name)
      Used to get the team uuid from the team name
      Parameters:
      name - The name of the team
      Returns:
      The UUID of the specified team
    • loadTeams

      public abstract void loadTeams()
      Used to load the stored values into the storage manager
    • isLoaded

      public boolean isLoaded(UUID teamUUID)
    • registerNewTeam

      protected abstract void registerNewTeam(Team team, org.bukkit.entity.Player player)
      Called when a new team is registered, this can be used to register it in any full team trackers The team file will be fully prepared with the members within the team
      Parameters:
      team - The new team
      player - The player that created the team
    • disbandTeam

      public void disbandTeam(Team team)
      Used to disband a team
      Parameters:
      team - The team that is being disbanded
    • deleteTeamStorage

      protected abstract void deleteTeamStorage(Team team)
      Used when a team is disbanded, can be used to remove it from any team trackers
      Parameters:
      team - The team that is being disbanded
    • teamNameChange

      public abstract void teamNameChange(Team team, String newName)
      Called when a team changes its name as this will effect the getTeam(String teamName) method
      Parameters:
      team - The new team
      newName - The name the team has changed to
    • playerJoinTeam

      public abstract void playerJoinTeam(Team team, TeamPlayer player)
      Called when a player joins a team, this can be used to track the players location
      Parameters:
      team - The team that the player has joined
      player - The player that has joined the team
    • playerLeaveTeam

      public abstract void playerLeaveTeam(Team team, TeamPlayer player)
      Called when a player leaves a team
      Parameters:
      team - The team that the player has left
      player - The team that the player has left
    • createTeamStorage

      public abstract TeamStorage createTeamStorage(Team team)
      Called when a team needs a storage manager to manage all information, this is called for preexisting teams
      Parameters:
      team - The team instance
      Returns:
      The created team storage
    • createNewTeamStorage

      public abstract TeamStorage createNewTeamStorage(Team team)
      Called when a new team is made
      Parameters:
      team - The team
      Returns:
      The created team storage
    • sortTeamsByScore

      public abstract String[] sortTeamsByScore()
      This method is used to sort all the teams into an array ranking from highest score to lowest
      Returns:
      the array of teams in order of their rank
    • sortTeamsByBalance

      public abstract String[] sortTeamsByBalance()
      This method is used to sort all the team names into an array ranking from highest to lowest
      Returns:
      The sorted array
    • sortTeamsByMembers

      public abstract String[] sortTeamsByMembers()
      Used to sort all members from largest to smallest by number of members
      Returns:
      the sorted array
    • purgeTeamScore

      public abstract void purgeTeamScore()
      Used to reset the score of all teams
    • purgeTeamMoney

      public abstract void purgeTeamMoney()
      Used to reset the balance of all teams
    • getHoloDetails

      public abstract List<String> getHoloDetails()
      Returns:
      The stored hologram details
    • setHoloDetails

      public abstract void setHoloDetails(List<String> details)
      Used to store and save the updated hologram details
      Parameters:
      details - the details to save
    • addChestClaim

      public abstract void addChestClaim(Team team, org.bukkit.Location loc)
    • removeChestclaim

      public abstract void removeChestclaim(org.bukkit.Location loc)
    • rebuildLookups

      public abstract void rebuildLookups()
      Can be called by a config option if the server is having difficulties. Do not call from anywhere else as it may cause problems depending on the storage type
    • disable

      public void disable()
      this can be overritten if any code needs to be run when onDisable is called
    • isLogChat

      public boolean isLogChat()
      If chat is being logged to the console