diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index cde1ac371..37ffcfbbf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -1,12 +1,28 @@ package com.intellectualcrafters.plot; -import java.io.File; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; -import java.util.Map.Entry; - +import com.intellectualcrafters.plot.commands.*; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector; +import com.intellectualcrafters.plot.database.plotme.LikePlotMeConverter; +import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.generator.BukkitHybridUtils; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.listeners.*; +import com.intellectualcrafters.plot.listeners.worldedit.WEListener; +import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.titles.AbstractTitle; +import com.intellectualcrafters.plot.titles.DefaultTitle; +import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.bukkit.*; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -19,130 +35,14 @@ import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; -import com.intellectualcrafters.plot.commands.Add; -import com.intellectualcrafters.plot.commands.Auto; -import com.intellectualcrafters.plot.commands.BukkitCommand; -import com.intellectualcrafters.plot.commands.Chat; -import com.intellectualcrafters.plot.commands.Claim; -import com.intellectualcrafters.plot.commands.Clear; -import com.intellectualcrafters.plot.commands.Cluster; -import com.intellectualcrafters.plot.commands.Comment; -import com.intellectualcrafters.plot.commands.Condense; -import com.intellectualcrafters.plot.commands.Confirm; -import com.intellectualcrafters.plot.commands.Copy; -import com.intellectualcrafters.plot.commands.CreateRoadSchematic; -import com.intellectualcrafters.plot.commands.Database; -import com.intellectualcrafters.plot.commands.Debug; -import com.intellectualcrafters.plot.commands.DebugClaimTest; -import com.intellectualcrafters.plot.commands.DebugClear; -import com.intellectualcrafters.plot.commands.DebugExec; -import com.intellectualcrafters.plot.commands.DebugFill; -import com.intellectualcrafters.plot.commands.DebugFixFlags; -import com.intellectualcrafters.plot.commands.DebugLoadTest; -import com.intellectualcrafters.plot.commands.DebugRoadRegen; -import com.intellectualcrafters.plot.commands.DebugSaveTest; -import com.intellectualcrafters.plot.commands.DebugUUID; -import com.intellectualcrafters.plot.commands.Delete; -import com.intellectualcrafters.plot.commands.Deny; -import com.intellectualcrafters.plot.commands.FlagCmd; -import com.intellectualcrafters.plot.commands.Help; -import com.intellectualcrafters.plot.commands.Home; -import com.intellectualcrafters.plot.commands.Inbox; -import com.intellectualcrafters.plot.commands.Info; -import com.intellectualcrafters.plot.commands.Inventory; -import com.intellectualcrafters.plot.commands.Kick; -import com.intellectualcrafters.plot.commands.MainCommand; -import com.intellectualcrafters.plot.commands.Merge; -import com.intellectualcrafters.plot.commands.Move; -import com.intellectualcrafters.plot.commands.MusicSubcommand; -import com.intellectualcrafters.plot.commands.Purge; -import com.intellectualcrafters.plot.commands.Rate; -import com.intellectualcrafters.plot.commands.RegenAllRoads; -import com.intellectualcrafters.plot.commands.Reload; -import com.intellectualcrafters.plot.commands.Remove; -import com.intellectualcrafters.plot.commands.SchematicCmd; -import com.intellectualcrafters.plot.commands.Set; -import com.intellectualcrafters.plot.commands.SetOwner; -import com.intellectualcrafters.plot.commands.Setup; -import com.intellectualcrafters.plot.commands.Swap; -import com.intellectualcrafters.plot.commands.TP; -import com.intellectualcrafters.plot.commands.Target; -import com.intellectualcrafters.plot.commands.Template; -import com.intellectualcrafters.plot.commands.Toggle; -import com.intellectualcrafters.plot.commands.Trim; -import com.intellectualcrafters.plot.commands.Trust; -import com.intellectualcrafters.plot.commands.Unclaim; -import com.intellectualcrafters.plot.commands.Undeny; -import com.intellectualcrafters.plot.commands.Unlink; -import com.intellectualcrafters.plot.commands.Untrust; -import com.intellectualcrafters.plot.commands.Visit; -import com.intellectualcrafters.plot.commands.WE_Anywhere; -import com.intellectualcrafters.plot.commands.list; -import com.intellectualcrafters.plot.commands.plugin; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector; -import com.intellectualcrafters.plot.database.plotme.LikePlotMeConverter; -import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.generator.BukkitHybridUtils; -import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.generator.HybridUtils; -import com.intellectualcrafters.plot.listeners.APlotListener; -import com.intellectualcrafters.plot.listeners.ChunkListener; -import com.intellectualcrafters.plot.listeners.ForceFieldListener; -import com.intellectualcrafters.plot.listeners.InventoryListener; -import com.intellectualcrafters.plot.listeners.PlayerEvents; -import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; -import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8_3; -import com.intellectualcrafters.plot.listeners.PlotListener; -import com.intellectualcrafters.plot.listeners.PlotPlusListener; -import com.intellectualcrafters.plot.listeners.TNTListener; -import com.intellectualcrafters.plot.listeners.WorldEvents; -import com.intellectualcrafters.plot.listeners.worldedit.WEListener; -import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.titles.AbstractTitle; -import com.intellectualcrafters.plot.titles.DefaultTitle; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.BlockUpdateUtil; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.ConsoleColors; -import com.intellectualcrafters.plot.util.EconHandler; -import com.intellectualcrafters.plot.util.EventUtil; -import com.intellectualcrafters.plot.util.InventoryUtil; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.PlayerManager; -import com.intellectualcrafters.plot.util.SetupUtils; -import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitEconHandler; -import com.intellectualcrafters.plot.util.bukkit.BukkitEventUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitInventoryUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.Metrics; -import com.intellectualcrafters.plot.util.bukkit.SendChunk; -import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; -import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8; -import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; -import com.intellectualcrafters.plot.util.bukkit.SetGenCB; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; -import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; -import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; -import com.intellectualcrafters.plot.uuid.UUIDWrapper; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { + public static BukkitMain THIS = null; - public static PlotSquared MAIN = null; private int[] version; @@ -168,7 +68,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void onEnable() { THIS = this; - MAIN = new PlotSquared(this); + PlotSquared.instance = new PlotSquared(this); if (Settings.METRICS) { try { final Metrics metrics = new Metrics(this); @@ -197,8 +97,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void onDisable() { - MAIN.disable(); - MAIN = null; + PlotSquared.getInstance().disable(); THIS = null; } @@ -336,7 +235,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { this.error = 0l; } World world; - for (final String w : PlotSquared.getPlotWorlds()) { + for (final String w : PlotSquared.getInstance().getPlotWorlds()) { world = Bukkit.getWorld(w); try { if (world.getLoadedChunks().length < 1) { @@ -364,7 +263,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { WorldEvents.lastWorld = world; - if (!PlotSquared.setupPlotWorld(world, id)) { + if (!PlotSquared.getInstance().setupPlotWorld(world, id)) { return null; } HybridGen result = new HybridGen(world); @@ -409,8 +308,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void registerWorldEditEvents() { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { - PlotSquared.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); - final String version = PlotSquared.worldEdit.getDescription().getVersion(); + PlotSquared.getInstance().worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + final String version = PlotSquared.getInstance().worldEdit.getDescription().getVersion(); if ((version != null) && version.startsWith("5.")) { log("&cThis version of WorldEdit does not support PlotSquared."); log("&cPlease use WorldEdit 6+ for masking support"); @@ -430,8 +329,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (econ.init()) { return econ; } + } catch (Throwable e) { } - catch (Throwable e) {}; return null; } @@ -472,10 +371,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } } }, 20); - if (Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null) { - return true; - } - return false; + return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null; } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 5a6d32a36..8656225f0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -1,5 +1,22 @@ package com.intellectualcrafters.plot; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Configuration; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.*; +import com.intellectualcrafters.plot.flag.AbstractFlag; +import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.flag.FlagValue; +import com.intellectualcrafters.plot.generator.*; +import com.intellectualcrafters.plot.listeners.APlotListener; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.object.comment.CommentManager; +import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.Logger.LogLevel; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import org.bukkit.configuration.file.YamlConfiguration; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -8,101 +25,147 @@ import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; -import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.bukkit.configuration.file.YamlConfiguration; +/** + * An implementation of the core, + * with a static getter for easy access + */ +public class PlotSquared implements PlotSquaredMain { -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.Configuration; -import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.database.Database; -import com.intellectualcrafters.plot.database.MySQL; -import com.intellectualcrafters.plot.database.SQLManager; -import com.intellectualcrafters.plot.database.SQLite; -import com.intellectualcrafters.plot.flag.AbstractFlag; -import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.flag.FlagValue; -import com.intellectualcrafters.plot.generator.AugmentedPopulator; -import com.intellectualcrafters.plot.generator.ClassicPlotWorld; -import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.generator.HybridPlotWorld; -import com.intellectualcrafters.plot.generator.HybridUtils; -import com.intellectualcrafters.plot.generator.SquarePlotManager; -import com.intellectualcrafters.plot.generator.SquarePlotWorld; -import com.intellectualcrafters.plot.listeners.APlotListener; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotCluster; -import com.intellectualcrafters.plot.object.PlotGenerator; -import com.intellectualcrafters.plot.object.PlotHandler; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.comment.CommentManager; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.EconHandler; -import com.intellectualcrafters.plot.util.EventUtil; -import com.intellectualcrafters.plot.util.ExpireManager; -import com.intellectualcrafters.plot.util.InventoryUtil; -import com.intellectualcrafters.plot.util.Logger; -import com.intellectualcrafters.plot.util.Logger.LogLevel; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.PlayerManager; -import com.intellectualcrafters.plot.util.SetupUtils; -import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; - -public class PlotSquared { public static final String MAIN_PERMISSION = "plots.use"; - public static final String ADMIN_PERMISSION = "plots.admin"; - public static File styleFile; - public static YamlConfiguration style; - public static File configFile; - public static YamlConfiguration config; - public static File storageFile; - public static YamlConfiguration storage; - public static PlotSquared THIS = null; // This class - public static File FILE = null; // This file - public static IPlotMain IMP = null; // Specific implementation of PlotSquared - public static String VERSION = null; - public static TaskManager TASK = null; - private static boolean LOADING_WORLD = false; - public static WorldEditPlugin worldEdit = null; - private final static HashMap plotworlds = new HashMap<>(); - private final static HashMap plotmanagers = new HashMap<>(); - - - private static LinkedHashMap> plots; - - - private static Database database; - public static Connection connection; - - public static Database getDatabase() { + protected static PlotSquared instance; + private final HashMap plotworlds = new HashMap<>(); + private final HashMap plotmanagers = new HashMap<>(); + public WorldEditPlugin worldEdit = null; + private File styleFile; + private YamlConfiguration style; + private File configFile; + private YamlConfiguration config; + private File storageFile; + private YamlConfiguration storage; + private File FILE = null; // This file + private IPlotMain IMP = null; // Specific implementation of PlotSquared + private String VERSION = null; + private boolean LOADING_WORLD = false; + private LinkedHashMap> plots; + private Database database; + private Connection connection; + + public PlotSquared(final IPlotMain imp_class) { + SetupUtils.generators = new HashMap<>(); + IMP = imp_class; + try { + FILE = new File(PlotSquared.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); + } catch (Exception e) { + log("Could not determine file path"); + } + VERSION = IMP.getVersion(); + EconHandler.manager = IMP.getEconomyHandler(); + C.setupTranslations(); + C.saveTranslations(); + if (getJavaVersion() < 1.7) { + log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); + // Didn't know of any other link :D + log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); + IMP.disable(); + return; + } + if (getJavaVersion() < 1.8) { + log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); + } + TaskManager TASK = IMP.getTaskManager(); + if (C.ENABLED.s().length() > 0) { + log(C.ENABLED.s()); + } + setupConfigs(); + setupDefaultFlags(); + setupDatabase(); + CommentManager.registerDefaultInboxes(); + // Tasks + if (Settings.KILL_ROAD_MOBS) { + IMP.runEntityTask(); + } + // Events + IMP.registerCommands(); + IMP.registerPlayerEvents(); + IMP.registerInventoryEvents(); + IMP.registerPlotPlusEvents(); + IMP.registerForceFieldEvents(); + IMP.registerWorldEditEvents(); + IMP.registerWorldEvents(); + if (Settings.TNT_LISTENER) { + IMP.registerTNTListener(); + } + if (Settings.CHUNK_PROCESSOR) { + IMP.registerChunkProcessor(); + } + // create UUIDWrapper + UUIDHandler.uuidWrapper = IMP.initUUIDHandler(); + // create event util class + EventUtil.manager = IMP.initEventUtil(); + // create Hybrid utility class + HybridUtils.manager = IMP.initHybridUtils(); + // Inventory utility class + InventoryUtil.manager = IMP.initInventoryUtil(); + // create setup util class + SetupUtils.manager = IMP.initSetupUtils(); + // Set block + BlockManager.manager = IMP.initBlockManager(); + // Set chunk + ChunkManager.manager = IMP.initChunkManager(); + // Plot listener + APlotListener.manager = IMP.initPlotListener(); + // Player manager + PlayerManager.manager = IMP.initPlayerManager(); + + // PlotMe + if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + if (IMP.initPlotMeConverter()) { + log("&c=== IMPORTANT ==="); + log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); + log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); + log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); + log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'"); + } + } + }, 200); + } + if (Settings.AUTO_CLEAR) { + ExpireManager.runTask(); + } + + // Copy files + copyFile("town.template", "templates"); + copyFile("skyblock.template", "templates"); + copyFile("german.yml", "translations"); + copyFile("s_chinese_unescaped.yml", "translations"); + copyFile("s_chinese.yml", "translations"); + copyFile("italian.yml", "translations"); + showDebug(); + } + + public static PlotSquared getInstance() { + return instance; + } + + public static void log(final String message) { + getInstance().IMP.log(message); + } + + @Override + public Database getDatabase() { return database; } - public static void updatePlot(final Plot plot) { + @Override + public void updatePlot(final Plot plot) { final String world = plot.world; if (!plots.containsKey(world)) { plots.put(world, new HashMap()); @@ -111,14 +174,16 @@ public class PlotSquared { plots.get(world).put(plot.id, plot); } - public static PlotWorld getPlotWorld(final String world) { + @Override + public PlotWorld getPlotWorld(final String world) { if (plotworlds.containsKey(world)) { return plotworlds.get(world); } return null; } - public static void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) { + @Override + public void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) { plotworlds.put(world, plotworld); plotmanagers.put(world, manager); if (!plots.containsKey(world)) { @@ -126,26 +191,31 @@ public class PlotSquared { } } - public static void removePlotWorld(final String world) { + @Override + public void removePlotWorld(final String world) { plots.remove(world); plotmanagers.remove(world); plotworlds.remove(world); } - - public static void removePlotWorldAbs(final String world) { + + @Override + public void removePlotWorldAbs(final String world) { plotmanagers.remove(world); plotworlds.remove(world); } - public static HashMap> getAllPlotsRaw() { + @Override + public HashMap> getAllPlotsRaw() { return plots; } - public static void setAllPlotsRaw(final LinkedHashMap> plots) { - PlotSquared.plots = plots; + @Override + public void setAllPlotsRaw(final LinkedHashMap> plots) { + this.plots = plots; } - public static Set getPlots() { + @Override + public Set getPlots() { final ArrayList newplots = new ArrayList<>(); for (final Entry> entry : plots.entrySet()) { if (isPlotWorld(entry.getKey())) { @@ -154,16 +224,18 @@ public class PlotSquared { } return new LinkedHashSet<>(newplots); } - - public static Set getPlotsRaw() { + + @Override + public Set getPlotsRaw() { final ArrayList newplots = new ArrayList<>(); for (final Entry> entry : plots.entrySet()) { newplots.addAll(entry.getValue().values()); } return new LinkedHashSet<>(newplots); } - - public static ArrayList sortPlots(Collection plots) { + + @Override + public ArrayList sortPlots(Collection plots) { ArrayList newPlots = new ArrayList<>(); newPlots.addAll(plots); Collections.sort(newPlots, new Comparator() { @@ -188,10 +260,11 @@ public class PlotSquared { }); return newPlots; } - - public static ArrayList sortPlots(Collection plots, final String priorityWorld) { + + @Override + public ArrayList sortPlots(Collection plots, final String priorityWorld) { ArrayList newPlots = new ArrayList<>(); - HashMap worldPlots = PlotSquared.plots.get(priorityWorld); + HashMap worldPlots = this.plots.get(priorityWorld); if (worldPlots != null) { for (Plot plot : sortPlots(worldPlots.values())) { if (plots.contains(plot)) { @@ -199,11 +272,11 @@ public class PlotSquared { } } } - ArrayList worlds = new ArrayList<>(PlotSquared.plots.keySet()); + ArrayList worlds = new ArrayList<>(this.plots.keySet()); Collections.sort(worlds); for (String world : worlds) { if (!world.equals(priorityWorld)) { - for (Plot plot : PlotSquared.plots.get(world).values()) { + for (Plot plot : this.plots.get(world).values()) { if (plots.contains(plot)) { newPlots.add(plot); } @@ -212,13 +285,14 @@ public class PlotSquared { } return newPlots; } - - public static ArrayList sortPlotsByWorld(Collection plots) { + + @Override + public ArrayList sortPlotsByWorld(Collection plots) { ArrayList newPlots = new ArrayList<>(); - ArrayList worlds = new ArrayList<>(PlotSquared.plots.keySet()); + ArrayList worlds = new ArrayList<>(this.plots.keySet()); Collections.sort(worlds); for (String world : worlds) { - for (Plot plot : PlotSquared.plots.get(world).values()) { + for (Plot plot : this.plots.get(world).values()) { if (plots.contains(plot)) { newPlots.add(plot); } @@ -227,17 +301,20 @@ public class PlotSquared { return newPlots; } - public static Set getPlots(final String world, final String player) { + @Override + public Set getPlots(final String world, final String player) { final UUID uuid = UUIDHandler.getUUID(player); return getPlots(world, uuid); } - public static Set getPlots(final String world, final PlotPlayer player) { + @Override + public Set getPlots(final String world, final PlotPlayer player) { final UUID uuid = player.getUUID(); return getPlots(world, uuid); } - public static Set getPlots(final String world, final UUID uuid) { + @Override + public Set getPlots(final String world, final UUID uuid) { final ArrayList myplots = new ArrayList<>(); for (final Plot plot : getPlots(world).values()) { if (plot.hasOwner()) { @@ -249,34 +326,40 @@ public class PlotSquared { return new HashSet<>(myplots); } - public static boolean isPlotWorld(final String world) { + @Override + public boolean isPlotWorld(final String world) { return (plotworlds.containsKey(world)); } - public static PlotManager getPlotManager(final String world) { + @Override + public PlotManager getPlotManager(final String world) { if (plotmanagers.containsKey(world)) { return plotmanagers.get(world); } return null; } - public static String[] getPlotWorldsString() { + @Override + public String[] getPlotWorldsString() { final Set strings = plots.keySet(); return strings.toArray(new String[strings.size()]); } - public static HashMap getPlots(final String world) { + @Override + public HashMap getPlots(final String world) { if (plots.containsKey(world)) { return plots.get(world); } return new HashMap<>(); } - public static Set getPlots(final PlotPlayer player) { + @Override + public Set getPlots(final PlotPlayer player) { return getPlots(player.getUUID()); } - - public static Set getPlots(final UUID uuid) { + + @Override + public Set getPlots(final UUID uuid) { final ArrayList myplots = new ArrayList<>(); for (final String world : plots.keySet()) { if (isPlotWorld(world)) { @@ -292,7 +375,8 @@ public class PlotSquared { return new HashSet<>(myplots); } - public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) { + @Override + public boolean removePlot(final String world, final PlotId id, final boolean callEvent) { if (callEvent) { EventUtil.manager.callDelete(world, id); } @@ -308,8 +392,9 @@ public class PlotSquared { return true; } - public static void loadWorld(final String world, PlotGenerator generator) { - PlotWorld plotWorld = getPlotWorld(world); + @Override + public void loadWorld(final String world, PlotGenerator generator) { + PlotWorld plotWorld = getPlotWorld(world); if (plotWorld != null) { if (generator != null) { generator.init(plotWorld); @@ -370,7 +455,7 @@ public class PlotSquared { final PlotGenerator gen_class = generator; plotWorld = gen_class.getNewPlotWorld(world); plotManager = gen_class.getPlotManager(); - + if (!config.contains(path)) { config.createSection(path); } @@ -378,13 +463,13 @@ public class PlotSquared { plotWorld.TERRAIN = 0; plotWorld.saveConfiguration(config.getConfigurationSection(path)); plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); - + try { config.save(configFile); } catch (final IOException e) { e.printStackTrace(); } - + if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) { log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!"); return; @@ -404,7 +489,8 @@ public class PlotSquared { } } - public static boolean setupPlotWorld(final String world, final String id) { + @Override + public boolean setupPlotWorld(final String world, final String id) { if ((id != null) && (id.length() > 0)) { // save configuration final String[] split = id.split(","); @@ -428,39 +514,39 @@ public class PlotSquared { switch (key) { case "s": case "size": { - SquarePlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + SquarePlotWorld.PLOT_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue(); break; } case "g": case "gap": { - SquarePlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + SquarePlotWorld.ROAD_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue(); break; } case "h": case "height": { - ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); - ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); - ClassicPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); + ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); + ClassicPlotWorld.WALL_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); break; } case "f": case "floor": { - ClassicPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + ClassicPlotWorld.TOP_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value); break; } case "m": case "main": { - ClassicPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + ClassicPlotWorld.MAIN_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value); break; } case "w": case "wall": { - ClassicPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + ClassicPlotWorld.WALL_FILLING_DEFAULT = Configuration.BLOCK.parseString(value); break; } case "b": case "border": { - ClassicPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + ClassicPlotWorld.WALL_BLOCK_DEFAULT = Configuration.BLOCK.parseString(value); break; } default: { @@ -496,112 +582,109 @@ public class PlotSquared { return true; } - public static Connection getConnection() { + @Override + public boolean setupPlotWorld(final String world, final String id) { + if ((id != null) && (id.length() > 0)) { + // save configuration + final String[] split = id.split(","); + final HybridPlotWorld plotworld = new HybridPlotWorld(world); + final int width = SquarePlotWorld.PLOT_WIDTH_DEFAULT; + final int gap = SquarePlotWorld.ROAD_WIDTH_DEFAULT; + final int height = ClassicPlotWorld.PLOT_HEIGHT_DEFAULT; + final PlotBlock[] floor = ClassicPlotWorld.TOP_BLOCK_DEFAULT; + final PlotBlock[] main = ClassicPlotWorld.MAIN_BLOCK_DEFAULT; + final PlotBlock wall = ClassicPlotWorld.WALL_FILLING_DEFAULT; + final PlotBlock border = ClassicPlotWorld.WALL_BLOCK_DEFAULT; + for (final String element : split) { + final String[] pair = element.split("="); + if (pair.length != 2) { + log("&cNo value provided for: &7" + element); + return false; + } + final String key = pair[0].toLowerCase(); + final String value = pair[1]; + try { + switch (key) { + case "s": + case "size": { + SquarePlotWorld.PLOT_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue(); + break; + } + case "g": + case "gap": { + SquarePlotWorld.ROAD_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue(); + break; + } + case "h": + case "height": { + ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); + ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); + ClassicPlotWorld.WALL_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); + break; + } + case "f": + case "floor": { + ClassicPlotWorld.TOP_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value); + break; + } + case "m": + case "main": { + ClassicPlotWorld.MAIN_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value); + break; + } + case "w": + case "wall": { + ClassicPlotWorld.WALL_FILLING_DEFAULT = Configuration.BLOCK.parseString(value); + break; + } + case "b": + case "border": { + ClassicPlotWorld.WALL_BLOCK_DEFAULT = Configuration.BLOCK.parseString(value); + break; + } + default: { + log("&cKey not found: &7" + element); + return false; + } + } + } catch (final Exception e) { + e.printStackTrace(); + log("&cInvalid value: &7" + value + " in arg " + element); + return false; + } + } + try { + final String root = "worlds." + world; + if (!config.contains(root)) { + config.createSection(root); + } + plotworld.saveConfiguration(config.getConfigurationSection(root)); + ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = height; + ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = height; + ClassicPlotWorld.WALL_HEIGHT_DEFAULT = height; + ClassicPlotWorld.TOP_BLOCK_DEFAULT = floor; + ClassicPlotWorld.MAIN_BLOCK_DEFAULT = main; + ClassicPlotWorld.WALL_BLOCK_DEFAULT = border; + ClassicPlotWorld.WALL_FILLING_DEFAULT = wall; + SquarePlotWorld.PLOT_WIDTH_DEFAULT = width; + SquarePlotWorld.ROAD_WIDTH_DEFAULT = gap; + } catch (final Exception e) { + e.printStackTrace(); + } + } + return true; + } + + @Override + public Connection getConnection() { return connection; } - public PlotSquared(final IPlotMain imp_class) { - SetupUtils.generators = new HashMap<>(); - THIS = this; - IMP = imp_class; - try { - FILE = new File(PlotSquared.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); - } - catch (Exception e) { - log("Could not determine file path"); - } - VERSION = IMP.getVersion(); - EconHandler.manager = IMP.getEconomyHandler(); - C.setupTranslations(); - C.saveTranslations(); - if (getJavaVersion() < 1.7) { - log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); - // Didn't know of any other link :D - log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); - IMP.disable(); - return; - } - if (getJavaVersion() < 1.8) { - log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); - } - TASK = IMP.getTaskManager(); - if (C.ENABLED.s().length() > 0) { - log(C.ENABLED.s()); - } - setupConfigs(); - setupDefaultFlags(); - setupDatabase(); - CommentManager.registerDefaultInboxes(); - // Tasks - if (Settings.KILL_ROAD_MOBS) { - IMP.runEntityTask(); - } - // Events - IMP.registerCommands(); - IMP.registerPlayerEvents(); - IMP.registerInventoryEvents(); - IMP.registerPlotPlusEvents(); - IMP.registerForceFieldEvents(); - IMP.registerWorldEditEvents(); - IMP.registerWorldEvents(); - if (Settings.TNT_LISTENER) { - IMP.registerTNTListener(); - } - if (Settings.CHUNK_PROCESSOR) { - IMP.registerChunkProcessor(); - } - // create UUIDWrapper - UUIDHandler.uuidWrapper = IMP.initUUIDHandler(); - // create event util class - EventUtil.manager = IMP.initEventUtil(); - // create Hybrid utility class - HybridUtils.manager = IMP.initHybridUtils(); - // Inventory utility class - InventoryUtil.manager = IMP.initInventoryUtil(); - // create setup util class - SetupUtils.manager = IMP.initSetupUtils(); - // Set block - BlockManager.manager = IMP.initBlockManager(); - // Set chunk - ChunkManager.manager = IMP.initChunkManager(); - // Plot listener - APlotListener.manager = IMP.initPlotListener(); - // Player manager - PlayerManager.manager = IMP.initPlayerManager(); - - // PlotMe - if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - if (IMP.initPlotMeConverter()) { - log("&c=== IMPORTANT ==="); - log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); - log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); - log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); - log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'"); - } - } - }, 200); - } - if (Settings.AUTO_CLEAR) { - ExpireManager.runTask(); - } - - // Copy files - copyFile("town.template", "templates"); - copyFile("skyblock.template", "templates"); - copyFile("german.yml", "translations"); - copyFile("s_chinese_unescaped.yml", "translations"); - copyFile("s_chinese.yml", "translations"); - copyFile("italian.yml", "translations"); - showDebug(); - } - + @Override public void copyFile(String file, String folder) { try { byte[] buffer = new byte[2048]; - File output = PlotSquared.IMP.getDirectory(); + File output = IMP.getDirectory(); if (!output.exists()) { output.mkdirs(); } @@ -636,6 +719,7 @@ public class PlotSquared { } } + @Override public void disable() { try { database.closeConnection(); @@ -644,14 +728,11 @@ public class PlotSquared { } } - public static void log(final String message) { - IMP.log(message); - } - + @Override public void setupDatabase() { if (Settings.DB.USE_MYSQL) { try { - database = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD); + database = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD); connection = database.openConnection(); { if (DBFunc.dbManager == null) { @@ -679,7 +760,7 @@ public class PlotSquared { log(C.PREFIX.s() + "MongoDB is not yet implemented"); } else if (Settings.DB.USE_SQLITE) { try { - this.database = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db"); + this.database = new SQLite(this, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db"); connection = this.database.openConnection(); { DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); @@ -705,7 +786,8 @@ public class PlotSquared { } } - public static void setupDefaultFlags() { + @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"); final List stringFlags = Arrays.asList("greeting", "farewell"); @@ -797,7 +879,8 @@ public class PlotSquared { }); } - public static void setupConfig() { + @Override + public void setupConfig() { config.set("version", VERSION); final Map options = new HashMap<>(); @@ -976,7 +1059,8 @@ public class PlotSquared { Settings.METRICS = config.getBoolean("metrics"); } - public static void setupConfigs() { + @Override + public void setupConfigs() { final File folder = new File(IMP.getDirectory() + File.separator + "config"); if (!folder.exists() && !folder.mkdirs()) { log(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually."); @@ -1030,7 +1114,7 @@ public class PlotSquared { } } - private static void setupStorage() { + private void setupStorage() { storage.set("version", VERSION); final Map options = new HashMap<>(); options.put("mysql.use", false); @@ -1062,7 +1146,8 @@ public class PlotSquared { Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban"); } - public static void showDebug() { + @Override + public void showDebug() { C.COLOR_1 = "&" + (style.getString("color.1")); C.COLOR_2 = "&" + (style.getString("color.2")); C.COLOR_3 = "&" + (style.getString("color.3")); @@ -1085,7 +1170,7 @@ public class PlotSquared { } } - private static void setupStyle() { + private void setupStyle() { style.set("version", VERSION); final Map o = new HashMap<>(); o.put("color.1", C.COLOR_1.substring(1)); @@ -1099,15 +1184,18 @@ public class PlotSquared { } } - public static double getJavaVersion() { + @Override + public double getJavaVersion() { return Double.parseDouble(System.getProperty("java.specification.version")); } - public static Set getPlotWorlds() { + @Override + public Set getPlotWorlds() { return plotworlds.keySet(); } - - public static Collection getPlotWorldObjects() { + + @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 new file mode 100644 index 000000000..868c779ec --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquaredMain.java @@ -0,0 +1,85 @@ +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); + + Set getPlots(UUID uuid); + + boolean removePlot(String world, PlotId id, boolean callEvent); + + void loadWorld(String world, PlotGenerator generator); + + boolean setupPlotWorld(String world, String id); + + Connection getConnection(); + + void copyFile(String file, String folder); + + void disable(); + + void setupDatabase(); + + void setupDefaultFlags(); + + void setupConfig(); + + void setupConfigs(); + + void showDebug(); + + double getJavaVersion(); + + Set getPlotWorlds(); + + Collection getPlotWorldObjects(); +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index d8509d15c..284ff289d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -21,37 +21,27 @@ package com.intellectualcrafters.plot.api; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; - -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.SubCommand; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.uuid.UUIDWrapper; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; /** * PlotSquared API @@ -93,7 +83,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.PlotSquared#getPlots() */ public Set getAllPlots() { - return PlotSquared.getPlots(); + return PlotSquared.getInstance().getPlots(); } /** @@ -104,7 +94,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @return all plots that a player owns */ public Set getPlayerPlots(final Player player) { - return PlotSquared.getPlots(BukkitUtil.getPlayer(player)); + return PlotSquared.getInstance().getPlots(BukkitUtil.getPlayer(player)); } /** @@ -118,7 +108,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * com.intellectualcrafters.plot.object.PlotManager) */ public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) { - PlotSquared.addPlotWorld(world, plotWorld, manager); + PlotSquared.getInstance().addPlotWorld(world, plotWorld, manager); } /** @@ -286,7 +276,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see PlotSquared#getPlotManager(String) */ public PlotManager getPlotManager(final World world) { - return PlotSquared.getPlotManager(world.getName()); + return PlotSquared.getInstance().getPlotManager(world.getName()); } /** @@ -301,7 +291,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.object.PlotManager */ public PlotManager getPlotManager(final String world) { - return PlotSquared.getPlotManager(world); + return PlotSquared.getInstance().getPlotManager(world); } /** @@ -316,7 +306,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.object.PlotWorld */ public PlotWorld getWorldSettings(final World world) { - return PlotSquared.getPlotWorld(world.getName()); + return PlotSquared.getInstance().getPlotWorld(world.getName()); } /** @@ -330,7 +320,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.object.PlotWorld */ public PlotWorld getWorldSettings(final String world) { - return PlotSquared.getPlotWorld(world); + return PlotSquared.getInstance().getPlotWorld(world); } /** @@ -472,7 +462,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; */ public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) { final ArrayList pPlots = new ArrayList<>(); - for (final Plot plot : PlotSquared.getPlots(world.getName()).values()) { + for (final Plot plot : PlotSquared.getInstance().getPlots(world.getName()).values()) { if (just_owner) { if ((plot.owner != null) && (plot.owner.equals(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr))))) { pPlots.add(plot); @@ -497,7 +487,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.object.Plot */ public Plot[] getPlots(final World world) { - Collection plots = PlotSquared.getPlots(world.getName()).values(); + Collection plots = PlotSquared.getInstance().getPlots(world.getName()).values(); return plots.toArray(new Plot[plots.size()]); } @@ -509,7 +499,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.PlotSquared#getPlotWorlds() */ public String[] getPlotWorlds() { - Set worlds = PlotSquared.getPlotWorlds(); + Set worlds = PlotSquared.getInstance().getPlotWorlds(); return worlds.toArray(new String[worlds.size()]); } @@ -523,7 +513,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(String) */ public boolean isPlotWorld(final World world) { - return PlotSquared.isPlotWorld(world.getName()); + return PlotSquared.getInstance().isPlotWorld(world.getName()); } /** @@ -652,7 +642,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @see com.intellectualcrafters.plot.object.Plot */ public Set getPlayerPlots(final World world, final Player player) { - return PlotSquared.getPlots(world.getName(), BukkitUtil.getPlayer(player)); + return PlotSquared.getInstance().getPlots(world.getName(), BukkitUtil.getPlayer(player)); } /** @@ -662,7 +652,6 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return the number of allowed plots * - * @see com.intellectualcrafters.plot.util.MainUtil#getAllowedPlots(PlotPlayer, int) */ public int getAllowedPlots(final Player player) { PlotPlayer pp = BukkitUtil.getPlayer(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java index bf2a7572a..c938517d1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.UUID; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -33,6 +31,8 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import java.util.UUID; + public class Add extends SubCommand { public Add() { super(Command.ADD, "Allow a user to build while you are online", "add ", CommandCategory.ACTIONS, true); @@ -77,7 +77,7 @@ public class Add extends SubCommand { DBFunc.removeTrusted(loc.getWorld(), plot, uuid); } if (plot.denied.contains(uuid)) { - if (plot.members.size() + plot.trusted.size() >= PlotSquared.getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { + if (plot.members.size() + plot.trusted.size() >= PlotSquared.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); return false; } @@ -91,7 +91,7 @@ public class Add extends SubCommand { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } - if (plot.members.size() + plot.trusted.size() >= PlotSquared.getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { + if (plot.members.size() + plot.trusted.size() >= PlotSquared.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index e685683d1..98459cfc4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -23,12 +23,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotCluster; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; @@ -75,11 +70,11 @@ public class Auto extends SubCommand { int size_x = 1; int size_z = 1; String schematic = ""; - if (PlotSquared.getPlotWorlds().size() == 1) { - world = PlotSquared.getPlotWorlds().iterator().next(); + if (PlotSquared.getInstance().getPlotWorlds().size() == 1) { + world = PlotSquared.getInstance().getPlotWorlds().iterator().next(); } else { world = plr.getLocation().getWorld(); - if (!PlotSquared.isPlotWorld(world)) { + if (!PlotSquared.getInstance().isPlotWorld(world)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } @@ -127,7 +122,7 @@ public class Auto extends SubCommand { } return false; } - final PlotWorld pWorld = PlotSquared.getPlotWorld(world); + final PlotWorld pWorld = PlotSquared.getInstance().getPlotWorld(world); if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) { double cost = pWorld.PLOT_PRICE; cost = (size_x * size_z) * cost; @@ -153,7 +148,7 @@ public class Auto extends SubCommand { // } } final String worldname = world; - final PlotWorld plotworld = PlotSquared.getPlotWorld(worldname); + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(worldname); if (plotworld.TYPE == 2) { final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(new Location(worldname, loc.getX(), loc.getY(), loc.getZ())); @@ -204,7 +199,7 @@ public class Auto extends SubCommand { MainUtil.lastPlot.put(worldname, start); if (lastPlot) { } - if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) { + if ((PlotSquared.getInstance().getPlots(worldname).get(start) != null) && (PlotSquared.getInstance().getPlots(worldname).get(start).owner != null)) { continue; } else { lastPlot = false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 51bf5ff35..36769c9cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -26,12 +26,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotHandler; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -51,7 +46,7 @@ public class Buy extends SubCommand { } final Location loc = plr.getLocation(); final String world = loc.getWorld(); - if (!PlotSquared.isPlotWorld(world)) { + if (!PlotSquared.getInstance().isPlotWorld(world)) { return sendMessage(plr, C.NOT_IN_PLOT_WORLD); } Plot plot; @@ -88,7 +83,7 @@ public class Buy extends SubCommand { final PlotId id = plot.id; final PlotId id2 = MainUtil.getTopPlot(plot).id; final int size = MainUtil.getPlotSelectionIds(id, id2).size(); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); if (plotworld.USE_ECONOMY) { price += plotworld.PLOT_PRICE * size; initPrice += plotworld.SELL_PRICE * size; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Chat.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Chat.java index 96badc9a1..c3a63c616 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Chat.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Chat.java @@ -13,7 +13,7 @@ public class Chat extends SubCommand { @Override public boolean execute(PlotPlayer plr, String... args) { final String world = plr.getLocation().getWorld(); - if (!PlotSquared.isPlotWorld(world)) { + if (!PlotSquared.getInstance().isPlotWorld(world)) { return !sendMessage(plr, C.NOT_IN_PLOT_WORLD); } boolean enable = !(plr.getMeta("chat") != null && (Boolean) plr.getMeta("chat")); @@ -24,7 +24,7 @@ public class Chat extends SubCommand { enable = false; } } - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); if (!enable && plotworld.PLOT_CHAT) { return !sendMessage(plr, C.PLOT_CHAT_FORCED); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index ef1f75809..52cdecbe3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -27,11 +27,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.EconHandler; -import com.intellectualcrafters.plot.util.EventUtil; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; /** @@ -60,8 +56,8 @@ public class Claim extends SubCommand { MainUtil.teleportPlayer(player, loc, plot); } final String world = plot.world; - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final Plot plot2 = PlotSquared.getPlots(world).get(plot.id); + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); + final Plot plot2 = PlotSquared.getInstance().getPlots(world).get(plot.id); if (plotworld.SCHEMATIC_ON_CLAIM) { Schematic sch; if (schematic.equals("")) { @@ -74,7 +70,7 @@ public class Claim extends SubCommand { } SchematicHandler.manager.paste(sch, plot2, 0, 0); } - PlotSquared.getPlotManager(world).claimPlot(plotworld, plot); + PlotSquared.getInstance().getPlotManager(world).claimPlot(plotworld, plot); } return result; } @@ -97,7 +93,7 @@ public class Claim extends SubCommand { if (!MainUtil.canClaim(plr, plot)) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } - final PlotWorld world = PlotSquared.getPlotWorld(plot.world); + final PlotWorld world = PlotSquared.getInstance().getPlotWorld(plot.world); if ((EconHandler.manager != null) && world.USE_ECONOMY) { final double cost = world.PLOT_PRICE; if (cost > 0d) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 287c0e05d..2b96075e1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.Set; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -35,6 +33,8 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import java.util.Set; + public class Clear extends SubCommand { public Clear() { super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false); @@ -52,7 +52,7 @@ public class Clear extends SubCommand { if (id == null) { PlotSquared.log("Invalid Plot ID: " + args[0]); } else { - if (!PlotSquared.isPlotWorld(world)) { + if (!PlotSquared.getInstance().isPlotWorld(world)) { PlotSquared.log("Invalid plot world: " + world); } else { final Plot plot = MainUtil.getPlot(world, id); @@ -84,7 +84,7 @@ public class Clear extends SubCommand { PlotId id = PlotId.fromString(args[0]); if (id == null) { if (args[1].equalsIgnoreCase("mine")) { - Set plots = PlotSquared.getPlots(plr); + Set plots = PlotSquared.getInstance().getPlots(plr); if (plots.size() == 0) { MainUtil.sendMessage(plr, C.NO_PLOTS); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 55211105c..f88809168 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -20,29 +20,21 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.UUID; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotCluster; -import com.intellectualcrafters.plot.object.PlotClusterId; -import com.intellectualcrafters.plot.object.PlotGenerator; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.UUID; + public class Cluster extends SubCommand { public Cluster() { super(Command.CLUSTER, "Manage a plot cluster", "cluster", CommandCategory.ACTIONS, true); @@ -129,17 +121,17 @@ public class Cluster extends SubCommand { } ClusterManager.clusters.get(world).add(cluster); // Add any existing plots to the current cluster - for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { + for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster current = ClusterManager.getCluster(plot); if (cluster.equals(current) && !cluster.isAdded(plot.owner)) { cluster.invited.add(plot.owner); DBFunc.setInvited(world, cluster, plot.owner); } } - PlotWorld plotworld = PlotSquared.getPlotWorld(world); + PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); if (plotworld == null) { PlotSquared.config.createSection("worlds." + world); - PlotSquared.loadWorld(world, null); + PlotSquared.getInstance().loadWorld(world, null); } else { final String gen_string = PlotSquared.config.getString("worlds." + world + "." + "generator.plugin"); @@ -185,10 +177,10 @@ public class Cluster extends SubCommand { return false; } } - final PlotWorld plotworld = PlotSquared.getPlotWorld(plr.getLocation().getWorld()); + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plr.getLocation().getWorld()); if (plotworld.TYPE == 2) { final ArrayList toRemove = new ArrayList<>(); - for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { + for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster other = ClusterManager.getCluster(plot); if (cluster.equals(other)) { toRemove.add(plot); @@ -369,7 +361,7 @@ public class Cluster extends SubCommand { if (player != null) { MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } - for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld(), uuid)) { + for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { final String world = plr.getLocation().getWorld(); @@ -419,7 +411,7 @@ public class Cluster extends SubCommand { cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); - for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld(), uuid)) { + for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { final String world = plr.getLocation().getWorld(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index 4beff2d08..c86d0194c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -20,14 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang.StringUtils; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; @@ -35,6 +27,10 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import org.apache.commons.lang.StringUtils; + +import java.util.*; +import java.util.Set; public class Condense extends SubCommand { public static boolean TASK = false; @@ -43,6 +39,10 @@ public class Condense extends SubCommand { super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false); } + public static void sendMessage(final String message) { + PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message); + } + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { @@ -54,7 +54,7 @@ public class Condense extends SubCommand { return false; } final String worldname = args[0]; - if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) { + if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.getInstance().isPlotWorld(worldname)) { MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } @@ -199,8 +199,4 @@ public class Condense extends SubCommand { } return outside; } - - public static void sendMessage(final String message) { - PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message); - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java index 3d41ef692..7abfed0a4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -41,7 +41,7 @@ public class CreateRoadSchematic extends SubCommand { if (plot == null) { return sendMessage(player, C.NOT_IN_PLOT); } - if (!(PlotSquared.getPlotWorld(loc.getWorld()) instanceof HybridPlotWorld)) { + if (!(PlotSquared.getInstance().getPlotWorld(loc.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } HybridUtils.manager.setupRoadSchematic(plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java index a4fcf1075..4cf51a847 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -1,10 +1,5 @@ package com.intellectualcrafters.plot.commands; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.UUID; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.MySQL; @@ -16,6 +11,11 @@ import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.UUID; + /** * Created 2014-11-15 for PlotSquared * @@ -41,7 +41,7 @@ public class Database extends SubCommand { } public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) { - final java.util.Set plots = PlotSquared.getPlots(); + final java.util.Set plots = PlotSquared.getInstance().getPlots(); TaskManager.runTaskAsync(new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index b3b50dea6..7f1e6329b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -51,7 +51,7 @@ public class Debug extends SubCommand { } { final StringBuilder worlds = new StringBuilder(""); - for (final String world : PlotSquared.getPlotWorlds()) { + for (final String world : PlotSquared.getInstance().getPlotWorlds()) { worlds.append(world).append(" "); } information.append(header); @@ -61,7 +61,7 @@ public class Debug extends SubCommand { information.append(getLine(line, "TPS Percentage", (int) Lag.getFullPercentage() + "%")); information.append(getSection(section, "PlotWorld")); information.append(getLine(line, "Plot Worlds", worlds)); - information.append(getLine(line, "Owned Plots", PlotSquared.getPlots().size())); + information.append(getLine(line, "Owned Plots", PlotSquared.getInstance().getPlots().size())); information.append(getSection(section, "Messages")); information.append(getLine(line, "Total Messages", C.values().length)); information.append(getLine(line, "View all captions", "/plot debug msg")); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index f007b537a..8fb5dc78c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -20,27 +20,20 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.UUID; - import com.google.common.collect.BiMap; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.object.ChunkLoc; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import java.util.ArrayList; +import java.util.UUID; + /** * @author Citymonstret */ @@ -73,7 +66,7 @@ public class DebugClaimTest extends SubCommand { return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}"); } final String world = args[0]; - if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) { + if (!BlockManager.manager.isWorld(world) || !PlotSquared.getInstance().isPlotWorld(world)) { return !MainUtil.sendMessage(null, "&cInvalid plot world!"); } PlotId min, max; @@ -87,12 +80,12 @@ public class DebugClaimTest extends SubCommand { } MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while..."); MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)"); - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotManager manager = PlotSquared.getInstance().getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); final ArrayList plots = new ArrayList<>(); for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) { final Plot plot = MainUtil.getPlot(world, id); - final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id); + final boolean contains = PlotSquared.getInstance().getPlots(world).containsKey(plot.id); if (contains) { MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id); continue; @@ -141,7 +134,7 @@ public class DebugClaimTest extends SubCommand { } }); for (final Plot plot : plots) { - PlotSquared.updatePlot(plot); + PlotSquared.getInstance().updatePlot(plot); } MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index 2883c198c..524d38270 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -49,7 +49,7 @@ public class DebugClear extends SubCommand { if (id == null) { PlotSquared.log("Invalid Plot ID: " + args[0]); } else { - if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) { + if (!PlotSquared.getInstance().isPlotWorld(world) || !(PlotSquared.getInstance().getPlotWorld(world) instanceof SquarePlotWorld)) { PlotSquared.log("Invalid plot world: " + world); } else { final Plot plot = MainUtil.getPlot(world, id); @@ -79,7 +79,7 @@ public class DebugClear extends SubCommand { } final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); - if ((plot == null) || !(PlotSquared.getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) { + if ((plot == null) || !(PlotSquared.getInstance().getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) { return sendMessage(plr, C.NOT_IN_PLOT); } if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 71dfe6766..3af3007b0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -20,38 +20,26 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.flag.FlagValue; -import com.intellectualcrafters.plot.flag.FlagValue.IntegerListValue; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils; -import com.intellectualcrafters.plot.object.ChunkLoc; -import com.intellectualcrafters.plot.object.OfflinePlotPlayer; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotAnalysis; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.sql.Timestamp; +import java.util.*; public class DebugExec extends SubCommand { public DebugExec() { @@ -60,7 +48,7 @@ public class DebugExec extends SubCommand { @Override public boolean execute(final PlotPlayer player, final String... args) { - final List allowed_params = Arrays.asList(new String[] { "analyze", "reset-modified", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check" }); + final List allowed_params = Arrays.asList("analyze", "reset-modified", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check"); if (args.length > 0) { final String arg = args[0].toLowerCase(); switch (arg) { @@ -70,13 +58,13 @@ public class DebugExec extends SubCommand { @Override public void run() { List result = new ArrayList<>(); - result.add((double) (Math.round(value.air * 100) / 100d)); - result.add((double) (Math.round(value.changes * 100) / 100d)); - result.add((double) (Math.round(value.complexity * 100) / 100d)); - result.add((double) (Math.round(value.data * 100) / 100d)); - result.add((double) (Math.round(value.faces * 100) / 100d)); - result.add((double) (Math.round(value.air * 100) / 100d)); - result.add((double) (Math.round(value.variety * 100) / 100d)); + result.add(Math.round(value.air * 100) / 100d); + result.add(Math.round(value.changes * 100) / 100d); + result.add(Math.round(value.complexity * 100) / 100d); + result.add(Math.round(value.data * 100) / 100d); + result.add(Math.round(value.faces * 100) / 100d); + result.add(Math.round(value.air * 100) / 100d); + result.add(Math.round(value.variety * 100) / 100d); Flag flag = new Flag(FlagManager.getFlag("analysis"), result); FlagManager.addPlotFlag(plot, flag); } @@ -98,7 +86,7 @@ public class DebugExec extends SubCommand { return false; } String flag = args[1]; - for (Plot plot : PlotSquared.getPlots()) { + for (Plot plot : PlotSquared.getInstance().getPlots()) { if (FlagManager.getPlotFlag(plot, flag) != null) { FlagManager.removePlotFlag(plot, flag); } @@ -111,7 +99,7 @@ public class DebugExec extends SubCommand { return false; } boolean result; - if (!PlotSquared.isPlotWorld(args[1])) { + if (!PlotSquared.getInstance().isPlotWorld(args[1])) { MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]); return false; } @@ -138,7 +126,7 @@ public class DebugExec extends SubCommand { while (BukkitHybridUtils.chunks.size() > 0) { ChunkLoc chunk = BukkitHybridUtils.chunks.get(0); BukkitHybridUtils.chunks.remove(0); - ((BukkitHybridUtils)(HybridUtils.manager)).regenerateRoad(BukkitHybridUtils.world, chunk, 0); + HybridUtils.manager.regenerateRoad(BukkitHybridUtils.world, chunk, 0); ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk); } PlotSquared.log("&cCancelled!"); @@ -209,7 +197,7 @@ public class DebugExec extends SubCommand { return MainUtil.sendMessage(player, "&7 - Run after plot expiry has run"); } final String world = args[1]; - if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(args[1])) { + if (!BlockManager.manager.isWorld(world) || !PlotSquared.getInstance().isPlotWorld(args[1])) { return MainUtil.sendMessage(player, "Invalid world: " + args[1]); } final ArrayList empty = new ArrayList<>(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java index fd2959b45..efe5d2981 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -20,16 +20,9 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.Set; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; @@ -37,6 +30,10 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + public class DebugFixFlags extends SubCommand { public DebugFixFlags() { super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false); @@ -53,12 +50,12 @@ public class DebugFixFlags extends SubCommand { return false; } final String world = args[0]; - if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) { + if (!BlockManager.manager.isWorld(world) || !PlotSquared.getInstance().isPlotWorld(world)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); return false; } MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---"); - for (final Plot plot : PlotSquared.getPlots(world).values()) { + for (final Plot plot : PlotSquared.getInstance().getPlots(world).values()) { final HashMap flags = plot.settings.flags; Iterator> i = flags.entrySet().iterator(); boolean changed = false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index 960dc77d4..7e9b8b106 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -38,7 +38,7 @@ public class DebugRoadRegen extends SubCommand { public boolean execute(final PlotPlayer player, final String... args) { final Location loc = player.getLocation(); final String world = loc.getWorld(); - if (!(PlotSquared.getPlotWorld(world) instanceof HybridPlotWorld)) { + if (!(PlotSquared.getInstance().getPlotWorld(world) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java index 6b3166742..f4854901d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -20,14 +20,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import java.util.ArrayList; + /** * @author Citymonstret */ @@ -40,7 +40,7 @@ public class DebugSaveTest extends SubCommand { public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { final ArrayList plots = new ArrayList(); - plots.addAll(PlotSquared.getPlots()); + plots.addAll(PlotSquared.getInstance().getPlots()); MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`"); DBFunc.createPlotsAndData(plots, new Runnable() { @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 92c2f2351..702672cca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -20,16 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.io.File; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map.Entry; -import java.util.UUID; - -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -47,6 +37,15 @@ import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper; +import org.bukkit.Bukkit; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.UUID; public class DebugUUID extends SubCommand { public DebugUUID() { @@ -215,8 +214,8 @@ public class DebugUUID extends SubCommand { UUIDHandler.uuidWrapper = newWrapper; MainUtil.sendConsoleMessage("&7 - Updating plot objects"); - - for (Plot plot : PlotSquared.getPlotsRaw()) { + + for (Plot plot : PlotSquared.getInstance().getPlotsRaw()) { UUID value = uCMap.get(plot.owner); if (value != null) { plot.owner = value; @@ -236,13 +235,13 @@ public class DebugUUID extends SubCommand { database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite"); if (!result) { MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery"); - for (Plot plot : PlotSquared.getPlots()) { + for (Plot plot : PlotSquared.getInstance().getPlots()) { UUID value = uCReverse.get(plot.owner); if (value != null) { plot.owner = value; } } - database.createPlotsAndData(new ArrayList<>(PlotSquared.getPlots()), new Runnable() { + database.createPlotsAndData(new ArrayList<>(PlotSquared.getInstance().getPlots()), new Runnable() { @Override public void run() { MainUtil.sendMessage(null, "&6Recovery was successful!"); @@ -280,7 +279,7 @@ public class DebugUUID extends SubCommand { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - ArrayList plots = new ArrayList<>(PlotSquared.getPlots()); + ArrayList plots = new ArrayList<>(PlotSquared.getInstance().getPlots()); database.createPlotsAndData(plots, new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index fb416dde1..e3659f964 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -28,11 +28,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.CmdConfirm; -import com.intellectualcrafters.plot.util.EconHandler; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Delete extends SubCommand { @@ -54,7 +50,7 @@ public class Delete extends SubCommand { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world); + final PlotWorld pWorld = PlotSquared.getInstance().getPlotWorld(plot.world); if (MainUtil.runners.containsKey(plot)) { MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); return false; @@ -69,7 +65,7 @@ public class Delete extends SubCommand { sendMessage(plr, C.ADDED_BALANCE, c + ""); } } - PlotSquared.removePlot(loc.getWorld(), plot.id, true); + PlotSquared.getInstance().removePlot(loc.getWorld(), plot.id, true); final long start = System.currentTimeMillis(); final boolean result = MainUtil.clearAsPlayer(plot, true, new Runnable() { @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 24da0bc8b..9337babbc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -20,14 +20,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import java.util.ArrayList; + /** * @author Citymonstret */ @@ -37,7 +37,7 @@ public class Home extends SubCommand { } private Plot isAlias(final String a) { - for (final Plot p : PlotSquared.getPlots()) { + for (final Plot p : PlotSquared.getInstance().getPlots()) { if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { return p; } @@ -47,7 +47,7 @@ public class Home extends SubCommand { @Override public boolean execute(final PlotPlayer plr, String... args) { - final ArrayList plots = PlotSquared.sortPlotsByWorld(PlotSquared.getPlots(plr)); + final ArrayList plots = PlotSquared.getInstance().sortPlotsByWorld(PlotSquared.getInstance().getPlots(plr)); if (plots.size() == 1) { MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 948e271dc..75b50510c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -20,26 +20,17 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import org.apache.commons.lang.StringUtils; + import java.util.ArrayList; import java.util.HashSet; import java.util.UUID; -import org.apache.commons.lang.StringUtils; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.CmdConfirm; -import com.intellectualcrafters.plot.util.EconHandler; -import com.intellectualcrafters.plot.util.EventUtil; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; - /** * @author Citymonstret */ @@ -172,7 +163,7 @@ public class Merge extends SubCommand { sendMessage(accepter, C.MERGE_NOT_VALID); return; } - final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); + final PlotWorld plotWorld = PlotSquared.getInstance().getPlotWorld(world); if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; cost = plots.size() * cost; @@ -201,7 +192,7 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.MERGE_REQUESTED); return true; } - final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); + final PlotWorld plotWorld = PlotSquared.getInstance().getPlotWorld(world); if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; cost = plots.size() * cost; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 6ea615e2d..bede75847 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -22,11 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; @@ -65,12 +61,12 @@ public class Move extends SubCommand { } String world2; if (args.length == 2) { - PlotWorld other = PlotSquared.getPlotWorld(args[1]); - PlotWorld current = PlotSquared.getPlotWorld(loc.getWorld()); - if (other == null || current == null || !other.equals(current)) { - MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE); - return false; - } + PlotWorld other = PlotSquared.getInstance().getPlotWorld(args[1]); + PlotWorld current = PlotSquared.getInstance().getPlotWorld(loc.getWorld()); + if (other == null || current == null || !other.equals(current)) { + MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE); + return false; + } world2 = other.worldname; } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index e729212e1..affc60720 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -20,11 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -34,6 +29,11 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + @SuppressWarnings({ "javadoc" }) public class Purge extends SubCommand { public Purge() { @@ -91,7 +91,7 @@ public class Purge extends SubCommand { return false; } final String worldname = args[1]; - if (!PlotSquared.getAllPlotsRaw().containsKey(worldname)) { + if (!PlotSquared.getInstance().getAllPlotsRaw().containsKey(worldname)) { MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } @@ -107,7 +107,7 @@ public class Purge extends SubCommand { return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0); } if (arg.equals("all")) { - final Set ids = PlotSquared.getPlots(worldname).keySet(); + final Set ids = PlotSquared.getInstance().getPlots(worldname).keySet(); int length = ids.size(); if (length == 0) { return MainUtil.sendMessage(null, "&cNo plots found"); @@ -116,7 +116,7 @@ public class Purge extends SubCommand { return finishPurge(length); } if (arg.equals("unknown")) { - final Collection plots = PlotSquared.getPlots(worldname).values(); + final Collection plots = PlotSquared.getInstance().getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { if (plot.owner != null) { @@ -134,7 +134,7 @@ public class Purge extends SubCommand { return finishPurge(length); } if (arg.equals("unowned")) { - final Collection plots = PlotSquared.getPlots(worldname).values(); + final Collection plots = PlotSquared.getInstance().getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { if (plot.owner == null) { @@ -150,7 +150,7 @@ public class Purge extends SubCommand { } final UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - final Set plots = PlotSquared.getPlots(worldname, uuid); + final Set plots = PlotSquared.getInstance().getPlots(worldname, uuid); final Set ids = new HashSet<>(); for (final Plot plot : plots) { ids.add(plot.id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index a34696752..21ffe0e08 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.List; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; @@ -31,6 +29,8 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.ChunkManager; +import java.util.List; + public class RegenAllRoads extends SubCommand { public RegenAllRoads() { super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "rgar", CommandCategory.DEBUG, false); @@ -58,7 +58,7 @@ public class RegenAllRoads extends SubCommand { } } final String name = args[0]; - final PlotManager manager = PlotSquared.getPlotManager(name); + final PlotManager manager = PlotSquared.getInstance().getPlotManager(name); if ((manager == null) || !(manager instanceof HybridPlotManager)) { sendMessage(player, C.NOT_VALID_PLOT_WORLD); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index 07b9cb6ad..ef37e30c0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -37,10 +37,10 @@ public class Reload extends SubCommand { // The following won't affect world generation, as that has to be // loaded during startup unfortunately. PlotSquared.config.load(PlotSquared.configFile); - PlotSquared.setupConfig(); + PlotSquared.getInstance().setupConfig(); C.setupTranslations(); - for (final String pw : PlotSquared.getPlotWorlds()) { - final PlotWorld plotworld = PlotSquared.getPlotWorld(pw); + for (final String pw : PlotSquared.getInstance().getPlotWorlds()) { + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(pw); plotworld.loadDefaultConfiguration(PlotSquared.config.getConfigurationSection("worlds." + pw)); } MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index e258227c1..dfdd69b16 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -20,26 +20,22 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; -import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; + public class SchematicCmd extends SubCommand { private int counter = 0; private boolean running = false; @@ -202,7 +198,7 @@ public class SchematicCmd extends SubCommand { MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall "); return false; } - final HashMap plotmap = PlotSquared.getPlots(args[1]); + final HashMap plotmap = PlotSquared.getInstance().getPlots(args[1]); if ((plotmap == null) || (plotmap.size() == 0)) { MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall "); return false; @@ -254,11 +250,11 @@ public class SchematicCmd extends SubCommand { world = args[1]; final String[] split = args[2].split(";"); final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) { + if ((PlotSquared.getInstance().getPlots(world) == null) || (PlotSquared.getInstance().getPlots(world).get(i) == null)) { MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } - p2 = PlotSquared.getPlots(world).get(i); + p2 = PlotSquared.getInstance().getPlots(world).get(i); } catch (final Exception e) { MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 36cc120e9..052448af9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -20,12 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang.StringUtils; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; @@ -33,22 +27,15 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.flag.FlagValue.PlotBlockListValue; import com.intellectualcrafters.plot.listeners.APlotListener; -import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.SetBlockQueue; -import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** * @author Citymonstret @@ -79,10 +66,10 @@ public class Set extends SubCommand { } } if (args.length < 1) { - PlotManager manager = PlotSquared.getPlotManager(loc.getWorld()); + PlotManager manager = PlotSquared.getInstance().getPlotManager(loc.getWorld()); ArrayList newValues = new ArrayList(); newValues.addAll(Arrays.asList(values)); - newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getPlotWorld(loc.getWorld()), plot.id))); + newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getInstance().getPlotWorld(loc.getWorld()), plot.id))); MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues)); return false; } @@ -184,7 +171,7 @@ public class Set extends SubCommand { MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG); return false; } - for (final Plot p : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { + for (final Plot p : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) { if (p.settings.getAlias().equalsIgnoreCase(alias)) { MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; @@ -230,8 +217,8 @@ public class Set extends SubCommand { } // Get components final String world = plr.getLocation().getWorld(); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); + final PlotManager manager = PlotSquared.getInstance().getPlotManager(world); final String[] components = manager.getPlotComponents(plotworld, plot.id); for (final String component : components) { if (component.equalsIgnoreCase(args[0])) { @@ -321,7 +308,7 @@ public class Set extends SubCommand { } ArrayList newValues = new ArrayList(); newValues.addAll(Arrays.asList(values)); - newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getPlotWorld(loc.getWorld()), plot.id))); + newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getInstance().getPlotWorld(loc.getWorld()), plot.id))); MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues)); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 34615be81..59afdc198 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -20,9 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.UUID; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -35,6 +32,9 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import java.util.ArrayList; +import java.util.UUID; + public class SetOwner extends SubCommand { public SetOwner() { super("setowner", "plots.set.owner", "Set the plot owner", "setowner ", "so", CommandCategory.ACTIONS, true); @@ -93,14 +93,14 @@ public class SetOwner extends SubCommand { final String world = loc.getWorld(); for (final PlotId id : plots) { - final Plot current = PlotSquared.getPlots(world).get(id); + final Plot current = PlotSquared.getInstance().getPlots(world).get(id); final UUID uuid = getUUID(args[0]); if (uuid == null) { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } current.owner = uuid; - PlotSquared.updatePlot(current); + PlotSquared.getInstance().updatePlot(current); DBFunc.setOwner(current, current.owner); } MainUtil.setSign(args[0], plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java index ba0b9a4d8..4cbd47b85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.apache.commons.lang.StringUtils; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; @@ -31,6 +29,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import org.apache.commons.lang.StringUtils; /** * @author Citymonstret @@ -56,7 +55,7 @@ public class TP extends SubCommand { world = args[1]; } } - if (!PlotSquared.isPlotWorld(world)) { + if (!PlotSquared.getInstance().isPlotWorld(world)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } @@ -86,7 +85,7 @@ public class TP extends SubCommand { } final PlotPlayer player = UUIDHandler.getPlayer(a); if (player != null) { - final java.util.Set plotMainPlots = PlotSquared.getPlots(world, player); + final java.util.Set plotMainPlots = PlotSquared.getInstance().getPlots(world, player); final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]); if (plots.length > index) { return plots[index]; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java index 6d507888b..34422d4d3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -35,7 +35,7 @@ public class Target extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { final Location ploc = plr.getLocation(); - if (!PlotSquared.isPlotWorld(ploc.getWorld())) { + if (!PlotSquared.getInstance().isPlotWorld(ploc.getWorld())) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java index 46e7aa581..234883688 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -20,6 +20,17 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.ConfigurationNode; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetupUtils; +import com.intellectualcrafters.plot.util.TaskManager; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -29,125 +40,11 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.ConfigurationNode; -import com.intellectualcrafters.plot.object.FileBytes; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.SetupObject; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.SetupUtils; -import com.intellectualcrafters.plot.util.TaskManager; - public class Template extends SubCommand { public Template() { super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, false); } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length != 2 && args.length != 3) { - if (args.length == 1) { - if (args[0].equalsIgnoreCase("export")) { - MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export "); - return false; - } - else if (args[0].equalsIgnoreCase("import")) { - MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import