mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Some database fixes
This commit is contained in:
parent
a4f55dc3f6
commit
3499cf1341
@ -35,136 +35,207 @@ import java.util.UUID;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractDB {
|
public interface AbstractDB {
|
||||||
|
|
||||||
// TODO MongoDB @Brandon
|
// TODO MongoDB @Brandon
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* The UUID that will count as everyone
|
||||||
*/
|
*/
|
||||||
public UUID everyone = UUID.fromString("1-1-3-3-7");
|
public UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Plot owner
|
* Set Plot owner
|
||||||
*
|
*
|
||||||
* @param plot
|
* @param plot Plot in which the owner should be set
|
||||||
* @param uuid
|
* @param uuid The uuid of the new owner
|
||||||
*/
|
*/
|
||||||
public abstract void setOwner(final Plot plot, final UUID uuid);
|
public void setOwner(final Plot plot, final UUID uuid);
|
||||||
|
|
||||||
public abstract void createAllSettingsAndHelpers(final ArrayList<Plot> plots);
|
/**
|
||||||
|
* Create all settings, and create default helpers, trusted + denied lists
|
||||||
|
*
|
||||||
|
* @param plots Plots for which the default table entries should be created
|
||||||
|
*/
|
||||||
|
public void createAllSettingsAndHelpers(final ArrayList<Plot> plots);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a plot
|
* Create a plot
|
||||||
*
|
*
|
||||||
* @param plots
|
* @param plots Plots that should be created
|
||||||
*/
|
*/
|
||||||
public abstract void createPlots(final ArrayList<Plot> plots);
|
public void createPlots(final ArrayList<Plot> plots);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a plot
|
* Create a plot
|
||||||
*
|
*
|
||||||
* @param plot
|
* @param plot That should be created
|
||||||
*/
|
*/
|
||||||
public abstract void createPlot(final Plot plot);
|
public void createPlot(final Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create tables
|
* Create tables
|
||||||
*
|
*
|
||||||
* @throws SQLException
|
* @param database Database in which the tables will be created
|
||||||
|
*
|
||||||
|
* @throws SQLException If the database manager is unable to create the tables
|
||||||
*/
|
*/
|
||||||
public abstract void createTables(final String database, final boolean add_constraint) throws Exception;
|
public void createTables(final String database, final boolean add_constraint) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a plot
|
* Delete a plot
|
||||||
*
|
*
|
||||||
* @param plot
|
* @param plot Plot that should be deleted
|
||||||
*/
|
*/
|
||||||
public abstract void delete(final String world, final Plot plot);
|
public void delete(final String world, final Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create plot settings
|
* Create plot settings
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id Plot Entry ID
|
||||||
* @param plot
|
* @param plot Plot Object
|
||||||
*/
|
*/
|
||||||
public abstract void createPlotSettings(final int id, final Plot plot);
|
public void createPlotSettings(final int id, final Plot plot);
|
||||||
|
|
||||||
public abstract int getId(final String world, final PlotId id2);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* Get the table entry ID
|
||||||
|
*
|
||||||
|
* @param world Which the plot is located in
|
||||||
|
* @param id2 Plot ID
|
||||||
|
* @return Integer = Plot Entry Id
|
||||||
*/
|
*/
|
||||||
public abstract LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots();
|
public int getId(final String world, final PlotId id2);
|
||||||
|
|
||||||
public abstract void setMerged(final String world, final Plot plot, final boolean[] merged);
|
|
||||||
|
|
||||||
public abstract void setFlags(final String world, final Plot plot, final Flag[] flags);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @return A linked hashmap containing all plots
|
||||||
* @param alias
|
|
||||||
*/
|
*/
|
||||||
public abstract void setAlias(final String world, final Plot plot, final String alias);
|
public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots();
|
||||||
|
|
||||||
public abstract void purge(final String world, final PlotId id);
|
|
||||||
|
|
||||||
public abstract void purge(final String world);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* Set the merged status for a plot
|
||||||
* @param position
|
*
|
||||||
|
* @param world World in which the plot is located
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param merged boolean[]
|
||||||
*/
|
*/
|
||||||
public abstract void setPosition(final String world, final Plot plot, final String position);
|
public void setMerged(final String world, final Plot plot, final boolean[] merged);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* Set plot flags
|
||||||
* @return
|
*
|
||||||
|
* @param world World in which the plot is located
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param flags flags to set (flag[])
|
||||||
*/
|
*/
|
||||||
public abstract HashMap<String, Object> getSettings(final int id);
|
public void setFlags(final String world, final Plot plot, final Flag[] flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* Set the plot alias
|
||||||
* @param player
|
*
|
||||||
|
* @param plot Plot for which the alias should be set
|
||||||
|
* @param alias Plot Alias
|
||||||
*/
|
*/
|
||||||
public abstract void removeHelper(final String world, final Plot plot, final OfflinePlayer player);
|
public void setAlias(final String world, final Plot plot, final String alias);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* Purgle a plot
|
||||||
* @param player
|
*
|
||||||
|
* @param world World in which the plot is located
|
||||||
|
* @param id Plot ID
|
||||||
*/
|
*/
|
||||||
public abstract void removeTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
public void purge(final String world, final PlotId id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* Purge a whole world
|
||||||
* @param player
|
*
|
||||||
|
* @param world World in which the plots should be purged
|
||||||
*/
|
*/
|
||||||
public abstract void setHelper(final String world, final Plot plot, final OfflinePlayer player);
|
public void purge(final String world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* Set Plot Home Position
|
||||||
* @param player
|
* @param plot Plot Object
|
||||||
|
* @param position Plot Home Position
|
||||||
*/
|
*/
|
||||||
public abstract void setTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
public void setPosition(final String world, final Plot plot, final String position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param id Plot Entry ID
|
||||||
* @param player
|
* @return Plot Settings
|
||||||
*/
|
*/
|
||||||
public abstract void removeDenied(final String world, final Plot plot, final OfflinePlayer player);
|
public HashMap<String, Object> getSettings(final int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot Plot Object
|
||||||
* @param player
|
* @param player Player that should be removed
|
||||||
*/
|
*/
|
||||||
public abstract void setDenied(final String world, final Plot plot, final OfflinePlayer player);
|
public void removeHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
public abstract double getRatings(final Plot plot);
|
/**
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param player Player that should be removed
|
||||||
|
*/
|
||||||
|
public void removeTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
public abstract void removeComment(final String world, final Plot plot, final PlotComment comment);
|
/**
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param player Player that should be removed
|
||||||
|
*/
|
||||||
|
public void setHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
public abstract void setComment(final String world, final Plot plot, final PlotComment comment);
|
/**
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param player Player that should be added
|
||||||
|
*/
|
||||||
|
public void setTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
public abstract ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier);
|
/**
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param player Player that should be added
|
||||||
|
*/
|
||||||
|
public void removeDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param player Player that should be added
|
||||||
|
*/
|
||||||
|
public void setDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plots ratings
|
||||||
|
*
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @return Plot Ratings (pre-calculated)
|
||||||
|
*/
|
||||||
|
public double getRatings(final Plot plot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a plot comment
|
||||||
|
*
|
||||||
|
* @param world World in which the plot is located
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param comment Comment to remove
|
||||||
|
*/
|
||||||
|
public void removeComment(final String world, final Plot plot, final PlotComment comment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a plot comment
|
||||||
|
*
|
||||||
|
* @param world World in which the plot is located
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param comment Comment to add
|
||||||
|
*/
|
||||||
|
public void setComment(final String world, final Plot plot, final PlotComment comment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plot Comments
|
||||||
|
*
|
||||||
|
* @param world World in which the plot is located
|
||||||
|
* @param plot Plot Object
|
||||||
|
* @param tier Comment Tier
|
||||||
|
* @return Plot Comments within the specified tier
|
||||||
|
*/
|
||||||
|
public ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier);
|
||||||
}
|
}
|
||||||
|
@ -40,17 +40,9 @@ public class DBFunc {
|
|||||||
public static AbstractDB dbManager;
|
public static AbstractDB dbManager;
|
||||||
|
|
||||||
// TODO MongoDB @Brandon
|
// TODO MongoDB @Brandon
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static UUID everyone = UUID.fromString("1-1-3-3-7");
|
public static UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Plot owner
|
|
||||||
*
|
|
||||||
* @param plot
|
|
||||||
* @param uuid
|
|
||||||
*/
|
|
||||||
public static void setOwner(final Plot plot, final UUID uuid) {
|
public static void setOwner(final Plot plot, final UUID uuid) {
|
||||||
dbManager.setOwner(plot, uuid);
|
dbManager.setOwner(plot, uuid);
|
||||||
}
|
}
|
||||||
@ -59,11 +51,6 @@ public class DBFunc {
|
|||||||
dbManager.createAllSettingsAndHelpers(plots);
|
dbManager.createAllSettingsAndHelpers(plots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a plot
|
|
||||||
*
|
|
||||||
* @param plots
|
|
||||||
*/
|
|
||||||
public static void createPlots(final ArrayList<Plot> plots) {
|
public static void createPlots(final ArrayList<Plot> plots) {
|
||||||
dbManager.createPlots(plots);
|
dbManager.createPlots(plots);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ import java.util.*;
|
|||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class SQLManager extends AbstractDB {
|
public class SQLManager implements AbstractDB {
|
||||||
|
|
||||||
// Public final
|
// Public final
|
||||||
public final String SET_OWNER;
|
public final String SET_OWNER;
|
||||||
@ -452,7 +452,6 @@ public class SQLManager extends AbstractDB {
|
|||||||
plots.put(id, p);
|
plots.put(id, p);
|
||||||
}
|
}
|
||||||
// stmt.close();
|
// stmt.close();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Getting helpers
|
* Getting helpers
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user