Class Team

java.lang.Object
com.booksaw.betterTeams.Team

public class Team extends Object
This class is used to manage a team and all of it's participants
Author:
booksaw
  • Constructor Details

    • Team

      public Team(UUID id)
      this is used to load a team from the configuration file
      Parameters:
      id - the ID of the team to load
    • Team

      public Team(String name, UUID id, org.bukkit.entity.Player owner)
      Creates a new team with the provided name

      This is a private method as the creation of a new team should be done by the Team.createNewTeam(name) method

      Parameters:
      name - The selected name for the team
      id - The UUID of the team
      owner - The owner of the team (whoever initiated the creation of the team)
  • Method Details

    • setupTeamManager

      public static void setupTeamManager(StorageType storageType)
    • disable

      public static void disable()
      Used to disable betterteams so the singleton is removed
    • getTeamManager

      public static TeamManager getTeamManager()
    • getTeam

      @Contract(pure=true, value="null -> null") @Nullable public static @Nullable Team getTeam(@Nullable @Nullable UUID uuid)
    • getTeam

      @Contract(pure=true, value="null -> null") @Nullable public static @Nullable Team getTeam(@Nullable @Nullable String name)
    • getTeam

      @Contract(pure=true, value="null -> null") @Nullable public static @Nullable Team getTeam(@Nullable @Nullable org.bukkit.OfflinePlayer player)
    • getTeamByName

      public static Team getTeamByName(String name)
    • getClaimingTeam

      public static Team getClaimingTeam(org.bukkit.block.Block block)
    • getClaimingTeam

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

      public static org.bukkit.Location getClaimingLocation(org.bukkit.block.Block block)
    • canOpenAllyChests

      public static boolean canOpenAllyChests()
      Used to get the config value checking if ally chests can be opened
      Returns:
      If ally chests can be opened
    • isValidTeamName

      @Contract("null -> false") public static boolean isValidTeamName(@Nullable @Nullable String name)
      Used to check if the provided team name is a valid name for a team
      Parameters:
      name - The name of the team
      Returns:
      If the team name is valid
    • setName

      public void setName(String name, org.bukkit.entity.Player playerSource)
      This is used to set the name of the team, it is important that you check that the name is unique before running this method
      Parameters:
      name - the new team namexg
    • getOpenColor

      @NotNull public @NotNull String getOpenColor()
    • getCloseColor

      @NotNull public @NotNull String getCloseColor()
    • getAdventureDisplayName

      @NotNull public @NotNull String getAdventureDisplayName()
    • getAdventureDisplayName

      @NotNull public @NotNull String getAdventureDisplayName(boolean checkConfig)
    • getDisplayName

      @NotNull public @NotNull String getDisplayName(org.bukkit.ChatColor resetTo)
    • getDisplayName

      @NotNull public @NotNull String getDisplayName(org.bukkit.ChatColor resetTo, boolean asAdventure)
      Used to get the current name of the team
      Parameters:
      resetTo - the color to return to at the end of the string
      Returns:
      the name of the team
    • getDisplayName

      @NotNull public @NotNull String getDisplayName()
    • getDisplayName

      @NotNull public @NotNull String getDisplayName(boolean asAdventure)
    • getAdventureTag

      public String getAdventureTag()
    • getAdventureTag

      public String getAdventureTag(boolean checkConfig)
    • getTag

      public String getTag()
    • getTag

      public String getTag(boolean asAdventure)
    • getTag

      public String getTag(org.bukkit.ChatColor returnTo)
    • getTag

      public String getTag(org.bukkit.ChatColor returnTo, boolean asAdventure)
    • getOriginalTag

      public String getOriginalTag()
    • setTag

      public void setTag(String tag)
    • setOpen

      public void setOpen(boolean open)
    • setDescription

      public void setDescription(String description)
      Used to change the team description
      Parameters:
      description - the new team description
    • setColor

      public void setColor(org.bukkit.ChatColor color)
      Used to change the team color
      Parameters:
      color - the new team color
    • removePlayer

      public boolean removePlayer(org.bukkit.OfflinePlayer p)
      Used to remove the given player from the team, you must firstly be sure that the player is in this team (as it is not checked or caught in this method)
      Parameters:
      p - the player to remove from the team
      Returns:
      If the player was removed from the team
    • removePlayer

      public boolean removePlayer(TeamPlayer p)
      Used to remove the given teamPlayer from the team, you must firstly be sure that the player is in this team (as it is not checked or caught in this method)
      Parameters:
      p - the player to remove from the team
      Returns:
      If the player was removed from the team
    • isPlayerAnchored

      public boolean isPlayerAnchored(org.bukkit.OfflinePlayer p)
    • isPlayerAnchored

      public boolean isPlayerAnchored(TeamPlayer p)
      Used to check if the given team player is anchored within this team
      Parameters:
      p - the team player
    • setPlayerAnchor

      public AnchoredPlayerUUIDSetComponent.AnchorResult setPlayerAnchor(org.bukkit.OfflinePlayer p, boolean anchor)
    • setPlayerAnchor

      public AnchoredPlayerUUIDSetComponent.AnchorResult setPlayerAnchor(TeamPlayer p, boolean anchor)
    • anchorPlayer

      Used for anchoring this player.
      Parameters:
      p - the team player to anchor
      Returns:
      AnchorResult
    • unanchorPlayer

      Used for unanchoring this player.
      Parameters:
      p - the team player to unanchor
      Returns:
      AnchorResult
    • getTeamPlayer

      @Nullable public @Nullable TeamPlayer getTeamPlayer(org.bukkit.OfflinePlayer player)
      Used to get the teamPlayer version of an included player
      Parameters:
      player - the player to search for
      Returns:
      the team player object for that player [null - player is not in the team]
    • getRank

      public List<TeamPlayer> getRank(PlayerRank rank)
      Used to get all players which have the specified rank within the team
      Parameters:
      rank - the rank to search for
      Returns:
      a list of players which have that rank [emtpy list - no players have that rank]
    • disband

      public void disband()
      This command is used to disband a team, BE CAREFUL, this is irreversible
    • disband

      public void disband(org.bukkit.entity.Player player)
      This command is used to disband a team, BE CAREFUL, this is irreversible
      Parameters:
      player - The player responsible for disbandment [null - initiated by console]
    • isInvited

      public boolean isInvited(UUID uuid)
      Used to check if a player is invited to this team
      Parameters:
      uuid - the UUID of the player to check
      Returns:
      [true - the player is invited] [false - the player is not invited]
    • invite

      public void invite(UUID uniqueId)
      Used to create an invite for the included player to this team
      Parameters:
      uniqueId - the UUID of the player being invited
    • join

      public boolean join(org.bukkit.entity.Player p)
      This is used when a player is joining the team
      Parameters:
      p - the player who is joining the team
      Returns:
      true if the player joined the team, else false
    • promotePlayer

      public void promotePlayer(TeamPlayer promotePlayer)
      This method is used to promote a player to the next applicable rank, this method does not check the promotion is valid but instead only promotes the player, see PromoteCommand to see validation
      Parameters:
      promotePlayer - the player to be promoted
    • promotePlayerToOwner

      public void promotePlayerToOwner(TeamPlayer promotePlayer)
    • demotePlayer

      public void demotePlayer(TeamPlayer demotePlayer)
      This method is used to demote a player to the next applicable rank, this method does not check the demotion is valid but instead only promotes the player, see DemoteCommand to see validation
      Parameters:
      demotePlayer - the player to be demoted
    • setTeamHome

      public void setTeamHome(org.bukkit.Location teamHome)
    • deleteTeamHome

      public void deleteTeamHome()
    • banPlayer

      public void banPlayer(org.bukkit.OfflinePlayer player)
      This method is used to add a player to the list of players which are banned from the team
      Parameters:
      player - the player to add to the list
    • unbanPlayer

      public void unbanPlayer(org.bukkit.OfflinePlayer player)
      This method is used to remove a player from the list of players which are banned from the team
      Parameters:
      player - the player to remove from the list
    • isBanned

      public boolean isBanned(org.bukkit.OfflinePlayer player)
      This method searches the ban list to check if the player is banned
      Parameters:
      player - the player to check
      Returns:
      [true - the player is banned] [false - the player isen't banned]
    • sendMessage

      public void sendMessage(TeamPlayer sender, String message)
      Used when a player sends a message to the team chat
      Parameters:
      sender - the player which sent the message to the team chat
      message - the message to send to the team chat
    • getTeamChatSyntax

      public String getTeamChatSyntax(TeamPlayer sender)
      Used to get the chat syntax and apply placeholders when possible
      Parameters:
      sender - - The team player who sent the command
    • getAllyChatSyntax

      public String getAllyChatSyntax(TeamPlayer sender)
    • sendAllyMessage

      public void sendAllyMessage(TeamPlayer sender, String message)
      Used to send a message to all of the teams allies
      Parameters:
      sender - the player who sent the message
      message - the message that the player sent
    • getScore

      public int getScore()
    • getScoreComponent

      public ScoreComponent getScoreComponent()
    • setScore

      public void setScore(int score)
    • getMoney

      public double getMoney()
    • getMoneyComponent

      public MoneyComponent getMoneyComponent()
    • setMoney

      public void setMoney(double money)
    • getTeamRank

      public int getTeamRank()
      Returns:
      the rank of the team (-1 if the team has not been ranked)
    • setTeamRank

      public void setTeamRank(int rank)
    • setTeamBalRank

      public void setTeamBalRank(int rank)
    • getTeamBalRank

      public int getTeamBalRank()
    • getScoreboardTeam

      public org.bukkit.scoreboard.Team getScoreboardTeam(org.bukkit.scoreboard.Scoreboard board)
      Used throughout all below name management (showing team name above player name)
      Parameters:
      board - the scoreboard to add the team to
      Returns:
      the team that has been created
    • getScoreboardTeamOrNull

      public org.bukkit.scoreboard.Team getScoreboardTeamOrNull()
      Used to return the scoreboard team, and not create a new one if it does not exist
      Returns:
      The scoreboard team (if already created)
    • getBalance

      public String getBalance()
    • setTitle

      public void setTitle(TeamPlayer player, String title)
    • addAlly

      public void addAlly(UUID otherTeam, boolean sendPostEvent)
      Used to add an ally for this team
      Parameters:
      otherTeam - the UUID of the new ally
      sendPostEvent - If you want the post event to be sent. This is useful if you are switching from one relation to another.
    • addAlly

      public void addAlly(@Nullable @Nullable Team ally, boolean sendPostEvent)
      Used to add an ally for this team
      Parameters:
      ally - the UUID of the new ally
      sendPostEvent - If you want the post event to be sent. This is useful if you are switching from one relation to another.
    • addAlly

      public void addAlly(@Nullable @Nullable Team ally)
    • addAlly

      public void addAlly(@Nullable @Nullable UUID ally)
    • becomeNeutral

      public void becomeNeutral(UUID otherTeam, boolean sendPostEvent)
      Used to become neutral to a team
      Parameters:
      otherTeam - the team to become neutral to
      sendPostEvent - If you want the post event to be sent. This is useful if you are switching from one relation to another.
    • becomeNeutral

      public void becomeNeutral(Team otherTeam, boolean sendPostEvent)
      Used to become neutral to a team
      Parameters:
      otherTeam - the team to become neutral to
      sendPostEvent - If you want the post event to be sent. This is useful if you are switching from one relation to another.
    • isAlly

      public boolean isAlly(UUID team)
      Used to check if a team is in alliance with this team
      Parameters:
      team - the team to check for allies
      Returns:
      if the team is an ally
    • isAlly

      public boolean isAlly(@Nullable @Nullable Team team)
      Used to check if a team is in alliance with this team
      Parameters:
      team - the team to check for allies
      Returns:
      if the team is an ally
    • isNeutral

      public boolean isNeutral(UUID team)
      Used to check if the provided team is a neutral to the other team
      Parameters:
      team - the team to check
      Returns:
      if the team is neutral
    • isNeutral

      public boolean isNeutral(@Nullable @Nullable Team team)
    • addAllyRequest

      public void addAllyRequest(UUID team)
      Used to add an ally request to this team
      Parameters:
      team - the team that has sent the request
    • addAllyRequest

      public void addAllyRequest(@Nullable @Nullable Team team)
      Used to add an ally request to this team
      Parameters:
      team - the team that has sent the request
    • removeAllyRequest

      public void removeAllyRequest(UUID team)
      Used to remove an ally request from this team
      Parameters:
      team - the team to remove the ally request for
    • removeAllyRequest

      public void removeAllyRequest(@Nullable @Nullable Team team)
      Used to remove an ally request from this team
      Parameters:
      team - the team to remove the ally request for
    • hasRequested

      public boolean hasRequested(UUID team)
      Used to check if a team has sent an ally request for this team
      Parameters:
      team - the team to check for
      Returns:
      if they have sent an ally request
    • hasRequested

      public boolean hasRequested(@Nullable @Nullable Team team)
      Used to check if a team has sent an ally request for this team
      Parameters:
      team - the team to check for
      Returns:
      if they have sent an ally request
    • getAllyRequests

      public Set<UUID> getAllyRequests()
      Returns:
      the set of all UUIDS of teams that have sent ally requests
    • getID

      public UUID getID()
    • canDamage

      public boolean canDamage(org.bukkit.entity.Player player, org.bukkit.entity.Player source)
      Used to check if a member of this team can damage the specified player
      Parameters:
      player - the player to check for
      source - the source of the damage
      Returns:
      if this team can damage that player
    • canDamage

      public boolean canDamage(Team team, org.bukkit.entity.Player source)
      Used to check if this team can damage members of the specified team
      Parameters:
      team - the team to test
      source - The source of the damage
      Returns:
      if players of this team can damage members of the other team
    • canDamage

      public boolean canDamage(org.bukkit.entity.Player player)
      Used to check if a member of this team can damage the specified player
      Parameters:
      player - the player to check for
      Returns:
      if this team can damage that player
    • canDamage

      public boolean canDamage(Team team)
      Used to check if this team can damage members of the specified team
      Parameters:
      team - the team to test
      Returns:
      if players of this team can damage members of the other team
    • hasMaxAllies

      public boolean hasMaxAllies()
    • saveWarps

      public void saveWarps()
      Used to save all warps that this team has set
    • getWarp

      public Warp getWarp(String name)
      Used to get a warp with the specified name
      Parameters:
      name - the name of the warp
      Returns:
      the warp with that name
    • addWarp

      public void addWarp(Warp warp)
    • delWarp

      public void delWarp(String name)
    • getOnlineMembers

      public List<org.bukkit.entity.Player> getOnlineMembers()
      Used to get a list of all the online players that are on this team
      Returns:
      a list of online members for this team
    • addClaim

      public void addClaim(org.bukkit.Location location)
      Used to add a chest claim to this team
      Parameters:
      location - The location of the chest claim (round to the nearest block)
    • removeClaim

      public void removeClaim(org.bukkit.Location location)
      Used to remove a chest claim from this team
      Parameters:
      location - The location of the chest claim (round to the nearest block)
    • clearClaims

      public void clearClaims()
    • getClaimCount

      public int getClaimCount()
    • isClaimed

      public boolean isClaimed(org.bukkit.Location location)
    • saveEchest

      public void saveEchest()
    • getEchest

      public org.bukkit.inventory.Inventory getEchest()
    • getEchestComponent

      public EChestComponent getEchestComponent()
    • getMaxWarps

      public int getMaxWarps()
    • setLevel

      public void setLevel(int level)
    • setPvp

      public void setPvp(boolean pvp)
    • toggleAnchor

      public boolean toggleAnchor()
      Toggle anchor status for this team
      Returns:
      false if trying to anchor the team and its home is not set, true otherwise
    • setAnchored

      public boolean setAnchored(boolean anchor)
    • isAnchored

      public boolean isAnchored()
    • getMaxMoney

      public double getMaxMoney()
    • getTeamLimit

      public int getTeamLimit()
    • isTeamFull

      public boolean isTeamFull()
    • getMaxAdmins

      public int getMaxAdmins()
    • getMaxOwners

      public int getMaxOwners()
    • isMaxAdmins

      public boolean isMaxAdmins()
    • isMaxOwners

      public boolean isMaxOwners()
    • setAndSaveMeta

      public void setAndSaveMeta(String key, String value)
    • removeAndSaveMeta

      public void removeAndSaveMeta(String key)
    • getStorage

      public TeamStorage getStorage()
    • getName

      public String getName()
      The name of the team, this can be changed after the creation of a teams, so do not store references to it
    • getDescription

      public String getDescription()
      The description of a team, used in /team info
    • isOpen

      public boolean isOpen()
      If the team is open or invite only

      change this to an enum - which is more expressive

      Returns:
      [true - anyone can join the team] [false - the team is invite only]
    • getTeamHome

      public org.bukkit.Location getTeamHome()
      The location of the teams home (/team home)
    • getMembers

      public MemberSetComponent getMembers()
      tracks and provides utility methods relating to the members of this team
    • getAnchoredPlayers

      public AnchoredPlayerUUIDSetComponent getAnchoredPlayers()
      tracks and provides utility methods relating to anchored players of this team
    • getAllies

      public AllySetComponent getAllies()
      the list of all UUIDS of teams that are allied with this team
    • getInvitedPlayers

      public List<UUID> getInvitedPlayers()
      This is a list of invited players to this team since the last restart of the server
    • isPvp

      public boolean isPvp()
      Tracks if the team has pvp enabled between team members
    • getColor

      public org.bukkit.ChatColor getColor()
      The color of the team
    • getLevel

      public int getLevel()
    • getWarps

      public WarpSetComponent getWarps()
    • getMeta

      public MetaComponent getMeta()