diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 37ffcfbbf..9dcbee212 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -68,7 +68,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void onEnable() { THIS = this; - PlotSquared.instance = new PlotSquared(this); + PS.instance = new PS(this); if (Settings.METRICS) { try { final Metrics metrics = new Metrics(this); @@ -97,7 +97,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void onDisable() { - PlotSquared.getInstance().disable(); + PS.get().disable(); THIS = null; } @@ -235,7 +235,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { this.error = 0l; } World world; - for (final String w : PlotSquared.getInstance().getPlotWorlds()) { + for (final String w : PS.get().getPlotWorlds()) { world = Bukkit.getWorld(w); try { if (world.getLoadedChunks().length < 1) { @@ -263,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.getInstance().setupPlotWorld(world, id)) { + if (!PS.get().setupPlotWorld(world, id)) { return null; } HybridGen result = new HybridGen(world); @@ -308,8 +308,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void registerWorldEditEvents() { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { - PlotSquared.getInstance().worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); - final String version = PlotSquared.getInstance().worldEdit.getDescription().getVersion(); + PS.get().worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + final String version = PS.get().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"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PS.java similarity index 99% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/PS.java index 3ed63c504..ffc188ba7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PS.java @@ -37,14 +37,11 @@ import java.util.zip.ZipInputStream; * @author Sauilitired | Citymonstret * @author boy0001 | Empire92 */ -public class PlotSquared { - - // public static final: - public static final String MAIN_PERMISSION = "plots.use"; +public class PS { // protected static: - protected static PlotSquared instance; - + protected static PS instance; + // private final: private final HashMap plotworlds = new HashMap<>(); private final HashMap plotmanagers = new HashMap<>(); @@ -72,11 +69,11 @@ public class PlotSquared { * Initialize PlotSquared with the desired Implementation class * @param imp_class */ - protected PlotSquared(final IPlotMain imp_class) { + protected PS(final IPlotMain imp_class) { SetupUtils.generators = new HashMap<>(); IMP = imp_class; try { - FILE = new File(PlotSquared.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); + FILE = new File(PS.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); } catch (Exception e) { log("Could not determine file path"); } @@ -167,13 +164,13 @@ public class PlotSquared { copyFile("italian.yml", "translations"); showDebug(); } - + /** * Get the instance of PlotSquared * * @return the instance created by IPlotMain */ - public static PlotSquared getInstance() { + public static PS get() { return instance; } @@ -184,7 +181,7 @@ public class PlotSquared { * @see IPlotMain#log(String) */ public static void log(final String message) { - getInstance().IMP.log(message); + get().IMP.log(message); } /** 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 b2d5e2a58..d13602959 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -21,7 +21,7 @@ package com.intellectualcrafters.plot.api; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.SubCommand; import com.intellectualcrafters.plot.config.C; @@ -68,7 +68,7 @@ import java.util.Set; * * @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotSquared * instance - * @see com.intellectualcrafters.plot.PlotSquared + * @see com.intellectualcrafters.plot.PS */ @Deprecated public PlotAPI(final JavaPlugin plugin) { @@ -82,10 +82,10 @@ import java.util.Set; * * @return all plots * - * @see com.intellectualcrafters.plot.PlotSquared#getPlots() + * @see com.intellectualcrafters.plot.PS#getPlots() */ public Set getAllPlots() { - return PlotSquared.getInstance().getPlots(); + return PS.get().getPlots(); } /** @@ -96,7 +96,7 @@ import java.util.Set; * @return all plots that a player owns */ public Set getPlayerPlots(final Player player) { - return PlotSquared.getInstance().getPlots(BukkitUtil.getPlayer(player)); + return PS.get().getPlots(BukkitUtil.getPlayer(player)); } /** @@ -106,29 +106,29 @@ import java.util.Set; * @param plotWorld Plot World Object * @param manager World Manager * - * @see com.intellectualcrafters.plot.PlotSquared#addPlotWorld(String, com.intellectualcrafters.plot.object.PlotWorld, + * @see com.intellectualcrafters.plot.PS#addPlotWorld(String, com.intellectualcrafters.plot.object.PlotWorld, * com.intellectualcrafters.plot.object.PlotManager) */ public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) { - PlotSquared.getInstance().addPlotWorld(world, plotWorld, manager); + PS.get().addPlotWorld(world, plotWorld, manager); } /** * @return main configuration * - * @see com.intellectualcrafters.plot.PlotSquared#config + * @see com.intellectualcrafters.plot.PS#config */ public YamlConfiguration getConfig() { - return PlotSquared.getInstance().config; + return PS.get().config; } /** * @return storage configuration * - * @see com.intellectualcrafters.plot.PlotSquared#storage + * @see com.intellectualcrafters.plot.PS#storage */ public YamlConfiguration getStorage() { - return PlotSquared.getInstance().storage; + return PS.get().storage; } /** @@ -137,10 +137,10 @@ import java.util.Set; * * @return PlotSquared PlotSquared Main Class * - * @see com.intellectualcrafters.plot.PlotSquared + * @see com.intellectualcrafters.plot.PS */ - public PlotSquared getMain() { - return PlotSquared.getInstance(); + public PS getMain() { + return PS.get(); } /** @@ -275,10 +275,10 @@ import java.util.Set; * @return PlotManager * * @see com.intellectualcrafters.plot.object.PlotManager - * @see PlotSquared#getPlotManager(String) + * @see PS#getPlotManager(String) */ public PlotManager getPlotManager(final World world) { - return PlotSquared.getInstance().getPlotManager(world.getName()); + return PS.get().getPlotManager(world.getName()); } /** @@ -289,11 +289,11 @@ import java.util.Set; * * @return PlotManager * - * @see PlotSquared#getPlotManager(String) + * @see PS#getPlotManager(String) * @see com.intellectualcrafters.plot.object.PlotManager */ public PlotManager getPlotManager(final String world) { - return PlotSquared.getInstance().getPlotManager(world); + return PS.get().getPlotManager(world); } /** @@ -304,11 +304,11 @@ import java.util.Set; * * @return PlotWorld class for that world ! will return null if not a plot world world * - * @see PlotSquared#getPlotWorld(String) + * @see PS#getPlotWorld(String) * @see com.intellectualcrafters.plot.object.PlotWorld */ public PlotWorld getWorldSettings(final World world) { - return PlotSquared.getInstance().getPlotWorld(world.getName()); + return PS.get().getPlotWorld(world.getName()); } /** @@ -318,11 +318,11 @@ import java.util.Set; * * @return PlotWorld class for that world ! will return null if not a plot world world * - * @see PlotSquared#getPlotWorld(String) + * @see PS#getPlotWorld(String) * @see com.intellectualcrafters.plot.object.PlotWorld */ public PlotWorld getWorldSettings(final String world) { - return PlotSquared.getInstance().getPlotWorld(world); + return PS.get().getPlotWorld(world); } /** @@ -464,7 +464,7 @@ import java.util.Set; */ public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) { final ArrayList pPlots = new ArrayList<>(); - for (final Plot plot : PlotSquared.getInstance().getPlots(world.getName()).values()) { + for (final Plot plot : PS.get().getPlots(world.getName()).values()) { if (just_owner) { if ((plot.owner != null) && (plot.owner.equals(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr))))) { pPlots.add(plot); @@ -485,11 +485,11 @@ import java.util.Set; * * @return Plot[] - array of plot objects in world * - * @see PlotSquared#getPlots(String) + * @see PS#getPlots(String) * @see com.intellectualcrafters.plot.object.Plot */ public Plot[] getPlots(final World world) { - Collection plots = PlotSquared.getInstance().getPlots(world.getName()).values(); + Collection plots = PS.get().getPlots(world.getName()).values(); return plots.toArray(new Plot[plots.size()]); } @@ -498,10 +498,10 @@ import java.util.Set; * * @return World[] - array of plot worlds * - * @see com.intellectualcrafters.plot.PlotSquared#getPlotWorlds() + * @see com.intellectualcrafters.plot.PS#getPlotWorlds() */ public String[] getPlotWorlds() { - Set worlds = PlotSquared.getInstance().getPlotWorlds(); + Set worlds = PS.get().getPlotWorlds(); return worlds.toArray(new String[worlds.size()]); } @@ -512,10 +512,10 @@ import java.util.Set; * * @return boolean (if plot world or not) * - * @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(String) + * @see com.intellectualcrafters.plot.PS#isPlotWorld(String) */ public boolean isPlotWorld(final World world) { - return PlotSquared.getInstance().isPlotWorld(world.getName()); + return PS.get().isPlotWorld(world.getName()); } /** @@ -611,10 +611,10 @@ import java.util.Set; * * @return PlotSquared Class * - * @see com.intellectualcrafters.plot.PlotSquared + * @see com.intellectualcrafters.plot.PS */ - public PlotSquared getPlotSquared() { - return PlotSquared.getInstance(); + public PS getPlotSquared() { + return PS.get(); } /** @@ -639,12 +639,12 @@ import java.util.Set; * * @return a set containing the players plots * - * @see com.intellectualcrafters.plot.PlotSquared#getPlots(String, PlotPlayer) + * @see com.intellectualcrafters.plot.PS#getPlots(String, PlotPlayer) * org.bukkit.entity.Player) * @see com.intellectualcrafters.plot.object.Plot */ public Set getPlayerPlots(final World world, final Player player) { - return PlotSquared.getInstance().getPlots(world.getName(), BukkitUtil.getPlayer(player)); + return PS.get().getPlots(world.getName(), 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 c938517d1..f4b4e0b28 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; @@ -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.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { + if (plot.members.size() + plot.trusted.size() >= PS.get().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.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { + if (plot.members.size() + plot.trusted.size() >= PS.get().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 98459cfc4..f2d09b387 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.*; @@ -70,11 +70,11 @@ public class Auto extends SubCommand { int size_x = 1; int size_z = 1; String schematic = ""; - if (PlotSquared.getInstance().getPlotWorlds().size() == 1) { - world = PlotSquared.getInstance().getPlotWorlds().iterator().next(); + if (PS.get().getPlotWorlds().size() == 1) { + world = PS.get().getPlotWorlds().iterator().next(); } else { world = plr.getLocation().getWorld(); - if (!PlotSquared.getInstance().isPlotWorld(world)) { + if (!PS.get().isPlotWorld(world)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } @@ -122,7 +122,7 @@ public class Auto extends SubCommand { } return false; } - final PlotWorld pWorld = PlotSquared.getInstance().getPlotWorld(world); + final PlotWorld pWorld = PS.get().getPlotWorld(world); if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) { double cost = pWorld.PLOT_PRICE; cost = (size_x * size_z) * cost; @@ -148,7 +148,7 @@ public class Auto extends SubCommand { // } } final String worldname = world; - final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(worldname); + final PlotWorld plotworld = PS.get().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())); @@ -199,7 +199,7 @@ public class Auto extends SubCommand { MainUtil.lastPlot.put(worldname, start); if (lastPlot) { } - if ((PlotSquared.getInstance().getPlots(worldname).get(start) != null) && (PlotSquared.getInstance().getPlots(worldname).get(start).owner != null)) { + if ((PS.get().getPlots(worldname).get(start) != null) && (PS.get().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 36769c9cb..b7e3dec3c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -46,7 +46,7 @@ public class Buy extends SubCommand { } final Location loc = plr.getLocation(); final String world = loc.getWorld(); - if (!PlotSquared.getInstance().isPlotWorld(world)) { + if (!PS.get().isPlotWorld(world)) { return sendMessage(plr, C.NOT_IN_PLOT_WORLD); } Plot plot; @@ -83,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.getInstance().getPlotWorld(world); + final PlotWorld plotworld = PS.get().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 c3a63c616..7b8a521af 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Chat.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Chat.java @@ -1,6 +1,6 @@ package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; @@ -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.getInstance().isPlotWorld(world)) { + if (!PS.get().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.getInstance().getPlotWorld(world); + final PlotWorld plotworld = PS.get().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 52cdecbe3..3d9fe02ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; @@ -56,8 +56,8 @@ public class Claim extends SubCommand { MainUtil.teleportPlayer(player, loc, plot); } final String world = plot.world; - final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); - final Plot plot2 = PlotSquared.getInstance().getPlots(world).get(plot.id); + final PlotWorld plotworld = PS.get().getPlotWorld(world); + final Plot plot2 = PS.get().getPlots(world).get(plot.id); if (plotworld.SCHEMATIC_ON_CLAIM) { Schematic sch; if (schematic.equals("")) { @@ -70,7 +70,7 @@ public class Claim extends SubCommand { } SchematicHandler.manager.paste(sch, plot2, 0, 0); } - PlotSquared.getInstance().getPlotManager(world).claimPlot(plotworld, plot); + PS.get().getPlotManager(world).claimPlot(plotworld, plot); } return result; } @@ -93,7 +93,7 @@ public class Claim extends SubCommand { if (!MainUtil.canClaim(plr, plot)) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } - final PlotWorld world = PlotSquared.getInstance().getPlotWorld(plot.world); + final PlotWorld world = PS.get().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 2b96075e1..c644ddbd4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; @@ -45,25 +45,25 @@ public class Clear extends SubCommand { if (plr == null) { // Is console if (args.length < 2) { - PlotSquared.log("You need to specify two arguments: ID (0;0) & World (world)"); + PS.log("You need to specify two arguments: ID (0;0) & World (world)"); } else { final PlotId id = PlotId.fromString(args[0]); final String world = args[1]; if (id == null) { - PlotSquared.log("Invalid Plot ID: " + args[0]); + PS.log("Invalid Plot ID: " + args[0]); } else { - if (!PlotSquared.getInstance().isPlotWorld(world)) { - PlotSquared.log("Invalid plot world: " + world); + if (!PS.get().isPlotWorld(world)) { + PS.log("Invalid plot world: " + world); } else { final Plot plot = MainUtil.getPlot(world, id); if (plot == null) { - PlotSquared.log("Could not find plot " + args[0] + " in world " + world); + PS.log("Could not find plot " + args[0] + " in world " + world); } else { Runnable runnable = new Runnable() { @Override public void run() { MainUtil.clear(world, plot, plot.owner == null, null); - PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); + PS.log("Plot " + plot.getId().toString() + " cleared."); } }; if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { @@ -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.getInstance().getPlots(plr); + Set plots = PS.get().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 68d282e47..11e2dc2cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.generator.AugmentedPopulator; @@ -121,25 +121,25 @@ public class Cluster extends SubCommand { } ClusterManager.clusters.get(world).add(cluster); // Add any existing plots to the current cluster - for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) { + for (final Plot plot : PS.get().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.getInstance().getPlotWorld(world); + PlotWorld plotworld = PS.get().getPlotWorld(world); if (plotworld == null) { - PlotSquared.getInstance().config.createSection("worlds." + world); - PlotSquared.getInstance().loadWorld(world, null); + PS.get().config.createSection("worlds." + world); + PS.get().loadWorld(world, null); } else { - final String gen_string = PlotSquared.getInstance().config.getString("worlds." + world + "." + "generator.plugin"); + final String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin"); PlotGenerator generator; if (gen_string == null) { generator = new HybridGen(world); } else { - generator = (PlotGenerator) PlotSquared.getInstance().IMP.getGenerator(world, gen_string); + generator = (PlotGenerator) PS.get().IMP.getGenerator(world, gen_string); } new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); } @@ -177,10 +177,10 @@ public class Cluster extends SubCommand { return false; } } - final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plr.getLocation().getWorld()); + final PlotWorld plotworld = PS.get().getPlotWorld(plr.getLocation().getWorld()); if (plotworld.TYPE == 2) { final ArrayList toRemove = new ArrayList<>(); - for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) { + for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster other = ClusterManager.getCluster(plot); if (cluster.equals(other)) { toRemove.add(plot); @@ -361,7 +361,7 @@ public class Cluster extends SubCommand { if (player != null) { MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } - for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld(), uuid)) { + for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { final String world = plr.getLocation().getWorld(); @@ -411,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.getInstance().getPlots(plr.getLocation().getWorld(), uuid)) { + for (final Plot plot : PS.get().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 28b715b15..0302012fe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -40,7 +40,7 @@ public class Condense extends SubCommand { } public static void sendMessage(final String message) { - PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message); + PS.log("&3PlotSquared -> Plot condense&8: &7" + message); } @Override @@ -54,7 +54,7 @@ public class Condense extends SubCommand { return false; } final String worldname = args[0]; - if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.getInstance().isPlotWorld(worldname)) { + if (!BlockManager.manager.isWorld(worldname) || !PS.get().isPlotWorld(worldname)) { MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } @@ -77,7 +77,7 @@ public class Condense extends SubCommand { return false; } final int radius = Integer.parseInt(args[2]); - final Collection plots = PlotSquared.getInstance().getPlots(worldname).values(); + final Collection plots = PS.get().getPlots(worldname).values(); final int size = plots.size(); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { @@ -166,7 +166,7 @@ public class Condense extends SubCommand { return false; } final int radius = Integer.parseInt(args[2]); - final Collection plots = PlotSquared.getInstance().getPlots(worldname).values(); + final Collection plots = PS.get().getPlots(worldname).values(); final int size = plots.size(); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { 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 7abfed0a4..32661bf60 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridUtils; @@ -41,7 +41,7 @@ public class CreateRoadSchematic extends SubCommand { if (plot == null) { return sendMessage(player, C.NOT_IN_PLOT); } - if (!(PlotSquared.getInstance().getPlotWorld(loc.getWorld()) instanceof HybridPlotWorld)) { + if (!(PS.get().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 68d0054ff..bbaf44cd4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -1,6 +1,6 @@ package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLManager; @@ -28,7 +28,7 @@ public class Database extends SubCommand { private static boolean sendMessageU(final UUID uuid, final String msg) { if (uuid == null) { - PlotSquared.log(msg); + PS.log(msg); } else { final PlotPlayer p = UUIDHandler.getPlayer(uuid); if ((p != null) && p.isOnline()) { @@ -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.getInstance().getPlots(); + final java.util.Set plots = PS.get().getPlots(); TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -92,7 +92,7 @@ public class Database extends SubCommand { } Connection n; try { - n = new MySQL(PlotSquared.getInstance(), host, port, database, username, password).openConnection(); + n = new MySQL(PS.get(), host, port, database, username, password).openConnection(); // Connection if (n.isClosed()) { return sendMessage(plr, "Failed to open connection"); @@ -128,7 +128,7 @@ public class Database extends SubCommand { private boolean sendMessage(final PlotPlayer player, final String msg) { if (player == null) { - PlotSquared.log(msg); + PS.log(msg); } else { MainUtil.sendMessage(player, msg); } 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 7f1e6329b..9c1be1085 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.Lag; @@ -51,7 +51,7 @@ public class Debug extends SubCommand { } { final StringBuilder worlds = new StringBuilder(""); - for (final String world : PlotSquared.getInstance().getPlotWorlds()) { + for (final String world : PS.get().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.getInstance().getPlots().size())); + information.append(getLine(line, "Owned Plots", PS.get().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 8fb5dc78c..00be7f0c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -21,7 +21,7 @@ package com.intellectualcrafters.plot.commands; import com.google.common.collect.BiMap; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.*; @@ -66,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.getInstance().isPlotWorld(world)) { + if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) { return !MainUtil.sendMessage(null, "&cInvalid plot world!"); } PlotId min, max; @@ -80,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.getInstance().getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); + final PlotManager manager = PS.get().getPlotManager(world); + final PlotWorld plotworld = PS.get().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.getInstance().getPlots(world).containsKey(plot.id); + final boolean contains = PS.get().getPlots(world).containsKey(plot.id); if (contains) { MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id); continue; @@ -134,7 +134,7 @@ public class DebugClaimTest extends SubCommand { } }); for (final Plot plot : plots) { - PlotSquared.getInstance().updatePlot(plot); + PS.get().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 524d38270..9adbc94da 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Location; @@ -42,19 +42,19 @@ public class DebugClear extends SubCommand { if (plr == null) { // Is console if (args.length < 2) { - PlotSquared.log("You need to specify two arguments: ID (0;0) & World (world)"); + PS.log("You need to specify two arguments: ID (0;0) & World (world)"); } else { final PlotId id = PlotId.fromString(args[0]); final String world = args[1]; if (id == null) { - PlotSquared.log("Invalid Plot ID: " + args[0]); + PS.log("Invalid Plot ID: " + args[0]); } else { - if (!PlotSquared.getInstance().isPlotWorld(world) || !(PlotSquared.getInstance().getPlotWorld(world) instanceof SquarePlotWorld)) { - PlotSquared.log("Invalid plot world: " + world); + if (!PS.get().isPlotWorld(world) || !(PS.get().getPlotWorld(world) instanceof SquarePlotWorld)) { + PS.log("Invalid plot world: " + world); } else { final Plot plot = MainUtil.getPlot(world, id); if (plot == null) { - PlotSquared.log("Could not find plot " + args[0] + " in world " + world); + PS.log("Could not find plot " + args[0] + " in world " + world); } else { final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); @@ -67,8 +67,8 @@ public class DebugClear extends SubCommand { @Override public void run() { MainUtil.runners.remove(plot); - PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); - PlotSquared.log("&aDone!"); + PS.log("Plot " + plot.getId().toString() + " cleared."); + PS.log("&aDone!"); } }); } @@ -79,7 +79,7 @@ public class DebugClear extends SubCommand { } final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); - if ((plot == null) || !(PlotSquared.getInstance().getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) { + if ((plot == null) || !(PS.get().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 d21a3e9d6..194cb6474 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; @@ -86,7 +86,7 @@ public class DebugExec extends SubCommand { return false; } String flag = args[1]; - for (Plot plot : PlotSquared.getInstance().getPlots()) { + for (Plot plot : PS.get().getPlots()) { if (FlagManager.getPlotFlag(plot, flag) != null) { FlagManager.removePlotFlag(plot, flag); } @@ -95,11 +95,11 @@ public class DebugExec extends SubCommand { } case "start-rgar": { if (args.length != 2) { - PlotSquared.log("&cInvalid syntax: /plot debugexec start-rgar "); + PS.log("&cInvalid syntax: /plot debugexec start-rgar "); return false; } boolean result; - if (!PlotSquared.getInstance().isPlotWorld(args[1])) { + if (!PS.get().isPlotWorld(args[1])) { MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]); return false; } @@ -110,26 +110,26 @@ public class DebugExec extends SubCommand { result = HybridUtils.manager.scheduleRoadUpdate(args[1], 0); } if (!result) { - PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); + PS.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); return false; } return true; } case "stop-rgar": { if (((BukkitHybridUtils)(HybridUtils.manager)).task == 0) { - PlotSquared.log("&cTASK NOT RUNNING!"); + PS.log("&cTASK NOT RUNNING!"); return false; } ((BukkitHybridUtils)(HybridUtils.manager)).task = 0; Bukkit.getScheduler().cancelTask(((BukkitHybridUtils)(HybridUtils.manager)).task); - PlotSquared.log("&cCancelling task..."); + PS.log("&cCancelling task..."); while (BukkitHybridUtils.chunks.size() > 0) { ChunkLoc chunk = BukkitHybridUtils.chunks.get(0); BukkitHybridUtils.chunks.remove(0); HybridUtils.manager.regenerateRoad(BukkitHybridUtils.world, chunk, 0); ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk); } - PlotSquared.log("&cCancelled!"); + PS.log("&cCancelled!"); return true; } case "start-expire": { @@ -197,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.getInstance().isPlotWorld(args[1])) { + if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(args[1])) { return MainUtil.sendMessage(player, "Invalid world: " + args[1]); } final ArrayList empty = new ArrayList<>(); @@ -208,7 +208,7 @@ public class DebugExec extends SubCommand { Trim.sendMessage(" - MCA #: " + empty.size()); Trim.sendMessage(" - CHUNKS: " + (empty.size() * 1024) + " (max)"); Trim.sendMessage("Exporting log for manual approval..."); - final File file = new File(PlotSquared.getInstance().IMP.getDirectory() + File.separator + "trim.txt"); + final File file = new File(PS.get().IMP.getDirectory() + File.separator + "trim.txt"); PrintWriter writer; try { writer = new PrintWriter(file); 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 efe5d2981..0c13dce78 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; @@ -50,12 +50,12 @@ public class DebugFixFlags extends SubCommand { return false; } final String world = args[0]; - if (!BlockManager.manager.isWorld(world) || !PlotSquared.getInstance().isPlotWorld(world)) { + if (!BlockManager.manager.isWorld(world) || !PS.get().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.getInstance().getPlots(world).values()) { + for (final Plot plot : PS.get().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/DebugLoadTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java index 12b79ecb3..6bdaf9d3b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -22,7 +22,7 @@ package com.intellectualcrafters.plot.commands; import java.lang.reflect.Field; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -39,13 +39,13 @@ public class DebugLoadTest extends SubCommand { public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { try { - final Field fPlots = PlotSquared.class.getDeclaredField("plots"); + final Field fPlots = PS.class.getDeclaredField("plots"); fPlots.setAccessible(true); fPlots.set(null, DBFunc.getPlots()); } catch (final Exception e) { - PlotSquared.log("&3===FAILED&3==="); + PS.log("&3===FAILED&3==="); e.printStackTrace(); - PlotSquared.log("&3===END OF STACKTRACE==="); + PS.log("&3===END OF STACKTRACE==="); } } else { MainUtil.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.."); 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 7e9b8b106..862609aaa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridUtils; @@ -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.getInstance().getPlotWorld(world) instanceof HybridPlotWorld)) { + if (!(PS.get().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 f4854901d..3b98a2204 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -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.getInstance().getPlots()); + plots.addAll(PS.get().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 aea05eb04..203d7519d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.AbstractDB; @@ -139,7 +139,7 @@ public class DebugUUID extends SubCommand { final UUID uuid = UUID.fromString(s); uuids.add(uuid); } catch (final Exception e) { - PlotSquared.log(C.PREFIX.s() + "Invalid playerdata: " + current); + PS.log(C.PREFIX.s() + "Invalid playerdata: " + current); } } } @@ -170,7 +170,7 @@ public class DebugUUID extends SubCommand { uCReverse.put(uuid2, uuid); } } catch (final Throwable e) { - PlotSquared.log(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat"); + PS.log(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat"); } } for (final String name : names) { @@ -215,7 +215,7 @@ public class DebugUUID extends SubCommand { MainUtil.sendConsoleMessage("&7 - Updating plot objects"); - for (Plot plot : PlotSquared.getInstance().getPlotsRaw()) { + for (Plot plot : PS.get().getPlotsRaw()) { UUID value = uCMap.get(plot.owner); if (value != null) { plot.owner = value; @@ -235,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.getInstance().getPlots()) { + for (Plot plot : PS.get().getPlots()) { UUID value = uCReverse.get(plot.owner); if (value != null) { plot.owner = value; } } - database.createPlotsAndData(new ArrayList<>(PlotSquared.getInstance().getPlots()), new Runnable() { + database.createPlotsAndData(new ArrayList<>(PS.get().getPlots()), new Runnable() { @Override public void run() { MainUtil.sendMessage(null, "&6Recovery was successful!"); @@ -256,19 +256,19 @@ public class DebugUUID extends SubCommand { } if (newWrapper instanceof OfflineUUIDWrapper) { - PlotSquared.getInstance().config.set("UUID.force-lowercase", false); - PlotSquared.getInstance().config.set("UUID.offline", true); + PS.get().config.set("UUID.force-lowercase", false); + PS.get().config.set("UUID.offline", true); } else if (newWrapper instanceof LowerOfflineUUIDWrapper) { - PlotSquared.getInstance().config.set("UUID.force-lowercase", true); - PlotSquared.getInstance().config.set("UUID.offline", true); + PS.get().config.set("UUID.force-lowercase", true); + PS.get().config.set("UUID.offline", true); } else if (newWrapper instanceof DefaultUUIDWrapper) { - PlotSquared.getInstance().config.set("UUID.force-lowercase", false); - PlotSquared.getInstance().config.set("UUID.offline", false); + PS.get().config.set("UUID.force-lowercase", false); + PS.get().config.set("UUID.offline", false); } try { - PlotSquared.getInstance().config.save(PlotSquared.getInstance().configFile); + PS.get().config.save(PS.get().configFile); } catch (Exception e) { MainUtil.sendConsoleMessage("Could not save configuration. It will need to be manuall set!"); @@ -279,7 +279,7 @@ public class DebugUUID extends SubCommand { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - ArrayList plots = new ArrayList<>(PlotSquared.getInstance().getPlots()); + ArrayList plots = new ArrayList<>(PS.get().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 e3659f964..7524181bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -50,7 +50,7 @@ public class Delete extends SubCommand { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotSquared.getInstance().getPlotWorld(plot.world); + final PlotWorld pWorld = PS.get().getPlotWorld(plot.world); if (MainUtil.runners.containsKey(plot)) { MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); return false; @@ -65,7 +65,7 @@ public class Delete extends SubCommand { sendMessage(plr, C.ADDED_BALANCE, c + ""); } } - PlotSquared.getInstance().removePlot(loc.getWorld(), plot.id, true); + PS.get().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/Deny.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index 3697e7ab5..e75319229 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; @@ -89,7 +89,7 @@ public class Deny extends SubCommand { } MainUtil.sendMessage(plr, C.DENIED_ADDED); if (!uuid.equals(DBFunc.everyone)) { - PlotSquared.getInstance().IMP.handleKick(uuid, C.YOU_GOT_DENIED); + PS.get().IMP.handleKick(uuid, C.YOU_GOT_DENIED); } return true; } 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 9337babbc..9448cd1a4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -37,7 +37,7 @@ public class Home extends SubCommand { } private Plot isAlias(final String a) { - for (final Plot p : PlotSquared.getInstance().getPlots()) { + for (final Plot p : PS.get().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.getInstance().sortPlotsByWorld(PlotSquared.getInstance().getPlots(plr)); + final ArrayList plots = PS.get().sortPlotsByWorld(PS.get().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/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index b0288d3bd..8db90cd9c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -28,7 +28,7 @@ import java.util.regex.Matcher; import org.apache.commons.lang.StringUtils; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 1cf1f3a26..cbdb50821 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -111,9 +111,6 @@ public class MainCommand { } public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { - if (!Permissions.hasPermission(player, PlotSquared.MAIN_PERMISSION)) { - return no_permission(player, PlotSquared.MAIN_PERMISSION); - } if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) { if (args.length < 2) { final StringBuilder builder = new StringBuilder(); 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 195856867..d7b6a1946 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.*; @@ -131,7 +131,7 @@ public class Merge extends SubCommand { HashSet multiPlots = new HashSet<>(); final UUID u1 = plot.owner; for (final PlotId myid : plots) { - final Plot myplot = PlotSquared.getInstance().getPlots(world).get(myid); + final Plot myplot = PS.get().getPlots(world).get(myid); if (myplot == null || myplot.owner == null) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; @@ -163,7 +163,7 @@ public class Merge extends SubCommand { sendMessage(accepter, C.MERGE_NOT_VALID); return; } - final PlotWorld plotWorld = PlotSquared.getInstance().getPlotWorld(world); + final PlotWorld plotWorld = PS.get().getPlotWorld(world); if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; cost = plots.size() * cost; @@ -192,7 +192,7 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.MERGE_REQUESTED); return true; } - final PlotWorld plotWorld = PlotSquared.getInstance().getPlotWorld(world); + final PlotWorld plotWorld = PS.get().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 bede75847..2fbebfe9d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.MainUtil; @@ -61,8 +61,8 @@ public class Move extends SubCommand { } String world2; if (args.length == 2) { - PlotWorld other = PlotSquared.getInstance().getPlotWorld(args[1]); - PlotWorld current = PlotSquared.getInstance().getPlotWorld(loc.getWorld()); + PlotWorld other = PS.get().getPlotWorld(args[1]); + PlotWorld current = PS.get().getPlotWorld(loc.getWorld()); if (other == null || current == null || !other.equals(current)) { MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE); return false; 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 affc60720..4cb85542b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -91,7 +91,7 @@ public class Purge extends SubCommand { return false; } final String worldname = args[1]; - if (!PlotSquared.getInstance().getAllPlotsRaw().containsKey(worldname)) { + if (!PS.get().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.getInstance().getPlots(worldname).keySet(); + final Set ids = PS.get().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.getInstance().getPlots(worldname).values(); + final Collection plots = PS.get().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.getInstance().getPlots(worldname).values(); + final Collection plots = PS.get().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.getInstance().getPlots(worldname, uuid); + final Set plots = PS.get().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/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 990f579fb..cc838be80 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -49,7 +49,7 @@ public class Rate extends SubCommand { public boolean execute(final PlotPlayer player, final String... args) { if (args.length == 1) { if (args[0].equalsIgnoreCase("next")) { - ArrayList plots = new ArrayList<>(PlotSquared.getInstance().getPlots()); + ArrayList plots = new ArrayList<>(PS.get().getPlots()); Collections.sort(plots, new Comparator() { @Override public int compare(Plot p1, Plot p2) { 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 21ffe0e08..14f8850ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridUtils; @@ -58,19 +58,19 @@ public class RegenAllRoads extends SubCommand { } } final String name = args[0]; - final PlotManager manager = PlotSquared.getInstance().getPlotManager(name); + final PlotManager manager = PS.get().getPlotManager(name); if ((manager == null) || !(manager instanceof HybridPlotManager)) { sendMessage(player, C.NOT_VALID_PLOT_WORLD); return false; } final List chunks = ChunkManager.manager.getChunkChunks(name); - PlotSquared.log("&cIf no schematic is set, the following will not do anything"); - PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); - PlotSquared.log("&6Potential chunks to update: &7" + (chunks.size() * 1024)); - PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds"); + PS.log("&cIf no schematic is set, the following will not do anything"); + PS.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); + PS.log("&6Potential chunks to update: &7" + (chunks.size() * 1024)); + PS.log("&6Estimated time: &7" + (chunks.size()) + " seconds"); final boolean result = HybridUtils.manager.scheduleRoadUpdate(name, height); if (!result) { - PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); + PS.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); return false; } return true; 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 a573cda1c..a299d1b85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; @@ -36,12 +36,12 @@ public class Reload extends SubCommand { try { // The following won't affect world generation, as that has to be // loaded during startup unfortunately. - PlotSquared.getInstance().config.load(PlotSquared.getInstance().configFile); - PlotSquared.getInstance().setupConfig(); + PS.get().config.load(PS.get().configFile); + PS.get().setupConfig(); C.setupTranslations(); - for (final String pw : PlotSquared.getInstance().getPlotWorlds()) { - final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(pw); - plotworld.loadDefaultConfiguration(PlotSquared.getInstance().config.getConfigurationSection("worlds." + pw)); + for (final String pw : PS.get().getPlotWorlds()) { + final PlotWorld plotworld = PS.get().getPlotWorld(pw); + plotworld.loadDefaultConfiguration(PS.get().config.getConfigurationSection("worlds." + pw)); } MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); } catch (final Exception e) { 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 8587ca70c..1ce79d6ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -58,7 +58,7 @@ public class SchematicCmd extends SubCommand { switch (arg) { case "paste": { if (plr == null) { - PlotSquared.log(C.IS_CONSOLE.s()); + PS.log(C.IS_CONSOLE.s()); return false; } if (!Permissions.hasPermission(plr, "plots.schematic.paste")) { @@ -134,7 +134,7 @@ public class SchematicCmd extends SubCommand { SchematicHandler.manager.pasteStates(schematic, plot, 0, 0); sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); SchematicCmd.this.running = false; - PlotSquared.getInstance().TASK.cancelTask(SchematicCmd.this.task); + PS.get().TASK.cancelTask(SchematicCmd.this.task); return; } final int end = Math.min(start + 5000, blen); @@ -155,7 +155,7 @@ public class SchematicCmd extends SubCommand { } case "test": { if (plr == null) { - PlotSquared.log(C.IS_CONSOLE.s()); + PS.log(C.IS_CONSOLE.s()); return false; } if (!Permissions.hasPermission(plr, "plots.schematic.test")) { @@ -198,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.getInstance().getPlots(args[1]); + final HashMap plotmap = PS.get().getPlots(args[1]); if ((plotmap == null) || (plotmap.size() == 0)) { MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall "); return false; @@ -215,8 +215,8 @@ public class SchematicCmd extends SubCommand { return false; } else { - PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); - PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); + PS.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); + PS.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); } break; } @@ -250,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.getInstance().getPlots(world) == null) || (PlotSquared.getInstance().getPlots(world).get(i) == null)) { + if ((PS.get().getPlots(world) == null) || (PS.get().getPlots(world).get(i) == null)) { MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } - p2 = PlotSquared.getInstance().getPlots(world).get(i); + p2 = PS.get().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 052448af9..f3f6376c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.database.DBFunc; @@ -66,10 +66,10 @@ public class Set extends SubCommand { } } if (args.length < 1) { - PlotManager manager = PlotSquared.getInstance().getPlotManager(loc.getWorld()); + PlotManager manager = PS.get().getPlotManager(loc.getWorld()); ArrayList newValues = new ArrayList(); newValues.addAll(Arrays.asList(values)); - newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getInstance().getPlotWorld(loc.getWorld()), plot.id))); + newValues.addAll(Arrays.asList(manager.getPlotComponents(PS.get().getPlotWorld(loc.getWorld()), plot.id))); MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues)); return false; } @@ -171,7 +171,7 @@ public class Set extends SubCommand { MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG); return false; } - for (final Plot p : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) { + for (final Plot p : PS.get().getPlots(plr.getLocation().getWorld()).values()) { if (p.settings.getAlias().equalsIgnoreCase(alias)) { MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; @@ -217,8 +217,8 @@ public class Set extends SubCommand { } // Get components final String world = plr.getLocation().getWorld(); - final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); - final PlotManager manager = PlotSquared.getInstance().getPlotManager(world); + final PlotWorld plotworld = PS.get().getPlotWorld(world); + final PlotManager manager = PS.get().getPlotManager(world); final String[] components = manager.getPlotComponents(plotworld, plot.id); for (final String component : components) { if (component.equalsIgnoreCase(args[0])) { @@ -308,7 +308,7 @@ public class Set extends SubCommand { } ArrayList newValues = new ArrayList(); newValues.addAll(Arrays.asList(values)); - newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getInstance().getPlotWorld(loc.getWorld()), plot.id))); + newValues.addAll(Arrays.asList(manager.getPlotComponents(PS.get().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 59afdc198..4267d71ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -93,14 +93,14 @@ public class SetOwner extends SubCommand { final String world = loc.getWorld(); for (final PlotId id : plots) { - final Plot current = PlotSquared.getInstance().getPlots(world).get(id); + final Plot current = PS.get().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.getInstance().updatePlot(current); + PS.get().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 0f691fbd5..4c012e433 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -55,7 +55,7 @@ public class TP extends SubCommand { world = args[1]; } } - if (!PlotSquared.getInstance().isPlotWorld(world)) { + if (!PS.get().isPlotWorld(world)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } @@ -85,14 +85,14 @@ public class TP extends SubCommand { } final PlotPlayer player = UUIDHandler.getPlayer(a); if (player != null) { - final java.util.Set plotMainPlots = PlotSquared.getInstance().getPlots(world, player); + final java.util.Set plotMainPlots = PS.get().getPlots(world, player); final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]); if (plots.length > index) { return plots[index]; } return null; } - for (final Plot p : PlotSquared.getInstance().getPlots(world).values()) { + for (final Plot p : PS.get().getPlots(world).values()) { if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { return p; } 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 34422d4d3..8b5839461 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotId; @@ -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.getInstance().isPlotWorld(ploc.getWorld())) { + if (!PS.get().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 ad283ec2e..442c0a4cc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.object.*; @@ -48,12 +48,12 @@ public class Template extends SubCommand { public static boolean extractAllFiles(String world, String template) { byte[] buffer = new byte[2048]; try { - File folder = new File(PlotSquared.getInstance().IMP.getDirectory() + File.separator + "templates"); + File folder = new File(PS.get().IMP.getDirectory() + File.separator + "templates"); if (!folder.exists()) { return false; } File input = new File(folder + File.separator + template + ".template"); - File output = PlotSquared.getInstance().IMP.getDirectory(); + File output = PS.get().IMP.getDirectory(); if (!output.exists()) { output.mkdirs(); } @@ -81,7 +81,7 @@ public class Template extends SubCommand { } public static byte[] getBytes(PlotWorld plotworld) { - ConfigurationSection section = PlotSquared.getInstance().config.getConfigurationSection("worlds." + plotworld.worldname); + ConfigurationSection section = PS.get().config.getConfigurationSection("worlds." + plotworld.worldname); YamlConfiguration config = new YamlConfiguration(); String generator = SetupUtils.manager.getGenerator(plotworld); if (generator != null) { @@ -94,7 +94,7 @@ public class Template extends SubCommand { } public static void zipAll(final String world, Set files) throws IOException { - File output = new File(PlotSquared.getInstance().IMP.getDirectory() + File.separator + "templates"); + File output = new File(PS.get().IMP.getDirectory() + File.separator + "templates"); output.mkdirs(); FileOutputStream fos = new FileOutputStream(output + File.separator + world + ".template"); ZipOutputStream zos = new ZipOutputStream(fos); @@ -131,7 +131,7 @@ public class Template extends SubCommand { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import