Package com.booksaw.betterTeams.team
Class TeamManager
java.lang.Object
com.booksaw.betterTeams.team.TeamManager
- Direct Known Subclasses:
SQLStorageManager
,YamlStorageManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionA list of all teams -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract 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 nameabstract TeamStorage
createNewTeamStorage
(Team team) Called when a new team is madeabstract TeamStorage
createTeamStorage
(Team team) Called when a team needs a storage manager to manage all information, this is called for preexisting teamsprotected abstract void
deleteTeamStorage
(Team team) Used when a team is disbanded, can be used to remove it from any team trackersvoid
disable()
this can be overritten if any code needs to be run when onDisable is calledvoid
disbandTeam
(Team team) Used to disband a teamorg.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 chestgetClaimingTeam
(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 chestgetClaimingTeam
(org.bukkit.Location location) Used to get the team which has claimed the provided chest, will return null if that location is not claimedabstract 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 claimedUsed to get an clone of the loaded team list.@Nullable Team
Used to get the team by it's display name or a player within it@Nullable Team
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 nameabstract UUID
getTeamUUID
(String name) Used to get the team uuid from the team nameabstract UUID
getTeamUUID
(org.bukkit.OfflinePlayer player) Used to get the uuid of the team that the specified player is inabstract boolean
isInTeam
(org.bukkit.OfflinePlayer player) Used to check if the specified player is in a teamboolean
boolean
If chat is being logged to the consoleabstract boolean
Used to check if a team exists with that nameabstract boolean
Used to check if a team exists with that uuidabstract void
Used to load the stored values into the storage managerabstract void
playerJoinTeam
(Team team, TeamPlayer player) Called when a player joins a team, this can be used to track the players locationabstract void
playerLeaveTeam
(Team team, TeamPlayer player) Called when a player leaves a teamabstract void
Used to reset the balance of all teamsboolean
purgeTeams
(boolean money, boolean score) Used to reset all teams scores to 0abstract void
Used to reset the score of all teamsabstract 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 teamabstract void
removeChestclaim
(org.bukkit.Location loc) abstract void
setHoloDetails
(List<String> details) Used to store and save the updated hologram detailsabstract String[]
This method is used to sort all the team names into an array ranking from highest to lowestabstract String[]
Used to sort all members from largest to smallest by number of membersabstract String[]
This method is used to sort all the teams into an array ranking from highest score to lowestabstract void
teamNameChange
(Team team, String newName) Called when a team changes its name as this will effect the getTeam(String teamName) method
-
Field Details
-
loadedTeams
A list of all teams
-
-
Constructor Details
-
TeamManager
protected TeamManager()Used to create a new teamManager
-
-
Method Details
-
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
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
This method is used to create a new team with the specified nameChecks 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 teamowner
- the owner of the new team (the player who ran /team create)- Returns:
- The created team
-
getClaimingTeam
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
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
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
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
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
-
registerNewTeam
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 teamplayer
- The player that created the team
-
disbandTeam
Used to disband a team- Parameters:
team
- The team that is being disbanded
-
deleteTeamStorage
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
Called when a team changes its name as this will effect the getTeam(String teamName) method- Parameters:
team
- The new teamnewName
- The name the team has changed to
-
playerJoinTeam
Called when a player joins a team, this can be used to track the players location- Parameters:
team
- The team that the player has joinedplayer
- The player that has joined the team
-
playerLeaveTeam
Called when a player leaves a team- Parameters:
team
- The team that the player has leftplayer
- The team that the player has left
-
createTeamStorage
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
Called when a new team is made- Parameters:
team
- The team- Returns:
- The created team storage
-
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
This method is used to sort all the team names into an array ranking from highest to lowest- Returns:
- The sorted array
-
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
- Returns:
- The stored hologram details
-
setHoloDetails
Used to store and save the updated hologram details- Parameters:
details
- the details to save
-
addChestClaim
-
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
-