Package com.booksaw.betterTeams
Class Team
java.lang.Object
com.booksaw.betterTeams.Team
This class is used to manage a team and all of it's participants
- Author:
- booksaw
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Used to add an ally for this teamvoid
void
Used to add an ally for this teamvoid
addAllyRequest
(@Nullable Team team) Used to add an ally request to this teamvoid
addAllyRequest
(UUID team) Used to add an ally request to this teamvoid
addClaim
(org.bukkit.Location location) Used to add a chest claim to this teamvoid
Used for anchoring this player.void
banPlayer
(org.bukkit.OfflinePlayer player) This method is used to add a player to the list of players which are banned from the teamvoid
becomeNeutral
(Team otherTeam, boolean sendPostEvent) Used to become neutral to a teamvoid
becomeNeutral
(UUID otherTeam, boolean sendPostEvent) Used to become neutral to a teamboolean
Used to check if this team can damage members of the specified teamboolean
Used to check if this team can damage members of the specified teamboolean
canDamage
(org.bukkit.entity.Player player) Used to check if a member of this team can damage the specified playerboolean
canDamage
(org.bukkit.entity.Player player, org.bukkit.entity.Player source) Used to check if a member of this team can damage the specified playerstatic boolean
Used to get the config value checking if ally chests can be openedvoid
void
void
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 validationstatic void
disable()
Used to disable betterteams so the singleton is removedvoid
disband()
This command is used to disband a team, BE CAREFUL, this is irreversiblevoid
disband
(org.bukkit.entity.Player player) This command is used to disband a team, BE CAREFUL, this is irreversible@NotNull String
@NotNull String
getAdventureDisplayName
(boolean checkConfig) getAdventureTag
(boolean checkConfig) the list of all UUIDS of teams that are allied with this teamgetAllyChatSyntax
(TeamPlayer sender) tracks and provides utility methods relating to anchored players of this teamint
static org.bukkit.Location
getClaimingLocation
(org.bukkit.block.Block block) static Team
getClaimingTeam
(org.bukkit.block.Block block) static Team
getClaimingTeam
(org.bukkit.Location location) @NotNull String
org.bukkit.ChatColor
getColor()
The color of the teamThe description of a team, used in /team info@NotNull String
@NotNull String
getDisplayName
(boolean asAdventure) @NotNull String
getDisplayName
(org.bukkit.ChatColor resetTo) @NotNull String
getDisplayName
(org.bukkit.ChatColor resetTo, boolean asAdventure) Used to get the current name of the teamorg.bukkit.inventory.Inventory
getID()
This is a list of invited players to this team since the last restart of the serverint
getLevel()
int
double
int
int
tracks and provides utility methods relating to the members of this teamgetMeta()
double
getMoney()
getName()
The name of the team, this can be changed after the creation of a teams, so do not store references to itList<org.bukkit.entity.Player>
Used to get a list of all the online players that are on this team@NotNull String
getRank
(PlayerRank rank) Used to get all players which have the specified rank within the teamint
getScore()
org.bukkit.scoreboard.Team
getScoreboardTeam
(org.bukkit.scoreboard.Scoreboard board) Used throughout all below name management (showing team name above player name)org.bukkit.scoreboard.Team
Used to return the scoreboard team, and not create a new one if it does not existgetTag()
getTag
(boolean asAdventure) getTag
(org.bukkit.ChatColor returnTo) getTag
(org.bukkit.ChatColor returnTo, boolean asAdventure) static @Nullable Team
static @Nullable Team
static @Nullable Team
getTeam
(@Nullable org.bukkit.OfflinePlayer player) int
static Team
getTeamByName
(String name) getTeamChatSyntax
(TeamPlayer sender) Used to get the chat syntax and apply placeholders when possibleorg.bukkit.Location
The location of the teams home (/team home)int
static TeamManager
@Nullable TeamPlayer
getTeamPlayer
(org.bukkit.OfflinePlayer player) Used to get the teamPlayer version of an included playerint
Used to get a warp with the specified namegetWarps()
boolean
boolean
hasRequested
(@Nullable Team team) Used to check if a team has sent an ally request for this teamboolean
hasRequested
(UUID team) Used to check if a team has sent an ally request for this teamvoid
Used to create an invite for the included player to this teamboolean
Used to check if a team is in alliance with this teamboolean
Used to check if a team is in alliance with this teamboolean
boolean
isBanned
(org.bukkit.OfflinePlayer player) This method searches the ban list to check if the player is bannedboolean
isClaimed
(org.bukkit.Location location) boolean
Used to check if a player is invited to this teamboolean
boolean
boolean
boolean
Used to check if the provided team is a neutral to the other teamboolean
isOpen()
If the team is open or invite onlyboolean
Used to check if the given team player is anchored within this teamboolean
isPlayerAnchored
(org.bukkit.OfflinePlayer p) boolean
isPvp()
Tracks if the team has pvp enabled between team membersboolean
static boolean
isValidTeamName
(@Nullable String name) Used to check if the provided team name is a valid name for a teamboolean
join
(org.bukkit.entity.Player p) This is used when a player is joining the teamvoid
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 validationvoid
promotePlayerToOwner
(TeamPlayer promotePlayer) void
removeAllyRequest
(@Nullable Team team) Used to remove an ally request from this teamvoid
removeAllyRequest
(UUID team) Used to remove an ally request from this teamvoid
removeAndSaveMeta
(String key) void
removeClaim
(org.bukkit.Location location) Used to remove a chest claim from this teamboolean
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)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)void
void
Used to save all warps that this team has setvoid
sendAllyMessage
(TeamPlayer sender, String message) Used to send a message to all of the teams alliesvoid
sendMessage
(TeamPlayer sender, String message) Used when a player sends a message to the team chatboolean
setAnchored
(boolean anchor) void
setAndSaveMeta
(String key, String value) void
setColor
(org.bukkit.ChatColor color) Used to change the team colorvoid
setDescription
(String description) Used to change the team descriptionvoid
setLevel
(int level) void
setMoney
(double money) void
This is used to set the name of the team, it is important that you check that the name is unique before running this methodvoid
setOpen
(boolean open) setPlayerAnchor
(TeamPlayer p, boolean anchor) setPlayerAnchor
(org.bukkit.OfflinePlayer p, boolean anchor) void
setPvp
(boolean pvp) void
setScore
(int score) void
void
setTeamBalRank
(int rank) void
setTeamHome
(org.bukkit.Location teamHome) void
setTeamRank
(int rank) void
setTitle
(TeamPlayer player, String title) static void
setupTeamManager
(StorageType storageType) boolean
Toggle anchor status for this teamUsed for unanchoring this player.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
-
Constructor Details
-
Team
this is used to load a team from the configuration file- Parameters:
id
- the ID of the team to load
-
Team
Creates a new team with the provided nameThis 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 teamid
- The UUID of the teamowner
- The owner of the team (whoever initiated the creation of the team)
-
-
Method Details
-
setupTeamManager
-
disable
public static void disable()Used to disable betterteams so the singleton is removed -
getTeamManager
-
getTeam
-
getTeam
-
getTeam
@Contract(pure=true, value="null -> null") @Nullable public static @Nullable Team getTeam(@Nullable @Nullable org.bukkit.OfflinePlayer player) -
getTeamByName
-
getClaimingTeam
-
getClaimingTeam
- 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
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
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
-
getCloseColor
-
getAdventureDisplayName
-
getAdventureDisplayName
-
getDisplayName
-
getDisplayName
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
-
getDisplayName
-
getAdventureTag
-
getAdventureTag
-
getTag
-
getTag
-
getTag
-
getTag
-
getOriginalTag
-
setTag
-
setOpen
public void setOpen(boolean open) -
setDescription
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
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
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
-
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
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
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
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
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
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
-
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
Used when a player sends a message to the team chat- Parameters:
sender
- the player which sent the message to the team chatmessage
- the message to send to the team chat
-
getTeamChatSyntax
Used to get the chat syntax and apply placeholders when possible- Parameters:
sender
- - The team player who sent the command
-
getAllyChatSyntax
-
sendAllyMessage
Used to send a message to all of the teams allies- Parameters:
sender
- the player who sent the messagemessage
- the message that the player sent
-
getScore
public int getScore() -
getScoreComponent
-
setScore
public void setScore(int score) -
getMoney
public double getMoney() -
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
-
setTitle
-
addAlly
Used to add an ally for this team- Parameters:
otherTeam
- the UUID of the new allysendPostEvent
- If you want the post event to be sent. This is useful if you are switching from one relation to another.
-
addAlly
Used to add an ally for this team- Parameters:
ally
- the UUID of the new allysendPostEvent
- If you want the post event to be sent. This is useful if you are switching from one relation to another.
-
addAlly
-
addAlly
-
becomeNeutral
Used to become neutral to a team- Parameters:
otherTeam
- the team to become neutral tosendPostEvent
- If you want the post event to be sent. This is useful if you are switching from one relation to another.
-
becomeNeutral
Used to become neutral to a team- Parameters:
otherTeam
- the team to become neutral tosendPostEvent
- If you want the post event to be sent. This is useful if you are switching from one relation to another.
-
isAlly
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
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
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
-
addAllyRequest
Used to add an ally request to this team- Parameters:
team
- the team that has sent the request
-
addAllyRequest
Used to add an ally request to this team- Parameters:
team
- the team that has sent the request
-
removeAllyRequest
Used to remove an ally request from this team- Parameters:
team
- the team to remove the ally request for
-
removeAllyRequest
Used to remove an ally request from this team- Parameters:
team
- the team to remove the ally request for
-
hasRequested
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
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
- Returns:
- the set of all UUIDS of teams that have sent ally requests
-
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 forsource
- the source of the damage- Returns:
- if this team can damage that player
-
canDamage
Used to check if this team can damage members of the specified team- Parameters:
team
- the team to testsource
- 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
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
Used to get a warp with the specified name- Parameters:
name
- the name of the warp- Returns:
- the warp with that name
-
addWarp
-
delWarp
-
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
-
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
-
removeAndSaveMeta
-
getStorage
-
getName
The name of the team, this can be changed after the creation of a teams, so do not store references to it -
getDescription
The description of a team, used in /team info -
isOpen
public boolean isOpen()If the team is open or invite onlychange 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
tracks and provides utility methods relating to the members of this team -
getAnchoredPlayers
tracks and provides utility methods relating to anchored players of this team -
getAllies
the list of all UUIDS of teams that are allied with this team -
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
-
getMeta
-