Package com.plotsquared.core.database
Class SQLManager
java.lang.Object
com.plotsquared.core.database.SQLManager
- All Implemented Interfaces:
AbstractDB
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptioncluster cluster_helpers cluster_invited cluster_settingsfinal String
final String
final String
final String
final String
final String
final String
important tasksNotify tasksplayer_metaplot plot_denied plot_helpers plot_trusted plot_comments plot_settings plot_ratingfinal String
Fields inherited from interface com.plotsquared.core.database.AbstractDB
everyone
-
Constructor Summary
ConstructorDescriptionSQLManager
(@NonNull Database database, @NonNull String prefix, @NonNull EventDispatcher eventDispatcher, @NonNull PlotListener plotListener, @NonNull YamlConfiguration worldConfiguration) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClusterTask
(PlotCluster cluster, SQLManager.UniqueStatement task) void
addGlobalTask
(Runnable task) void
addNotifyTask
(Runnable task) void
addPersistentMeta
(UUID uuid, String key, byte[] meta, boolean replace) void
addPlayerTask
(UUID uuid, SQLManager.UniqueStatement task) void
addPlotTask
(@NonNull Plot plot, SQLManager.UniqueStatement task) void
clearInbox
(Plot plot, String inbox) Clears the specified inbox on the given plot.void
close()
Closes the database.void
commit()
boolean
void
createCluster
(PlotCluster cluster) void
createEmptySettings
(ArrayList<Integer> myList, Runnable whenDone) void
void
createPlotAndSettings
(Plot plot, Runnable whenDone) void
createPlots
(List<Plot> myList, Runnable whenDone) Create a plotvoid
createPlotSafe
(Plot plot, Runnable success, Runnable failure) Creates a plot.void
createPlotsAndData
(List<Plot> myList, Runnable whenDone) Creates all settings, and create default helpers, trusted + denied lists.void
createPlotSettings
(int id, Plot plot) Creates plot settingsvoid
createSettings
(ArrayList<com.plotsquared.core.database.SQLManager.LegacySettings> myList, Runnable whenDone) void
Create tables.void
createTiers
(ArrayList<com.plotsquared.core.database.SQLManager.UUIDPair> myList, String tier, Runnable whenDone) Create a plotvoid
Delete a plot.void
delete
(PlotCluster cluster) void
deleteComments
(Plot plot) Deletes all comments from the plot.void
deleteDenied
(Plot plot) Removes all denied players from the plot.void
deleteHelpers
(Plot plot) void
deleteRatings
(Plot plot) void
deleteRows
(ArrayList<Integer> rowIds, String table, String column) void
deleteSettings
(Plot plot) boolean
Don't use this method unless you want to ruin someone's server.void
deleteTrusted
(Plot plot) int
getClusterId
(PlotCluster cluster) Gets the id of a given plot cluster.void
getComments
(@NonNull Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) Gets Plot comments.int
Gets the table entry ID.void
getPersistentMeta
(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.boolean
isValid()
void
void
Purges a whole world.void
Purge all plots with the following database IDsvoid
void
removeComment
(Plot plot, PlotComment comment) Removes the specified comment from the given plot.void
removeDenied
(Plot plot, UUID uuid) Removes the specified player from the denied list of the specified plot.void
removeFlag
(Plot plot, PlotFlag<?, ?> flag) Remove a plot flag.void
removeHelper
(PlotCluster cluster, UUID uuid) void
removeInvited
(PlotCluster cluster, UUID uuid) void
removeMember
(Plot plot, UUID uuid) void
removePersistentMeta
(UUID uuid, String key) void
removeTrusted
(Plot plot, UUID uuid) Remove the specified player from the trust list of the specified plot.void
replaceUUID
(UUID old, UUID now) Replaces a old uuid with a new one in the database.void
replaceWorld
(String oldWorld, String newWorld, PlotId min, PlotId max) void
resizeCluster
(PlotCluster current, PlotId min, PlotId max) boolean
void
Sets the plot alias.<T> void
void
setClusterName
(PlotCluster cluster, String name) Renames a cluster to the given name.void
setComment
(Plot plot, PlotComment comment) Adds the specified comment to the given plot.void
Denies the specified player from the given plot.void
Sets plot flag.void
setHelper
(PlotCluster cluster, UUID uuid) void
setInvited
(PlotCluster cluster, UUID uuid) void
void
Sets the merged status for a plot.void
Set Plot ownervoid
setPosition
(PlotCluster cluster, String position) void
setPosition
(Plot plot, String position) Sets the plot home position.void
Sets a rating for a plot.void
setTrusted
(Plot plot, UUID uuid) Swaps the settings, helpers etc.void
updateTables
(int[] oldVersion) void
validateAllPlots
(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:
SQLException
ClassNotFoundException
-
-
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:
setOwner
in interfaceAbstractDB
- Parameters:
plot
- Plot Objectuuid
- Owner UUID
-
createPlotsAndData
Description copied from interface:AbstractDB
Creates all settings, and create default helpers, trusted + denied lists.- Specified by:
createPlotsAndData
in 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:AbstractDB
Creates a plot.- Specified by:
createPlotSafe
in interfaceAbstractDB
- Parameters:
plot
- the plot to create
-
commit
public void commit() -
createPlotAndSettings
- Specified by:
createPlotAndSettings
in interfaceAbstractDB
-
createTables
Create tables.- Specified by:
createTables
in interfaceAbstractDB
- Throws:
SQLException
-
deleteSettings
- Specified by:
deleteSettings
in interfaceAbstractDB
-
deleteHelpers
- Specified by:
deleteHelpers
in interfaceAbstractDB
-
deleteTrusted
- Specified by:
deleteTrusted
in interfaceAbstractDB
-
deleteDenied
Description copied from interface:AbstractDB
Removes all denied players from the plot.- Specified by:
deleteDenied
in interfaceAbstractDB
- Parameters:
plot
- the plot
-
deleteComments
Description copied from interface:AbstractDB
Deletes all comments from the plot.- Specified by:
deleteComments
in interfaceAbstractDB
- Parameters:
plot
- the plot
-
deleteRatings
- Specified by:
deleteRatings
in interfaceAbstractDB
-
delete
Delete a plot.- Specified by:
delete
in interfaceAbstractDB
- Parameters:
plot
-
-
createPlotSettings
Creates plot settings- Specified by:
createPlotSettings
in interfaceAbstractDB
- Parameters:
id
-plot
-
-
getClusterId
Description copied from interface:AbstractDB
Gets the id of a given plot cluster.- Specified by:
getClusterId
in interfaceAbstractDB
- Parameters:
cluster
- PlotCluster Object- Returns:
- Integer = Cluster Entry Id
-
getId
Description copied from interface:AbstractDB
Gets the table entry ID.- Specified by:
getId
in interfaceAbstractDB
- Parameters:
plot
- the plot- Returns:
Integer
= Plot Entry Id
-
updateTables
public void updateTables(int[] oldVersion) - Specified by:
updateTables
in interfaceAbstractDB
-
deleteRows
-
convertFlags
public boolean convertFlags()- Specified by:
convertFlags
in interfaceAbstractDB
-
getPlots
Load all plots, helpers, denied, trusted, and every setting from DB into aHashMap
.- Specified by:
getPlots
in interfaceAbstractDB
- Returns:
- A linked HashMap containing all plots
-
setMerged
Description copied from interface:AbstractDB
Sets the merged status for a plot.- Specified by:
setMerged
in interfaceAbstractDB
- Parameters:
plot
- The plot to set the merged status ofmerged
- boolean[]
-
swapPlots
Description copied from interface:AbstractDB
Swaps the settings, helpers etc. of two plots.- Specified by:
swapPlots
in interfaceAbstractDB
- Parameters:
plot1
- Plot1plot2
- Plot2
-
movePlot
- Specified by:
movePlot
in interfaceAbstractDB
-
setFlag
Description copied from interface:AbstractDB
Sets plot flag.- Specified by:
setFlag
in interfaceAbstractDB
- Parameters:
plot
- Plot Objectflag
- Flag to set
-
removeFlag
Description copied from interface:AbstractDB
Remove a plot flag.- Specified by:
removeFlag
in interfaceAbstractDB
- Parameters:
plot
- Plot Objectflag
- Flag to remove
-
setAlias
Description copied from interface:AbstractDB
Sets the plot alias.- Specified by:
setAlias
in interfaceAbstractDB
- Parameters:
plot
- Plot for which the alias should be setalias
- Plot Alias
-
purgeIds
Purge all plots with the following database IDs- Specified by:
purgeIds
in interfaceAbstractDB
- Parameters:
uniqueIds
- list of plot id (db) to be purged
-
purge
Description copied from interface:AbstractDB
Purges a whole world.- Specified by:
purge
in interfaceAbstractDB
- Parameters:
area
- World in which the plots should be purgedplots
- thePlotId
s ofPlot
s to purge
-
setPosition
Description copied from interface:AbstractDB
Sets the plot home position.- Specified by:
setPosition
in interfaceAbstractDB
- Parameters:
plot
- the plotposition
- the position of plot home
-
removeComment
Description copied from interface:AbstractDB
Removes the specified comment from the given plot.- Specified by:
removeComment
in interfaceAbstractDB
- Parameters:
plot
- the plotcomment
- the comment to remove
-
clearInbox
Description copied from interface:AbstractDB
Clears the specified inbox on the given plot.- Specified by:
clearInbox
in interfaceAbstractDB
- Parameters:
plot
- the plotinbox
- the inbox to clear
-
getComments
Description copied from interface:AbstractDB
Gets Plot comments.- Specified by:
getComments
in interfaceAbstractDB
- Parameters:
plot
- The Plot to get comments from
-
setComment
Description copied from interface:AbstractDB
Adds the specified comment to the given plot.- Specified by:
setComment
in interfaceAbstractDB
- Parameters:
plot
- the plotcomment
- the comment to add
-
removeTrusted
Description copied from interface:AbstractDB
Remove the specified player from the trust list of the specified plot.- Specified by:
removeTrusted
in interfaceAbstractDB
- Parameters:
plot
- the plotuuid
- the uuid of the player to remove
-
removeMember
- Specified by:
removeMember
in interfaceAbstractDB
- Parameters:
plot
- the plotuuid
- Player that should be removed
-
setTrusted
- Specified by:
setTrusted
in interfaceAbstractDB
- Parameters:
plot
- Plot Objectuuid
- Player that should be removed
-
setMember
- Specified by:
setMember
in interfaceAbstractDB
- Parameters:
plot
- Plot Objectuuid
- Player that should be added
-
removeDenied
Description copied from interface:AbstractDB
Removes the specified player from the denied list of the specified plot.- Specified by:
removeDenied
in interfaceAbstractDB
- Parameters:
plot
- the plotuuid
- the uuid of the player to remove
-
setDenied
Description copied from interface:AbstractDB
Denies the specified player from the given plot.- Specified by:
setDenied
in interfaceAbstractDB
- Parameters:
plot
- the plotuuid
- the uuid of the player to deny
-
getRatings
Description copied from interface:AbstractDB
Gets the ratings from the specified plot.- Specified by:
getRatings
in interfaceAbstractDB
- Parameters:
plot
- the plot- Returns:
- the plot ratings (pre-calculated)
-
setRating
Description copied from interface:AbstractDB
Sets a rating for a plot.- Specified by:
setRating
in interfaceAbstractDB
-
delete
- Specified by:
delete
in interfaceAbstractDB
-
addPersistentMeta
- Specified by:
addPersistentMeta
in interfaceAbstractDB
-
removePersistentMeta
- Specified by:
removePersistentMeta
in interfaceAbstractDB
-
getPersistentMeta
- Specified by:
getPersistentMeta
in interfaceAbstractDB
-
getClusters
- Specified by:
getClusters
in interfaceAbstractDB
- Returns:
- A HashMap containing all plot clusters
-
setClusterName
Description copied from interface:AbstractDB
Renames a cluster to the given name.- Specified by:
setClusterName
in interfaceAbstractDB
- Parameters:
cluster
- the cluster to renamename
- the new cluster name
-
removeHelper
- Specified by:
removeHelper
in interfaceAbstractDB
- Parameters:
cluster
- PlotCluster Objectuuid
- Player that should be removed
-
setHelper
- Specified by:
setHelper
in interfaceAbstractDB
- Parameters:
cluster
- PlotCluster Objectuuid
- Player that should be removed
-
createCluster
- Specified by:
createCluster
in interfaceAbstractDB
-
resizeCluster
- Specified by:
resizeCluster
in interfaceAbstractDB
-
setPosition
- Specified by:
setPosition
in interfaceAbstractDB
-
removeInvited
- Specified by:
removeInvited
in interfaceAbstractDB
-
setInvited
- Specified by:
setInvited
in interfaceAbstractDB
-
deleteTables
public boolean deleteTables()Description copied from interface:AbstractDB
Don't use this method unless you want to ruin someone's server.- Specified by:
deleteTables
in interfaceAbstractDB
- Returns:
true
if the tables were deleted,false
when an error is encountered
-
validateAllPlots
- Specified by:
validateAllPlots
in interfaceAbstractDB
-
replaceWorld
- Specified by:
replaceWorld
in interfaceAbstractDB
-
replaceUUID
Description copied from interface:AbstractDB
Replaces 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:
replaceUUID
in interfaceAbstractDB
-
close
public void close()Description copied from interface:AbstractDB
Closes the database. Generally not recommended to be used by add-ons.- Specified by:
close
in interfaceAbstractDB
-