Package com.plotsquared.core.database
Class SQLManager
java.lang.Object
com.plotsquared.core.database.SQLManager
- All Implemented Interfaces:
AbstractDB
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptioncluster cluster_helpers cluster_invited cluster_settingsfinal Stringfinal Stringfinal Stringfinal Stringfinal Stringfinal Stringfinal Stringimportant tasksNotify tasksplayer_metaplot plot_denied plot_helpers plot_trusted plot_comments plot_settings plot_ratingfinal StringFields inherited from interface com.plotsquared.core.database.AbstractDB
everyone -
Constructor Summary
ConstructorsConstructorDescriptionSQLManager(@NonNull Database database, @NonNull String prefix, @NonNull EventDispatcher eventDispatcher, @NonNull PlotListener plotListener, @NonNull YamlConfiguration worldConfiguration) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClusterTask(PlotCluster cluster, SQLManager.UniqueStatement task) voidaddGlobalTask(Runnable task) voidaddNotifyTask(Runnable task) voidaddPersistentMeta(UUID uuid, String key, byte[] meta, boolean replace) voidaddPlayerTask(UUID uuid, SQLManager.UniqueStatement task) voidaddPlotTask(@NonNull Plot plot, SQLManager.UniqueStatement task) voidclearInbox(Plot plot, String inbox) Clears the specified inbox on the given plot.voidclose()Closes the database.voidcommit()booleanvoidcreateCluster(PlotCluster cluster) voidcreateEmptySettings(ArrayList<Integer> myList, Runnable whenDone) voidvoidcreatePlotAndSettings(Plot plot, Runnable whenDone) voidcreatePlots(List<Plot> myList, Runnable whenDone) Create a plotvoidcreatePlotSafe(Plot plot, Runnable success, Runnable failure) Creates a plot.voidcreatePlotsAndData(List<Plot> myList, Runnable whenDone) Creates all settings, and create default helpers, trusted + denied lists.voidcreatePlotSettings(int id, Plot plot) Creates plot settingsvoidcreateSettings(ArrayList<com.plotsquared.core.database.SQLManager.LegacySettings> myList, Runnable whenDone) voidCreate tables.voidcreateTiers(ArrayList<com.plotsquared.core.database.SQLManager.UUIDPair> myList, String tier, Runnable whenDone) Create a plotvoidDelete a plot.voiddelete(PlotCluster cluster) voiddeleteComments(Plot plot) Deletes all comments from the plot.voiddeleteDenied(Plot plot) Removes all denied players from the plot.voiddeleteHelpers(Plot plot) voiddeleteRatings(Plot plot) voiddeleteRows(ArrayList<Integer> rowIds, String table, String column) voiddeleteSettings(Plot plot) booleanDon't use this method unless you want to ruin someone's server.voiddeleteTrusted(Plot plot) intgetClusterId(PlotCluster cluster) Gets the id of a given plot cluster.voidgetComments(@NonNull Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) Gets Plot comments.intGets the table entry ID.voidgetPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result) getPlots()Load all plots, helpers, denied, trusted, and every setting from DB into aHashMap.getRatings(Plot plot) Gets the ratings from the specified plot.booleanisValid()voidvoidPurges a whole world.voidPurge all plots with the following database IDsvoidvoidremoveComment(Plot plot, PlotComment comment) Removes the specified comment from the given plot.voidremoveDenied(Plot plot, UUID uuid) Removes the specified player from the denied list of the specified plot.voidremoveFlag(Plot plot, PlotFlag<?, ?> flag) Remove a plot flag.voidremoveHelper(PlotCluster cluster, UUID uuid) voidremoveInvited(PlotCluster cluster, UUID uuid) voidremoveMember(Plot plot, UUID uuid) voidremovePersistentMeta(UUID uuid, String key) voidremoveTrusted(Plot plot, UUID uuid) Remove the specified player from the trust list of the specified plot.voidreplaceUUID(UUID old, UUID now) Replaces a old uuid with a new one in the database.voidreplaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max) voidresizeCluster(PlotCluster current, PlotId min, PlotId max) booleanvoidSets the plot alias.<T> voidvoidsetClusterName(PlotCluster cluster, String name) Renames a cluster to the given name.voidsetComment(Plot plot, PlotComment comment) Adds the specified comment to the given plot.voidDenies the specified player from the given plot.voidSets plot flag.voidsetHelper(PlotCluster cluster, UUID uuid) voidsetInvited(PlotCluster cluster, UUID uuid) voidvoidSets the merged status for a plot.voidSet Plot ownervoidsetPosition(PlotCluster cluster, String position) voidsetPosition(Plot plot, String position) Sets the plot home position.voidSets a rating for a plot.voidsetTrusted(Plot plot, UUID uuid) Swaps the settings, helpers etc.voidupdateTables(int[] oldVersion) voidvalidateAllPlots(Set<Plot> toValidate)
-
Field Details
-
SET_OWNER
-
GET_ALL_PLOTS
-
CREATE_PLOTS
-
CREATE_SETTINGS
-
CREATE_TIERS
-
CREATE_PLOT
-
CREATE_PLOT_SAFE
-
CREATE_CLUSTER
-
globalTasks
important tasks -
notifyTasks
Notify tasks -
plotTasks
plot plot_denied plot_helpers plot_trusted plot_comments plot_settings plot_rating -
playerTasks
player_meta -
clusterTasks
cluster cluster_helpers cluster_invited cluster_settings
-
-
Constructor Details
-
SQLManager
public SQLManager(@NonNull Database database, @NonNull String prefix, @NonNull EventDispatcher eventDispatcher, @NonNull PlotListener plotListener, @NonNull YamlConfiguration worldConfiguration) throws SQLException, ClassNotFoundException Constructor- Parameters:
database-prefix- prefix- Throws:
SQLExceptionClassNotFoundException
-
-
Method Details
-
isValid
public boolean isValid() -
reconnect
public void reconnect() -
getGlobalTasks
-
getNotifyTasks
-
addPlotTask
-
addPlayerTask
-
addClusterTask
-
addGlobalTask
-
addNotifyTask
-
sendBatch
public boolean sendBatch() -
getConnection
-
setOwner
Set Plot owner- Specified by:
setOwnerin interfaceAbstractDB- Parameters:
plot- Plot Objectuuid- Owner UUID
-
createPlotsAndData
Description copied from interface:AbstractDBCreates all settings, and create default helpers, trusted + denied lists.- Specified by:
createPlotsAndDatain interfaceAbstractDB- Parameters:
myList- Plots for which the default table entries should be createdwhenDone- the task to run when the method is finished executing
-
createTiers
public void createTiers(ArrayList<com.plotsquared.core.database.SQLManager.UUIDPair> myList, String tier, Runnable whenDone) Create a plot- Parameters:
myList- list of plots to be created
-
createFlags
-
createPlots
Create a plot- Parameters:
myList- list of plots to be created
-
setBulk
-
createSettings
-
createEmptySettings
-
createPlotSafe
Description copied from interface:AbstractDBCreates a plot.- Specified by:
createPlotSafein interfaceAbstractDB- Parameters:
plot- the plot to create
-
commit
public void commit() -
createPlotAndSettings
- Specified by:
createPlotAndSettingsin interfaceAbstractDB
-
createTables
Create tables.- Specified by:
createTablesin interfaceAbstractDB- Throws:
SQLException
-
deleteSettings
- Specified by:
deleteSettingsin interfaceAbstractDB
-
deleteHelpers
- Specified by:
deleteHelpersin interfaceAbstractDB
-
deleteTrusted
- Specified by:
deleteTrustedin interfaceAbstractDB
-
deleteDenied
Description copied from interface:AbstractDBRemoves all denied players from the plot.- Specified by:
deleteDeniedin interfaceAbstractDB- Parameters:
plot- the plot
-
deleteComments
Description copied from interface:AbstractDBDeletes all comments from the plot.- Specified by:
deleteCommentsin interfaceAbstractDB- Parameters:
plot- the plot
-
deleteRatings
- Specified by:
deleteRatingsin interfaceAbstractDB
-
delete
Delete a plot.- Specified by:
deletein interfaceAbstractDB- Parameters:
plot-
-
createPlotSettings
Creates plot settings- Specified by:
createPlotSettingsin interfaceAbstractDB- Parameters:
id-plot-
-
getClusterId
Description copied from interface:AbstractDBGets the id of a given plot cluster.- Specified by:
getClusterIdin interfaceAbstractDB- Parameters:
cluster- PlotCluster Object- Returns:
- Integer = Cluster Entry Id
-
getId
Description copied from interface:AbstractDBGets the table entry ID.- Specified by:
getIdin interfaceAbstractDB- Parameters:
plot- the plot- Returns:
Integer= Plot Entry Id
-
updateTables
public void updateTables(int[] oldVersion) - Specified by:
updateTablesin interfaceAbstractDB
-
deleteRows
-
convertFlags
public boolean convertFlags()- Specified by:
convertFlagsin interfaceAbstractDB
-
getPlots
Load all plots, helpers, denied, trusted, and every setting from DB into aHashMap.- Specified by:
getPlotsin interfaceAbstractDB- Returns:
- A linked HashMap containing all plots
-
setMerged
Description copied from interface:AbstractDBSets the merged status for a plot.- Specified by:
setMergedin interfaceAbstractDB- Parameters:
plot- The plot to set the merged status ofmerged- boolean[]
-
swapPlots
Description copied from interface:AbstractDBSwaps the settings, helpers etc. of two plots.- Specified by:
swapPlotsin interfaceAbstractDB- Parameters:
plot1- Plot1plot2- Plot2
-
movePlot
- Specified by:
movePlotin interfaceAbstractDB
-
setFlag
Description copied from interface:AbstractDBSets plot flag.- Specified by:
setFlagin interfaceAbstractDB- Parameters:
plot- Plot Objectflag- Flag to set
-
removeFlag
Description copied from interface:AbstractDBRemove a plot flag.- Specified by:
removeFlagin interfaceAbstractDB- Parameters:
plot- Plot Objectflag- Flag to remove
-
setAlias
Description copied from interface:AbstractDBSets the plot alias.- Specified by:
setAliasin interfaceAbstractDB- Parameters:
plot- Plot for which the alias should be setalias- Plot Alias
-
purgeIds
Purge all plots with the following database IDs- Specified by:
purgeIdsin interfaceAbstractDB- Parameters:
uniqueIds- list of plot id (db) to be purged
-
purge
Description copied from interface:AbstractDBPurges a whole world.- Specified by:
purgein interfaceAbstractDB- Parameters:
area- World in which the plots should be purgedplots- thePlotIds ofPlots to purge
-
setPosition
Description copied from interface:AbstractDBSets the plot home position.- Specified by:
setPositionin interfaceAbstractDB- Parameters:
plot- the plotposition- the position of plot home
-
removeComment
Description copied from interface:AbstractDBRemoves the specified comment from the given plot.- Specified by:
removeCommentin interfaceAbstractDB- Parameters:
plot- the plotcomment- the comment to remove
-
clearInbox
Description copied from interface:AbstractDBClears the specified inbox on the given plot.- Specified by:
clearInboxin interfaceAbstractDB- Parameters:
plot- the plotinbox- the inbox to clear
-
getComments
Description copied from interface:AbstractDBGets Plot comments.- Specified by:
getCommentsin interfaceAbstractDB- Parameters:
plot- The Plot to get comments from
-
setComment
Description copied from interface:AbstractDBAdds the specified comment to the given plot.- Specified by:
setCommentin interfaceAbstractDB- Parameters:
plot- the plotcomment- the comment to add
-
removeTrusted
Description copied from interface:AbstractDBRemove the specified player from the trust list of the specified plot.- Specified by:
removeTrustedin interfaceAbstractDB- Parameters:
plot- the plotuuid- the uuid of the player to remove
-
removeMember
- Specified by:
removeMemberin interfaceAbstractDB- Parameters:
plot- the plotuuid- Player that should be removed
-
setTrusted
- Specified by:
setTrustedin interfaceAbstractDB- Parameters:
plot- Plot Objectuuid- Player that should be removed
-
setMember
- Specified by:
setMemberin interfaceAbstractDB- Parameters:
plot- Plot Objectuuid- Player that should be added
-
removeDenied
Description copied from interface:AbstractDBRemoves the specified player from the denied list of the specified plot.- Specified by:
removeDeniedin interfaceAbstractDB- Parameters:
plot- the plotuuid- the uuid of the player to remove
-
setDenied
Description copied from interface:AbstractDBDenies the specified player from the given plot.- Specified by:
setDeniedin interfaceAbstractDB- Parameters:
plot- the plotuuid- the uuid of the player to deny
-
getRatings
Description copied from interface:AbstractDBGets the ratings from the specified plot.- Specified by:
getRatingsin interfaceAbstractDB- Parameters:
plot- the plot- Returns:
- the plot ratings (pre-calculated)
-
setRating
Description copied from interface:AbstractDBSets a rating for a plot.- Specified by:
setRatingin interfaceAbstractDB
-
delete
- Specified by:
deletein interfaceAbstractDB
-
addPersistentMeta
- Specified by:
addPersistentMetain interfaceAbstractDB
-
removePersistentMeta
- Specified by:
removePersistentMetain interfaceAbstractDB
-
getPersistentMeta
- Specified by:
getPersistentMetain interfaceAbstractDB
-
getClusters
- Specified by:
getClustersin interfaceAbstractDB- Returns:
- A HashMap containing all plot clusters
-
setClusterName
Description copied from interface:AbstractDBRenames a cluster to the given name.- Specified by:
setClusterNamein interfaceAbstractDB- Parameters:
cluster- the cluster to renamename- the new cluster name
-
removeHelper
- Specified by:
removeHelperin interfaceAbstractDB- Parameters:
cluster- PlotCluster Objectuuid- Player that should be removed
-
setHelper
- Specified by:
setHelperin interfaceAbstractDB- Parameters:
cluster- PlotCluster Objectuuid- Player that should be removed
-
createCluster
- Specified by:
createClusterin interfaceAbstractDB
-
resizeCluster
- Specified by:
resizeClusterin interfaceAbstractDB
-
setPosition
- Specified by:
setPositionin interfaceAbstractDB
-
removeInvited
- Specified by:
removeInvitedin interfaceAbstractDB
-
setInvited
- Specified by:
setInvitedin interfaceAbstractDB
-
deleteTables
public boolean deleteTables()Description copied from interface:AbstractDBDon't use this method unless you want to ruin someone's server.- Specified by:
deleteTablesin interfaceAbstractDB- Returns:
trueif the tables were deleted,falsewhen an error is encountered
-
validateAllPlots
- Specified by:
validateAllPlotsin interfaceAbstractDB
-
replaceWorld
- Specified by:
replaceWorldin interfaceAbstractDB
-
replaceUUID
Description copied from interface:AbstractDBReplaces a old uuid with a new one in the database.- Useful for replacing a few uuids (not the entire database).
- or entire conversion, the uuidconvert command scales better.
- Specified by:
replaceUUIDin interfaceAbstractDB
-
close
public void close()Description copied from interface:AbstractDBCloses the database. Generally not recommended to be used by add-ons.- Specified by:
closein interfaceAbstractDB
-