diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index d7b3c8da4..c8523c574 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -33,10 +33,8 @@ import java.util.zip.ZipInputStream; /** * An implementation of the core, * with a static getter for easy access - * - * @see com.intellectualcrafters.plot.PlotSquaredMain Structure */ -public class PlotSquared implements PlotSquaredMain { +public class PlotSquared { public static final String MAIN_PERMISSION = "plots.use"; protected static PlotSquared instance; @@ -128,7 +126,7 @@ public class PlotSquared implements PlotSquaredMain { // PlotMe if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { TaskManager.runTaskLater(new Runnable() { - @Override + public void run() { if (IMP.initPlotMeConverter()) { log("&c=== IMPORTANT ==="); @@ -162,12 +160,12 @@ public class PlotSquared implements PlotSquaredMain { getInstance().IMP.log(message); } - @Override + public Database getDatabase() { return database; } - @Override + public void updatePlot(final Plot plot) { final String world = plot.world; if (!plots.containsKey(world)) { @@ -177,7 +175,7 @@ public class PlotSquared implements PlotSquaredMain { plots.get(world).put(plot.id, plot); } - @Override + public PlotWorld getPlotWorld(final String world) { if (plotworlds.containsKey(world)) { return plotworlds.get(world); @@ -185,7 +183,7 @@ public class PlotSquared implements PlotSquaredMain { return null; } - @Override + public void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) { plotworlds.put(world, plotworld); plotmanagers.put(world, manager); @@ -194,30 +192,30 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public void removePlotWorld(final String world) { plots.remove(world); plotmanagers.remove(world); plotworlds.remove(world); } - @Override + public void removePlotWorldAbs(final String world) { plotmanagers.remove(world); plotworlds.remove(world); } - @Override + public HashMap> getAllPlotsRaw() { return plots; } - @Override + public void setAllPlotsRaw(final LinkedHashMap> plots) { this.plots = plots; } - @Override + public Set getPlots() { final ArrayList newplots = new ArrayList<>(); for (final Entry> entry : plots.entrySet()) { @@ -228,7 +226,7 @@ public class PlotSquared implements PlotSquaredMain { return new LinkedHashSet<>(newplots); } - @Override + public Set getPlotsRaw() { final ArrayList newplots = new ArrayList<>(); for (final Entry> entry : plots.entrySet()) { @@ -237,12 +235,12 @@ public class PlotSquared implements PlotSquaredMain { return new LinkedHashSet<>(newplots); } - @Override + public ArrayList sortPlots(Collection plots) { ArrayList newPlots = new ArrayList<>(); newPlots.addAll(plots); Collections.sort(newPlots, new Comparator() { - @Override + public int compare(Plot p1, Plot p2) { int h1 = p1.hashCode(); int h2 = p2.hashCode(); @@ -264,7 +262,7 @@ public class PlotSquared implements PlotSquaredMain { return newPlots; } - @Override + public ArrayList sortPlots(Collection plots, final String priorityWorld) { ArrayList newPlots = new ArrayList<>(); HashMap worldPlots = this.plots.get(priorityWorld); @@ -289,7 +287,7 @@ public class PlotSquared implements PlotSquaredMain { return newPlots; } - @Override + public ArrayList sortPlotsByWorld(Collection plots) { ArrayList newPlots = new ArrayList<>(); ArrayList worlds = new ArrayList<>(this.plots.keySet()); @@ -304,19 +302,19 @@ public class PlotSquared implements PlotSquaredMain { return newPlots; } - @Override + public Set getPlots(final String world, final String player) { final UUID uuid = UUIDHandler.getUUID(player); return getPlots(world, uuid); } - @Override + public Set getPlots(final String world, final PlotPlayer player) { final UUID uuid = player.getUUID(); return getPlots(world, uuid); } - @Override + public Set getPlots(final String world, final UUID uuid) { final ArrayList myplots = new ArrayList<>(); for (final Plot plot : getPlots(world).values()) { @@ -329,12 +327,12 @@ public class PlotSquared implements PlotSquaredMain { return new HashSet<>(myplots); } - @Override + public boolean isPlotWorld(final String world) { return (plotworlds.containsKey(world)); } - @Override + public PlotManager getPlotManager(final String world) { if (plotmanagers.containsKey(world)) { return plotmanagers.get(world); @@ -342,13 +340,13 @@ public class PlotSquared implements PlotSquaredMain { return null; } - @Override + public String[] getPlotWorldsString() { final Set strings = plots.keySet(); return strings.toArray(new String[strings.size()]); } - @Override + public HashMap getPlots(final String world) { if (plots.containsKey(world)) { return plots.get(world); @@ -356,12 +354,12 @@ public class PlotSquared implements PlotSquaredMain { return new HashMap<>(); } - @Override + public Set getPlots(final PlotPlayer player) { return getPlots(player.getUUID()); } - @Override + public Set getPlots(final UUID uuid) { final ArrayList myplots = new ArrayList<>(); for (final String world : plots.keySet()) { @@ -378,7 +376,7 @@ public class PlotSquared implements PlotSquaredMain { return new HashSet<>(myplots); } - @Override + public boolean removePlot(final String world, final PlotId id, final boolean callEvent) { if (callEvent) { EventUtil.manager.callDelete(world, id); @@ -395,7 +393,7 @@ public class PlotSquared implements PlotSquaredMain { return true; } - @Override + public void loadWorld(final String world, PlotGenerator generator) { PlotWorld plotWorld = getPlotWorld(world); if (plotWorld != null) { @@ -492,7 +490,7 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public boolean setupPlotWorld(final String world, final String id) { if ((id != null) && (id.length() > 0)) { // save configuration @@ -585,12 +583,12 @@ public class PlotSquared implements PlotSquaredMain { return true; } - @Override + public Connection getConnection() { return connection; } - @Override + public void copyFile(String file, String folder) { try { byte[] buffer = new byte[2048]; @@ -629,7 +627,7 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public void disable() { try { database.closeConnection(); @@ -638,7 +636,7 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public void setupDatabase() { if (Settings.DB.USE_MYSQL) { try { @@ -695,7 +693,7 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public void setupDefaultFlags() { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone", "keep"); final List intervalFlags = Arrays.asList("feed", "heal"); @@ -734,7 +732,7 @@ public class PlotSquared implements PlotSquaredMain { FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue())); FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue())); FlagManager.addFlag(new AbstractFlag("gamemode") { - @Override + public String parseValueRaw(final String value) { switch (value) { case "creative": @@ -754,7 +752,7 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public String getValueDesc() { return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'"; } @@ -762,7 +760,7 @@ public class PlotSquared implements PlotSquaredMain { FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue())); FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue())); FlagManager.addFlag(new AbstractFlag("weather") { - @Override + public String parseValueRaw(final String value) { switch (value) { case "rain": @@ -781,14 +779,14 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public String getValueDesc() { return "Flag value must be weather type: 'clear' or 'rain'"; } }); } - @Override + public void setupConfig() { config.set("version", VERSION); @@ -968,7 +966,7 @@ public class PlotSquared implements PlotSquaredMain { Settings.METRICS = config.getBoolean("metrics"); } - @Override + public void setupConfigs() { final File folder = new File(IMP.getDirectory() + File.separator + "config"); if (!folder.exists() && !folder.mkdirs()) { @@ -1055,7 +1053,7 @@ public class PlotSquared implements PlotSquaredMain { Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban"); } - @Override + public void showDebug() { C.COLOR_1 = "&" + (style.getString("color.1")); C.COLOR_2 = "&" + (style.getString("color.2")); @@ -1093,17 +1091,17 @@ public class PlotSquared implements PlotSquaredMain { } } - @Override + public double getJavaVersion() { return Double.parseDouble(System.getProperty("java.specification.version")); } - @Override + public Set getPlotWorlds() { return plotworlds.keySet(); } - @Override + public Collection getPlotWorldObjects() { return plotworlds.values(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquaredMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquaredMain.java deleted file mode 100644 index 159808f25..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquaredMain.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.intellectualcrafters.plot; - -import com.intellectualcrafters.plot.database.Database; -import com.intellectualcrafters.plot.object.*; - -import java.sql.Connection; -import java.util.*; - -/** - * Core of the PlotSquared Plugin - */ -public interface PlotSquaredMain { - - Database getDatabase(); - - void updatePlot(Plot plot); - - PlotWorld getPlotWorld(String world); - - void addPlotWorld(String world, PlotWorld plotworld, PlotManager manager); - - void removePlotWorld(String world); - - void removePlotWorldAbs(String world); - - HashMap> getAllPlotsRaw(); - - void setAllPlotsRaw(LinkedHashMap> plots); - - Set getPlots(); - - Set getPlotsRaw(); - - ArrayList sortPlots(Collection plots); - - ArrayList sortPlots(Collection plots, String priorityWorld); - - ArrayList sortPlotsByWorld(Collection plots); - - Set getPlots(String world, String player); - - Set getPlots(String world, PlotPlayer player); - - Set getPlots(String world, UUID uuid); - - boolean isPlotWorld(String world); - - PlotManager getPlotManager(String world); - - String[] getPlotWorldsString(); - - HashMap getPlots(String world); - - Set getPlots(PlotPlayer player); - - /** - * Get all plots belonging to a specified - * player UUID - * - * @param uuid Player UUID - * @return A set containing the plots - * @see #getPlots(PlotPlayer) Using PlotPlayer rather than UUID - * @see #getPlots(String, UUID) To limit the search to a specific world - * @see #getPlots(String, String) To limit the search to a specific world, and use player names - */ - Set getPlots(UUID uuid); - - /** - * Remove a plot from the specified plot world - * - * @param world World Name - * @param id Plot ID - * @param callEvent If the plot delete event should be called - * @return true on success | false on failure - */ - boolean removePlot(String world, PlotId id, boolean callEvent); - - /** - * Load a world - * - * @param world World Name - * @param generator PlotGenerator Implementation - */ - void loadWorld(String world, PlotGenerator generator); - - /** - * Setup a PlotWorld - * - * @param world World Name - * @param id World ID - * @return true on success | false on failure - */ - boolean setupPlotWorld(String world, String id); - - /** - * Get the database connection - * - * @see #getDatabase() Get the database implementation - * @return Database connection - */ - Connection getConnection(); - - /** - * Copy a file into the specified folder - * - * @param file File to copy - * @param folder Folder to copy to - */ - void copyFile(String file, String folder); - - /** - * Disable the PlotSquared core - */ - void disable(); - - /** - * Setup the database configuration file - */ - void setupDatabase(); - - /** - * Setup the default flags - */ - void setupDefaultFlags(); - - /** - * Setup the global configuration file - */ - void setupConfig(); - - /** - * Setup all configuration classes - * - * @see #setupDatabase() Setup the database configuration file - * @see #setupConfig() Setup the general configuration file - * @see #setupDefaultFlags() Setup the default flags - */ - void setupConfigs(); - - void showDebug(); - - /** - * Get the current java version as - * a double - * @code { - * 1.7 = Java 7 - * 1.8 = Java 8 - * etc... - * } - * - * @return Java version as a double - */ - double getJavaVersion(); - - /** - * Get a set containing the names of - * all PlotWorlds - * - * @see #getPlotWorldObjects() To get the actual objects - * - * @return A set containing the names of all PlotWorlds - */ - Set getPlotWorlds(); - - /** - * Get a collection containing the - * PlotWorld objects - * - * @see #getPlotWorlds() To get the names of the worlds - * @see PlotWorld The returned object - * - * @return Collection containing PlotWorld's - */ - Collection getPlotWorldObjects(); -}