Package com.palmergames.bukkit.towny
Class TownyUniverse
java.lang.Object
com.palmergames.bukkit.towny.TownyUniverse
Towny's class for internal API Methods
If you don't want to change the dataSource, war, permissions or similar behavior
and only for example want to get Resident objects you should use
TownyAPI
- Author:
- Articdive
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addSpawnPoint
(SpawnPoint spawn) void
addTownBlock
(TownBlock townBlock) void
Clears the object maps.void
Run during onDisable() to finish cleanup and backup.@Nullable District
getDistrict
(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 PlotGroup
Gets 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 Jail
getJails()
@Nullable Nation
Get the nation with the passed-in nation name if it exists.@Nullable Nation
Get the nation with the given UUID if it exists.@Unmodifiable Collection
<Nation> int
int
Map
<String, CustomDataField<?>> Map
<String, CustomDataField<?>> @Nullable Resident
getResident
(@NotNull String residentName) Get the resident matching the passed in name.@Nullable Resident
getResident
(@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 SpawnPoint
getSpawnPoint
(org.bukkit.Location loc) @Nullable Town
@Nullable Town
getTownBlock
(WorldCoord worldCoord) How to get a TownBlock for now.@Nullable TownBlock
getTownBlockOrNull
(WorldCoord worldCoord) Get Universe-wide ConcurrentHashMap of WorldCoords and their TownBlocks.@Unmodifiable Collection
<Town> getTowns()
getTreeString
(int depth) @Nullable TownyWorld
@Nullable TownyWorld
boolean
boolean
Check if the nation matching the given name exists.boolean
Check if the nation matching the given UUID exists.boolean
hasResident
(@NotNull String residentName) Check if a resident exists with the passed in name.boolean
hasResident
(@NotNull UUID residentUUID) Check if a resident exists matching the passed in UUID.boolean
hasSpawnPoint
(org.bukkit.Location loc) boolean
boolean
boolean
hasTownBlock
(WorldCoord worldCoord) Does this WorldCoord have a TownBlock?boolean
hasTownyWorld
(String worldName) void
newDistrictInternal
(UUID uuid) Used in loading only.void
newJailInternal
(String uuid) Used in loading only.void
newPlotGroupInternal
(UUID uuid) Used in loading only.void
Create a new town from the string name.void
newTownInternal
(String name) void
newWorld
(@NotNull org.bukkit.World world) Causes a new TownyWorld object to be made in the Universe, from a Bukkit World.void
Performs CleanupTask and BackupTask in async,void
registerDistrict
(District district) void
registerGroup
(PlotGroup group) void
registerJail
(Jail jail) void
registerNation
(@NotNull Nation nation) Used to register a nation into the TownyUniverse internal maps.void
registerNationUUID
(@NotNull Nation nation) void
registerResident
(@NotNull Resident resident) Register a resident into the internal structures.void
registerResidentUUID
(@NotNull Resident resident) void
registerTown
(@NotNull Town town) Used to register a town into the TownyUniverse internal maps.void
registerTownUUID
(@NotNull Town town) void
registerTownyWorld
(@NotNull TownyWorld world) void
void
removeSpawnPoint
(org.bukkit.Location loc) void
removeTownBlock
(TownBlock townBlock) Remove one townblock from the TownyUniverse townblock map.void
removeTownBlocks
(List<TownBlock> townBlocks) Remove a list of TownBlocks from the TownyUniverse townblock map.void
setPermissionSource
(TownyPermissionSource permissionSource) void
unregisterDistrict
(UUID uuid) void
unregisterGroup
(UUID uuid) void
unregisterJail
(Jail jail) void
unregisterNation
(@NotNull Nation nation) Used to unregister a nation from the TownyUniverse internal maps.void
unregisterResident
(@NotNull Resident resident) Unregister a resident from the internal structures.void
unregisterTown
(@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
null
if 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
Get the resident with the passed-in UUID.- Parameters:
residentUUID
- UUID of the resident to get.- Returns:
- the resident with the passed-in UUID or
null
if no resident is found.
-
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
-
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
Get the nation with the passed-in nation name if it exists.- Parameters:
nationName
- Name of the nation to fetch.- Returns:
- the nation matching the name or
null
if it doesn't exist.
-
getNation
Get the nation with the given UUID if it exists.- Parameters:
nationUUID
- UUID of the nation to get.- Returns:
- the nation with the given UUID or
null
if it doesn't exist.
-
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
Gets the plot group from the town name and the plot group UUID- Parameters:
groupID
- UUID of the plot group- Returns:
- PlotGroup if found, null if none found.
-
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
Gets the district from the town name and the district UUID- Parameters:
districtID
- UUID of the district- Returns:
- District if found, null if none found.
-
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
Remove a list of TownBlocks from the TownyUniverse townblock map.- Parameters:
townBlocks
- to remove.
-
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
-