TF-PlotSquared/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java

327 lines
10 KiB
Java
Raw Normal View History

2014-11-08 20:27:09 +01:00
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.database;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
2015-01-25 21:16:10 -07:00
import java.util.HashSet;
import java.util.LinkedHashMap;
2015-01-07 03:08:29 +11:00
import java.util.Set;
import java.util.UUID;
2015-01-14 03:38:15 +11:00
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Plot;
2015-01-25 21:16:10 -07:00
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotClusterId;
2015-01-14 03:38:15 +11:00
import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.object.PlotId;
/**
* @author Citymonstret
2014-11-19 18:18:18 +01:00
* @author Empire92
*/
2014-11-19 18:18:18 +01:00
public interface AbstractDB {
// TODO MongoDB @Brandon
2014-11-16 10:48:18 +01:00
/**
2014-11-19 18:18:18 +01:00
* The UUID that will count as everyone
2014-11-16 10:48:18 +01:00
*/
public UUID everyone = UUID.fromString("1-1-3-3-7");
/**
* Set Plot owner
2014-11-05 14:42:08 +11:00
*
2014-12-17 20:15:11 -06:00
* @param plot Plot in which the owner should be set
* @param uuid The uuid of the new owner
*/
2014-11-19 18:18:18 +01:00
public void setOwner(final Plot plot, final UUID uuid);
2014-11-19 18:18:18 +01:00
/**
* Create all settings, and create default helpers, trusted + denied lists
*
2014-12-17 20:15:11 -06:00
* @param plots Plots for which the default table entries should be created
2014-11-19 18:18:18 +01:00
*/
public void createAllSettingsAndHelpers(final ArrayList<Plot> plots);
/**
* Create a plot
2014-11-05 14:42:08 +11:00
*
2014-12-17 20:15:11 -06:00
* @param plots Plots that should be created
*/
2014-11-19 18:18:18 +01:00
public void createPlots(final ArrayList<Plot> plots);
/**
* Create a plot
2014-11-05 14:42:08 +11:00
*
2014-12-17 20:15:11 -06:00
* @param plot That should be created
*/
2014-11-19 18:18:18 +01:00
public void createPlot(final Plot plot);
/**
* Create tables
2014-11-05 14:42:08 +11:00
*
2014-12-17 20:15:11 -06:00
* @param database Database in which the tables will be created
2014-11-19 18:18:18 +01:00
*
2014-12-17 20:15:11 -06:00
* @throws SQLException If the database manager is unable to create the tables
*/
2014-11-19 18:18:18 +01:00
public void createTables(final String database, final boolean add_constraint) throws Exception;
/**
* Delete a plot
2014-11-05 14:42:08 +11:00
*
2014-12-17 20:15:11 -06:00
* @param plot Plot that should be deleted
*/
2014-11-19 18:18:18 +01:00
public void delete(final String world, final Plot plot);
2015-01-25 21:16:10 -07:00
public void delete(final PlotCluster cluster);
/**
* Create plot settings
2014-11-05 14:42:08 +11:00
*
2014-12-17 20:15:11 -06:00
* @param id Plot Entry ID
* @param plot Plot Object
*/
2014-11-19 18:18:18 +01:00
public void createPlotSettings(final int id, final Plot plot);
2014-11-19 18:18:18 +01:00
/**
* Get the table entry ID
*
2014-12-17 20:15:11 -06:00
* @param world Which the plot is located in
* @param id2 Plot ID
*
2014-11-19 18:18:18 +01:00
* @return Integer = Plot Entry Id
*/
public int getId(final String world, final PlotId id2);
2015-01-25 21:16:10 -07:00
/**
* Get the id of a given plot cluster
*
* @param world Which the plot is located in
* @param pos1 bottom Plot ID
* @param pos2 top Plot ID
*
* @return Integer = Cluster Entry Id
*/
public int getClusterId(final String world, final PlotClusterId id);
/**
2014-11-19 18:18:18 +01:00
* @return A linked hashmap containing all plots
*/
2014-11-19 18:18:18 +01:00
public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots();
2015-01-25 21:16:10 -07:00
/**
* @return A hashmap containing all plot clusters
*/
public HashMap<String, HashSet<PlotCluster>> getClusters();
2014-11-19 18:18:18 +01:00
/**
* Set the merged status for a plot
*
2014-12-17 20:15:11 -06:00
* @param world World in which the plot is located
* @param plot Plot Object
* @param merged boolean[]
2014-11-19 18:18:18 +01:00
*/
public void setMerged(final String world, final Plot plot, final boolean[] merged);
2014-11-19 18:18:18 +01:00
/**
* Set plot flags
*
2014-12-17 20:15:11 -06:00
* @param world World in which the plot is located
* @param plot Plot Object
* @param flags flags to set (flag[])
2014-11-19 18:18:18 +01:00
*/
2015-01-07 03:08:29 +11:00
public void setFlags(final String world, final Plot plot, final Set<Flag> flags);
2015-01-25 21:16:10 -07:00
/**
* Set cluster flags
*
* @param world World in which the plot is located
* @param cluster PlotCluster Object
* @param flags flags to set (flag[])
*/
public void setFlags(final PlotCluster cluster, final Set<Flag> flags);
/**
* Rename a cluster
*/
public void setClusterName(final PlotCluster cluster, final String name);
/**
2014-11-19 18:18:18 +01:00
* Set the plot alias
*
2014-12-17 20:15:11 -06:00
* @param plot Plot for which the alias should be set
* @param alias Plot Alias
*/
2014-11-19 18:18:18 +01:00
public void setAlias(final String world, final Plot plot, final String alias);
2014-11-19 18:18:18 +01:00
/**
* Purgle a plot
*
2014-12-17 20:15:11 -06:00
* @param world World in which the plot is located
* @param id Plot ID
2014-11-19 18:18:18 +01:00
*/
2015-01-07 17:44:03 +11:00
public void purgeIds(final String world, final Set<Integer> uniqueIds);
2014-11-19 18:18:18 +01:00
/**
* Purge a whole world
*
2014-12-17 20:15:11 -06:00
* @param world World in which the plots should be purged
2014-11-19 18:18:18 +01:00
*/
2015-01-07 17:44:03 +11:00
public void purge(final String world, final Set<PlotId> plotIds);
2014-11-05 14:42:08 +11:00
/**
2014-11-19 18:18:18 +01:00
* Set Plot Home Position
2014-12-16 16:03:20 +11:00
*
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
* @param position Plot Home Position
*/
2014-11-19 18:18:18 +01:00
public void setPosition(final String world, final Plot plot, final String position);
2015-01-25 21:16:10 -07:00
/**
*
* @param cluster
* @param position
*/
public void setPosition(final PlotCluster cluster, final String position);
/**
2014-12-17 20:15:11 -06:00
* @param id Plot Entry ID
*
2014-11-19 18:18:18 +01:00
* @return Plot Settings
*/
2014-11-19 18:18:18 +01:00
public HashMap<String, Object> getSettings(final int id);
2015-01-25 21:16:10 -07:00
/**
*
* @param id
* @return
*/
public HashMap<String, Object> getClusterSettings(final int id);
/**
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
2015-01-18 12:30:32 -08:00
* @param uuid Player that should be removed
*/
2015-01-18 12:30:32 -08:00
public void removeHelper(final String world, final Plot plot, final UUID uuid);
2015-01-25 21:16:10 -07:00
/**
* @param cluster PlotCluster Object
* @param uuid Player that should be removed
*/
public void removeHelper(final PlotCluster cluster, final UUID uuid);
/**
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
2015-01-18 12:30:32 -08:00
* @param uuid Player that should be removed
*/
2015-01-18 12:30:32 -08:00
public void removeTrusted(final String world, final Plot plot, final UUID uuid);
2015-01-29 14:20:29 +11:00
/**
*
* @param cluster
* @param uuid
*/
public void removeInvited(final PlotCluster cluster, final UUID uuid);
/**
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
2015-01-18 12:30:32 -08:00
* @param uuid Player that should be removed
*/
2015-01-18 12:30:32 -08:00
public void setHelper(final String world, final Plot plot, final UUID uuid);
2015-01-25 21:16:10 -07:00
/**
* @param cluster PlotCluster Object
* @param uuid Player that should be removed
*/
public void setHelper(final PlotCluster cluster, final UUID uuid);
/**
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
2015-01-18 12:30:32 -08:00
* @param uuid Player that should be added
*/
2015-01-18 12:30:32 -08:00
public void setTrusted(final String world, final Plot plot, final UUID uuid);
2015-01-29 14:20:29 +11:00
/**
*
* @param world
* @param cluster
* @param uuid
*/
public void setInvited(final String world, final PlotCluster cluster, final UUID uuid);
/**
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
* @param player Player that should be added
*/
2015-01-18 12:30:32 -08:00
public void removeDenied(final String world, final Plot plot, final UUID uuid);
/**
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
* @param player Player that should be added
*/
2015-01-18 12:30:32 -08:00
public void setDenied(final String world, final Plot plot, final UUID uuid);
2014-11-19 18:18:18 +01:00
/**
* Get Plots ratings
*
2014-12-17 20:15:11 -06:00
* @param plot Plot Object
*
2014-11-19 18:18:18 +01:00
* @return Plot Ratings (pre-calculated)
*/
public double getRatings(final Plot plot);
2014-11-02 14:45:52 +11:00
2014-11-19 18:18:18 +01:00
/**
* Remove a plot comment
*
2014-12-17 20:15:11 -06:00
* @param world World in which the plot is located
* @param plot Plot Object
* @param comment Comment to remove
2014-11-19 18:18:18 +01:00
*/
public void removeComment(final String world, final Plot plot, final PlotComment comment);
2014-11-02 14:45:52 +11:00
2014-11-19 18:18:18 +01:00
/**
* Set a plot comment
*
2014-12-17 20:15:11 -06:00
* @param world World in which the plot is located
* @param plot Plot Object
* @param comment Comment to add
2014-11-19 18:18:18 +01:00
*/
public void setComment(final String world, final Plot plot, final PlotComment comment);
2014-11-02 14:45:52 +11:00
2014-11-19 18:18:18 +01:00
/**
* Get Plot Comments
*
2014-12-17 20:15:11 -06:00
* @param world World in which the plot is located
* @param plot Plot Object
* @param tier Comment Tier
*
2014-11-19 18:18:18 +01:00
* @return Plot Comments within the specified tier
*/
2015-01-15 01:22:45 +11:00
public ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier, boolean below);
2014-12-23 03:04:56 +11:00
public void createPlotAndSettings(Plot plot);
2015-01-25 21:16:10 -07:00
public void createCluster(PlotCluster cluster);
public void resizeCluster(PlotCluster current, PlotClusterId resize);
}