Package com.palmergames.bukkit.towny.db
Class TownyDatabaseHandler
java.lang.Object
com.palmergames.bukkit.towny.db.TownyDataSource
com.palmergames.bukkit.towny.db.TownyDatabaseHandler
- Direct Known Subclasses:
TownyFlatFileSource
,TownySQLSource
- Author:
- ElgarL
-
Field Summary
Fields inherited from class com.palmergames.bukkit.towny.db.TownyDataSource
plugin, universe
-
Constructor Summary
ModifierConstructorDescriptionprotected
TownyDatabaseHandler
(Towny plugin, TownyUniverse universe) -
Method Summary
Modifier and TypeMethodDescriptionboolean
backup()
void
deleteFile
(String fileName) void
deletePlotData
(PlotBlockData plotChunk) void
generateReplacementName
(boolean town) Generates a town or nation replacementname.getLegacyPlotFilename
(TownBlock townBlock) boolean
hasPlotData
(TownBlock townBlock) loadPlotData
(TownBlock townBlock) Load PlotBlockData for regen at unclaim First attempts to load a .zip file containing the data file.loadPlotData
(String worldName, int x, int z) Load PlotBlockDataboolean
void
mergeNation
(Nation succumbingNation, Nation prevailingNation) Merges the succumbingNation into the prevailingNation.void
Merges the mergeFrom town into the mergeInto town.void
void
@NotNull Resident
newResident
(String name) @NotNull Resident
newResident
(String name, UUID uuid) void
void
removeJail
(Jail jail) boolean
removeNation
(@NotNull Nation nation, DeleteNationEvent.Cause cause, @Nullable org.bukkit.command.CommandSender sender) void
removePlotGroup
(PlotGroup group) void
removeResident
(Resident resident) boolean
removeTown
(@NotNull Town town, DeleteTownEvent.Cause cause, @Nullable org.bukkit.command.CommandSender sender, boolean delayFullRemoval) void
removeTownBlock
(TownBlock townBlock) void
removeTownBlocks
(Town town) void
removeWorld
(TownyWorld world) void
renameGroup
(PlotGroup group, String newName) void
renameNation
(Nation nation, String newName) void
renamePlayer
(Resident resident, String newName) void
renameTown
(Town town, String newName) boolean
savePlotData
(PlotBlockData plotChunk) Save PlotBlockDataboolean
protected final String
UUID[]
toUUIDArray
(String[] uuidArray) toUUIDList
(Collection<Resident> residents) Methods inherited from class com.palmergames.bukkit.towny.db.TownyDataSource
cleanup, deleteHibernatedResident, deleteJail, deleteNation, deletePlotGroup, deleteResident, deleteTown, deleteTownBlock, deleteWorld, getHibernatedResidentRegistered, loadAll, loadCooldowns, loadJail, loadJailList, loadJails, loadNation, loadNationList, loadNations, loadPlotGroup, loadPlotGroupList, loadPlotGroups, loadResident, loadResidentList, loadResidents, loadTown, loadTownBlockList, loadTownBlocks, loadTownList, loadTowns, loadWorld, loadWorldList, loadWorlds, removeNation, removeNation, removeTown, removeTown, removeTown, saveAll, saveAllWorlds, saveCooldowns, saveHibernatedResident, saveJail, saveJails, saveNation, saveNations, savePlotGroup, savePlotGroups, saveQueues, saveResident, saveResidents, saveTown, saveTownBlock, saveTownBlocks, saveTowns, saveWorld, saveWorlds
-
Field Details
-
BACKUP_DATE_FORMAT
-
queryQueue
-
-
Constructor Details
-
TownyDatabaseHandler
-
-
Method Details
-
finishTasks
public void finishTasks()- Specified by:
finishTasks
in classTownyDataSource
-
backup
- Specified by:
backup
in classTownyDataSource
- Throws:
IOException
-
newResident
@NotNull public @NotNull Resident newResident(String name) throws AlreadyRegisteredException, NotRegisteredException - Specified by:
newResident
in classTownyDataSource
- Throws:
AlreadyRegisteredException
NotRegisteredException
-
newResident
@NotNull public @NotNull Resident newResident(String name, UUID uuid) throws AlreadyRegisteredException, NotRegisteredException - Specified by:
newResident
in classTownyDataSource
- Throws:
AlreadyRegisteredException
NotRegisteredException
-
newNation
- Specified by:
newNation
in classTownyDataSource
- Throws:
AlreadyRegisteredException
NotRegisteredException
-
newNation
public void newNation(String name, @Nullable @Nullable UUID uuid) throws AlreadyRegisteredException, NotRegisteredException - Specified by:
newNation
in classTownyDataSource
- Throws:
AlreadyRegisteredException
NotRegisteredException
-
newWorld
- Specified by:
newWorld
in classTownyDataSource
- Throws:
AlreadyRegisteredException
-
removeResident
- Specified by:
removeResident
in classTownyDataSource
-
removeTownBlock
- Specified by:
removeTownBlock
in classTownyDataSource
-
removeTownBlocks
- Specified by:
removeTownBlocks
in classTownyDataSource
-
removeTown
public boolean removeTown(@NotNull @NotNull Town town, @NotNull DeleteTownEvent.Cause cause, @Nullable @Nullable org.bukkit.command.CommandSender sender, boolean delayFullRemoval) - Specified by:
removeTown
in classTownyDataSource
-
removeNation
public boolean removeNation(@NotNull @NotNull Nation nation, @NotNull DeleteNationEvent.Cause cause, @Nullable @Nullable org.bukkit.command.CommandSender sender) - Specified by:
removeNation
in classTownyDataSource
-
removeWorld
- Specified by:
removeWorld
in classTownyDataSource
- Throws:
UnsupportedOperationException
-
removeJail
- Specified by:
removeJail
in classTownyDataSource
-
removePlotGroup
- Specified by:
removePlotGroup
in classTownyDataSource
-
renameTown
public void renameTown(Town town, String newName) throws AlreadyRegisteredException, NotRegisteredException - Specified by:
renameTown
in classTownyDataSource
- Throws:
AlreadyRegisteredException
NotRegisteredException
-
renameNation
public void renameNation(Nation nation, String newName) throws AlreadyRegisteredException, NotRegisteredException - Specified by:
renameNation
in classTownyDataSource
- Throws:
AlreadyRegisteredException
NotRegisteredException
-
renameGroup
- Specified by:
renameGroup
in classTownyDataSource
- Throws:
AlreadyRegisteredException
-
renamePlayer
public void renamePlayer(Resident resident, String newName) throws AlreadyRegisteredException, NotRegisteredException - Specified by:
renamePlayer
in classTownyDataSource
- Throws:
AlreadyRegisteredException
NotRegisteredException
-
savePlotData
Save PlotBlockData- Specified by:
savePlotData
in classTownyDataSource
- Parameters:
plotChunk
- - Plot for data to be saved for.- Returns:
- true if saved
-
loadPlotData
Load PlotBlockData- Specified by:
loadPlotData
in classTownyDataSource
- Parameters:
worldName
- - World in which to load PlotBlockData for.x
- - Coordinate for X.z
- - Coordinate for Z.- Returns:
- PlotBlockData or null
-
loadPlotData
Load PlotBlockData for regen at unclaim First attempts to load a .zip file containing the data file. Fallback attempts to load old .data files instead. Once it finds a zip or data file it will send it to be unpacked byloadDataStream(PlotBlockData, InputStream)
which will return the populated PlotBlockData object.- Specified by:
loadPlotData
in classTownyDataSource
- Parameters:
townBlock
- - townBlock being reverted- Returns:
- PlotBlockData or null
-
deletePlotData
- Specified by:
deletePlotData
in classTownyDataSource
-
hasPlotData
- Specified by:
hasPlotData
in classTownyDataSource
-
getLegacyPlotFilename
-
loadRegenList
public boolean loadRegenList()- Specified by:
loadRegenList
in classTownyDataSource
-
serializeMetadata
-
saveRegenList
public boolean saveRegenList()- Specified by:
saveRegenList
in classTownyDataSource
-
deleteFile
- Specified by:
deleteFile
in classTownyDataSource
-
mergeNation
Merges the succumbingNation into the prevailingNation.- Specified by:
mergeNation
in classTownyDataSource
- Parameters:
succumbingNation
- - Nation to be removed, towns put into prevailingNation.prevailingNation
- - Nation which survives, absorbs other nation's towns.
-
mergeTown
Merges the mergeFrom town into the mergeInto town.- Specified by:
mergeTown
in classTownyDataSource
- Parameters:
mergeInto
- The town that the other town merges into.mergeFrom
- The town that will be deleted.
-
toUUIDList
-
toUUIDArray
-
generateReplacementName
Generates a town or nation replacementname. i.e.: Town1 or Nation2- Parameters:
town
- Boolean for whether it's a town or a nation we're creating a name for.- Returns:
- replacementName String.
-