Class TownyUniverse
java.lang.Object
com.palmergames.bukkit.towny.TownyUniverse
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddSpawnPoint(SpawnPoint spawn) voidaddTownBlock(TownBlock townBlock) voidClears the object maps.voidRun during onDisable() to finish cleanup and backup.@Nullable DistrictgetDistrict(UUID districtID) Gets the district from the town name and the district UUIDGet all the districts from all towns Returns a collection that does not reflect any district additions/removals@Nullable PlotGroupGets the plot group from the town name and the plot group UUIDGet all the plot object groups from all towns Returns a collection that does not reflect any group additions/removalsstatic TownyUniverse@Nullable JailgetJails()@Nullable NationGet the nation with the passed-in nation name if it exists.@Nullable NationGet the nation with the given UUID if it exists.@Unmodifiable Collection<Nation> intintMap<String, CustomDataField<?>> Map<String, CustomDataField<?>> @Nullable ResidentgetResident(@NotNull String residentName) Get the resident matching the passed in name.@Nullable ResidentgetResident(@NotNull UUID residentUUID) Get the resident with the passed-in UUID.getResidentOpt(@NotNull String residentName) Get an optional instance of the resident matching the passed in name.getResidentOpt(@NotNull UUID residentUUID) Get an optional object that may contain the resident with the passed-in UUID.@Unmodifiable Collection<Resident> @Nullable SpawnPointgetSpawnPoint(org.bukkit.Location loc) @Nullable Town@Nullable TowngetTownBlock(WorldCoord worldCoord) How to get a TownBlock for now.@Nullable TownBlockgetTownBlockOrNull(WorldCoord worldCoord) Get Universe-wide ConcurrentHashMap of WorldCoords and their TownBlocks.@Unmodifiable Collection<Town> getTowns()getTreeString(int depth) @Nullable TownyWorld@Nullable TownyWorldbooleanbooleanCheck if the nation matching the given name exists.booleanCheck if the nation matching the given UUID exists.booleanhasResident(@NotNull String residentName) Check if a resident exists with the passed in name.booleanhasResident(@NotNull UUID residentUUID) Check if a resident exists matching the passed in UUID.booleanhasSpawnPoint(org.bukkit.Location loc) booleanbooleanbooleanhasTownBlock(WorldCoord worldCoord) Does this WorldCoord have a TownBlock?booleanhasTownyWorld(String worldName) voidnewDistrictInternal(UUID uuid) Used in loading only.voidnewJailInternal(String uuid) Used in loading only.voidnewPlotGroupInternal(UUID uuid) Used in loading only.voidCreate a new town from the string name.voidnewTownInternal(String name, UUID uuid) voidnewWorld(@NotNull org.bukkit.World world) Causes a new TownyWorld object to be made in the Universe, from a Bukkit World.voidPerforms CleanupTask and BackupTask in async,voidregisterDistrict(District district) voidregisterGroup(PlotGroup group) voidregisterJail(Jail jail) voidregisterNation(@NotNull Nation nation) Used to register a nation into the TownyUniverse internal maps.voidregisterNationUUID(@NotNull Nation nation) voidregisterResident(@NotNull Resident resident) Register a resident into the internal structures.voidregisterResidentUUID(@NotNull Resident resident) voidregisterTown(@NotNull Town town) Used to register a town into the TownyUniverse internal maps.voidregisterTownUUID(@NotNull Town town) voidregisterTownyWorld(@NotNull TownyWorld world) voidvoidremoveSpawnPoint(org.bukkit.Location loc) voidremoveTownBlock(TownBlock townBlock) Remove one townblock from the TownyUniverse townblock map.voidremoveTownBlocks(List<TownBlock> townBlocks) Remove a list of TownBlocks from the TownyUniverse townblock map.voidsetPermissionSource(TownyPermissionSource permissionSource) voidunregisterDistrict(UUID uuid) voidunregisterGroup(UUID uuid) voidunregisterJail(Jail jail) voidunregisterNation(@NotNull Nation nation) Used to unregister a nation from the TownyUniverse internal maps.voidunregisterResident(@NotNull Resident resident) Unregister a resident from the internal structures.voidunregisterTown(@NotNull Town town) Used to unregister a town from the TownyUniverse internal maps.
-
Method Details
-
getInstance
-
performCleanupAndBackup
public void performCleanupAndBackup()Performs CleanupTask and BackupTask in async, -
clearAllObjects
public void clearAllObjects()Clears the object maps. -
finishTasks
public void finishTasks()Run during onDisable() to finish cleanup and backup. -
getDataSource
-
getPermissionSource
-
setPermissionSource
-
getRootFolder
-
hasResident
Check if a resident exists with the passed in name. Will return true for fake residents and registered NPCs.- Parameters:
residentName- Resident name to check for.- Returns:
- whether Towny has a resident matching that name.
-
hasResident
Check if a resident exists matching the passed in UUID.- Parameters:
residentUUID- UUID of the resident to check.- Returns:
- whether the resident matching the UUID exists.
-
getResident
Get the resident matching the passed in name. Any fake residents (not registered NPCs) will return a new instance of a resident on method call.- Parameters:
residentName- Name of the resident to fetch.- Returns:
- the resident matching the given name or
nullif no resident is found.
-
getResidentOpt
Get an optional instance of the resident matching the passed in name.- Parameters:
residentName- Name of the resident to fetch.- Returns:
- Optional object that may contain the resident matching the given name.
-
getResident
-
getResidentOpt
Get an optional object that may contain the resident with the passed-in UUID.- Parameters:
residentUUID- UUID of the resident to get.- Returns:
- an optional object that may contain the resident with the passed-in UUID.
-
registerResidentUUID
public void registerResidentUUID(@NotNull @NotNull Resident resident) throws AlreadyRegisteredException - Throws:
AlreadyRegisteredException
-
registerResident
Register a resident into the internal structures. This will allow the resident to be fetched by name and UUID, as well as autocomplete the resident name. If a resident's name or UUID change, the resident must be re-registered into the maps. This does not modify the resident internally, nor saves the resident in the database.- Parameters:
resident- Resident to register.- Throws:
AlreadyRegisteredException- if another resident has been registered with the same name or UUID.
-
unregisterResident
Unregister a resident from the internal structures. This does not modify the resident internally, nor performs any database operations using the resident.- Parameters:
resident- Resident to unregister- Throws:
NotRegisteredException- if the resident's name or UUID was not registered.
-
getResidents
-
getNumResidents
public int getNumResidents()- Returns:
- number of residents that Towny has.
-
getResidentsTrie
-
getJailedResidentMap
-
hasTown
-
hasTown
-
getTown
-
getTown
-
getTowns
-
getTownsTrie
-
newTownInternal
@Internal public void newTownInternal(String name, UUID uuid) throws AlreadyRegisteredException, InvalidNameException -
newTown
public void newTown(@NotNull @NotNull String name) throws AlreadyRegisteredException, InvalidNameException Create a new town from the string name.- Parameters:
name- Town name- Throws:
AlreadyRegisteredException- Town name is already in use.InvalidNameException- Town name is invalid.
-
registerTownUUID
- Throws:
AlreadyRegisteredException
-
registerTown
Used to register a town into the TownyUniverse internal maps. This does not create a new town, or save a new town.- Parameters:
town- Town to register.- Throws:
AlreadyRegisteredException- Town is already in the universe maps.
-
unregisterTown
Used to unregister a town from the TownyUniverse internal maps. This does not delete a town, nor perform any actions that affect the town internally.- Parameters:
town- Town to unregister- Throws:
NotRegisteredException- Town is not registered in the universe maps.
-
hasNation
Check if the nation matching the given name exists.- Parameters:
nationName- Name of the nation to check.- Returns:
- whether the nation matching the name exists.
-
hasNation
Check if the nation matching the given UUID exists.- Parameters:
nationUUID- UUID of the nation to check.- Returns:
- whether the nation matching the UUID exists.
-
getNation
-
getNation
-
getNations
-
getNumNations
public int getNumNations() -
registerNationUUID
- Throws:
AlreadyRegisteredException
-
registerNation
Used to register a nation into the TownyUniverse internal maps. This does not create a new nation, or save a new nation.- Parameters:
nation- Nation to register.- Throws:
AlreadyRegisteredException- Nation is already in the universe maps.
-
unregisterNation
Used to unregister a nation from the TownyUniverse internal maps. This does not delete a nation, nor perform any actions that affect the nation internally.- Parameters:
nation- Nation to unregister- Throws:
NotRegisteredException- Nation is not registered in the universe maps.
-
getNationsTrie
-
newWorld
public void newWorld(@NotNull @NotNull org.bukkit.World world) Causes a new TownyWorld object to be made in the Universe, from a Bukkit World. -
registerTownyWorld
-
getWorldIDMap
-
getWorld
-
getWorldUUIDs
-
getWorldMap
-
getWorld
-
getTownyWorlds
-
hasTownyWorld
-
getTreeString
-
newPlotGroupInternal
Used in loading only.- Parameters:
uuid- UUID to assign to the PlotGroup.
-
registerGroup
-
unregisterGroup
-
getGroups
Get all the plot object groups from all towns Returns a collection that does not reflect any group additions/removals- Returns:
- collection of PlotObjectGroup
-
getPlotGroupUUIDs
-
getGroup
-
newDistrictInternal
Used in loading only.- Parameters:
uuid- UUID to assign to the District.
-
registerDistrict
-
unregisterDistrict
-
getDistricts
Get all the districts from all towns Returns a collection that does not reflect any district additions/removals- Returns:
- collection of District
-
getDistrictUUIDs
-
getDistrict
-
addCustomCustomDataField
- Throws:
KeyAlreadyRegisteredException
-
getRegisteredMetadataMap
-
getRegisteredMetadata
-
getTownBlock
How to get a TownBlock for now.- Parameters:
worldCoord- we are testing for a townblock.- Returns:
- townblock if it exists, otherwise null.
- Throws:
NotRegisteredException- if there is no homeblock to get.
-
getTownBlockOrNull
-
getTownBlocks
Get Universe-wide ConcurrentHashMap of WorldCoords and their TownBlocks. Populated at load time from townblocks folder's files.- Returns:
- townblocks hashmap read from townblock files.
-
addTownBlock
-
hasTownBlock
Does this WorldCoord have a TownBlock?- Parameters:
worldCoord- - the coord for which we want to know if there is a townblock.- Returns:
- true if Coord is a townblock
-
removeTownBlock
Remove one townblock from the TownyUniverse townblock map.- Parameters:
townBlock- to remove.
-
removeTownBlocks
-
getSpawnPoints
-
getSpawnPoint
-
hasSpawnPoint
public boolean hasSpawnPoint(org.bukkit.Location loc) -
addSpawnPoint
-
removeSpawnPoint
public void removeSpawnPoint(org.bukkit.Location loc) -
removeSpawnPoint
-
getJails
-
getJailUUIDMap
-
getJail
-
hasJail
-
registerJail
-
unregisterJail
-
newJailInternal
Used in loading only.- Parameters:
uuid- UUID of the given jail, taken from the Jail filename.
-
getWildernessMapDataMap
-
getReplacementNameMap
-