diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index cafc78387..ce8911fc1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -6,12 +6,19 @@ import java.util.Arrays; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.world.WorldInitEvent; +import org.bukkit.event.world.WorldLoadEvent; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; @@ -19,7 +26,12 @@ import com.intellectualcrafters.plot.commands.Buy; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.WE_Anywhere; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.PlotMeConverter; +import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.listeners.ForceFieldListener; import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.PlayerEvents; @@ -27,8 +39,19 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.Metrics; +import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.SendChunk; +import com.intellectualcrafters.plot.util.SetBlockFast; +import com.intellectualcrafters.plot.util.SetBlockManager; +import com.intellectualcrafters.plot.util.SetBlockSlow; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.sk89q.worldedit.bukkit.WorldEditPlugin; @@ -37,6 +60,46 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { public static BukkitMain THIS = null; public static PlotSquared MAIN = null; + public static boolean hasPermission(final Player player, final String perm) { + if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { + return true; + } + if (player.hasPermission(perm)) { + return true; + } + final String[] nodes = perm.split("\\."); + final StringBuilder n = new StringBuilder(); + for (int i = 0; i < (nodes.length - 1); i++) { + n.append(nodes[i] + (".")); + if (player.hasPermission(n + "*")) { + return true; + } + } + return false; + } + + @EventHandler + public static void worldLoad(WorldLoadEvent event) { + UUIDHandler.cacheAll(); + } + + @EventHandler + public void PlayerCommand(PlayerCommandPreprocessEvent event) { + String message = event.getMessage(); + if (message.toLowerCase().startsWith("/plotme")) { + Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe"); + if (plotme == null) { + Player player = event.getPlayer(); + if (Settings.USE_PLOTME_ALIAS) { + player.performCommand(message.replace("/plotme", "plots")); + } else { + PlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME); + } + event.setCancelled(true); + } + } + } + @Override public void onEnable() { MAIN = new PlotSquared(this); @@ -54,7 +117,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); } - // TODO world load event + getServer().getPluginManager().registerEvents(this, this); } @Override @@ -66,7 +129,15 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { @Override public void log(String message) { - // TODO Auto-generated method stub + if (THIS == null || Bukkit.getServer().getConsoleSender() == null) { + System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message))); + } else { + message = ChatColor.translateAlternateColorCodes('&', message); + if (!Settings.CONSOLE_COLOR) { + message = ChatColor.stripColor(message); + } + Bukkit.getServer().getConsoleSender().sendMessage(message); + } } @Override @@ -139,6 +210,14 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { }, 20); } + @Override + final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { + if (!PlotSquared.setupPlotWorld(world, id)) { + return null; + } + return new HybridGen(world); + } + public static boolean checkVersion(int major, int minor, int minor2) { try { String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\."); @@ -209,4 +288,64 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { } return null; } + + @Override + public void initSetBlockManager() { + if (checkVersion(1, 8, 0)) { + try { + SetBlockManager.setBlockManager = new SetBlockSlow(); + } + catch (Throwable e) { + e.printStackTrace(); + SetBlockManager.setBlockManager = new SetBlockSlow(); + } + } + else { + try { + SetBlockManager.setBlockManager = new SetBlockFast(); + } catch (Throwable e) { + SetBlockManager.setBlockManager = new SetBlockSlow(); + } + } + try { + new SendChunk(); + PlotHelper.canSendChunk = true; + } catch (final Throwable e) { + PlotHelper.canSendChunk = false; + } + } + + @Override + public boolean initPlotMeConverter() { + try { + new PlotMeConverter().runAsync(); + } catch (final Exception e) { + e.printStackTrace(); + } + if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) { + return true; + } + return false; + } + + @Override + public void getGenerator(String world, String name) { + Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name); + if (gen_plugin != null && gen_plugin.isEnabled()) { + gen_plugin.getDefaultWorldGenerator(world, ""); + } else { + new HybridGen(world); + } + } + + @Override + public boolean callRemovePlot(String world, PlotId id) { + final PlotDeleteEvent event = new PlotDeleteEvent(world, id); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + event.setCancelled(true); + return false; + } + return true; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 8df37227d..3129a48ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -4,6 +4,7 @@ import java.io.File; import net.milkbowl.vault.economy.Economy; +import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.TaskManager; public interface IPlotMain { @@ -32,4 +33,12 @@ public interface IPlotMain { public void registerWorldEditEvents(); public Economy getEconomy(); -} + + public void initSetBlockManager(); + + public boolean initPlotMeConverter(); + + public void getGenerator(String world, String name); + + public boolean callRemovePlot(String world, PlotId id); +} \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 14d66d1fb..f95ae7d61 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -6,11 +6,15 @@ 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.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.Map.Entry; import java.util.Set; @@ -22,6 +26,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.commands.Cluster; import com.intellectualcrafters.plot.commands.MainCommand; 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.MySQL; @@ -30,18 +35,30 @@ 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.HybridGen; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.generator.SquarePlotManager; 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.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.Logger; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.Logger.LogLevel; import com.intellectualcrafters.plot.util.TaskManager; 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; @@ -55,6 +72,7 @@ public class PlotSquared { 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 Economy economy = null; private final static HashMap plotworlds = new HashMap<>(); @@ -68,6 +86,302 @@ public class PlotSquared { return mySQL; } + public static void updatePlot(final Plot plot) { + final String world = plot.world; + if (!plots.containsKey(world)) { + plots.put(world, new HashMap()); + } + plot.hasChanged = true; + plots.get(world).put(plot.id, plot); + } + + public static PlotWorld getWorldSettings(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) { + plotworlds.put(world, plotworld); + plotmanagers.put(world, manager); + if (!plots.containsKey(world)) { + plots.put(world, new HashMap()); + } + } + + public static void removePlotWorld(final String world) { + plots.remove(world); + plotmanagers.remove(world); + plotworlds.remove(world); + } + + public static void setAllPlotsRaw(final LinkedHashMap> plots) { + PlotSquared.plots = plots; + } + + public static Set getPlots() { + final ArrayList newplots = new ArrayList<>(); + for (final HashMap world : plots.values()) { + newplots.addAll(world.values()); + } + return new LinkedHashSet<>(newplots); + } + + public static LinkedHashSet getPlotsSorted() { + final ArrayList newplots = new ArrayList<>(); + for (final HashMap world : plots.values()) { + newplots.addAll(world.values()); + } + return new LinkedHashSet<>(newplots); + } + + public static 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 UUID uuid) { + final ArrayList myplots = new ArrayList<>(); + for (final Plot plot : getPlots(world).values()) { + if (plot.hasOwner()) { + if (plot.getOwner().equals(uuid)) { + myplots.add(plot); + } + } + } + return new HashSet<>(myplots); + } + + public static boolean isPlotWorld(final String world) { + return (plotworlds.containsKey(world)); + } + + public static PlotManager getPlotManager(final String world) { + if (plotmanagers.containsKey(world)) { + return plotmanagers.get(world); + } + return null; + } + + public static String[] getPlotWorldsString() { + final Set strings = plots.keySet(); + return strings.toArray(new String[strings.size()]); + } + + public static HashMap getPlots(final String world) { + if (plots.containsKey(world)) { + return plots.get(world); + } + return new HashMap<>(); + } + + public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) { + if (callEvent) { + if (!IMP.callRemovePlot(world, id)) { + return false; + } + } + plots.get(world).remove(id); + if (PlotHelper.lastPlot.containsKey(world)) { + PlotId last = PlotHelper.lastPlot.get(world); + int last_max = Math.max(last.x, last.y); + int this_max = Math.max(id.x, id.y); + + if (this_max < last_max) { + PlotHelper.lastPlot.put(world, id); + } + } + return true; + } + + public static void loadWorld(final String world, final PlotGenerator generator) { + if (getWorldSettings(world) != null) { + return; + } + + final Set worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet()); + + final PlotWorld plotWorld; + final PlotGenerator plotGenerator; + final PlotManager plotManager; + final String path = "worlds." + world; + + if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) { + plotGenerator = (PlotGenerator) generator; + plotWorld = plotGenerator.getNewPlotWorld(world); + plotManager = plotGenerator.getPlotManager(); + if (!world.equals("CheckingPlotSquaredGenerator")) { + log(C.PREFIX.s() + "&aDetected world load for '" + world + "'"); + log(C.PREFIX.s() + "&3 - generator: &7" + plotGenerator.getClass().getName()); + log(C.PREFIX.s() + "&3 - plotworld: &7" + plotWorld.getClass().getName()); + log(C.PREFIX.s() + "&3 - manager: &7" + plotManager.getClass().getName()); + } + if (!config.contains(path)) { + config.createSection(path); + } + plotWorld.saveConfiguration(config.getConfigurationSection(path)); + plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); + try { + config.save(configFile); + } catch (final IOException e) { + e.printStackTrace(); + } + // Now add it + addPlotWorld(world, plotWorld, plotManager); + PlotHelper.setupBorder(world); + } else { + if (!worlds.contains(world)) { + return; + } + if (!LOADING_WORLD) { + LOADING_WORLD = true; + try { + String gen_string = config.getString("worlds." + world + "." + "generator.plugin"); + if (gen_string == null) { + new HybridGen(world); + } + else { + IMP.getGenerator(world, gen_string); + } + } catch (Exception e) { + log("&d=== Oh no! Please set the generator for the " + world + " ==="); + e.printStackTrace(); + LOADING_WORLD = false; + removePlotWorld(world); + } finally { + LOADING_WORLD = false; + } + } else { + PlotGenerator gen_class = (PlotGenerator) generator; + plotWorld = gen_class.getNewPlotWorld(world); + plotManager = gen_class.getPlotManager(); + if (!config.contains(path)) { + config.createSection(path); + } + plotWorld.TYPE = 2; + 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; + } + addPlotWorld(world, plotWorld, plotManager); + if (plotWorld.TYPE == 2) { + if (ClusterManager.getClusters(world).size() > 0) { + for (PlotCluster cluster : ClusterManager.getClusters(world)) { + new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2); + } + } + } else if (plotWorld.TYPE == 1) { + new AugmentedPopulator(world, gen_class, null, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2); + } + } + } + } + + public static boolean setupPlotWorld(String world, String id) { + if (id != null && id.length() > 0) { + // save configuration + String[] split = id.split(","); + HybridPlotWorld plotworld = new HybridPlotWorld(world); + + int width = HybridPlotWorld.PLOT_WIDTH_DEFAULT; + int gap = HybridPlotWorld.ROAD_WIDTH_DEFAULT; + int height = HybridPlotWorld.PLOT_HEIGHT_DEFAULT; + PlotBlock[] floor = HybridPlotWorld.TOP_BLOCK_DEFAULT; + PlotBlock[] main = HybridPlotWorld.MAIN_BLOCK_DEFAULT; + PlotBlock wall = HybridPlotWorld.WALL_FILLING_DEFAULT; + PlotBlock border = HybridPlotWorld.WALL_BLOCK_DEFAULT; + + for (String element : split) { + String[] pair = element.split("="); + if (pair.length != 2) { + log("&cNo value provided for: &7" + element); + return false; + } + String key = pair[0].toLowerCase(); + String value = pair[1]; + try { + switch (key) { + case "s": + case "size": { + HybridPlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + break; + } + case "g": + case "gap": { + HybridPlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + break; + } + case "h": + case "height": { + HybridPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + HybridPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + HybridPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + break; + } + case "f": + case "floor": { + HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + break; + } + case "m": + case "main": { + HybridPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + break; + } + case "w": + case "wall": { + HybridPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + break; + } + case "b": + case "border": { + HybridPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + break; + } + default: { + log("&cKey not found: &7" + element); + return false; + } + } + } + catch (Exception e) { + e.printStackTrace(); + log("&cInvalid value: &7" + value + " in arg " + element); + return false; + } + } + try { + String root = "worlds." + world; + if (!config.contains(root)) { + config.createSection(root); + } + plotworld.saveConfiguration(config.getConfigurationSection(root)); + HybridPlotWorld.PLOT_HEIGHT_DEFAULT = height; + HybridPlotWorld.ROAD_HEIGHT_DEFAULT = height; + HybridPlotWorld.WALL_HEIGHT_DEFAULT = height; + HybridPlotWorld.TOP_BLOCK_DEFAULT = floor; + HybridPlotWorld.MAIN_BLOCK_DEFAULT = main; + HybridPlotWorld.WALL_BLOCK_DEFAULT = border; + HybridPlotWorld.WALL_FILLING_DEFAULT = wall; + HybridPlotWorld.PLOT_WIDTH_DEFAULT = width; + HybridPlotWorld.ROAD_WIDTH_DEFAULT = gap; + } + catch (Exception e) { + e.printStackTrace(); + } + } + return true; + } + public static Connection getConnection() { return connection; } @@ -111,6 +425,23 @@ public class PlotSquared { IMP.registerForceFieldEvents(); IMP.registerWorldEditEvents(); + // Set block + IMP.initSetBlockManager(); + + // 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(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java new file mode 100644 index 000000000..2eab9284a --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java @@ -0,0 +1,1553 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// + +package com.intellectualcrafters.plot; + +import com.intellectualcrafters.plot.commands.Buy; +import com.intellectualcrafters.plot.commands.Cluster; +import com.intellectualcrafters.plot.commands.MainCommand; +import com.intellectualcrafters.plot.commands.WE_Anywhere; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Configuration; +import com.intellectualcrafters.plot.config.ConfigurationNode; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.*; +import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; +import com.intellectualcrafters.plot.events.PlotDeleteEvent; +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.HybridGen; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.generator.SquarePlotManager; +import com.intellectualcrafters.plot.listeners.*; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.titles.AbstractTitle; +import com.intellectualcrafters.plot.titles.DefaultTitle; +import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.Logger.LogLevel; +import com.intellectualcrafters.plot.util.bukkit.TaskManager; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; + +import me.confuser.barapi.BarAPI; +import net.milkbowl.vault.economy.Economy; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; + +/** + * PlotSquared class. + * + * @author Citymonstret + * @author Empire92 + */ +public class _PlotSquared { + + /** + * style + */ + public static File styleFile; + public static YamlConfiguration styleConfig; + /** + * The main configuration file + */ + public static YamlConfiguration config; + /** + * Contains storage options + */ + public static YamlConfiguration storage; + + public static IPlotSquared MAIN_IMP = new BukkitMain(); + + /** + * Permission that allows for "everything" + */ + public static final String ADMIN_PERMISSION = "plots.admin"; + /** + * Storage version + */ + public final static int storage_ver = 1; + /** + * All loaded plot worlds + */ + private final static HashMap worlds = new HashMap<>(); + /** + * All world managers + */ + private final static HashMap managers = new HashMap<>(); + /** + * settings.properties + */ + public static File configFile; + + /** + * storage.properties + */ + public static File storageFile; + /** + * MySQL Connection + */ + public static Connection connection; + /** + * WorldEdit object + */ + public static WorldEditPlugin worldEdit = null; + /** + * BarAPI object + */ + public static BarAPI barAPI = null; + /** + * World Guard Object + */ + public static WorldGuardPlugin worldGuard = null; + /** + * World Guard Listener + */ + public static WorldGuardListener worldGuardListener = null; + /** + * Economy Object (vault) + */ + public static Economy economy; + /** + * Use Economy? + */ + public static boolean useEconomy = false; + private static PlotSquared main = null; + private static boolean LOADING_WORLD = false; + /** + * MySQL Object + */ + private static MySQL mySQL; + /** + * List of all plots DO NOT USE EXCEPT FOR DATABASE PURPOSES + */ + private static LinkedHashMap> plots; + + /** + * Return an instance of MySQL + */ + public static MySQL getMySQL() { + return mySQL; + } + + /** + * Get all plots + * + * @return HashMap containing the plot ID and the plot object. + */ + public static Set getPlots() { + final ArrayList _plots = new ArrayList<>(); + for (final HashMap world : plots.values()) { + _plots.addAll(world.values()); + } + return new LinkedHashSet<>(_plots); + } + + /** + * Get a sorted list of plots + * + * @return sorted list + */ + public static LinkedHashSet getPlotsSorted() { + final ArrayList _plots = new ArrayList<>(); + for (final HashMap world : plots.values()) { + _plots.addAll(world.values()); + } + return new LinkedHashSet<>(_plots); + } + + /** + * @param world plot world + * @param player plot owner + * + * @return players plots + */ + public static Set getPlots(final String world, final String player) { + final UUID uuid = UUIDHandler.getUUID(player); + return getPlots(world, uuid); + } + + /** + * @param world plot world + * @param player plot owner + * + * @return players plots + */ + public static Set getPlots(final String world, final UUID uuid) { + final ArrayList myplots = new ArrayList<>(); + for (final Plot plot : getPlots(world).values()) { + if (plot.hasOwner()) { + if (plot.getOwner().equals(uuid)) { + myplots.add(plot); + } + } + } + return new HashSet<>(myplots); + } + + /** + * @param world plot world + * + * @return plots in world + */ + public static HashMap getPlots(final String world) { + if (plots.containsKey(world)) { + return plots.get(world); + } + return new HashMap<>(); + } + + /** + * get all plot worlds + */ + public static String[] getPlotWorlds() { + final Set strings = worlds.keySet(); + return (strings.toArray(new String[strings.size()])); + } + + /** + * @return plots worlds + */ + public static String[] getPlotWorldsString() { + final Set strings = plots.keySet(); + return strings.toArray(new String[strings.size()]); + } + + /** + * @param world plotworld(?) + * + * @return true if the world is a plotworld + */ + public static boolean isPlotWorld(final String world) { + return (worlds.containsKey(world)); + } + + /** + * @param String world + * + * @return PlotManager + */ + public static PlotManager getPlotManager(final String world) { + if (managers.containsKey(world)) { + return managers.get(world); + } + return null; + } + + + /** + * @param world to search + * + * @return PlotWorld object + */ + public static PlotWorld getWorldSettings(final String world) { + if (worlds.containsKey(world)) { + return worlds.get(world); + } + return null; + } + + /** + * @param String world to search + * + * @return set containing the plots for a world + */ + public static Plot[] getWorldPlots(final String world) { + final Collection values = plots.get(world).values(); + return (values.toArray(new Plot[values.size()])); + } + + /** + * Remove a plot + * + * @param world The Plot World + * @param id The Plot ID + * @param callEvent Whether or not to call the PlotDeleteEvent + * + * @return true if successful, false if not + */ + public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) { + if (callEvent) { + if (!MAIN_IMP.callRemovePlot(world, id)) { + return false; + } + } + plots.get(world).remove(id); + if (PlotHelper.lastPlot.containsKey(world)) { + PlotId last = PlotHelper.lastPlot.get(world); + int last_max = Math.max(last.x, last.y); + int this_max = Math.max(id.x, id.y); + + if (this_max < last_max) { + PlotHelper.lastPlot.put(world, id); + } + } + return true; + } + + /** + * Replace the plot object with an updated version + * + * @param plot plot object + */ + public static void updatePlot(final Plot plot) { + final String world = plot.world; + if (!plots.containsKey(world)) { + plots.put(world, new HashMap()); + } + plot.hasChanged = true; + plots.get(world).put(plot.id, plot); + } + + /** + * Get the java version + * + * @return Java Version as a double + */ + public static double getJavaVersion() { + return Double.parseDouble(System.getProperty("java.specification.version")); + } + + /** + * Get MySQL Connection + * + * @return connection MySQL Connection. + */ + public static Connection getConnection() { + return connection; + } + + + /** + * Teleport a player to a plot + * + * @param player Player to teleport + * @param from Previous Location + * @param plot Plot to teleport to + * + * @return true if successful + */ + public boolean teleportPlayer(final Player player, final Location from, final Plot plot) { + Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot); + final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, bot); + Bukkit.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + final Location location = PlotHelper.getPlotHome(Bukkit.getWorld(bot.world), bot); + + int x = location.getX(); + int z = location.getZ(); + + + if ((x >= 29999999) || (x <= -29999999) || (z >= 299999999) || (z <= -29999999)) { + event.setCancelled(true); + return false; + } + if (Settings.TELEPORT_DELAY == 0 || hasPermission(player, "plots.teleport.delay.bypass")) { + Location bukkitLoc = new org.bukkit.Location(player.getWorld(), x, y, z) + PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT); + player.teleport(location); + return true; + } + PlayerFunctions.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + ""); + Location loc = player.getLocation(); + final String world = player.getWorld(); + final String name = player.getName(); + TaskManager.TELEPORT_QUEUE.add(name); + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + if (!TaskManager.TELEPORT_QUEUE.contains(name)) { + PlayerFunctions.sendMessage(player, C.TELEPORT_FAILED); + return; + } + TaskManager.TELEPORT_QUEUE.remove(name); + if (!player.isOnline()) { + return; + } + Location loc = player.getLocation(); + if (!loc.getWorld().equals(world)) { + PlayerFunctions.sendMessage(player, C.TELEPORT_FAILED); + return; + } + if (loc.getBlockX() != x || loc.getBlockZ() != z) { + PlayerFunctions.sendMessage(player, C.TELEPORT_FAILED); + return; + } + PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT); + player.teleport(location); + } + }, Settings.TELEPORT_DELAY * 20); + return true; + } + return !event.isCancelled(); + } + + /** + * Returns the main class. + * + * @return (this class) + */ + public static PlotSquared getMain() { + return PlotSquared.main; + } + + /** + * Broadcast a message to all admins + * + * @param c message + */ + public static void BroadcastWithPerms(final C c) { + for (final Player player : Bukkit.getOnlinePlayers()) { + if (player.hasPermission(ADMIN_PERMISSION)) { + PlayerFunctions.sendMessage(player, c); + } + } + System.out.println(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s()))); + } + + /** + * Reload all translations + * + * @throws IOException + */ + public static void reloadTranslations() throws IOException { + C.setupTranslations(); + } + + /** + * Ge the last played time + * + * @param uuid UUID for the player + * + * @return last play time as a long + */ + public static long getLastPlayed(final UUID uuid) { + if (uuid == null) { + return 0; + } + OfflinePlayer player; + if (((player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid)) == null) || !player.hasPlayedBefore()) { + return 0; + } + return player.getLastPlayed(); + } + + /** + * Load configuration files + */ + public static void configs() { + final File folder = new File(getMain().getDataFolder() + File.separator + "config"); + if (!folder.exists() && !folder.mkdirs()) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually."); + } + try { + styleFile = new File(getMain().getDataFolder() + File.separator + "translations" + File.separator + "style.yml"); + if (!styleFile.exists()) { + if (!styleFile.createNewFile()) { + sendConsoleSenderMessage("Could not create the style file, please create \"translations/style.yml\" manually"); + } + } + styleConfig = YamlConfiguration.loadConfiguration(styleFile); + setupStyle(); + } catch (final Exception err) { + Logger.add(LogLevel.DANGER, "Failed to save style.yml"); + System.out.println("failed to save style.yml"); + } + try { + configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml"); + if (!configFile.exists()) { + if (!configFile.createNewFile()) { + sendConsoleSenderMessage("Could not create the settings file, please create \"settings.yml\" manually."); + } + } + config = YamlConfiguration.loadConfiguration(configFile); + setupConfig(); + } catch (final Exception err_trans) { + Logger.add(LogLevel.DANGER, "Failed to save settings.yml"); + System.out.println("Failed to save settings.yml"); + } + try { + storageFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "storage.yml"); + if (!storageFile.exists()) { + if (!storageFile.createNewFile()) { + sendConsoleSenderMessage("Could not the storage settings file, please create \"storage.yml\" manually."); + } + } + storage = YamlConfiguration.loadConfiguration(storageFile); + setupStorage(); + } catch (final Exception err_trans) { + Logger.add(LogLevel.DANGER, "Failed to save storage.yml"); + System.out.println("Failed to save storage.yml"); + } + try { + styleConfig.save(styleFile); + config.save(configFile); + storage.save(storageFile); + } catch (final IOException e) { + Logger.add(LogLevel.DANGER, "Configuration file saving failed"); + e.printStackTrace(); + } + { + Settings.DB.USE_MYSQL = storage.getBoolean("mysql.use"); + Settings.DB.USER = storage.getString("mysql.user"); + Settings.DB.PASSWORD = storage.getString("mysql.password"); + Settings.DB.HOST_NAME = storage.getString("mysql.host"); + Settings.DB.PORT = storage.getString("mysql.port"); + Settings.DB.DATABASE = storage.getString("mysql.database"); + Settings.DB.USE_SQLITE = storage.getBoolean("sqlite.use"); + Settings.DB.SQLITE_DB = storage.getString("sqlite.db"); + Settings.DB.PREFIX = storage.getString("prefix"); + Settings.METRICS = config.getBoolean("metrics"); + Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); + Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); + Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban"); + Settings.API_URL = config.getString("uuid.api.location"); + Settings.CUSTOM_API = config.getBoolean("uuid.api.custom"); + Settings.UUID_FECTHING = config.getBoolean("uuid.fetching"); + + C.COLOR_1 = ChatColor.getByChar(styleConfig.getString("color.1")); + C.COLOR_2 = ChatColor.getByChar(styleConfig.getString("color.2")); + C.COLOR_3 = ChatColor.getByChar(styleConfig.getString("color.3")); + C.COLOR_4 = ChatColor.getByChar(styleConfig.getString("color.4")); + } + if (Settings.DEBUG) { + final Map settings = new HashMap<>(); + settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS); + settings.put("Use Metrics", "" + Settings.METRICS); + settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN); + settings.put("Mob Pathfinding", "" + Settings.MOB_PATHFINDING); + settings.put("DB Mysql Enabled", "" + Settings.DB.USE_MYSQL); + settings.put("DB SQLite Enabled", "" + Settings.DB.USE_SQLITE); + settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR); + settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS); + settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH); + settings.put("API Location", "" + Settings.API_URL); + for (final Entry setting : settings.entrySet()) { + sendConsoleSenderMessage(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue())); + } + } + } + + /** + * Kill all entities on roads + */ + public static void killAllEntities() { + Bukkit.getScheduler().scheduleSyncRepeatingTask(getMain(), new Runnable() { + long ticked = 0l; + long error = 0l; + + { + sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities started."); + } + + @Override + public void run() { + if (this.ticked > 36_000L) { + this.ticked = 0l; + if (this.error > 0) { + sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities has been running for 6 hours. Errors: " + this.error); + } + this.error = 0l; + } + String world; + for (final String w : getPlotWorlds()) { + getWorldSettings(w); + world = Bukkit.getServer().getWorld(w); + try { + if (world.getLoadedChunks().length < 1) { + continue; + } + for (final Chunk chunk : world.getLoadedChunks()) { + final Entity[] entities = chunk.getEntities(); + Entity entity; + for (int i = entities.length - 1; i >= 0; i--) { + if (!((entity = entities[i]) instanceof Player) && !PlotListener.isInPlot(entity.getLocation())) { + entity.remove(); + } + } + } + } catch (final Throwable e) { + ++this.error; + } finally { + ++this.ticked; + } + } + } + }, 20L, 20L); + } + + /** + * SETUP: settings.yml + */ + public static void setupConfig() { + final int config_ver = 1; + config.set("version", config_ver); + final Map options = new HashMap<>(); + options.put("teleport.delay", 0); + options.put("auto_update", false); + options.put("clusters.enabled", Settings.ENABLE_CLUSTERS); + options.put("plotme-alias", Settings.USE_PLOTME_ALIAS); + options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME); + options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE); + options.put("UUID.offline", Settings.OFFLINE_MODE); + options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); + options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT); + options.put("console.color", Settings.CONSOLE_COLOR); + options.put("metrics", true); + options.put("debug", true); + options.put("clear.auto.enabled", false); + options.put("clear.auto.days", 365); + options.put("clear.check-disk", Settings.AUTO_CLEAR_CHECK_DISK); + options.put("clear.on.ban", false); + options.put("max_plots", Settings.MAX_PLOTS); + options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); + options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK); + options.put("titles", Settings.TITLES); + options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); + options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); + + for (final Entry node : options.entrySet()) { + if (!config.contains(node.getKey())) { + config.set(node.getKey(), node.getValue()); + } + } + Settings.ENABLE_CLUSTERS = config.getBoolean("clusters.enabled"); + Settings.DEBUG = config.getBoolean("debug"); + if (Settings.DEBUG) { + sendConsoleSenderMessage(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); + } + Settings.TELEPORT_DELAY = config.getInt("teleport.delay"); + Settings.CONSOLE_COLOR = config.getBoolean("console.color"); + Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login"); + Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias"); + Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled"); + Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); + Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + + "inding"); + Settings.METRICS = config.getBoolean("metrics"); + Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); + Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk"); + Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area"); + Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); + Settings.TITLES = config.getBoolean("titles"); + Settings.MAX_PLOTS = config.getInt("max_plots"); + if (Settings.MAX_PLOTS > 32767) { + sendConsoleSenderMessage("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large."); + Settings.MAX_PLOTS = 32767; + } + Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); + + Settings.OFFLINE_MODE = config.getBoolean("UUID.offline"); + Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk"); + + Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); + } + + /** + * Create a plotworld config section + * + * @param plotString world to create the section for + */ + public static void createConfiguration(final PlotWorld plotworld) { + final Map options = new HashMap<>(); + + for (final ConfigurationNode setting : plotworld.getSettingNodes()) { + options.put(setting.getConstant(), setting.getValue()); + } + + for (final Entry node : options.entrySet()) { + if (!config.contains(node.getKey())) { + config.set(node.getKey(), node.getValue()); + } + } + + try { + config.save(PlotSquared.configFile); + } catch (final IOException e) { + PlotSquared.sendConsoleSenderMessage("&c[Warning] PlotSquared failed to save the configuration&7 (settings.yml may differ from the one in memory)\n - To force a save from console use /plots save"); + } + } + + @EventHandler + public static void worldLoad(WorldLoadEvent event) { + if (!UUIDHandler.CACHED) { + UUIDHandler.cacheAll(); + if (Settings.CONVERT_PLOTME) { + if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) { + sendConsoleSenderMessage("&c[IMPORTANT] THIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); + sendConsoleSenderMessage("&c[IMPORTANT] - Make sure 'UUID.read-from-disk' is disabled (false)!"); + sendConsoleSenderMessage("&c[IMPORTANT] - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); + sendConsoleSenderMessage("&c[IMPORTANT] - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml@'"); + } + try { + new PlotMeConverter(PlotSquared.getMain()).runAsync(); + } catch (final Exception e) { + e.printStackTrace(); + } + } + } + } + + public static void loadWorld(final String world, final PlotGenerator generator) { + if (getWorldSettings(world) != null) { + return; + } + + final Set worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet()); + + final PlotWorld plotWorld; + final PlotGenerator plotGenerator; + final PlotManager plotManager; + final String path = "worlds." + world; + + if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) { + plotGenerator = (PlotGenerator) generator; + plotWorld = plotGenerator.getNewPlotWorld(world); + plotManager = plotGenerator.getPlotManager(); + if (!world.equals("CheckingPlotSquaredGenerator")) { + sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'"); + sendConsoleSenderMessage(C.PREFIX.s() + "&3 - generator: &7" + plotGenerator.getClass().getName()); + sendConsoleSenderMessage(C.PREFIX.s() + "&3 - plotworld: &7" + plotWorld.getClass().getName()); + sendConsoleSenderMessage(C.PREFIX.s() + "&3 - manager: &7" + plotManager.getClass().getName()); + } + if (!config.contains(path)) { + config.createSection(path); + } + plotWorld.saveConfiguration(config.getConfigurationSection(path)); + plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); + try { + config.save(configFile); + } catch (final IOException e) { + e.printStackTrace(); + } + // Now add it + addPlotWorld(world, plotWorld, plotManager); + PlotHelper.setupBorder(world); + } else { + if (!worlds.contains(world)) { + return; + } + if (!LOADING_WORLD) { + LOADING_WORLD = true; + try { + String gen_string = config.getString("worlds." + world + "." + "generator.plugin"); + Plugin gen_plugin = gen_string == null ? null : Bukkit.getPluginManager().getPlugin(gen_string); + if (gen_plugin != null && gen_plugin.isEnabled()) { + gen_plugin.getDefaultWorldGenerator(world, ""); + } else { + new HybridGen(world); + } + } catch (Exception e) { + PlotSquared.sendConsoleSenderMessage("&d=== Oh no! Please set the generator for the " + world + " ==="); + e.printStackTrace(); + LOADING_WORLD = false; + removePlotWorld(world); + } finally { + LOADING_WORLD = false; + } + } else { + PlotGenerator gen_class = (PlotGenerator) generator; + plotWorld = gen_class.getNewPlotWorld(world); + plotManager = gen_class.getPlotManager(); + if (!config.contains(path)) { + config.createSection(path); + } + plotWorld.TYPE = 2; + 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)) { + sendConsoleSenderMessage("&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; + } + addPlotWorld(world, plotWorld, plotManager); + if (plotWorld.TYPE == 2) { + if (ClusterManager.getClusters(world).size() > 0) { + for (PlotCluster cluster : ClusterManager.getClusters(world)) { + new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2); + } + } + } else if (plotWorld.TYPE == 1) { + new AugmentedPopulator(world, gen_class, null, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2); + } + } + } + } + + /** + * Adds an external world as a recognized PlotSquared world - The PlotWorld class created is based off the + * configuration in the settings.yml - Do not use this method unless the required world is preconfigured in the + * settings.yml + * + * @param world to load + */ + public static void loadWorld(final String world) { + if (world == null) { + return; + } + final ChunkGenerator generator = world.getGenerator(); + loadWorld(world, generator); + } + + public static void setupStyle() { + styleConfig.set("version", 0); + final Map o = new HashMap<>(); + o.put("color.1", C.COLOR_1.getChar()); + o.put("color.2", C.COLOR_2.getChar()); + o.put("color.3", C.COLOR_3.getChar()); + o.put("color.4", C.COLOR_4.getChar()); + for (final Entry node : o.entrySet()) { + if (!styleConfig.contains(node.getKey())) { + styleConfig.set(node.getKey(), node.getValue()); + } + } + } + + /** + * SETUP: storage.properties + */ + private static void setupStorage() { + storage.set("version", storage_ver); + final Map options = new HashMap<>(); + options.put("mysql.use", false); + options.put("sqlite.use", true); + options.put("sqlite.db", "storage"); + options.put("mysql.host", "localhost"); + options.put("mysql.port", "3306"); + options.put("mysql.user", "root"); + options.put("mysql.password", "password"); + options.put("mysql.database", "plot_db"); + options.put("prefix", ""); + for (final Entry node : options.entrySet()) { + if (!storage.contains(node.getKey())) { + storage.set(node.getKey(), node.getValue()); + } + } + } + + private static void addPlusFlags() { + final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); + final List intervalFlags = Arrays.asList("feed", "heal"); + final List stringFlags = Arrays.asList("greeting", "farewell"); + for (final String flag : stringFlags) { + FlagManager.addFlag(new AbstractFlag(flag)); + } + for (final String flag : intervalFlags) { + FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.IntervalValue())); + } + for (final String flag : booleanFlags) { + FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue())); + } + } + + private static void defaultFlags() { + addPlusFlags(); + FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue())); + FlagManager.addFlag(new AbstractFlag("hostile-attack", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("animal-interact", new FlagValue.BooleanValue())); + FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue())); + FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("hanging-place", new FlagValue.BooleanValue())); + FlagManager.addFlag(new AbstractFlag("hanging-break", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("vehicle-use", new FlagValue.BooleanValue())); + FlagManager.addFlag(new AbstractFlag("vehicle-place", new FlagValue.BooleanValue())); + FlagManager.addFlag(new AbstractFlag("vehicle-break", new FlagValue.BooleanValue())); + + FlagManager.addFlag(new AbstractFlag("place", new FlagValue.PlotBlockListValue())); + FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue())); + FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue())); + + FlagManager.addFlag(new AbstractFlag("gamemode") { + @Override + public String parseValueRaw(final String value) { + switch (value) { + case "creative": + case "c": + case "1": + return "creative"; + case "survival": + case "s": + case "0": + return "survival"; + case "adventure": + case "a": + case "2": + return "adventure"; + default: + return null; + } + } + + @Override + public String getValueDesc() { + return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'"; + } + }); + + FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue())); + + FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue())); + + FlagManager.addFlag(new AbstractFlag("weather") { + @Override + public String parseValueRaw(final String value) { + switch (value) { + case "rain": + case "storm": + case "on": + return "rain"; + case "clear": + case "off": + case "sun": + return "clear"; + default: + return null; + } + } + + @Override + public String getValueDesc() { + return "Flag value must be weather type: 'clear' or 'rain'"; + } + }); + } + + /** + * Add a Plot world + * + * @param world World to add + * @param plotworld PlotWorld Object + * @param manager Plot Manager for the new world + */ + public static void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) { + worlds.put(world, plotworld); + managers.put(world, manager); + if (!plots.containsKey(world)) { + plots.put(world, new HashMap()); + } + } + + /** + * Remove a plot world + * + * @param String world to remove + */ + public static void removePlotWorld(final String world) { + plots.remove(world); + managers.remove(world); + worlds.remove(world); + } + + public static void removePlots(final String world) { + plots.put(world, new HashMap()); + } + + /** + * Get all plots + * + * @return All Plos in a hashmap (world, Hashmap contiang ids and objects)) + */ + public static HashMap> getAllPlotsRaw() { + return plots; + } + + /** + * Set all plots + * + * @param plots New Plot LinkedHashMap + */ + public static void setAllPlotsRaw(final LinkedHashMap> plots) { + PlotSquared.plots = plots; + } + + /** + * Set all plots + * + * @param plots New Plot HashMap + */ + public static void setAllPlotsRaw(final HashMap> plots) { + PlotSquared.plots = new LinkedHashMap<>(plots); + // PlotSquared.plots.putAll(plots); + } + + public static boolean checkVersion(int major, int minor, int minor2) { + try { + String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\."); + int a = Integer.parseInt(version[0]); + int b = Integer.parseInt(version[1]); + int c = 0; + if (version.length == 3) { + c = Integer.parseInt(version[2]); + } + if (a > major || (a == major && b > minor) || (a == major && b == minor && c >= minor2)) { + return true; + } + return false; + } catch (Exception e) { + return false; + } + } + + @EventHandler + public void PlayerCommand(PlayerCommandPreprocessEvent event) { + String message = event.getMessage(); + if (message.toLowerCase().startsWith("/plotme")) { + Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe"); + if (plotme == null) { + Player player = event.getPlayer(); + if (Settings.USE_PLOTME_ALIAS) { + player.performCommand(message.replace("/plotme", "plots")); + } else { + PlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME); + } + event.setCancelled(true); + } + } + } + + /** + * Get the PlotSquared World Generator + * + * @see com.intellectualcrafters.plot.generator.WorldGenerator + */ + @Override + final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { + if (id != null && id.length() > 0) { + // save configuration + String[] split = id.split(","); + HybridPlotWorld plotworld = new HybridPlotWorld(world); + + int width = HybridPlotWorld.PLOT_WIDTH_DEFAULT; + int gap = HybridPlotWorld.ROAD_WIDTH_DEFAULT; + int height = HybridPlotWorld.PLOT_HEIGHT_DEFAULT; + PlotBlock[] floor = HybridPlotWorld.TOP_BLOCK_DEFAULT; + PlotBlock[] main = HybridPlotWorld.MAIN_BLOCK_DEFAULT; + PlotBlock wall = HybridPlotWorld.WALL_FILLING_DEFAULT; + PlotBlock border = HybridPlotWorld.WALL_BLOCK_DEFAULT; + + for (String element : split) { + String[] pair = element.split("="); + if (pair.length != 2) { + sendConsoleSenderMessage("&cNo value provided for: &7" + element); + return null; + } + String key = pair[0].toLowerCase(); + String value = pair[1]; + try { + switch (key) { + case "s": + case "size": { + HybridPlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + break; + } + case "g": + case "gap": { + HybridPlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + break; + } + case "h": + case "height": { + HybridPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + HybridPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + HybridPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + break; + } + case "f": + case "floor": { + HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + break; + } + case "m": + case "main": { + HybridPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + break; + } + case "w": + case "wall": { + HybridPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + break; + } + case "b": + case "border": { + HybridPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + break; + } + default: { + sendConsoleSenderMessage("&cKey not found: &7" + element); + return null; + } + } + } + catch (Exception e) { + e.printStackTrace(); + sendConsoleSenderMessage("&cInvalid value: &7" + value + " in arg " + element); + return null; + } + } + try { + String root = "worlds." + world; + if (!config.contains(root)) { + config.createSection(root); + } + plotworld.saveConfiguration(config.getConfigurationSection(root)); + HybridPlotWorld.PLOT_HEIGHT_DEFAULT = height; + HybridPlotWorld.ROAD_HEIGHT_DEFAULT = height; + HybridPlotWorld.WALL_HEIGHT_DEFAULT = height; + HybridPlotWorld.TOP_BLOCK_DEFAULT = floor; + HybridPlotWorld.MAIN_BLOCK_DEFAULT = main; + HybridPlotWorld.WALL_BLOCK_DEFAULT = border; + HybridPlotWorld.WALL_FILLING_DEFAULT = wall; + HybridPlotWorld.PLOT_WIDTH_DEFAULT = width; + HybridPlotWorld.ROAD_WIDTH_DEFAULT = gap; + } + catch (Exception e) { + e.printStackTrace(); + } + } + return new HybridGen(world); + } + + /** + * Check a range of permissions e.g. 'plots.plot.<0-100>'
Returns highest integer in range. + * + * @param player to check + * @param stub to check + * @param range tp check + * + * @return permitted range + */ + public int hasPermissionRange(final Player player, final String stub, final int range) { + if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { + return Byte.MAX_VALUE; + } + if (player.hasPermission(stub + ".*")) { + return Byte.MAX_VALUE; + } + for (int i = range; i > 0; i--) { + if (player.hasPermission(stub + "." + i)) { + return i; + } + } + return 0; + } + + /** + * Check a player for a permission
- Op has all permissions
- checks for '*' nodes + * + * @param player to check + * @param perms to check + * + * @return true of player has permissions + */ + public boolean hasPermissions(final Player player, final String[] perms) { + if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { + return true; + } + for (final String perm : perms) { + boolean permitted = false; + if (player.hasPermission(perm)) { + permitted = true; + } else { + final String[] nodes = perm.split("\\."); + final StringBuilder n = new StringBuilder(); + for (int i = 0; i < (nodes.length - 1); i++) { + n.append(nodes[i]).append("."); + if (player.hasPermission(n + "*")) { + permitted = true; + break; + } + } + } + if (!permitted) { + return false; + } + } + return true; + } + + /** + * Check a player for a permission
- Op has all permissions
- checks for '*' nodes + * + * @param player to check + * @param perm to check + * + * @return true if player has the permission + */ + public boolean hasPermission(final Player player, final String perm) { + if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { + return true; + } + if (player.hasPermission(perm)) { + return true; + } + final String[] nodes = perm.split("\\."); + final StringBuilder n = new StringBuilder(); + for (int i = 0; i < (nodes.length - 1); i++) { + n.append(nodes[i] + (".")); + if (player.hasPermission(n + "*")) { + return true; + } + } + return false; + } + + @Override + public boolean callRemovePlot(String world, PlotId id) { + final PlotDeleteEvent event = new PlotDeleteEvent(world, id); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + event.setCancelled(true); + return false; + } + return true; + } + + @Override + public void sendConsoleSenderMessage(String string) { + if (BukkitMain.plugin == null || Bukkit.getServer().getConsoleSender() == null) { + System.out.println(ChatColor.stripColor(ConsoleColors.fromString(string))); + } else { + String message = ChatColor.translateAlternateColorCodes('&', string); + if (!Settings.CONSOLE_COLOR) { + message = ChatColor.stripColor(message); + } + Bukkit.getServer().getConsoleSender().sendMessage(message); + } + } + + /** + * On Load. + */ + public _PlotSquared() { + PlotSquared.main = this; + // Setup the logger mechanics + setupLogger(); + // Setup translations + C.setupTranslations(); + C.saveTranslations(); + // Check for outdated java version. + if (getJavaVersion() < 1.7) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); + // Didn't know of any other link :D + sendConsoleSenderMessage(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); + Bukkit.getPluginManager().disablePlugin(this); + return; + } else if (getJavaVersion() < 1.8) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); + } + // Setup configuration + configs(); + defaultFlags(); + // Setup metrics + if (Settings.METRICS) { + try { + final Metrics metrics = new Metrics(this); + metrics.start(); + sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled."); + } catch (final Exception e) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to load up metrics."); + } + } else { + // We should at least make them feel bad. + sendConsoleSenderMessage("Using metrics will allow us to improve the plugin\nPlease consider it :)"); + } + // Kill mobs on roads? + if (Settings.KILL_ROAD_MOBS) { + killAllEntities(); + } + if (C.ENABLED.s().length() > 0) { + sendConsoleSenderMessage(C.ENABLED); + } + final String[] tables; + if (Settings.ENABLE_CLUSTERS) { + MainCommand.subCommands.add(new Cluster()); + tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments", "cluster"}; + } + else { + tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"}; + } + + // Add tables to this one, if we create more :D + + + // Use mysql? + if (Settings.DB.USE_MYSQL) { + try { + mySQL = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD); + connection = mySQL.openConnection(); + { + if (DBFunc.dbManager == null) { + DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); + } + final DatabaseMetaData meta = connection.getMetaData(); + ResultSet res = meta.getTables(null, null, Settings.DB.PREFIX + "plot", null); + if (!res.next()) { + DBFunc.createTables("mysql", true); + } else { + for (final String table : tables) { + res = meta.getTables(null, null, Settings.DB.PREFIX + table, null); + if (!res.next()) { + DBFunc.createTables("mysql", false); + } + } + // We should not repeat our self :P + } + } + } catch (final Exception e) { + Logger.add(LogLevel.DANGER, "MySQL connection failed."); + sendConsoleSenderMessage("&c[Plots] MySQL is not setup correctly. The plugin will disable itself."); + if ((config == null) || config.getBoolean("debug")) { + sendConsoleSenderMessage("&d==== Here is an ugly stacktrace if you are interested in those things ===="); + e.printStackTrace(); + sendConsoleSenderMessage("&d==== End of stacktrace ===="); + sendConsoleSenderMessage("&6Please go to the PlotSquared 'storage.yml' and configure MySQL correctly."); + } + Bukkit.getPluginManager().disablePlugin(this); + return; + } + plots = DBFunc.getPlots(); + if (Settings.ENABLE_CLUSTERS) { + ClusterManager.clusters = DBFunc.getClusters(); + } + } + // TODO: Implement mongo + else if (Settings.DB.USE_MONGO) { + // DBFunc.dbManager = new MongoManager(); + sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented"); + } else if (Settings.DB.USE_SQLITE) { + try { + connection = new SQLite(this, this.getDataFolder() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection(); + { + DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); + final DatabaseMetaData meta = connection.getMetaData(); + ResultSet res = meta.getTables(null, null, Settings.DB.PREFIX + "plot", null); + if (!res.next()) { + DBFunc.createTables("sqlite", true); + } else { + for (final String table : tables) { + res = meta.getTables(null, null, Settings.DB.PREFIX + table, null); + if (!res.next()) { + DBFunc.createTables("sqlite", false); + } + } + } + } + } catch (final Exception e) { + Logger.add(LogLevel.DANGER, "SQLite connection failed"); + sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to open SQLite connection. The plugin will disable itself."); + sendConsoleSenderMessage("&9==== Here is an ugly stacktrace, if you are interested in those things ==="); + e.printStackTrace(); + Bukkit.getPluginManager().disablePlugin(this); + return; + } + plots = DBFunc.getPlots(); + if (Settings.ENABLE_CLUSTERS) { + ClusterManager.clusters = DBFunc.getClusters(); + } + } else { + Logger.add(LogLevel.DANGER, "No storage type is set."); + sendConsoleSenderMessage(C.PREFIX + "&cNo storage type is set!"); + getServer().getPluginManager().disablePlugin(this); + return; + } + // Setup the command handler + { + final MainCommand command = new MainCommand(); + final PluginCommand plotCommand = getCommand("plots"); + plotCommand.setExecutor(command); + plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot")); + plotCommand.setTabCompleter(command); + } + + // Main event handler + getServer().getPluginManager().registerEvents(new PlayerEvents(), this); + if (checkVersion(1, 8, 0)) { + getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); + } + // World load events + getServer().getPluginManager().registerEvents(this, this); + // Info Inventory + getServer().getPluginManager().registerEvents(new InventoryListener(), this); + // Flag runnable + PlotPlusListener.startRunnable(this); + // Flag+ listener + getServer().getPluginManager().registerEvents(new PlotPlusListener(), this); + // Forcefield listener + getServer().getPluginManager().registerEvents(new ForceFieldListener(), this); + // Default flags + + if (getServer().getPluginManager().getPlugin("BarAPI") != null) { + barAPI = (BarAPI) getServer().getPluginManager().getPlugin("BarAPI"); + } + if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { + worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + + final String version = worldEdit.getDescription().getVersion(); + if ((version != null) && version.startsWith("5.")) { + PlotSquared.sendConsoleSenderMessage("&cThis version of WorldEdit does not support PlotSquared."); + PlotSquared.sendConsoleSenderMessage("&cPlease use WorldEdit 6+ for masking support"); + PlotSquared.sendConsoleSenderMessage("&c - http://builds.enginehub.org/job/worldedit"); + } else { + getServer().getPluginManager().registerEvents(new WorldEditListener(), this); + MainCommand.subCommands.add(new WE_Anywhere()); + } + } +// if (Settings.WORLDGUARD) { +// if (getServer().getPluginManager().getPlugin("WorldGuard") != null) { +// worldGuard = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard"); +// worldGuardListener = new WorldGuardListener(this); +// getServer().getPluginManager().registerEvents(worldGuardListener, this); +// } +// } + if (Settings.AUTO_CLEAR) { + ExpireManager.runTask(); + } + // Economy setup + { + if ((getServer().getPluginManager().getPlugin("Vault") != null) && getServer().getPluginManager().getPlugin("Vault").isEnabled()) { + final RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); + if (economyProvider != null) { + economy = economyProvider.getProvider(); + MainCommand.subCommands.add(new Buy()); + } + } + useEconomy = (economy != null); + } + // TPS Measurement + { + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L); + } + // Test for SetBlockFast + { + if (checkVersion(1, 8, 0)) { + try { + SetBlockManager.setBlockManager = new SetBlockSlow(); + } + catch (Throwable e) { + e.printStackTrace(); + SetBlockManager.setBlockManager = new SetBlockSlow(); + } + } + else { + try { + SetBlockManager.setBlockManager = new SetBlockFast(); + } catch (Throwable e) { + SetBlockManager.setBlockManager = new SetBlockSlow(); + } + } + try { + new SendChunk(); + PlotHelper.canSendChunk = true; + } catch (final Throwable e) { + PlotHelper.canSendChunk = false; + } + } + // Setup the setup command + { + com.intellectualcrafters.plot.commands.plugin.setup(this); + } + // Handle UUIDS + { + boolean checkVersion = checkVersion(1, 7, 6); + if (!checkVersion) { + sendConsoleSenderMessage(C.PREFIX.s()+" &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature."); + Settings.TITLES = false; + FlagManager.removeFlag(FlagManager.getFlag("titles")); + } + else { + AbstractTitle.TITLE_CLASS = new DefaultTitle(); + } + if (Settings.OFFLINE_MODE) { + UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + Settings.OFFLINE_MODE = true; + } + else if (checkVersion) { + UUIDHandler.uuidWrapper = new DefaultUUIDWrapper(); + Settings.OFFLINE_MODE = false; + } + else { + UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + Settings.OFFLINE_MODE = true; + } + if (Settings.OFFLINE_MODE) { + sendConsoleSenderMessage(C.PREFIX.s()+" &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit"); + } + else { + sendConsoleSenderMessage(C.PREFIX.s()+" &6PlotSquared is using online UUIDs"); + } + } + // Now we're finished :D + if (C.ENABLED.s().length() > 0) { + Broadcast(C.ENABLED); + } + } + /** + * On unload + */ + public void disable() { + Logger.add(LogLevel.GENERAL, "Logger disabled"); + try { + Logger.write(); + } catch (final IOException e1) { + e1.printStackTrace(); + } + try { + connection.close(); + mySQL.closeConnection(); + } catch (NullPointerException | SQLException e) { + if (connection != null) { + Logger.add(LogLevel.DANGER, "Could not close mysql connection"); + } + } + } +} 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 53fed0097..f7a710779 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -31,7 +31,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.SubCommand; import com.intellectualcrafters.plot.config.C; @@ -56,596 +56,596 @@ import com.intellectualcrafters.plot.util.UUIDHandler; */ @SuppressWarnings("unused") public class PlotAPI { - - /** - * Permission that allows for admin access, this permission node will allow the player to use any part of the - * plugin, without limitations. - */ - public static final String ADMIN_PERMISSION = "plots.admin"; - - /** - * Plot Helper Class - *

- * General functions involving plots, and the management of them - * - * @see com.intellectualcrafters.plot.util.PlotHelper - */ - private static PlotHelper plotHelper; - - /** - * Player Functions - *

- * General functions involving players, and plot worlds - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions - */ - private static PlayerFunctions playerFunctions; - - /** - * Flag Manager - *

- * The manager which handles all flags - * - * @see com.intellectualcrafters.plot.flag.FlagManager - */ - private static FlagManager flagManager; - - /** - * Schematic Handler - *

- * The handler which is used to create, and paste, schematics - * - * @see com.intellectualcrafters.plot.util.SchematicHandler - */ - private static SchematicHandler schematicHandler; - - /** - * The translation class. - * - * @see com.intellectualcrafters.plot.config.C - */ - private static C c; - - /** - * PlotMain instance - *

- * This is the instance that allows for most methods to be used. - * - * @see com.intellectualcrafters.plot.PlotMain - */ - private final PlotMain plotMain; - - /** - * Constructor. Insert any Plugin. (Optimally the plugin that is accessing the method) - * - * @param plugin Plugin used to access this method - * - * @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotMain - * instance - * @see com.intellectualcrafters.plot.PlotMain - */ - public PlotAPI(final JavaPlugin plugin) { - this.plotMain = PlotMain.getMain(); - if (this.plotMain == null) { - throw new PlotSquaredException(PlotSquaredException.PlotError.PLOTMAIN_NULL, "Failed to fetch the plotmain instance, Plot API for " + plugin.getName() + " will be disabled"); - } - } - - /** - * Get all plots - * - * @return all plots - * - * @see com.intellectualcrafters.plot.PlotMain#getPlots() - */ - public Set getAllPlots() { - return PlotMain.getPlots(); - } - - /** - * Return all plots for a player - * - * @param player Player, whose plots to search for - * - * @return all plots that a player owns - */ - public Set getPlayerPlots(final Player player) { - return PlotMain.getPlots(player); - } - - /** - * Add a plot world - * - * @param world World Name - * @param plotWorld Plot World Object - * @param manager World Manager - * - * @see com.intellectualcrafters.plot.PlotMain#addPlotWorld(String, com.intellectualcrafters.plot.object.PlotWorld, - * com.intellectualcrafters.plot.object.PlotManager) - */ - public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) { - PlotMain.addPlotWorld(world, plotWorld, manager); - } - - /** - * @return main configuration - * - * @see com.intellectualcrafters.plot.PlotMain#config - */ - public YamlConfiguration getConfig() { - return PlotMain.config; - } - - /** - * @return storage configuration - * - * @see com.intellectualcrafters.plot.PlotMain#storage - */ - public YamlConfiguration getStorage() { - return PlotMain.storage; - } - - /** - * Get the main class for this plugin
- Contains a lot of fields and methods - not very well organized
- * Only use this if you really need it - * - * @return PlotMain PlotSquared Main Class - * - * @see com.intellectualcrafters.plot.PlotMain - */ - public PlotMain getMain() { - return this.plotMain; - } - - /** - * PlotHelper class contains useful methods relating to plots. - * - * @return PlotHelper - * - * @see com.intellectualcrafters.plot.util.PlotHelper - */ - public PlotHelper getPlotHelper() { - return plotHelper; - } - - /** - * PlayerFunctions class contains useful methods relating to players - Some player/plot methods are here as well - * - * @return PlayerFunctions - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions - */ - public PlayerFunctions getPlayerFunctions() { - return playerFunctions; - } - - /** - * FlagManager class contains methods relating to plot flags - * - * @return FlagManager - * - * @see com.intellectualcrafters.plot.flag.FlagManager - */ - public FlagManager getFlagManager() { - return flagManager; - } - - /** - * SchematicHandler class contains methods related to pasting schematics - * - * @return SchematicHandler - * - * @see com.intellectualcrafters.plot.util.SchematicHandler - */ - public SchematicHandler getSchematicHandler() { - return schematicHandler; - } - - /** - * C class contains all the captions from the translations.yml file. - * - * @return C - * - * @see com.intellectualcrafters.plot.config.C - */ - public C getCaptions() { - return c; - } - - /** - * Get the plot manager for a world. - Most of these methods can be accessed through the PlotHelper - * - * @param world Which manager to get - * - * @return PlotManager - * - * @see com.intellectualcrafters.plot.object.PlotManager - * @see PlotMain#getPlotManager(org.bukkit.World) - */ - public PlotManager getPlotManager(final World world) { - return PlotMain.getPlotManager(world); - } - - /** - * Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and - * tessellation - * - * @param world Plot World - * - * @return PlotManager - * - * @see PlotMain#getPlotManager(String) - * @see com.intellectualcrafters.plot.object.PlotManager - */ - public PlotManager getPlotManager(final String world) { - return PlotMain.getPlotManager(world); - } - - /** - * Get the settings for a world (settings bundled in PlotWorld class) - You will need to downcast for the specific - * settings a Generator has. e.g. DefaultPlotWorld class implements PlotWorld - * - * @param world (to get settings of) - * - * @return PlotWorld class for that world ! will return null if not a plot world world - * - * @see PlotMain#getWorldSettings(org.bukkit.World) - * @see com.intellectualcrafters.plot.object.PlotWorld - */ - public PlotWorld getWorldSettings(final World world) { - return PlotMain.getWorldSettings(world); - } - - /** - * Get the settings for a world (settings bundled in PlotWorld class) - * - * @param world (to get settings of) - * - * @return PlotWorld class for that world ! will return null if not a plot world world - * - * @see PlotMain#getWorldSettings(String) - * @see com.intellectualcrafters.plot.object.PlotWorld - */ - public PlotWorld getWorldSettings(final String world) { - return PlotMain.getWorldSettings(world); - } - - /** - * Send a message to a player. - * - * @param player Player that will receive the message - * @param c (Caption) - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, - * com.intellectualcrafters.plot.config.C, String...) - */ - public void sendMessage(final Player player, final C c) { - PlayerFunctions.sendMessage(player, c); - } - - /** - * Send a message to a player. - Supports color codes - * - * @param player Player that will receive the message - * @param string The message - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, String) - */ - public void sendMessage(final Player player, final String string) { - PlayerFunctions.sendMessage(player, string); - } - - /** - * Send a message to the console. - Supports color codes - * - * @param msg Message that should be sent to the console - * - * @see PlotMain#sendConsoleSenderMessage(String) - */ - public void sendConsoleMessage(final String msg) { - PlotMain.sendConsoleSenderMessage(msg); - } - - /** - * Send a message to the console - * - * @param c (Caption) - * - * @see #sendConsoleMessage(String) - * @see com.intellectualcrafters.plot.config.C - */ - public void sendConsoleMessage(final C c) { - sendConsoleMessage(c.s()); - } - - /** - * Register a flag for use in plots - * - * @param flag Flag that should be registered - * - * @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag) - * @see com.intellectualcrafters.plot.flag.AbstractFlag - */ - public void addFlag(final AbstractFlag flag) { - FlagManager.addFlag(flag); - } - - /** - * get all the currently registered flags - * - * @return array of Flag[] - * - * @see com.intellectualcrafters.plot.flag.FlagManager#getFlags() - * @see com.intellectualcrafters.plot.flag.AbstractFlag - */ - public AbstractFlag[] getFlags() { - return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]); - } - - /** - * Get a plot based on the ID - * - * @param world World in which the plot is located - * @param x Plot Location X Co-ord - * @param z Plot Location Z Co-ord - * - * @return plot, null if ID is wrong - * - * @see PlotHelper#getPlot(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) - * @see com.intellectualcrafters.plot.object.Plot - */ - public Plot getPlot(final World world, final int x, final int z) { - return PlotHelper.getPlot(world, new PlotId(x, z)); - } - - /** - * Get a plot based on the location - * - * @param l The location that you want to to retrieve the plot from - * - * @return plot if found, otherwise it creates a temporary plot- - * - * @see PlotHelper#getCurrentPlot(org.bukkit.Location) - * @see com.intellectualcrafters.plot.object.Plot - */ - public Plot getPlot(final Location l) { - return PlotHelper.getCurrentPlot(l); - } - - /** - * Get a plot based on the player location - * - * @param player Get the current plot for the player location - * - * @return plot if found, otherwise it creates a temporary plot - * - * @see #getPlot(org.bukkit.Location) - * @see com.intellectualcrafters.plot.object.Plot - */ - public Plot getPlot(final Player player) { - return this.getPlot(player.getLocation()); - } - - /** - * Check whether or not a player has a plot - * - * @param player Player that you want to check for - * - * @return true if player has a plot, false if not. - * - * @see #getPlots(org.bukkit.World, org.bukkit.entity.Player, boolean) - */ - public boolean hasPlot(final World world, final Player player) { - return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0); - } - - /** - * Get all plots for the player - * - * @param plr to search for - * @param just_owner should we just search for owner? Or with rights? - * - * @see com.intellectualcrafters.plot.object.Plot - */ - public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) { - final ArrayList pPlots = new ArrayList<>(); - for (final Plot plot : PlotMain.getPlots(world).values()) { - if (just_owner) { - if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(plr))) { - pPlots.add(plot); - } - } else { - if (plot.hasRights(plr)) { - pPlots.add(plot); - } - } - } - return pPlots.toArray(new Plot[pPlots.size()]); - } - - /** - * Get all plots for the world - * - * @param world to get plots of - * - * @return Plot[] - array of plot objects in world - * - * @see PlotMain#getWorldPlots(org.bukkit.World) - * @see com.intellectualcrafters.plot.object.Plot - */ - public Plot[] getPlots(final World world) { - return PlotMain.getWorldPlots(world); - } - - /** - * Get all plot worlds - * - * @return World[] - array of plot worlds - * - * @see com.intellectualcrafters.plot.PlotMain#getPlotWorlds() - */ - public String[] getPlotWorlds() { - return PlotMain.getPlotWorlds(); - } - - /** - * Get if plot world - * - * @param world (to check if plot world) - * - * @return boolean (if plot world or not) - * - * @see com.intellectualcrafters.plot.PlotMain#isPlotWorld(org.bukkit.World) - */ - public boolean isPlotWorld(final World world) { - return PlotMain.isPlotWorld(world); - } - - /** - * Get plot locations - * - * @param p Plot that you want to get the locations for - * - * @return [0] = bottomLc, [1] = topLoc, [2] = home - * - * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World, - * com.intellectualcrafters.plot.object.PlotId) - * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotTopLoc(org.bukkit.World, - * com.intellectualcrafters.plot.object.PlotId) - * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World, - * com.intellectualcrafters.plot.object.Plot) - * @see com.intellectualcrafters.plot.object.PlotHomePosition - * @see com.intellectualcrafters.plot.object.Plot - */ - public Location[] getLocations(final Plot p) { - final World world = Bukkit.getWorld(p.world); - return new Location[]{PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id)}; - } - - /** - * Get home location - * - * @param p Plot that you want to get the location for - * - * @return plot bottom location - * - * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World, - * com.intellectualcrafters.plot.object.Plot) - * @see com.intellectualcrafters.plot.object.PlotHomePosition - * @see com.intellectualcrafters.plot.object.Plot - */ - public Location getHomeLocation(final Plot p) { - return PlotHelper.getPlotHome(p.getWorld(), p.id); - } - - /** - * Get Bottom Location (min, min, min) - * - * @param p Plot that you want to get the location for - * - * @return plot bottom location - * - * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World, - * com.intellectualcrafters.plot.object.PlotId) - * @see com.intellectualcrafters.plot.object.Plot - */ - public Location getBottomLocation(final Plot p) { - final World world = Bukkit.getWorld(p.world); - return PlotHelper.getPlotBottomLoc(world, p.id); - } - - /** - * Get Top Location (max, max, max) - * - * @param p Plot that you want to get the location for - * - * @return plot top location - * - * @see PlotHelper#getPlotTopLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) - * @see com.intellectualcrafters.plot.object.Plot - */ - public Location getTopLocation(final Plot p) { - final World world = Bukkit.getWorld(p.world); - return PlotHelper.getPlotTopLoc(world, p.id); - } - - /** - * Check whether or not a player is in a plot - * - * @param player who we're checking for - * - * @return true if the player is in a plot, false if not- - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#isInPlot(org.bukkit.entity.Player) - */ - public boolean isInPlot(final Player player) { - return PlayerFunctions.isInPlot(player); - } - - /** - * Register a subcommand - * - * @param c SubCommand, that we want to register - * - * @see com.intellectualcrafters.plot.commands.MainCommand#subCommands - * @see com.intellectualcrafters.plot.commands.SubCommand - */ - public void registerCommand(final SubCommand c) { - MainCommand.subCommands.add(c); - } - - /** - * Get the plotMain class - * - * @return PlotMain Class - * - * @see com.intellectualcrafters.plot.PlotMain - */ - public PlotMain getPlotMain() { - return this.plotMain; - } - - /** - * Get the player plot count - * - * @param world Specify the world we want to select the plots from - * @param player Player, for whom we're getting the plot count - * - * @return the number of plots the player has - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlotCount(org.bukkit.World, - * org.bukkit.entity.Player) - */ - public int getPlayerPlotCount(final World world, final Player player) { - return PlayerFunctions.getPlayerPlotCount(world, player); - } - - /** - * Get a collection containing the players plots - * - * @param world Specify the world we want to select the plots from - * @param player Player, for whom we're getting the plots - * - * @return a set containing the players plots - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlots(org.bukkit.World, - * org.bukkit.entity.Player) - * @see com.intellectualcrafters.plot.object.Plot - */ - public Set getPlayerPlots(final World world, final Player player) { - return PlayerFunctions.getPlayerPlots(world, player); - } - - /** - * Get the numbers of plots, which the player is able to build in - * - * @param player Player, for whom we're getting the plots (trusted, helper and owner) - * - * @return the number of allowed plots - * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#getAllowedPlots(org.bukkit.entity.Player) - */ - public int getAllowedPlots(final Player player) { - return PlayerFunctions.getAllowedPlots(player); - } + // TODO API +// /** +// * Permission that allows for admin access, this permission node will allow the player to use any part of the +// * plugin, without limitations. +// */ +// public static final String ADMIN_PERMISSION = "plots.admin"; +// +// /** +// * Plot Helper Class +// *

+// * General functions involving plots, and the management of them +// * +// * @see com.intellectualcrafters.plot.util.PlotHelper +// */ +// private static PlotHelper plotHelper; +// +// /** +// * Player Functions +// *

+// * General functions involving players, and plot worlds +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions +// */ +// private static PlayerFunctions playerFunctions; +// +// /** +// * Flag Manager +// *

+// * The manager which handles all flags +// * +// * @see com.intellectualcrafters.plot.flag.FlagManager +// */ +// private static FlagManager flagManager; +// +// /** +// * Schematic Handler +// *

+// * The handler which is used to create, and paste, schematics +// * +// * @see com.intellectualcrafters.plot.util.SchematicHandler +// */ +// private static SchematicHandler schematicHandler; +// +// /** +// * The translation class. +// * +// * @see com.intellectualcrafters.plot.config.C +// */ +// private static C c; +// +// /** +// * PlotSquared instance +// *

+// * This is the instance that allows for most methods to be used. +// * +// * @see com.intellectualcrafters.plot.PlotSquared +// */ +// private final PlotSquared plotMain; +// +// /** +// * Constructor. Insert any Plugin. (Optimally the plugin that is accessing the method) +// * +// * @param plugin Plugin used to access this method +// * +// * @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotSquared +// * instance +// * @see com.intellectualcrafters.plot.PlotSquared +// */ +// public PlotAPI(final JavaPlugin plugin) { +// this.plotMain = PlotSquared.getMain(); +// if (this.plotMain == null) { +// throw new PlotSquaredException(PlotSquaredException.PlotError.PLOTMAIN_NULL, "Failed to fetch the plotmain instance, Plot API for " + plugin.getName() + " will be disabled"); +// } +// } +// +// /** +// * Get all plots +// * +// * @return all plots +// * +// * @see com.intellectualcrafters.plot.PlotSquared#getPlots() +// */ +// public Set getAllPlots() { +// return PlotSquared.getPlots(); +// } +// +// /** +// * Return all plots for a player +// * +// * @param player Player, whose plots to search for +// * +// * @return all plots that a player owns +// */ +// public Set getPlayerPlots(final Player player) { +// return PlotSquared.getPlots(player); +// } +// +// /** +// * Add a plot world +// * +// * @param world World Name +// * @param plotWorld Plot World Object +// * @param manager World Manager +// * +// * @see com.intellectualcrafters.plot.PlotSquared#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.addPlotWorld(world, plotWorld, manager); +// } +// +// /** +// * @return main configuration +// * +// * @see com.intellectualcrafters.plot.PlotSquared#config +// */ +// public YamlConfiguration getConfig() { +// return PlotSquared.config; +// } +// +// /** +// * @return storage configuration +// * +// * @see com.intellectualcrafters.plot.PlotSquared#storage +// */ +// public YamlConfiguration getStorage() { +// return PlotSquared.storage; +// } +// +// /** +// * Get the main class for this plugin
- Contains a lot of fields and methods - not very well organized
+// * Only use this if you really need it +// * +// * @return PlotSquared PlotSquared Main Class +// * +// * @see com.intellectualcrafters.plot.PlotSquared +// */ +// public PlotSquared getMain() { +// return this.plotMain; +// } +// +// /** +// * PlotHelper class contains useful methods relating to plots. +// * +// * @return PlotHelper +// * +// * @see com.intellectualcrafters.plot.util.PlotHelper +// */ +// public PlotHelper getPlotHelper() { +// return plotHelper; +// } +// +// /** +// * PlayerFunctions class contains useful methods relating to players - Some player/plot methods are here as well +// * +// * @return PlayerFunctions +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions +// */ +// public PlayerFunctions getPlayerFunctions() { +// return playerFunctions; +// } +// +// /** +// * FlagManager class contains methods relating to plot flags +// * +// * @return FlagManager +// * +// * @see com.intellectualcrafters.plot.flag.FlagManager +// */ +// public FlagManager getFlagManager() { +// return flagManager; +// } +// +// /** +// * SchematicHandler class contains methods related to pasting schematics +// * +// * @return SchematicHandler +// * +// * @see com.intellectualcrafters.plot.util.SchematicHandler +// */ +// public SchematicHandler getSchematicHandler() { +// return schematicHandler; +// } +// +// /** +// * C class contains all the captions from the translations.yml file. +// * +// * @return C +// * +// * @see com.intellectualcrafters.plot.config.C +// */ +// public C getCaptions() { +// return c; +// } +// +// /** +// * Get the plot manager for a world. - Most of these methods can be accessed through the PlotHelper +// * +// * @param world Which manager to get +// * +// * @return PlotManager +// * +// * @see com.intellectualcrafters.plot.object.PlotManager +// * @see PlotSquared#getPlotManager(org.bukkit.World) +// */ +// public PlotManager getPlotManager(final World world) { +// return PlotSquared.getPlotManager(world); +// } +// +// /** +// * Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and +// * tessellation +// * +// * @param world Plot World +// * +// * @return PlotManager +// * +// * @see PlotSquared#getPlotManager(String) +// * @see com.intellectualcrafters.plot.object.PlotManager +// */ +// public PlotManager getPlotManager(final String world) { +// return PlotSquared.getPlotManager(world); +// } +// +// /** +// * Get the settings for a world (settings bundled in PlotWorld class) - You will need to downcast for the specific +// * settings a Generator has. e.g. DefaultPlotWorld class implements PlotWorld +// * +// * @param world (to get settings of) +// * +// * @return PlotWorld class for that world ! will return null if not a plot world world +// * +// * @see PlotSquared#getWorldSettings(org.bukkit.World) +// * @see com.intellectualcrafters.plot.object.PlotWorld +// */ +// public PlotWorld getWorldSettings(final World world) { +// return PlotSquared.getWorldSettings(world); +// } +// +// /** +// * Get the settings for a world (settings bundled in PlotWorld class) +// * +// * @param world (to get settings of) +// * +// * @return PlotWorld class for that world ! will return null if not a plot world world +// * +// * @see PlotSquared#getWorldSettings(String) +// * @see com.intellectualcrafters.plot.object.PlotWorld +// */ +// public PlotWorld getWorldSettings(final String world) { +// return PlotSquared.getWorldSettings(world); +// } +// +// /** +// * Send a message to a player. +// * +// * @param player Player that will receive the message +// * @param c (Caption) +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, +// * com.intellectualcrafters.plot.config.C, String...) +// */ +// public void sendMessage(final Player player, final C c) { +// PlayerFunctions.sendMessage(player, c); +// } +// +// /** +// * Send a message to a player. - Supports color codes +// * +// * @param player Player that will receive the message +// * @param string The message +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, String) +// */ +// public void sendMessage(final Player player, final String string) { +// PlayerFunctions.sendMessage(player, string); +// } +// +// /** +// * Send a message to the console. - Supports color codes +// * +// * @param msg Message that should be sent to the console +// * +// * @see PlotSquared#sendConsoleSenderMessage(String) +// */ +// public void sendConsoleMessage(final String msg) { +// PlotSquared.sendConsoleSenderMessage(msg); +// } +// +// /** +// * Send a message to the console +// * +// * @param c (Caption) +// * +// * @see #sendConsoleMessage(String) +// * @see com.intellectualcrafters.plot.config.C +// */ +// public void sendConsoleMessage(final C c) { +// sendConsoleMessage(c.s()); +// } +// +// /** +// * Register a flag for use in plots +// * +// * @param flag Flag that should be registered +// * +// * @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag) +// * @see com.intellectualcrafters.plot.flag.AbstractFlag +// */ +// public void addFlag(final AbstractFlag flag) { +// FlagManager.addFlag(flag); +// } +// +// /** +// * get all the currently registered flags +// * +// * @return array of Flag[] +// * +// * @see com.intellectualcrafters.plot.flag.FlagManager#getFlags() +// * @see com.intellectualcrafters.plot.flag.AbstractFlag +// */ +// public AbstractFlag[] getFlags() { +// return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]); +// } +// +// /** +// * Get a plot based on the ID +// * +// * @param world World in which the plot is located +// * @param x Plot Location X Co-ord +// * @param z Plot Location Z Co-ord +// * +// * @return plot, null if ID is wrong +// * +// * @see PlotHelper#getPlot(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Plot getPlot(final World world, final int x, final int z) { +// return PlotHelper.getPlot(world, new PlotId(x, z)); +// } +// +// /** +// * Get a plot based on the location +// * +// * @param l The location that you want to to retrieve the plot from +// * +// * @return plot if found, otherwise it creates a temporary plot- +// * +// * @see PlotHelper#getCurrentPlot(org.bukkit.Location) +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Plot getPlot(final Location l) { +// return PlotHelper.getCurrentPlot(l); +// } +// +// /** +// * Get a plot based on the player location +// * +// * @param player Get the current plot for the player location +// * +// * @return plot if found, otherwise it creates a temporary plot +// * +// * @see #getPlot(org.bukkit.Location) +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Plot getPlot(final Player player) { +// return this.getPlot(player.getLocation()); +// } +// +// /** +// * Check whether or not a player has a plot +// * +// * @param player Player that you want to check for +// * +// * @return true if player has a plot, false if not. +// * +// * @see #getPlots(org.bukkit.World, org.bukkit.entity.Player, boolean) +// */ +// public boolean hasPlot(final World world, final Player player) { +// return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0); +// } +// +// /** +// * Get all plots for the player +// * +// * @param plr to search for +// * @param just_owner should we just search for owner? Or with rights? +// * +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// 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).values()) { +// if (just_owner) { +// if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(plr))) { +// pPlots.add(plot); +// } +// } else { +// if (plot.hasRights(plr)) { +// pPlots.add(plot); +// } +// } +// } +// return pPlots.toArray(new Plot[pPlots.size()]); +// } +// +// /** +// * Get all plots for the world +// * +// * @param world to get plots of +// * +// * @return Plot[] - array of plot objects in world +// * +// * @see PlotSquared#getWorldPlots(org.bukkit.World) +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Plot[] getPlots(final World world) { +// return PlotSquared.getWorldPlots(world); +// } +// +// /** +// * Get all plot worlds +// * +// * @return World[] - array of plot worlds +// * +// * @see com.intellectualcrafters.plot.PlotSquared#getPlotWorlds() +// */ +// public String[] getPlotWorlds() { +// return PlotSquared.getPlotWorlds(); +// } +// +// /** +// * Get if plot world +// * +// * @param world (to check if plot world) +// * +// * @return boolean (if plot world or not) +// * +// * @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(org.bukkit.World) +// */ +// public boolean isPlotWorld(final World world) { +// return PlotSquared.isPlotWorld(world); +// } +// +// /** +// * Get plot locations +// * +// * @param p Plot that you want to get the locations for +// * +// * @return [0] = bottomLc, [1] = topLoc, [2] = home +// * +// * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World, +// * com.intellectualcrafters.plot.object.PlotId) +// * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotTopLoc(org.bukkit.World, +// * com.intellectualcrafters.plot.object.PlotId) +// * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World, +// * com.intellectualcrafters.plot.object.Plot) +// * @see com.intellectualcrafters.plot.object.PlotHomePosition +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Location[] getLocations(final Plot p) { +// final World world = Bukkit.getWorld(p.world); +// return new Location[]{PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id)}; +// } +// +// /** +// * Get home location +// * +// * @param p Plot that you want to get the location for +// * +// * @return plot bottom location +// * +// * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World, +// * com.intellectualcrafters.plot.object.Plot) +// * @see com.intellectualcrafters.plot.object.PlotHomePosition +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Location getHomeLocation(final Plot p) { +// return PlotHelper.getPlotHome(p.getWorld(), p.id); +// } +// +// /** +// * Get Bottom Location (min, min, min) +// * +// * @param p Plot that you want to get the location for +// * +// * @return plot bottom location +// * +// * @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World, +// * com.intellectualcrafters.plot.object.PlotId) +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Location getBottomLocation(final Plot p) { +// final World world = Bukkit.getWorld(p.world); +// return PlotHelper.getPlotBottomLoc(world, p.id); +// } +// +// /** +// * Get Top Location (max, max, max) +// * +// * @param p Plot that you want to get the location for +// * +// * @return plot top location +// * +// * @see PlotHelper#getPlotTopLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Location getTopLocation(final Plot p) { +// final World world = Bukkit.getWorld(p.world); +// return PlotHelper.getPlotTopLoc(world, p.id); +// } +// +// /** +// * Check whether or not a player is in a plot +// * +// * @param player who we're checking for +// * +// * @return true if the player is in a plot, false if not- +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions#isInPlot(org.bukkit.entity.Player) +// */ +// public boolean isInPlot(final Player player) { +// return PlayerFunctions.isInPlot(player); +// } +// +// /** +// * Register a subcommand +// * +// * @param c SubCommand, that we want to register +// * +// * @see com.intellectualcrafters.plot.commands.MainCommand#subCommands +// * @see com.intellectualcrafters.plot.commands.SubCommand +// */ +// public void registerCommand(final SubCommand c) { +// MainCommand.subCommands.add(c); +// } +// +// /** +// * Get the plotMain class +// * +// * @return PlotSquared Class +// * +// * @see com.intellectualcrafters.plot.PlotSquared +// */ +// public PlotSquared getPlotSquared() { +// return this.plotMain; +// } +// +// /** +// * Get the player plot count +// * +// * @param world Specify the world we want to select the plots from +// * @param player Player, for whom we're getting the plot count +// * +// * @return the number of plots the player has +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlotCount(org.bukkit.World, +// * org.bukkit.entity.Player) +// */ +// public int getPlayerPlotCount(final World world, final Player player) { +// return PlayerFunctions.getPlayerPlotCount(world, player); +// } +// +// /** +// * Get a collection containing the players plots +// * +// * @param world Specify the world we want to select the plots from +// * @param player Player, for whom we're getting the plots +// * +// * @return a set containing the players plots +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlots(org.bukkit.World, +// * org.bukkit.entity.Player) +// * @see com.intellectualcrafters.plot.object.Plot +// */ +// public Set getPlayerPlots(final World world, final Player player) { +// return PlayerFunctions.getPlayerPlots(world, player); +// } +// +// /** +// * Get the numbers of plots, which the player is able to build in +// * +// * @param player Player, for whom we're getting the plots (trusted, helper and owner) +// * +// * @return the number of allowed plots +// * +// * @see com.intellectualcrafters.plot.util.PlayerFunctions#getAllowedPlots(org.bukkit.entity.Player) +// */ +// public int getAllowedPlots(final Player player) { +// return PlayerFunctions.getAllowedPlots(player); +// } } 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 bc6a2440f..999172e68 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -28,7 +28,8 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.BukkitMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; @@ -80,10 +81,10 @@ public class Auto extends SubCommand { int size_x = 1; int size_z = 1; String schematic = ""; - if (PlotMain.getPlotWorlds().length == 1) { - world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]); + if (PlotSquared.getPlotWorlds().size() == 1) { + world = Bukkit.getWorld(PlotSquared.getPlotWorlds().iterator().next()); } else { - if (PlotMain.isPlotWorld(plr.getWorld())) { + if (PlotSquared.isPlotWorld(plr.getWorld().getName())) { world = plr.getWorld(); } else { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); @@ -91,7 +92,7 @@ public class Auto extends SubCommand { } } if (args.length > 0) { - if (PlotMain.hasPermission(plr, "plots.auto.mega")) { + if (BukkitMain.hasPermission(plr, "plots.auto.mega")) { try { final String[] split = args[0].split(","); size_x = Integer.parseInt(split[0]); @@ -133,12 +134,12 @@ public class Auto extends SubCommand { } return false; } - final PlotWorld pWorld = PlotMain.getWorldSettings(world); - if (PlotMain.useEconomy && pWorld.USE_ECONOMY) { + final PlotWorld pWorld = PlotSquared.getWorldSettings(world.getName()); + if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY) { double cost = pWorld.PLOT_PRICE; cost = (size_x * size_z) * cost; if (cost > 0d) { - final Economy economy = PlotMain.economy; + final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < cost) { sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); return true; @@ -153,14 +154,14 @@ public class Auto extends SubCommand { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return true; } - if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { + if (!PlotSquared.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return true; } // } } - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (plotworld.TYPE == 2) { Location loc = plr.getLocation(); Plot plot = PlotHelper.getCurrentPlot(loc); @@ -214,7 +215,7 @@ public class Auto extends SubCommand { PlotHelper.lastPlot.put(worldname, start); if (lastPlot) { } - if ((PlotMain.getPlots(world).get(start) != null) && (PlotMain.getPlots(world).get(start).owner != null)) { + if ((PlotSquared.getPlots(world).get(start) != null) && (PlotSquared.getPlots(world).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 74e2444c0..7b0aa6dae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -26,7 +26,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; @@ -49,11 +49,11 @@ public class Buy extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlotMain.useEconomy) { + if (!PlotSquared.useEconomy) { return sendMessage(plr, C.ECON_DISABLED); } World world = plr.getWorld(); - if (!PlotMain.isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return sendMessage(plr, C.NOT_IN_PLOT_WORLD); } Plot plot; @@ -91,13 +91,13 @@ public class Buy extends SubCommand { PlotId id = plot.id; PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; int size = PlayerFunctions.getPlotSelectionIds(id, id2).size(); - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (plotworld.USE_ECONOMY) { price += plotworld.PLOT_PRICE * size; initPrice += plotworld.SELL_PRICE * size; } if (price > 0d) { - final Economy economy = PlotMain.economy; + final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < price) { return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price); } 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 15e1367ca..8b6b5120f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -27,7 +27,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.generator.ClassicPlotWorld; @@ -62,12 +62,12 @@ public class Claim extends SubCommand { PlotHelper.setSign(player, plot); PlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { - PlotMain.teleportPlayer(player, player.getLocation(), plot); + PlotSquared.teleportPlayer(player, player.getLocation(), plot); } World world = plot.getWorld(); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final Plot plot2 = PlotMain.getPlots(player.getWorld()).get(plot.id); + final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id); if (plotworld.SCHEMATIC_ON_CLAIM) { SchematicHandler.Schematic sch; @@ -81,7 +81,7 @@ public class Claim extends SubCommand { } SchematicHandler.paste(player.getLocation(), sch, plot2, 0, 0); } - PlotMain.getPlotManager(plot.world).claimPlot(world, plotworld, plot); + PlotSquared.getPlotManager(plot.world).claimPlot(world, plotworld, plot); PlotHelper.update(player.getLocation()); } return event.isCancelled(); @@ -103,11 +103,11 @@ public class Claim extends SubCommand { if (plot.hasOwner()) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } - final PlotWorld world = PlotMain.getWorldSettings(plot.getWorld()); - if (PlotMain.useEconomy && world.USE_ECONOMY) { + final PlotWorld world = PlotSquared.getWorldSettings(plot.getWorld()); + if (PlotSquared.useEconomy && world.USE_ECONOMY) { final double cost = world.PLOT_PRICE; if (cost > 0d) { - final Economy economy = PlotMain.economy; + final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < cost) { return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); } @@ -120,7 +120,7 @@ public class Claim extends SubCommand { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); } - if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { + if (!PlotSquared.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); } } 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 e52570c5a..b1cb3642a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -24,7 +24,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -43,22 +43,22 @@ public class Clear extends SubCommand { if (plr == null) { // Is console if (args.length < 2) { - PlotMain.sendConsoleSenderMessage("You need to specify two arguments: ID (0;0) & World (world)"); + PlotSquared.sendConsoleSenderMessage("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) { - PlotMain.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); + PlotSquared.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); } else { - if (!PlotMain.isPlotWorld(world)) { - PlotMain.sendConsoleSenderMessage("Invalid plot world: " + world); + if (!PlotSquared.isPlotWorld(world)) { + PlotSquared.sendConsoleSenderMessage("Invalid plot world: " + world); } else { final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); if (plot == null) { - PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); + PlotSquared.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); } else { plot.clear(null, false); - PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); + PlotSquared.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); } } } @@ -73,7 +73,7 @@ public class Clear extends SubCommand { if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.clear")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.clear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; 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 dfc7ce8f5..f91e5f63a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -30,7 +30,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.generator.AugmentedPopulator; @@ -64,7 +64,7 @@ public class Cluster extends SubCommand { switch (sub) { case "l": case "list": { - if (!PlotMain.hasPermission(plr, "plots.cluster.list")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.list")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.list"); return false; } @@ -94,7 +94,7 @@ public class Cluster extends SubCommand { } case "c": case "create": { - if (!PlotMain.hasPermission(plr, "plots.cluster.create")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.create")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create"); return false; } @@ -136,16 +136,16 @@ public class Cluster extends SubCommand { } ClusterManager.clusters.get(world).add(cluster); // Add any existing plots to the current cluster - for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) { + for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { PlotCluster current = ClusterManager.getCluster(plot); if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { cluster.invited.add(plot.owner); DBFunc.setInvited(world, cluster, plot.owner); } } - if (!PlotMain.isPlotWorld(world)) { - PlotMain.config.createSection("worlds." + world); - PlotMain.loadWorld(plr.getWorld()); + if (!PlotSquared.isPlotWorld(world)) { + PlotSquared.config.createSection("worlds." + world); + PlotSquared.loadWorld(plr.getWorld()); } PlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED); return true; @@ -153,7 +153,7 @@ public class Cluster extends SubCommand { case "disband": case "del": case "delete": { - if (!PlotMain.hasPermission(plr, "plots.cluster.delete")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.delete")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); return false; } @@ -177,15 +177,15 @@ public class Cluster extends SubCommand { } } if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { - if (!PlotMain.hasPermission(plr, "plots.cluster.delete.other")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.delete.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); return false; } } - PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld()); + PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld()); if (plotworld.TYPE == 2) { ArrayList toRemove = new ArrayList<>(); - for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) { + for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { PlotCluster other = ClusterManager.getCluster(plot); if (cluster.equals(other)) { toRemove.add(plot); @@ -216,7 +216,7 @@ public class Cluster extends SubCommand { } case "res": case "resize": { - if (!PlotMain.hasPermission(plr, "plots.cluster.resize")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.resize")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize"); return false; } @@ -238,7 +238,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!PlotMain.hasPermission(plr, "plots.cluster.resize.other")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.resize.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other"); return false; } @@ -258,7 +258,7 @@ public class Cluster extends SubCommand { case "reg": case "regenerate": case "regen": { - if (!PlotMain.hasPermission(plr, "plots.cluster.delete")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.delete")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen"); return false; } @@ -282,7 +282,7 @@ public class Cluster extends SubCommand { } } if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { - if (!PlotMain.hasPermission(plr, "plots.cluster.regen.other")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.regen.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen.other"); return false; } @@ -294,7 +294,7 @@ public class Cluster extends SubCommand { case "add": case "inv": case "invite": { - if (!PlotMain.hasPermission(plr, "plots.cluster.invite")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.invite")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite"); return false; } @@ -309,7 +309,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!PlotMain.hasPermission(plr, "plots.cluster.invite.other")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.invite.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other"); return false; } @@ -336,7 +336,7 @@ public class Cluster extends SubCommand { case "k": case "remove": case "kick": { - if (!PlotMain.hasPermission(plr, "plots.cluster.kick")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.kick")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick"); return false; } @@ -350,7 +350,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!PlotMain.hasPermission(plr, "plots.cluster.kick.other")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.kick.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); return false; } @@ -376,7 +376,7 @@ public class Cluster extends SubCommand { if (player != null) { PlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } - for (Plot plot : PlotMain.getPlots(plr.getWorld(), uuid)) { + for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { PlotCluster current = ClusterManager.getCluster(plot); if (current != null && current.equals(cluster)) { String world = plr.getWorld().getName(); @@ -388,7 +388,7 @@ public class Cluster extends SubCommand { } case "quit": case "leave": { - if (!PlotMain.hasPermission(plr, "plots.cluster.leave")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.leave")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); return false; } @@ -427,7 +427,7 @@ public class Cluster extends SubCommand { cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); - for (Plot plot : PlotMain.getPlots(plr.getWorld(), uuid)) { + for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { PlotCluster current = ClusterManager.getCluster(plot); if (current != null && current.equals(cluster)) { String world = plr.getWorld().getName(); @@ -439,7 +439,7 @@ public class Cluster extends SubCommand { case "admin": case "helper": case "helpers": { - if (!PlotMain.hasPermission(plr, "plots.cluster.helpers")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.helpers")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.helpers"); return false; } @@ -471,7 +471,7 @@ public class Cluster extends SubCommand { case "spawn": case "home": case "tp": { - if (!PlotMain.hasPermission(plr, "plots.cluster.tp")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.tp")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp"); return false; } @@ -486,7 +486,7 @@ public class Cluster extends SubCommand { } UUID uuid = UUIDHandler.getUUID(plr); if (!cluster.hasRights(uuid)) { - if (!PlotMain.hasPermission(plr, "plots.cluster.tp.other")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.tp.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); return false; } @@ -498,7 +498,7 @@ public class Cluster extends SubCommand { case "info": case "show": case "information": { - if (!PlotMain.hasPermission(plr, "plots.cluster.info")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.info")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); return false; } @@ -543,7 +543,7 @@ public class Cluster extends SubCommand { case "sh": case "setspawn": case "sethome": { - if (!PlotMain.hasPermission(plr, "plots.cluster.sethome")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.sethome")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); return false; } @@ -557,7 +557,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!PlotMain.hasPermission(plr, "plots.cluster.sethome.other")) { + if (!PlotSquared.hasPermission(plr, "plots.cluster.sethome.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other"); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java index 49b519f95..cec179db2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; /** * Created by Citymonstret on 2014-08-03. @@ -50,6 +50,6 @@ public class CommandPermission { * @return true of player has the required permission node */ public boolean hasPermission(final Player player) { - return PlotMain.hasPermission(player, this.permission); + return PlotSquared.hasPermission(player, this.permission); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 3f30d653f..b4d7883dc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -27,7 +27,7 @@ import java.util.List; import org.apache.commons.lang.StringUtils; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -54,7 +54,7 @@ public class Comment extends SubCommand { if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) { - if (PlotMain.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) { + if (PlotSquared.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) { final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " "); final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase())); plot.settings.addComment(comment); 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 321696f3d..9ee003dbc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -32,7 +32,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -60,7 +60,7 @@ public class Condense extends SubCommand { } String worldname = args[0]; final World world = Bukkit.getWorld(worldname); - if (world == null || !PlotMain.isPlotWorld(worldname)) { + if (world == null || !PlotSquared.isPlotWorld(worldname)) { PlayerFunctions.sendMessage(plr, "INVALID WORLD"); return false; } @@ -83,7 +83,7 @@ public class Condense extends SubCommand { return false; } int radius = Integer.parseInt(args[2]); - Collection plots = PlotMain.getPlots(worldname).values(); + Collection plots = PlotSquared.getPlots(worldname).values(); int size = plots.size(); int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1); if (radius < minimum_radius) { @@ -168,7 +168,7 @@ public class Condense extends SubCommand { return false; } int radius = Integer.parseInt(args[2]); - Collection plots = PlotMain.getPlots(worldname).values(); + Collection plots = PlotSquared.getPlots(worldname).values(); int size = plots.size(); int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1); if (radius < minimum_radius) { @@ -203,7 +203,7 @@ public class Condense extends SubCommand { } public static void sendMessage(final String message) { - PlotMain.sendConsoleSenderMessage("&3PlotSquared -> Plot condense&8: &7" + message); + PlotSquared.sendConsoleSenderMessage("&3PlotSquared -> Plot condense&8: &7" + message); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index 8cca3264e..82cdcbff4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotSelection; @@ -44,7 +44,7 @@ public class Copy extends SubCommand { return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.copy")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.copy")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } 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 8e073fa9d..cab2afda7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; @@ -45,13 +45,13 @@ public class CreateRoadSchematic extends SubCommand { return false; } - if (!(PlotMain.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { + if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } final Plot plot = PlayerFunctions.getCurrentPlot(player); - HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(player.getWorld()); + HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); PlotHelper.update(player.getLocation()); 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 9243e9941..063d48636 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -10,7 +10,7 @@ import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.object.Plot; @@ -33,7 +33,7 @@ public class Database extends SubCommand { private static boolean sendMessageU(final UUID uuid, final String msg) { if (uuid == null) { - PlotMain.sendConsoleSenderMessage(msg); + PlotSquared.sendConsoleSenderMessage(msg); } else { final Player p = UUIDHandler.uuidWrapper.getPlayer(uuid); if ((p != null) && p.isOnline()) { @@ -46,8 +46,8 @@ public class Database extends SubCommand { } public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) { - final Plugin p = PlotMain.getMain(); - final java.util.Set plots = PlotMain.getPlots(); + final Plugin p = PlotSquared.getMain(); + final java.util.Set plots = PlotSquared.getPlots(); p.getServer().getScheduler().runTaskAsynchronously(p, new Runnable() { @Override public void run() { @@ -94,7 +94,7 @@ public class Database extends SubCommand { } Connection n; try { - n = new MySQL(PlotMain.getMain(), host, port, database, username, password).openConnection(); + n = new MySQL(PlotSquared.getMain(), host, port, database, username, password).openConnection(); // Connection if (n.isClosed()) { return sendMessage(plr, "Failed to open connection"); @@ -141,7 +141,7 @@ public class Database extends SubCommand { private boolean sendMessage(final Player player, final String msg) { if (player == null) { - PlotMain.sendConsoleSenderMessage(msg); + PlotSquared.sendConsoleSenderMessage(msg); } else { PlayerFunctions.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 937e2bf6c..536ebe94f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -25,7 +25,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.util.Lag; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -58,7 +58,7 @@ public class Debug extends SubCommand { } { final StringBuilder worlds = new StringBuilder(""); - for (final String world : PlotMain.getPlotWorlds()) { + for (final String world : PlotSquared.getPlotWorlds()) { worlds.append(world).append(" "); } information.append(header); @@ -68,10 +68,10 @@ 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", PlotMain.getPlots().size())); + information.append(getLine(line, "Owned Plots", PlotSquared.getPlots().size())); // information.append(getLine(line, "PlotWorld Size", // PlotHelper.getWorldFolderSize() + "MB")); - for (final String worldname : PlotMain.getPlotWorlds()) { + for (final String worldname : PlotSquared.getPlotWorlds()) { final World world = Bukkit.getWorld(worldname); information.append(getLine(line, "World: " + world.getName() + " size", PlotHelper.getWorldFolderSize(world))); information.append(getLine(line, " - Entities", PlotHelper.getEntities(world))); 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 2d759a3bb..5a01d0a0b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -33,7 +33,7 @@ import org.bukkit.block.Sign; import org.bukkit.entity.Player; import com.google.common.collect.BiMap; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; @@ -68,7 +68,7 @@ public class DebugClaimTest extends SubCommand { PlotHelper.setSign(player, plot); PlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { - PlotMain.teleportPlayer(player, player.getLocation(), plot); + PlotSquared.teleportPlayer(player, player.getLocation(), plot); } } return event.isCancelled(); @@ -81,7 +81,7 @@ public class DebugClaimTest extends SubCommand { return !PlayerFunctions.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 World world = Bukkit.getWorld(args[0]); - if ((world == null) || !PlotMain.isPlotWorld(world)) { + if ((world == null) || !PlotSquared.isPlotWorld(world)) { return !PlayerFunctions.sendMessage(null, "&cInvalid plot world!"); } @@ -99,14 +99,14 @@ public class DebugClaimTest extends SubCommand { PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while..."); PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)"); - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final ArrayList plots = new ArrayList<>(); for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) { final Plot plot = PlotHelper.getPlot(world, id); - final boolean contains = PlotMain.getPlots(world).containsKey(plot.id); + final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id); if (contains) { PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id); continue; @@ -165,7 +165,7 @@ public class DebugClaimTest extends SubCommand { DBFunc.createAllSettingsAndHelpers(plots); for (final Plot plot : plots) { - PlotMain.updatePlot(plot); + PlotSquared.updatePlot(plot); } PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); 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 2bc50ca22..ad5d70e13 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -26,7 +26,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; @@ -47,19 +47,19 @@ public class DebugClear extends SubCommand { if (plr == null) { // Is console if (args.length < 2) { - PlotMain.sendConsoleSenderMessage("You need to specify two arguments: ID (0;0) & World (world)"); + PlotSquared.sendConsoleSenderMessage("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) { - PlotMain.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); + PlotSquared.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); } else { - if (!PlotMain.isPlotWorld(world) || !(PlotMain.getWorldSettings(world) instanceof SquarePlotWorld)) { - PlotMain.sendConsoleSenderMessage("Invalid plot world: " + world); + if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getWorldSettings(world) instanceof SquarePlotWorld)) { + PlotSquared.sendConsoleSenderMessage("Invalid plot world: " + world); } else { final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); if (plot == null) { - PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); + PlotSquared.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); } else { World bukkitWorld = Bukkit.getWorld(world); Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); @@ -73,8 +73,8 @@ public class DebugClear extends SubCommand { @Override public void run() { PlotHelper.runners.remove(plot); - PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); - PlotMain.sendConsoleSenderMessage("&aDone!"); + PlotSquared.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); + PlotSquared.sendConsoleSenderMessage("&aDone!"); } }); } @@ -84,14 +84,14 @@ public class DebugClear extends SubCommand { return true; } - if (!PlayerFunctions.isInPlot(plr) || !(PlotMain.getWorldSettings(plr.getWorld()) instanceof SquarePlotWorld)) { + if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getWorldSettings(plr.getWorld()) instanceof SquarePlotWorld)) { return sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = PlayerFunctions.getCurrentPlot(plr); if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.debugclear")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.debugclear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; 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 8df871d1c..b774f2f59 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -38,7 +38,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.ExpireManager; @@ -135,7 +135,7 @@ public class DebugExec extends SubCommand { return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run"); } final World world = Bukkit.getWorld(args[1]); - if (world == null || !PlotMain.isPlotWorld(args[1])) { + if (world == null || !PlotSquared.isPlotWorld(args[1])) { return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]); } final ArrayList empty = new ArrayList<>(); @@ -146,7 +146,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(PlotMain.getMain().getDirectory() + File.separator + "trim.txt"); + final File file = new File(PlotSquared.getMain().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 112f10d48..a95569da3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -28,7 +28,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; @@ -54,12 +54,12 @@ public class DebugFixFlags extends SubCommand { return false; } World world = Bukkit.getWorld(args[0]); - if (world == null || !PlotMain.isPlotWorld(world)) { + if (world == null || !PlotSquared.isPlotWorld(world)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); return false; } PlayerFunctions.sendMessage(plr, "&8--- &6Starting task &8 ---"); - for (Plot plot : PlotMain.getPlots(world).values()) { + for (Plot plot : PlotSquared.getPlots(world).values()) { Set flags = plot.settings.flags; ArrayList toRemove = new ArrayList(); for (Flag flag : flags) { 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 c8294ea6a..8cf301f4b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -25,7 +25,7 @@ import java.lang.reflect.Field; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -42,13 +42,13 @@ public class DebugLoadTest extends SubCommand { public boolean execute(final Player plr, final String... args) { if (plr == null) { try { - final Field fPlots = PlotMain.class.getDeclaredField("plots"); + final Field fPlots = PlotSquared.class.getDeclaredField("plots"); fPlots.setAccessible(true); fPlots.set(null, DBFunc.getPlots()); } catch (final Exception e) { - PlotMain.sendConsoleSenderMessage("&3===FAILED&3==="); + PlotSquared.sendConsoleSenderMessage("&3===FAILED&3==="); e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&3===END OF STACKTRACE==="); + PlotSquared.sendConsoleSenderMessage("&3===END OF STACKTRACE==="); } } else { PlayerFunctions.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 5cb30cdcb..eab28d1ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -26,7 +26,7 @@ import java.util.Arrays; import org.bukkit.Chunk; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; @@ -41,10 +41,10 @@ public class DebugRoadRegen extends SubCommand { @Override public boolean execute(final Player player, final String... args) { - if (!(PlotMain.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { + if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(player.getWorld()); + HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); Chunk chunk = player.getLocation().getChunk(); boolean result = manager.regenerateRoad(chunk); 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 4f8417658..a28f8f515 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -43,7 +43,7 @@ public class DebugSaveTest extends SubCommand { public boolean execute(final Player plr, final String... args) { if (plr == null) { final ArrayList plots = new ArrayList(); - plots.addAll(PlotMain.getPlots()); + plots.addAll(PlotSquared.getPlots()); DBFunc.createPlots(plots); DBFunc.createAllSettingsAndHelpers(plots); } else { 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 e6d41006a..fdc86b7bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -25,7 +25,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -48,20 +48,20 @@ public class Delete extends SubCommand { if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin.command.delete")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !PlotSquared.hasPermission(plr, "plots.admin.command.delete")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotMain.getWorldSettings(plot.getWorld()); - if (PlotMain.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.getWorld()); + if (PlotSquared.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) { final double c = pWorld.SELL_PRICE; if (c > 0d) { - final Economy economy = PlotMain.economy; + final Economy economy = PlotSquared.economy; economy.depositPlayer(plr, c); sendMessage(plr, C.ADDED_BALANCE, c + ""); } } - final boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true); + final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true); if (result) { plot.clear(plr, true); DBFunc.delete(plr.getWorld().getName(), plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index c89e7121a..861380467 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -26,7 +26,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; @@ -55,7 +55,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin.command.denied")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotSquared.hasPermission(plr, "plots.admin.command.denied")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 65780803f..d2007c374 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -28,7 +28,7 @@ import java.util.HashMap; import org.apache.commons.lang.StringUtils; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; @@ -67,13 +67,13 @@ public class FlagCmd extends SubCommand { sendMessage(player, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(player) && !PlotMain.hasPermission(player, "plots.set.flag.other")) { + if (!plot.hasRights(player) && !PlotSquared.hasPermission(player, "plots.set.flag.other")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other"); return false; } switch (args[0].toLowerCase()) { case "info": { - if (!PlotMain.hasPermission(player, "plots.set.flag")) { + if (!PlotSquared.hasPermission(player, "plots.set.flag")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.info"); return false; } @@ -96,7 +96,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, "&cNot implemented."); } case "set": { - if (!PlotMain.hasPermission(player, "plots.set.flag")) { + if (!PlotSquared.hasPermission(player, "plots.set.flag")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); return false; } @@ -109,7 +109,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; } - if (!PlotMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!PlotSquared.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -130,7 +130,7 @@ public class FlagCmd extends SubCommand { return true; } case "remove": { - if (!PlotMain.hasPermission(player, "plots.flag.remove")) { + if (!PlotSquared.hasPermission(player, "plots.flag.remove")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove"); return false; } @@ -143,7 +143,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; } - if (!PlotMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!PlotSquared.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -169,7 +169,7 @@ public class FlagCmd extends SubCommand { return true; } case "add": { - if (!PlotMain.hasPermission(player, "plots.flag.add")) { + if (!PlotSquared.hasPermission(player, "plots.flag.add")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.add"); return false; } @@ -182,7 +182,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; } - if (!PlotMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!PlotSquared.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -210,7 +210,7 @@ public class FlagCmd extends SubCommand { return true; } case "list": { - if (!PlotMain.hasPermission(player, "plots.flag.list")) { + if (!PlotSquared.hasPermission(player, "plots.flag.list")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.list"); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 791c09720..cfc49b3d2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -26,7 +26,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; @@ -55,7 +55,7 @@ public class Helpers extends SubCommand { PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin.command.helpers")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotSquared.hasPermission(plr, "plots.admin.command.helpers")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); 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 7ddf8ef47..e326d5eee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -39,7 +39,7 @@ public class Home extends SubCommand { } private Plot isAlias(final String a) { - for (final Plot p : PlotMain.getPlots()) { + for (final Plot p : PlotSquared.getPlots()) { if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { return p; } @@ -49,9 +49,9 @@ public class Home extends SubCommand { @Override public boolean execute(final Player plr, String... args) { - final Plot[] plots = PlotMain.getPlots(plr).toArray(new Plot[0]); + final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]); if (plots.length == 1) { - PlotMain.teleportPlayer(plr, plr.getLocation(), plots[0]); + PlotSquared.teleportPlayer(plr, plr.getLocation(), plots[0]); return true; } else if (plots.length > 1) { if (args.length < 1) { @@ -88,7 +88,7 @@ public class Home extends SubCommand { } public void teleportPlayer(Player player, Plot plot) { - PlotMain.teleportPlayer(player, player.getLocation(), plot); + PlotSquared.teleportPlayer(player, player.getLocation(), plot); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index baec7d6ca..5e5712432 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -29,7 +29,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -63,7 +63,7 @@ public class Inbox extends SubCommand { Integer tier; final UUID uuid = UUIDHandler.getUUID(plr); - if (PlotMain.hasPermission(plr, "plots.comment.admin")) { + if (PlotSquared.hasPermission(plr, "plots.comment.admin")) { tier = 0; } else if (plot != null && plot.owner.equals(uuid)) { tier = 1; @@ -138,7 +138,7 @@ public class Inbox extends SubCommand { final String world = plr.getWorld().getName(); final int tier2 = tier; - Bukkit.getScheduler().runTaskAsynchronously(PlotMain.getMain(), new Runnable() { + Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { @Override public void run() { ArrayList comments = null; 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 d92d38516..0ec16f5a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -31,7 +31,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; @@ -58,7 +58,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; Plot plot; if (player != null) { world = player.getWorld(); - if (!PlotMain.isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT_WORLD); return false; } @@ -72,7 +72,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; PlayerFunctions.sendMessage(null, C.INFO_SYNTAX_CONSOLE); return false; } - final PlotWorld plotworld = PlotMain.getWorldSettings(args[0]); + final PlotWorld plotworld = PlotSquared.getWorldSettings(args[0]); if (plotworld == null) { PlayerFunctions.sendMessage(player, C.NOT_VALID_WORLD); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 6c083384f..81e111c13 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -24,7 +24,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.kick")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.kick")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } 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 54e913c49..5eee15788 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -32,13 +32,14 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.BukkitMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.StringComparison; /** - * PlotMain command class + * PlotSquared command class * * @author Citymonstret */ @@ -47,8 +48,6 @@ public class MainCommand implements CommandExecutor, TabCompleter { /** * Main Permission Node */ - public static final String MAIN_PERMISSION = "plots.use"; - private final static SubCommand[] _subCommands = new SubCommand[]{new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense() }; public final static ArrayList subCommands = new ArrayList() { @@ -122,8 +121,8 @@ public class MainCommand implements CommandExecutor, TabCompleter { public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) { final Player player = (sender instanceof Player) ? (Player) sender : null; - if (!PlotMain.hasPermission(player, MAIN_PERMISSION)) { - return no_permission(player, MAIN_PERMISSION); + if (!BukkitMain.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")))) { 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 60536a80c..fc849d910 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -30,7 +30,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.object.Plot; @@ -85,7 +85,7 @@ public class Merge extends SubCommand { PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - boolean admin = PlotMain.hasPermission(plr, "plots.admin.command.merge"); + boolean admin = PlotSquared.hasPermission(plr, "plots.admin.command.merge"); if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; @@ -143,19 +143,19 @@ public class Merge extends SubCommand { plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top); for (final PlotId myid : plots) { - final Plot myplot = PlotMain.getPlots(world).get(myid); + final Plot myplot = PlotSquared.getPlots(world).get(myid); if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) { PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; } } - final PlotWorld plotWorld = PlotMain.getWorldSettings(world); - if (PlotMain.useEconomy && plotWorld.USE_ECONOMY) { + final PlotWorld plotWorld = PlotSquared.getWorldSettings(world); + if (PlotSquared.useEconomy && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; cost = plots.size() * cost; if (cost > 0d) { - final Economy economy = PlotMain.economy; + final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < cost) { sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + ""); return false; 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 7a9b9b61d..40ee9422b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -28,7 +28,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java index 70b21bee3..1d5003b0e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotSelection; @@ -44,7 +44,7 @@ public class Paste extends SubCommand { return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.paste")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.paste")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); 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 441d901a9..6af070d69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -30,7 +30,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -96,7 +96,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return false; } World world = Bukkit.getWorld(args[1]); - if (world == null || !PlotMain.isPlotWorld(world)) { + if (world == null || !PlotSquared.isPlotWorld(world)) { PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD); return false; } @@ -114,7 +114,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; } UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - Set plots = PlotMain.getPlots(world,uuid); + Set plots = PlotSquared.getPlots(world,uuid); Set ids = new HashSet<>(); for (Plot plot : plots) { ids.add(plot.id); @@ -123,7 +123,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return finishPurge(ids.size()); } if (arg.equals("all")) { - Set ids = PlotMain.getPlots(world).keySet(); + Set ids = PlotSquared.getPlots(world).keySet(); if (ids.size() == 0) { return PlayerFunctions.sendMessage(null, "&cNo plots found"); } @@ -131,7 +131,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return finishPurge(ids.size()); } if (arg.equals("unknown")) { - Collection plots = PlotMain.getPlots(world).values(); + Collection plots = PlotSquared.getPlots(world).values(); Set ids = new HashSet<>(); for (Plot plot : plots) { if (plot.owner != null) { @@ -148,7 +148,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return finishPurge(ids.size()); } if (arg.equals("unowned")) { - Collection plots = PlotMain.getPlots(world).values(); + Collection plots = PlotSquared.getPlots(world).values(); Set ids = new HashSet<>(); for (Plot plot : plots) { if (plot.owner == null) { 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 a7d4efea3..2155aef99 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -27,7 +27,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.object.ChunkLoc; @@ -54,7 +54,7 @@ public class RegenAllRoads extends SubCommand { } String name = args[0]; - PlotManager manager = PlotMain.getPlotManager(name); + PlotManager manager = PlotSquared.getPlotManager(name); if (manager == null || !(manager instanceof HybridPlotManager)) { sendMessage(player, C.NOT_VALID_PLOT_WORLD); @@ -66,15 +66,15 @@ public class RegenAllRoads extends SubCommand { World world = Bukkit.getWorld(name); ArrayList chunks = ChunkManager.getChunkChunks(world); - PlotMain.sendConsoleSenderMessage("&cIf no schematic is set, the following will not do anything"); - PlotMain.sendConsoleSenderMessage("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); - PlotMain.sendConsoleSenderMessage("&6Potential chunks to update: &7"+ (chunks.size() * 1024)); - PlotMain.sendConsoleSenderMessage("&6Estimated time: &7"+ (chunks.size()) + " seconds"); + PlotSquared.sendConsoleSenderMessage("&cIf no schematic is set, the following will not do anything"); + PlotSquared.sendConsoleSenderMessage("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); + PlotSquared.sendConsoleSenderMessage("&6Potential chunks to update: &7"+ (chunks.size() * 1024)); + PlotSquared.sendConsoleSenderMessage("&6Estimated time: &7"+ (chunks.size()) + " seconds"); boolean result = hpm.scheduleRoadUpdate(world); if (!result) { - PlotMain.sendConsoleSenderMessage("&cCannot schedule mass schematic update! (Is one already in progress?)"); + PlotSquared.sendConsoleSenderMessage("&cCannot schedule mass schematic update! (Is one already in progress?)"); 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 157fea4fe..f847acff3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -39,12 +39,12 @@ public class Reload extends SubCommand { try { // The following won't affect world generation, as that has to be // loaded during startup unfortunately. - PlotMain.config.load(PlotMain.configFile); - PlotMain.setupConfig(); + PlotSquared.config.load(PlotSquared.configFile); + PlotSquared.setupConfig(); C.setupTranslations(); - for (final String pw : PlotMain.getPlotWorlds()) { - final PlotWorld plotworld = PlotMain.getWorldSettings(pw); - plotworld.loadDefaultConfiguration(PlotMain.config.getConfigurationSection("worlds." + pw)); + for (final String pw : PlotSquared.getPlotWorlds()) { + final PlotWorld plotworld = PlotSquared.getWorldSettings(pw); + plotworld.loadDefaultConfiguration(PlotSquared.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/Schematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java index 08b1aaa1c..986555c73 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -31,7 +31,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.jnbt.CompoundTag; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; @@ -67,10 +67,10 @@ public class Schematic extends SubCommand { switch (arg) { case "paste": if (plr == null) { - PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE); + PlotSquared.sendConsoleSenderMessage(C.IS_CONSOLE); return false; } - if (!PlotMain.hasPermission(plr, "plots.schematic.paste")) { + if (!PlotSquared.hasPermission(plr, "plots.schematic.paste")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); return false; } @@ -131,7 +131,7 @@ public class Schematic extends SubCommand { final int LENGTH = schematic.getSchematicDimension().getZ(); final int blen = b.length - 1; - Schematic.this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() { + Schematic.this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { @Override public void run() { boolean result = false; @@ -155,10 +155,10 @@ public class Schematic extends SubCommand { break; case "test": if (plr == null) { - PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE); + PlotSquared.sendConsoleSenderMessage(C.IS_CONSOLE); return false; } - if (!PlotMain.hasPermission(plr, "plots.schematic.test")) { + if (!PlotSquared.hasPermission(plr, "plots.schematic.test")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); return false; } @@ -195,7 +195,7 @@ public class Schematic extends SubCommand { PlayerFunctions.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall "); return false; } - final HashMap plotmap = PlotMain.getPlots(args[1]); + final HashMap plotmap = PlotSquared.getPlots(args[1]); if ((plotmap == null) || (plotmap.size() == 0)) { PlayerFunctions.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall "); return false; @@ -205,8 +205,8 @@ public class Schematic extends SubCommand { return false; } - PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); - PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); + PlotSquared.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); + PlotSquared.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); final World worldObj = Bukkit.getWorld(args[1]); final String worldname = Bukkit.getWorld(args[1]).getName(); @@ -221,7 +221,7 @@ public class Schematic extends SubCommand { @Override public void run() { if (Schematic.this.counter >= Schematic.this.plots.length) { - PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); + PlotSquared.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); Schematic.this.running = false; Bukkit.getScheduler().cancelTask(Schematic.this.task); return; @@ -252,7 +252,7 @@ public class Schematic extends SubCommand { break; case "export": case "save": - if (!PlotMain.hasPermission(plr, "plots.schematic.save")) { + if (!PlotSquared.hasPermission(plr, "plots.schematic.save")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); return false; } @@ -280,11 +280,11 @@ public class Schematic extends SubCommand { world = args[0]; final String[] split = args[2].split(";"); final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - if ((PlotMain.getPlots(world) == null) || (PlotMain.getPlots(world).get(i) == null)) { + if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) { PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } - p2 = PlotMain.getPlots(world).get(i); + p2 = PlotSquared.getPlots(world).get(i); } catch (final Exception e) { PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; @@ -305,7 +305,7 @@ public class Schematic extends SubCommand { @Override public void run() { if (Schematic.this.counter >= Schematic.this.plots.length) { - PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); + PlotSquared.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); Schematic.this.running = false; Bukkit.getScheduler().cancelTask(Schematic.this.task); return; 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 1278c8347..249d9e7d6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -33,7 +33,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Configuration.SettingValue; @@ -78,7 +78,7 @@ public class Set extends SubCommand { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(plr) && !PlotMain.hasPermission(plr, "plots.admin.command.set")) { + if (!plot.hasRights(plr) && !PlotSquared.hasPermission(plr, "plots.admin.command.set")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -94,7 +94,7 @@ public class Set extends SubCommand { } /* TODO: Implement option */ // final boolean advanced_permissions = true; - if (!PlotMain.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { + if (!PlotSquared.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); return false; } @@ -102,11 +102,11 @@ public class Set extends SubCommand { if (args[0].equalsIgnoreCase("flag")) { if (args.length < 2) { String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6"); - if (PlotMain.worldGuardListener != null) { + if (PlotSquared.worldGuardListener != null) { if (message.equals("")) { - message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6"); + message = StringUtils.join(PlotSquared.worldGuardListener.str_flags, "&c, &6"); } else { - message += "," + StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6"); + message += "," + StringUtils.join(PlotSquared.worldGuardListener.str_flags, "&c, &6"); } } PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); @@ -121,19 +121,19 @@ public class Set extends SubCommand { af = new AbstractFlag(args[1].toLowerCase()); } - if (!FlagManager.getFlags().contains(af) && ((PlotMain.worldGuardListener == null) || !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) { + if (!FlagManager.getFlags().contains(af) && ((PlotSquared.worldGuardListener == null) || !PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); return false; } - if (!PlotMain.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) { + if (!PlotSquared.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); return false; } if (args.length == 2) { if (FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()) == null) { - if (PlotMain.worldGuardListener != null) { - if (PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { - PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]); + if (PlotSquared.worldGuardListener != null) { + if (PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { + PlotSquared.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]); return false; } } @@ -159,8 +159,8 @@ public class Set extends SubCommand { return false; } - if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotMain.worldGuardListener != null)) { - PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], af.toString(parsed_value)); + if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotSquared.worldGuardListener != null)) { + PlotSquared.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], af.toString(parsed_value)); return false; } @@ -209,7 +209,7 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.ALIAS_TOO_LONG); return false; } - for (final Plot p : PlotMain.getPlots(plr.getWorld()).values()) { + for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) { if (p.settings.getAlias().equalsIgnoreCase(alias)) { PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; @@ -254,8 +254,8 @@ public class Set extends SubCommand { // Get components World world = plr.getWorld(); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + PlotManager manager = PlotSquared.getPlotManager(world); String[] components = manager.getPlotComponents(world, plotworld, plot.id); for (String component : components) { if (component.equalsIgnoreCase(args[0])) { 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 e1ded1f0c..62f59874b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -27,7 +27,7 @@ import java.util.UUID; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -64,7 +64,7 @@ public class SetOwner extends SubCommand { return false; } - if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin.command.setowner")) { + if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !PlotSquared.hasPermission(plr, "plots.admin.command.setowner")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } @@ -73,7 +73,7 @@ public class SetOwner extends SubCommand { final PlotId top = PlayerFunctions.getTopPlot(world, plot).id; final ArrayList plots = PlayerFunctions.getPlotSelectionIds(bot, top); for (final PlotId id : plots) { - final Plot current = PlotMain.getPlots(world).get(id); + final Plot current = PlotSquared.getPlots(world).get(id); UUID uuid = getUUID(args[0]); @@ -83,11 +83,11 @@ public class SetOwner extends SubCommand { } current.owner = uuid; - PlotMain.updatePlot(current); + PlotSquared.updatePlot(current); DBFunc.setOwner(current, current.owner); - if (PlotMain.worldGuardListener != null) { - PlotMain.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); + if (PlotSquared.worldGuardListener != null) { + PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); } } PlotHelper.setSign(world, args[0], plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 71dfc9dcb..3acd85a14 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -36,7 +36,7 @@ import org.bukkit.entity.Player; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; @@ -72,7 +72,7 @@ public class Setup extends SubCommand { if (plugin.isEnabled()) { ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); if (generator != null) { - PlotMain.removePlotWorld(testWorld); + PlotSquared.removePlotWorld(testWorld); final String name = plugin.getDescription().getName(); if (generator instanceof PlotGenerator) { PlotGenerator pgen = (PlotGenerator) generator; @@ -299,15 +299,15 @@ public class Setup extends SubCommand { final ConfigurationNode[] steps = object.step; final String world = object.world; for (final ConfigurationNode step : steps) { - PlotMain.config.set("worlds." + world + "." + step.getConstant(), step.getValue()); + PlotSquared.config.set("worlds." + world + "." + step.getConstant(), step.getValue()); } if (object.type != 0) { - PlotMain.config.set("worlds." + world + "." + "generator.type", object.type); - PlotMain.config.set("worlds." + world + "." + "generator.terrain", object.terrain); - PlotMain.config.set("worlds." + world + "." + "generator.plugin", object.generator); + PlotSquared.config.set("worlds." + world + "." + "generator.type", object.type); + PlotSquared.config.set("worlds." + world + "." + "generator.terrain", object.terrain); + PlotSquared.config.set("worlds." + world + "." + "generator.plugin", object.generator); } try { - PlotMain.config.save(PlotMain.configFile); + PlotSquared.config.save(PlotSquared.configFile); } catch (final IOException e) { e.printStackTrace(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index df1a10bce..6362a2142 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -24,7 +24,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -57,7 +57,7 @@ public class Swap extends SubCommand { return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.swap")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.swap")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -70,8 +70,8 @@ public class Swap extends SubCommand { final World world = plr.getWorld(); try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); - final Plot plot2 = PlotMain.getPlots(world).get(plotid); - if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.swap")) { + final Plot plot2 = PlotSquared.getPlots(world).get(plotid); + if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.swap")) { PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); return false; } 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 9e491e771..9c1c6d2a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -26,7 +26,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -56,19 +56,19 @@ public class TP extends SubCommand { world = Bukkit.getWorld(args[1]); } } - if (!PlotMain.isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } Plot temp; if ((temp = isAlias(world, id)) != null) { - PlotMain.teleportPlayer(plr, plr.getLocation(), temp); + PlotSquared.teleportPlayer(plr, plr.getLocation(), temp); return true; } try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); - PlotMain.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid)); + PlotSquared.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid)); return true; } catch (final Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); @@ -87,14 +87,14 @@ public class TP extends SubCommand { } @SuppressWarnings("deprecation") final Player player = Bukkit.getPlayer(a); if (player != null) { - final java.util.Set plotMainPlots = PlotMain.getPlots(world, player); + final java.util.Set plotMainPlots = PlotSquared.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 : PlotMain.getPlots(world).values()) { + for (final Plot p : PlotSquared.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 a40f6ef4e..73526d3b5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -24,7 +24,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Location; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -38,7 +38,7 @@ public class Target extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlotMain.isPlotWorld(plr.getWorld())) { + if (!PlotSquared.isPlotWorld(plr.getWorld())) { PlayerFunctions.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 7357addb8..319820bab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -30,7 +30,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -48,7 +48,7 @@ public class Template extends SubCommand { return false; } World world = Bukkit.getWorld(args[1]); - PlotWorld plotworld = PlotMain.getWorldSettings(args[1]); + PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]); if (world == null || plotworld == null) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java index 0dc6d56cd..47c30e059 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -35,7 +35,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.generator.SquarePlotWorld; @@ -97,7 +97,7 @@ public class Trim extends SubCommand { return false; } final World world = Bukkit.getWorld(args[1]); - if (world == null || PlotMain.getWorldSettings(world) == null) { + if (world == null || PlotSquared.getWorldSettings(world) == null) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD); return false; } @@ -183,12 +183,12 @@ public class Trim extends SubCommand { final long startOld = System.currentTimeMillis(); sendMessage("Collecting region data..."); final ArrayList plots = new ArrayList<>(); - plots.addAll(PlotMain.getPlots(world).values()); + plots.addAll(PlotSquared.getPlots(world).values()); final HashSet chunks = new HashSet<>(ChunkManager.getChunkChunks(world)); sendMessage(" - MCA #: " + chunks.size()); sendMessage(" - CHUNKS: " + (chunks.size() * 1024) +" (max)"); sendMessage(" - TIME ESTIMATE: " + (chunks.size()/1200) +" minutes"); - Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() { + Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { @Override public void run() { long start = System.currentTimeMillis(); @@ -223,12 +223,12 @@ public class Trim extends SubCommand { public static ArrayList expired = null; // public static void updateUnmodifiedPlots(final World world) { -// final SquarePlotManager manager = (SquarePlotManager) PlotMain.getPlotManager(world); -// final SquarePlotWorld plotworld = (SquarePlotWorld) PlotMain.getWorldSettings(world); +// final SquarePlotManager manager = (SquarePlotManager) PlotSquared.getPlotManager(world); +// final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getWorldSettings(world); // final ArrayList expired = new ArrayList<>(); // final Set plots = ExpireManager.getOldPlots(world.getName()).keySet(); // sendMessage("Checking " + plots.size() +" plots! This may take a long time..."); -// Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() { +// Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { // @Override // public void run() { // if (manager != null && plots.size() > 0) { @@ -260,7 +260,7 @@ public class Trim extends SubCommand { } public static void sendMessage(final String message) { - PlotMain.sendConsoleSenderMessage("&3PlotSquared -> World trim&8: &7" + message); + PlotSquared.sendConsoleSenderMessage("&3PlotSquared -> World trim&8: &7" + message); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 75e44bf8b..910bb1a0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -26,7 +26,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; @@ -55,7 +55,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin.command.trusted")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotSquared.hasPermission(plr, "plots.admin.command.trusted")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index b564c4d12..aec693ee8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -26,7 +26,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; @@ -49,24 +49,24 @@ public class Unclaim extends SubCommand { if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin.command.unclaim")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !PlotSquared.hasPermission(plr, "plots.admin.command.unclaim")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotMain.getWorldSettings(plot.getWorld()); - if (PlotMain.useEconomy && pWorld.USE_ECONOMY) { + final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.getWorld()); + if (PlotSquared.useEconomy && pWorld.USE_ECONOMY) { final double c = pWorld.SELL_PRICE; if (c > 0d) { - final Economy economy = PlotMain.economy; + final Economy economy = PlotSquared.economy; economy.depositPlayer(plr, c); sendMessage(plr, C.ADDED_BALANCE, c + ""); } } - final boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true); + final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true); if (result) { World world = plr.getWorld(); String worldname = world.getName(); - PlotMain.getPlotManager(world).unclaimPlot(world, pWorld, plot); + PlotSquared.getPlotManager(world).unclaimPlot(world, pWorld, plot); DBFunc.delete(worldname, plot); // TODO set wall block } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 27afe382c..2877d8a7f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -27,7 +27,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotUnlinkEvent; @@ -56,7 +56,7 @@ public class Unlink extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.unlink")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotSquared.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { @@ -73,7 +73,7 @@ public class Unlink extends SubCommand { } catch (final Exception e) { // execute(final Player plr, final String... args) { try { - PlotMain.sendConsoleSenderMessage("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); + PlotSquared.sendConsoleSenderMessage("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); } catch (final Exception ex) { ex.printStackTrace(); } @@ -95,13 +95,13 @@ public class Unlink extends SubCommand { return false; } - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); manager.startPlotUnlink(world, plotworld, ids); for (final PlotId id : ids) { - final Plot myplot = PlotMain.getPlots(world).get(id); + final Plot myplot = PlotSquared.getPlots(world).get(id); if (plot == null) { continue; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index ad4756559..18df569ab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -27,7 +27,7 @@ import java.util.UUID; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.UUIDHandler; @@ -39,7 +39,7 @@ public class Visit extends SubCommand { public List getPlots(final UUID uuid) { final List plots = new ArrayList<>(); - for (final Plot p : PlotMain.getPlots()) { + for (final Plot p : PlotSquared.getPlots()) { if (p.hasOwner() && p.owner.equals(uuid)) { plots.add(p); } @@ -62,7 +62,7 @@ public class Visit extends SubCommand { return sendMessage(plr, C.FOUND_NO_PLOTS); } if (args.length < 2) { - PlotMain.teleportPlayer(plr, plr.getLocation(), plots.get(0)); + PlotSquared.teleportPlayer(plr, plr.getLocation(), plots.get(0)); return true; } int i; @@ -74,7 +74,7 @@ public class Visit extends SubCommand { if ((i < 0) || (i >= plots.size())) { return sendMessage(plr, C.NOT_VALID_NUMBER); } - PlotMain.teleportPlayer(plr, plr.getLocation(), plots.get(i)); + PlotSquared.teleportPlayer(plr, plr.getLocation(), plots.get(i)); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index aa6519d35..51055f254 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.util.PWE; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -35,12 +35,12 @@ public class WE_Anywhere extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (PlotMain.worldEdit == null) { + if (PlotSquared.worldEdit == null) { PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); return false; } - if (PlotMain.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { + if (PlotSquared.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { PWE.removeMask(plr); PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index 4da3617a3..40d6f0755 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -27,7 +27,7 @@ import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; @@ -71,13 +71,13 @@ public class list extends SubCommand { return true; } if (args[0].equalsIgnoreCase("forsale") && (plr != null)) { - if (PlotMain.economy == null) { + if (PlotSquared.economy == null) { return sendMessage(plr, C.ECON_DISABLED); } final StringBuilder string = new StringBuilder(); string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "buyable")).append("\n"); int idx = 0; - for (final Plot p : PlotMain.getPlots(plr.getWorld()).values()) { + for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) { Flag price = FlagManager.getPlotFlag(p, "price"); if (price != null) { string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", idx + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", price.getValueString()).replaceAll("%owner", getName(p.owner))).append("\n"); @@ -96,7 +96,7 @@ public class list extends SubCommand { final StringBuilder string = new StringBuilder(); string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your")).append("\n"); int idx = 0; - for (final Plot p : PlotMain.getPlots(plr)) { + for (final Plot p : PlotSquared.getPlots(plr)) { string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", idx + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); idx++; } @@ -110,12 +110,12 @@ public class list extends SubCommand { } else if (args[0].equalsIgnoreCase("shared") && (plr != null)) { final StringBuilder string = new StringBuilder(); string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")).append("\n"); - for (final Plot p : PlotMain.getPlotsSorted()) { + for (final Plot p : PlotSquared.getPlotsSorted()) { if (p.helpers.contains(UUIDHandler.getUUID(plr))) { string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); } } - string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There are").replaceAll("%num%", PlotMain.getPlotsSorted().size() + "").replaceAll("%plot%", PlotMain.getPlotsSorted().size() == 1 ? "plot" : "plots")); + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There are").replaceAll("%num%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots")); PlayerFunctions.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("all")) { @@ -137,8 +137,8 @@ public class list extends SubCommand { // Get the total pages // int totalPages = ((int) Math.ceil(12 * - // (PlotMain.getPlotsSorted().size()) / 100)); - final int totalPages = (int) Math.ceil(PlotMain.getPlotsSorted().size() / 12); + // (PlotSquared.getPlotsSorted().size()) / 100)); + final int totalPages = (int) Math.ceil(PlotSquared.getPlotsSorted().size() / 12); if (page > totalPages) { page = totalPages; @@ -147,8 +147,8 @@ public class list extends SubCommand { // Only display 12! int max = (page * 12) + 12; - if (max > PlotMain.getPlotsSorted().size()) { - max = PlotMain.getPlotsSorted().size(); + if (max > PlotSquared.getPlotsSorted().size()) { + max = PlotSquared.getPlotsSorted().size(); } final StringBuilder string = new StringBuilder(); @@ -158,17 +158,17 @@ public class list extends SubCommand { // This might work xD for (int x = (page * 12); x < max; x++) { - p = (Plot) PlotMain.getPlotsSorted().toArray()[x]; + p = (Plot) PlotSquared.getPlotsSorted().toArray()[x]; string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); } - string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotMain.getPlotsSorted().size() + "").replaceAll("%plot%", PlotMain.getPlotsSorted().size() == 1 ? "plot" : "plots")); + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots")); PlayerFunctions.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("world") && (plr != null)) { final StringBuilder string = new StringBuilder(); string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")).append("\n"); - final HashMap plots = PlotMain.getPlots(plr.getWorld()); + final HashMap plots = PlotSquared.getPlots(plr.getWorld()); for (final Plot p : plots.values()) { string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java index b569d6368..c368a2238 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -31,7 +31,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.util.PlayerFunctions; public class plugin extends SubCommand { @@ -92,12 +92,12 @@ public class plugin extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - Bukkit.getScheduler().runTaskAsynchronously(PlotMain.getMain(), new Runnable() { + Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { @Override public void run() { final ArrayList strings = new ArrayList() { { - add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion())); + add(String.format("&c>> &6PlotSquared (Version: %s)", PlotSquared.getMain().getDescription().getVersion())); add(String.format("&c>> &6Made by Citymonstret and Empire92")); add(String.format("&c>> &6Download at &lhttp://www.spigotmc.org/resources/1177")); add(String.format("&c>> &cNewest Version (Spigot): %s", version)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 0363ed188..9995b1689 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -21,7 +21,7 @@ package com.intellectualcrafters.plot.config; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualsites.translation.*; import com.intellectualsites.translation.bukkit.BukkitTranslation; import org.bukkit.ChatColor; @@ -506,7 +506,7 @@ public enum C { public static void setupTranslations() { manager = new TranslationManager(); - defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(PlotMain.getMain()), lang, "PlotSquared", manager).read(); + defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(), lang, "PlotSquared", manager).read(); // register everything in this class for (final C c : values()) { manager.addTranslationObject(new TranslationObject(c.toString(), c.d, "", "")); @@ -539,8 +539,8 @@ public enum C { String s = manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n"); return s.replace("$1", COLOR_1.toString()).replace("$2", COLOR_2.toString()).replace("$3", COLOR_3.toString()).replace("$4", COLOR_4.toString()); /* - * if (PlotMain.translations != null) { - * final String t = PlotMain.translations.getString(this.toString()); + * if (PlotSquared.translations != null) { + * final String t = PlotSquared.translations.getString(this.toString()); * if (t != null) { * this.s = t; * } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index 8e8b6ffef..da470b5c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -40,10 +40,11 @@ import org.bukkit.WorldCreator; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; /** @@ -54,27 +55,18 @@ import com.intellectualcrafters.plot.util.UUIDHandler; */ public class PlotMeConverter { - /** - * PlotMain Object - */ - private final PlotMain plugin; - /** * Constructor * * @param plugin Plugin Used to run the converter */ - public PlotMeConverter(final PlotMain plugin) { - this.plugin = plugin; - } - private void sendMessage(final String message) { - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7" + message); + PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message); } public void runAsync() throws Exception { // We have to make it wait a couple of seconds - Bukkit.getScheduler().runTaskLaterAsynchronously(this.plugin, new Runnable() { + TaskManager.runTaskLaterAsync(new Runnable() { @Override public void run() { try { @@ -96,7 +88,7 @@ public class PlotMeConverter { final String con = plotConfig.getString("mySQLconn"); connection = DriverManager.getConnection(con, user, password); } else { - connection = new SQLite(PlotMain.getMain(), dataFolder + File.separator + "plots.db").openConnection(); + connection = new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection(); } sendMessage("Collecting plot data"); sendMessage(" - plotmePlots"); @@ -179,28 +171,28 @@ public class PlotMeConverter { try { String plotMeWorldName = world.toLowerCase(); final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); // - PlotMain.config.set("worlds." + world + ".road.width", pathwidth); + PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); // - PlotMain.config.set("worlds." + world + ".plot.size", plotsize); + PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); // - PlotMain.config.set("worlds." + world + ".wall.block", wallblock); + PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); // - PlotMain.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); + PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); // - PlotMain.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); + PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId"); - PlotMain.config.set("worlds." + world + ".road.block", road); + PlotSquared.config.set("worlds." + world + ".road.block", road); Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // if (height == null) { height = 64; } - PlotMain.config.set("worlds." + world + ".road.height", height); + PlotSquared.config.set("worlds." + world + ".road.height", height); } catch (final Exception e) { sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); } @@ -216,37 +208,37 @@ public class PlotMeConverter { if (pathwidth == null) { pathwidth = 7; } - PlotMain.config.set("worlds." + world + ".road.width", pathwidth); + PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // if (plotsize == null) { plotsize = 32; } - PlotMain.config.set("worlds." + world + ".plot.size", plotsize); + PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // if (wallblock == null) { wallblock = "44"; } - PlotMain.config.set("worlds." + world + ".wall.block", wallblock); + PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // if (floor == null) { floor = "2"; } - PlotMain.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); + PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // if (filling == null) { filling = "3"; } - PlotMain.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); + PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); if (road == null) { road = "5"; } - PlotMain.config.set("worlds." + world + ".road.block", road); + PlotSquared.config.set("worlds." + world + ".road.block", road); Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // if (height == null || height == 0) { @@ -255,9 +247,9 @@ public class PlotMeConverter { height = 64; } } - PlotMain.config.set("worlds." + world + ".road.height", height); - PlotMain.config.set("worlds." + world + ".plot.height", height); - PlotMain.config.set("worlds." + world + ".wall.height", height); + PlotSquared.config.set("worlds." + world + ".road.height", height); + PlotSquared.config.set("worlds." + world + ".plot.height", height); + PlotSquared.config.set("worlds." + world + ".wall.height", height); } } catch (final Exception e) { @@ -266,14 +258,14 @@ public class PlotMeConverter { for (final String world : plots.keySet()) { int duplicate = 0; for (final Plot plot : plots.get(world).values()) { - if (!PlotMain.getPlots(world).containsKey(plot.id)) { + if (!PlotSquared.getPlots(world).containsKey(plot.id)) { createdPlots.add(plot); } else { duplicate++; } } if (duplicate > 0) { - PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?"); + PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?"); } } @@ -284,12 +276,11 @@ public class PlotMeConverter { DBFunc.createAllSettingsAndHelpers(createdPlots); sendMessage("Saving configuration..."); try { - PlotMain.config.save(PlotMain.configFile); + PlotSquared.config.save(PlotSquared.configFile); } catch (final IOException e) { sendMessage(" - &cFailed to save configuration."); } - - Bukkit.getScheduler().scheduleSyncDelayedTask(PlotMain.getMain(), new Runnable() { + TaskManager.runTask(new Runnable() { @Override public void run() { try { @@ -307,7 +298,7 @@ public class PlotMeConverter { final String actualWorldName = world.getName(); sendMessage("Reloading generator for world: '" + actualWorldName + "'..."); - PlotMain.removePlotWorld(actualWorldName); + PlotSquared.removePlotWorld(actualWorldName); if (MV) { // unload @@ -336,9 +327,9 @@ public class PlotMeConverter { } } - PlotMain.setAllPlotsRaw(DBFunc.getPlots()); + PlotSquared.setAllPlotsRaw(DBFunc.getPlots()); sendMessage("Conversion has finished"); - PlotMain.sendConsoleSenderMessage("&cPlease disable 'plotme-convert.enabled' in the settings.yml to indicate that you conversion is no longer required."); + PlotSquared.log("&cPlease disable 'plotme-convert.enabled' in the settings.yml to indicate that you conversion is no longer required."); } catch (final Exception e) { e.printStackTrace(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 25de2b636..292bf85ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -39,7 +39,7 @@ import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.block.Biome; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.BlockLoc; @@ -91,12 +91,12 @@ public class SQLManager implements AbstractDB { this.CREATE_CLUSTER = "INSERT INTO `" + this.prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)"; // schedule reconnect - if (PlotMain.getMySQL() != null) { - Bukkit.getScheduler().runTaskTimer(PlotMain.getMain(), new Runnable() { + if (PlotSquared.getMySQL() != null) { + Bukkit.getScheduler().runTaskTimer(PlotSquared.getMain(), new Runnable() { @Override public void run() { try { - SQLManager.this.connection = PlotMain.getMySQL().forceConnection(); + SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); } catch (final Exception e) { e.printStackTrace(); } @@ -126,7 +126,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Could not set owner for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Could not set owner for plot " + plot.id); } } }); @@ -136,7 +136,7 @@ public class SQLManager implements AbstractDB { public void createAllSettingsAndHelpers(final ArrayList mylist) { int size = mylist.size(); int packet; - if (PlotMain.getMySQL() != null) { + if (PlotSquared.getMySQL() != null) { packet = Math.min(size, 50000); } else { @@ -232,7 +232,7 @@ public class SQLManager implements AbstractDB { } } catch (Exception e2) {} - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set all helpers for plots"); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set all helpers for plots"); } } } @@ -246,7 +246,7 @@ public class SQLManager implements AbstractDB { public void createPlots(final ArrayList mylist) { int size = mylist.size(); int packet; - if (PlotMain.getMySQL() != null) { + if (PlotSquared.getMySQL() != null) { packet = Math.min(size, 50000); } else { @@ -284,20 +284,20 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&6[WARN] "+"Could not bulk save. Conversion may be slower..."); + PlotSquared.sendConsoleSenderMessage("&6[WARN] "+"Could not bulk save. Conversion may be slower..."); try { for (Plot plot : plots) { try { createPlot(plot); } catch (Exception e3) { - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot: "+plot.id); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot: "+plot.id); } } } catch (Exception e2) { e2.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plots!"); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plots!"); } } } @@ -324,7 +324,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot " + plot.id); } } }); @@ -352,7 +352,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot " + plot.id); } } }); @@ -411,7 +411,7 @@ public class SQLManager implements AbstractDB { */ @Override public void delete(final String world, final Plot plot) { - PlotMain.removePlot(world, plot.id, false); + PlotSquared.removePlot(world, plot.id, false); BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -439,7 +439,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] " + "Failed to delete plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] " + "Failed to delete plot " + plot.id); } } }); @@ -529,8 +529,8 @@ public class SQLManager implements AbstractDB { try { Set worlds = new HashSet<>(); - if (PlotMain.config.contains("worlds")) { - worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false); + if (PlotSquared.config.contains("worlds")) { + worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false); } final HashMap uuids = new HashMap(); final HashMap noExist = new HashMap(); @@ -582,7 +582,7 @@ public class SQLManager implements AbstractDB { if (plot != null) { plot.addHelper(user); } else { - PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry."); + PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry."); } } /* @@ -601,7 +601,7 @@ public class SQLManager implements AbstractDB { if (plot != null) { plot.addTrusted(user); } else { - PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry."); + PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry."); } } /* @@ -620,7 +620,7 @@ public class SQLManager implements AbstractDB { if (plot != null) { plot.addDenied(user); } else { - PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry."); + PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry."); } } r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`"); @@ -700,12 +700,12 @@ public class SQLManager implements AbstractDB { } } if (exception) { - PlotMain.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted."); + PlotSquared.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted."); setFlags(id, flags.toArray(new Flag[0])); } plot.settings.flags = flags; } else { - PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry."); + PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry."); } } stmt.close(); @@ -720,13 +720,13 @@ public class SQLManager implements AbstractDB { boolean invalidPlot = false; for (final String worldname : noExist.keySet()) { invalidPlot = true; - PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'."); + PlotSquared.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'."); } if (invalidPlot) { - PlotMain.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the plots using the purge command"); + PlotSquared.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the plots using the purge command"); } } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load plots."); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load plots."); e.printStackTrace(); } return newplots; @@ -750,7 +750,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Could not set merged for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set merged for plot " + plot.id); } } }); @@ -837,7 +837,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + plot.id); } } }); @@ -862,7 +862,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + id); } } }); @@ -886,7 +886,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set alias for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set alias for plot " + plot.id); e.printStackTrace(); } @@ -930,16 +930,16 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); return; } } - PlotMain.sendConsoleSenderMessage("&6[INFO] "+"SUCCESSFULLY PURGED WORLD '" + world + "'!"); + PlotSquared.sendConsoleSenderMessage("&6[INFO] "+"SUCCESSFULLY PURGED WORLD '" + world + "'!"); } @Override public void purge(final String world, Set plots) { for (PlotId id : plots) { - PlotMain.removePlot(world, id, true); + PlotSquared.removePlot(world, id, true); } PreparedStatement stmt; try { @@ -959,7 +959,7 @@ public class SQLManager implements AbstractDB { r.close(); } catch (SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); } } @@ -980,7 +980,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set position for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set position for plot " + plot.id); e.printStackTrace(); } } @@ -1034,7 +1034,7 @@ public class SQLManager implements AbstractDB { stmt.close(); r.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for plot: " + id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for plot: " + id); e.printStackTrace(); } return h; @@ -1064,7 +1064,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for plot " + plot.id); } } }); @@ -1096,7 +1096,7 @@ public class SQLManager implements AbstractDB { statement.close(); set.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch comment"); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch comment"); e.printStackTrace(); } return comments; @@ -1117,7 +1117,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set comment for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set comment for plot " + plot.id); } } }); @@ -1141,7 +1141,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for plot " + plot.id); } } }); @@ -1164,7 +1164,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove trusted user for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove trusted user for plot " + plot.id); } } }); @@ -1186,7 +1186,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for plot " + plot.id); e.printStackTrace(); } } @@ -1204,7 +1204,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for id " + id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for id " + id); e.printStackTrace(); } } @@ -1227,7 +1227,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set plot trusted for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set plot trusted for plot " + plot.id); e.printStackTrace(); } } @@ -1251,7 +1251,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove denied for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove denied for plot " + plot.id); } } }); @@ -1273,7 +1273,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set denied for plot " + plot.id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set denied for plot " + plot.id); e.printStackTrace(); } } @@ -1294,7 +1294,7 @@ public class SQLManager implements AbstractDB { set.close(); return rating; } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString()); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString()); e.printStackTrace(); } return 0.0d; @@ -1325,7 +1325,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2()); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2()); } } }); @@ -1363,8 +1363,8 @@ public class SQLManager implements AbstractDB { try { Set worlds = new HashSet<>(); - if (PlotMain.config.contains("worlds")) { - worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false); + if (PlotSquared.config.contains("worlds")) { + worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false); } final HashMap uuids = new HashMap(); final HashMap noExist = new HashMap(); @@ -1419,7 +1419,7 @@ public class SQLManager implements AbstractDB { if (cluster != null) { cluster.helpers.add(user); } else { - PlotMain.sendConsoleSenderMessage("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry."); + PlotSquared.sendConsoleSenderMessage("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry."); } } /* @@ -1438,7 +1438,7 @@ public class SQLManager implements AbstractDB { if (cluster != null) { cluster.invited.add(user); } else { - PlotMain.sendConsoleSenderMessage("&cCluster " + id + " in cluster_invited does not exist. Please create the cluster or remove this entry."); + PlotSquared.sendConsoleSenderMessage("&cCluster " + id + " in cluster_invited does not exist. Please create the cluster or remove this entry."); } } r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`"); @@ -1517,12 +1517,12 @@ public class SQLManager implements AbstractDB { } } if (exception) { - PlotMain.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted."); + PlotSquared.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted."); setFlags(id, flags.toArray(new Flag[0])); } cluster.settings.flags = flags; } else { - PlotMain.sendConsoleSenderMessage("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry."); + PlotSquared.sendConsoleSenderMessage("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry."); } } stmt.close(); @@ -1537,13 +1537,13 @@ public class SQLManager implements AbstractDB { boolean invalidPlot = false; for (final String w : noExist.keySet()) { invalidPlot = true; - PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(w) + " clusters in DB for non existant world; '" + w + "'."); + PlotSquared.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(w) + " clusters in DB for non existant world; '" + w + "'."); } if (invalidPlot) { - PlotMain.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the clusters using the purge command"); + PlotSquared.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the clusters using the purge command"); } } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load clusters."); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load clusters."); e.printStackTrace(); } return newClusters; @@ -1571,7 +1571,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + cluster); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + cluster); } } }); @@ -1592,7 +1592,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set alias for cluster " + cluster); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set alias for cluster " + cluster); e.printStackTrace(); } @@ -1613,7 +1613,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for cluster " + cluster); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for cluster " + cluster); } } }); @@ -1631,7 +1631,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for cluster " + cluster); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for cluster " + cluster); e.printStackTrace(); } } @@ -1663,7 +1663,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save cluster " + cluster); + PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save cluster " + cluster); } } }); @@ -1689,7 +1689,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to rezize cluster " + current); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to rezize cluster " + current); e.printStackTrace(); } } @@ -1709,7 +1709,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set position for cluster " + cluster); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set position for cluster " + cluster); e.printStackTrace(); } } @@ -1758,7 +1758,7 @@ public class SQLManager implements AbstractDB { stmt.close(); r.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for cluster: " + id); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for cluster: " + id); e.printStackTrace(); } return h; @@ -1777,7 +1777,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove invited for cluster " + cluster); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove invited for cluster " + cluster); } } }); @@ -1796,7 +1796,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for cluster " + cluster); + PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for cluster " + cluster); e.printStackTrace(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 7c54c5bc5..62aa970a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -30,7 +30,7 @@ import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotFlagAddEvent; @@ -63,10 +63,10 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @return success? */ public static boolean addFlag(final AbstractFlag af) { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&8 - Adding flag: &7" + af); + PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&8 - Adding flag: &7" + af); String key = af.getKey(); - if (PlotMain.getAllPlotsRaw() != null) { - for (Plot plot : PlotMain.getPlots()) { + if (PlotSquared.getAllPlotsRaw() != null) { + for (Plot plot : PlotSquared.getPlots()) { for (Flag flag : plot.settings.flags) { if (flag.getAbstractFlag().getKey().equals(af.getKey())) { flag.setKey(af); @@ -82,7 +82,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; if (settings.flags != null && settings.flags.size() > 0) { flags.addAll(settings.flags); } - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (plotworld != null && plotworld.DEFAULT_FLAGS != null && plotworld.DEFAULT_FLAGS.length > 0) { flags.addAll(Arrays.asList(plotworld.DEFAULT_FLAGS)); } @@ -179,7 +179,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; public static Set getSettingFlags(String world, PlotSettings settings) { Set plotflags = settings.flags; - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (plotworld != null && plotworld.DEFAULT_FLAGS != null && plotworld.DEFAULT_FLAGS.length > 0) { HashSet flagStrings = new HashSet<>(); for (Flag flag : plotflags) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index 38b69c74b..cd98d066b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -8,7 +8,7 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.BlockWrapper; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotCluster; @@ -54,7 +54,7 @@ public class AugmentedPopulator extends BlockPopulator { public AugmentedPopulator(String world, PlotGenerator generator, PlotCluster cluster, boolean p, boolean b) { this.cluster = cluster; this.generator = generator; - this.plotworld = PlotMain.getWorldSettings(world); + this.plotworld = PlotSquared.getWorldSettings(world); this.manager = generator.getPlotManager(); this.p = p; this.b = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index b47eb342c..c1d93bd85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -9,7 +9,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java index 5513c6742..6df341bb3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java @@ -3,7 +3,7 @@ package com.intellectualcrafters.plot.generator; import org.apache.commons.lang.StringUtils; import org.bukkit.configuration.ConfigurationSection; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.object.PlotBlock; @@ -50,7 +50,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { @Override public void loadConfiguration(final ConfigurationSection config) { if (!config.contains("plot.height")) { - PlotMain.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); + PlotSquared.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); } this.PLOT_BEDROCK = config.getBoolean("plot.bedrock"); this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height")); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 3d8714797..2eec00495 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -32,7 +32,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotManager; @@ -92,7 +92,7 @@ public class HybridGen extends PlotGenerator { public HybridGen(final String world) { super(world); if (this.plotworld == null) { - this.plotworld = (HybridPlotWorld) PlotMain.getWorldSettings(world); + this.plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); } this.plotsize = this.plotworld.PLOT_WIDTH; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 581a8fa33..b262d4326 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -34,7 +34,7 @@ import org.bukkit.block.Block; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.jnbt.CompoundTag; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; @@ -65,7 +65,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; int topx = top.getBlockX(); int topz = top.getBlockZ(); - HybridPlotWorld hpw = (HybridPlotWorld) PlotMain.getWorldSettings(world); + HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getWorldSettings(world); PlotBlock[] air = new PlotBlock[] {new PlotBlock((short) 0, (byte) 0)}; @@ -120,7 +120,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; Location bot = PlotHelper.getPlotBottomLoc(world, plot.id); Location top = PlotHelper.getPlotTopLoc(world, plot.id); - HybridPlotWorld plotworld = (HybridPlotWorld) PlotMain.getWorldSettings(world); + HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); int sx = bot.getBlockX() - plotworld.ROAD_WIDTH + 1; int sz = bot.getBlockZ() + 1; @@ -147,7 +147,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2); CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4); - String dir = PlotMain.getMain().getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator; + String dir = PlotSquared.getMain().getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator; SchematicHandler.save(sideroad, dir + "sideroad.schematic"); SchematicHandler.save(intersection, dir + "intersection.schematic"); @@ -205,29 +205,29 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; } final ArrayList chunks = ChunkManager.getChunkChunks(world); - final Plugin plugin = (Plugin) PlotMain.getMain(); + final Plugin plugin = (Plugin) PlotSquared.getMain(); this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { if (chunks.size() == 0) { HybridPlotManager.UPDATE = false; - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "Finished road conversion"); + PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "Finished road conversion"); Bukkit.getScheduler().cancelTask(task); return; } else { try { ChunkLoc loc = chunks.get(0); - PlotMain.sendConsoleSenderMessage("Updating .mcr: " + loc.x + ", "+loc.z + " (aprrox 256 chunks)"); - PlotMain.sendConsoleSenderMessage("Remaining regions: "+chunks.size()); + PlotSquared.sendConsoleSenderMessage("Updating .mcr: " + loc.x + ", "+loc.z + " (aprrox 256 chunks)"); + PlotSquared.sendConsoleSenderMessage("Remaining regions: "+chunks.size()); regenerateChunkChunk(world, loc); chunks.remove(0); } catch (Exception e) { ChunkLoc loc = chunks.get(0); - PlotMain.sendConsoleSenderMessage("&c[ERROR]&7 Could not update '"+world.getName() + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); - PlotMain.sendConsoleSenderMessage("&d - Potentially skipping 256 chunks"); - PlotMain.sendConsoleSenderMessage("&d - TODO: recommend chunkster if corrupt"); + PlotSquared.sendConsoleSenderMessage("&c[ERROR]&7 Could not update '"+world.getName() + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); + PlotSquared.sendConsoleSenderMessage("&d - Potentially skipping 256 chunks"); + PlotSquared.sendConsoleSenderMessage("&d - TODO: recommend chunkster if corrupt"); } } } @@ -246,7 +246,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; Location bot = new Location(world, x, 0, z); Location top = new Location(world, ex, 0, ez); - HybridPlotWorld plotworld = (HybridPlotWorld) PlotMain.getWorldSettings(world); + HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); if (!plotworld.ROAD_SCHEMATIC_ENABLED) { return false; } @@ -392,7 +392,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; @Override public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { PlotHelper.runners.put(plot, 1); - final Plugin plugin = PlotMain.getMain(); + final Plugin plugin = PlotSquared.getMain(); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index 24298dc70..cee7cc94b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -26,7 +26,7 @@ import java.util.HashMap; import org.apache.commons.lang.StringUtils; import org.bukkit.configuration.ConfigurationSection; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.object.ChunkLoc; @@ -62,7 +62,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { @Override public void loadConfiguration(final ConfigurationSection config) { if (!config.contains("plot.height")) { - PlotMain.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); + PlotSquared.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); } this.PLOT_BEDROCK = config.getBoolean("plot.bedrock"); this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height")); @@ -89,7 +89,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { try { setupSchematics(); } catch (Exception e) { - PlotMain.sendConsoleSenderMessage("&c - road schematics are disabled for this world."); + PlotSquared.sendConsoleSenderMessage("&c - road schematics are disabled for this world."); this.ROAD_SCHEMATIC_ENABLED = false; } System.out.print("LOADED!"); @@ -144,7 +144,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { } if (schem1 == null || schem2 == null || this.ROAD_WIDTH == 0) { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&3 - schematic: &7false"); + PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&3 - schematic: &7false"); return; } // Do not populate road if using schematic population diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index edeff424e..d66b0b75a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -8,7 +8,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; @@ -132,7 +132,7 @@ public class HybridPop extends BlockPopulator { this.X = cx << 4; this.Z = cz << 4; - HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(w); + HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(w); RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR; if (plot != null) { short sx = (short) ((X) % this.size); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java index 259bef52e..6b73512c4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -6,7 +6,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; @@ -127,7 +127,7 @@ public abstract class SquarePlotManager extends GridPlotManager { if (northSouth && eastWest) { // This means you are in the intersection final PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH)); - final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); + final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; } @@ -140,7 +140,7 @@ public abstract class SquarePlotManager extends GridPlotManager { // You are on a road running West to East (yeah, I named the var // poorly) final PlotId id = PlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH)); - final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); + final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; } @@ -152,7 +152,7 @@ public abstract class SquarePlotManager extends GridPlotManager { if (eastWest) { // This is the road separating an Eastern and Western plot final PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0)); - final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); + final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; } @@ -162,7 +162,7 @@ public abstract class SquarePlotManager extends GridPlotManager { return null; } final PlotId id = new PlotId(dx + 1, dz + 1); - final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); + final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); if (plot == null) { return id; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java index b48222d6e..39fd23fa0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java @@ -2,7 +2,7 @@ package com.intellectualcrafters.plot.generator; import org.bukkit.configuration.ConfigurationSection; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; public abstract class SquarePlotWorld extends GridPlotWorld { @@ -15,7 +15,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld { @Override public void loadConfiguration(final ConfigurationSection config) { if (!config.contains("plot.height")) { - PlotMain.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); + PlotSquared.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); } this.PLOT_WIDTH = config.getInt("plot.size"); this.ROAD_WIDTH = config.getInt("road.width"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 6f4d317db..5b1fc18dc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -83,7 +83,7 @@ import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.WorldInitEvent; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.commands.Setup; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -112,7 +112,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onWorldInit(final WorldInitEvent event) { - PlotMain.loadWorld(event.getWorld()); + PlotSquared.loadWorld(event.getWorld()); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -200,7 +200,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi Plot plot = getCurrentPlot(q); if (plot != null) { if (plot.deny_entry(player)) { - if (!PlotMain.hasPermission(player, "plots.admin.entry.denied")) { + if (!PlotSquared.hasPermission(player, "plots.admin.entry.denied")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; @@ -225,7 +225,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (!plotworld.PLOT_CHAT) { return; } @@ -264,7 +264,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasOwner()) { - if (PlotMain.hasPermission(player, "plots.admin.destroy.unowned")) { + if (PlotSquared.hasPermission(player, "plots.admin.destroy.unowned")) { return; } PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned"); @@ -277,7 +277,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (destroy != null && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), (byte) block.getData()))) { return; } - if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { + if (PlotSquared.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { return; } PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other"); @@ -286,7 +286,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.road")) { + if (PlotSquared.hasPermission(event.getPlayer(), "plots.admin.destroy.road")) { return; } if (isPlotArea(loc)) { @@ -345,7 +345,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = (Player) e; Location loc = b.getLocation(); if (!isInPlot(loc)) { - if (!PlotMain.hasPermission(p, "plots.admin.build.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; @@ -353,13 +353,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(loc); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.build.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin.build.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); @@ -504,7 +504,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (PlotMain.hasPermission(player, "plots.admin.interact.unowned")) { + if (PlotSquared.hasPermission(player, "plots.admin.interact.unowned")) { return; } PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned"); @@ -516,7 +516,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasRights(player)) { - if (PlotMain.hasPermission(player, "plots.admin.interact.other")) { + if (PlotSquared.hasPermission(player, "plots.admin.interact.other")) { return; } PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other"); @@ -525,7 +525,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (PlotMain.hasPermission(player, "plots.admin.interact.road")) { + if (PlotSquared.hasPermission(player, "plots.admin.interact.road")) { return; } if (isPlotArea(loc)) { @@ -589,7 +589,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (e.getPlayer() != null) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (!PlotMain.hasPermission(p, "plots.admin.build.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; @@ -597,13 +597,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(loc); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.build.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin.build.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); @@ -657,7 +657,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(loc)) { Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (PlotMain.hasPermission(p, "plots.admin.build.road")) { + if (PlotSquared.hasPermission(p, "plots.admin.build.road")) { return; } PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); @@ -666,7 +666,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(loc); if (plot == null || !plot.hasOwner()) { - if (PlotMain.hasPermission(p, "plots.admin.build.unowned")) { + if (PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { return; } PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); @@ -677,7 +677,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (use != null && ((HashSet) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { return; } - if (PlotMain.hasPermission(p, "plots.admin.build.other")) { + if (PlotSquared.hasPermission(p, "plots.admin.build.other")) { return; } if (isPlotArea(loc)) { @@ -707,13 +707,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi Setup.setupMap.remove(event.getPlayer().getName()); } if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { - final Set plots = PlotMain.getPlots(event.getPlayer()); + final Set plots = PlotSquared.getPlots(event.getPlayer()); for (final Plot plot : plots) { - PlotWorld plotworld = PlotMain.getWorldSettings(plot.world); - final PlotManager manager = PlotMain.getPlotManager(plot.getWorld()); + PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); + final PlotManager manager = PlotSquared.getPlotManager(plot.getWorld()); manager.clearPlot(null, plotworld, plot, true, null); DBFunc.delete(plot.getWorld().getName(), plot); - PlotMain.sendConsoleSenderMessage(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); + PlotSquared.sendConsoleSenderMessage(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); } } } @@ -725,7 +725,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(loc)) { Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (PlotMain.hasPermission(p, "plots.admin.build.road")) { + if (PlotSquared.hasPermission(p, "plots.admin.build.road")) { return; } PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); @@ -734,7 +734,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(loc); if (plot == null || !plot.hasOwner()) { - if (PlotMain.hasPermission(p, "plots.admin.build.unowned")) { + if (PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { return; } PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); @@ -746,7 +746,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (use != null && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - if (PlotMain.hasPermission(p, "plots.admin.build.other")) { + if (PlotSquared.hasPermission(p, "plots.admin.build.other")) { return; } if (isPlotArea(loc)) { @@ -766,7 +766,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (!PlotMain.hasPermission(p, "plots.admin.build.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; @@ -774,7 +774,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(loc); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.build.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; @@ -783,7 +783,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) { return; } - if (!PlotMain.hasPermission(p, "plots.admin.build.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); @@ -803,7 +803,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location l = e.getEntity().getLocation(); if (isPlotWorld(l)) { if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin.destroy.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.destroy.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.road"); e.setCancelled(true); return; @@ -811,7 +811,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(l); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.destroy.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.destroy.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); e.setCancelled(true); return; @@ -820,7 +820,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { return; } - if (!PlotMain.hasPermission(p, "plots.admin.destroy.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.destroy.other")) { if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.other"); e.setCancelled(true); @@ -839,7 +839,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin.interact.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.interact.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); return; @@ -847,7 +847,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(l); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.interact.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.interact.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); return; @@ -866,7 +866,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (entity instanceof RideableMinecart && FlagManager.isPlotFlagTrue(plot, "vehicle-use")) { return; } - if (!PlotMain.hasPermission(p, "plots.admin.interact.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.interact.other")) { if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); @@ -887,7 +887,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = (Player) d; final PlotWorld pW = getPlotWorld(l.getWorld()); if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin.vehicle.break.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.vehicle.break.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); e.setCancelled(true); return; @@ -895,7 +895,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(l); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.vehicle.break.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.vehicle.break.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); e.setCancelled(true); return; @@ -906,7 +906,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) { return; } - if (!PlotMain.hasPermission(p, "plots.admin.vehicle.break.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.vehicle.break.other")) { if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); e.setCancelled(true); @@ -944,7 +944,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin.pve.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.pve.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.road"); e.setCancelled(true); return; @@ -952,7 +952,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(l); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.pve.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.pve.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.unowned"); e.setCancelled(true); return; @@ -974,7 +974,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (a instanceof Tameable && ((Tameable) a).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-attack")) { return; } - if (!PlotMain.hasPermission(p, "plots.admin.pve.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.pve.other")) { if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.other"); e.setCancelled(true); @@ -996,7 +996,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin.projectile.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.projectile.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.road"); e.setHatching(false); return; @@ -1004,13 +1004,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(l); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.projectile.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.projectile.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.unowned"); e.setHatching(false); return; } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin.projectile.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.projectile.other")) { if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); e.setHatching(false); @@ -1028,7 +1028,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - if (PlotMain.hasPermission(event.getPlayer(), "plots.admin")) { + if (PlotSquared.hasPermission(event.getPlayer(), "plots.admin")) { return; } Player player = event.getPlayer(); @@ -1036,7 +1036,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (PlotMain.hasPermission(player, "plots.admin.build.unowned")) { + if (PlotSquared.hasPermission(player, "plots.admin.build.unowned")) { return; } PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.unowned"); @@ -1049,7 +1049,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (place != null && ((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), (byte) block.getData()))) { return; } - if (!PlotMain.hasPermission(player, "plots.admin.build.other")) { + if (!PlotSquared.hasPermission(player, "plots.admin.build.other")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; @@ -1057,7 +1057,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (!PlotMain.hasPermission(player, "plots.admin.build.road")) { + if (!PlotSquared.hasPermission(player, "plots.admin.build.road")) { if (isPlotArea(loc)) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index 320602b6a..c3f6b66b6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -7,7 +7,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -20,19 +20,19 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin.interact.road")) { + if (!PlotSquared.hasPermission(p, "plots.admin.interact.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); } } else { final Plot plot = getCurrentPlot(l); if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.interact.unowned")) { + if (!PlotSquared.hasPermission(p, "plots.admin.interact.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin.interact.other")) { + if (!PlotSquared.hasPermission(p, "plots.admin.interact.other")) { if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 3a5fb92b6..3b0165a98 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -34,7 +34,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; @@ -82,11 +82,11 @@ import com.intellectualcrafters.plot.util.UUIDHandler; } public static boolean isPlotWorld(final World world) { - return PlotMain.isPlotWorld(world); + return PlotSquared.isPlotWorld(world); } public static boolean isPlotArea(Location location) { - PlotWorld plotworld = PlotMain.getWorldSettings(location.getWorld()); + PlotWorld plotworld = PlotSquared.getWorldSettings(location.getWorld()); if (plotworld.TYPE == 2) { return ClusterManager.getCluster(location) != null; } @@ -94,7 +94,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; } public static PlotWorld getPlotWorld(final World world) { - return PlotMain.getWorldSettings(world); + return PlotSquared.getWorldSettings(world); } private static String getName(final UUID id) { @@ -126,7 +126,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; } public static boolean isPlotWorld(final Location l) { - return PlotMain.isPlotWorld(l.getWorld()); + return PlotSquared.isPlotWorld(l.getWorld()); } public static boolean isInPlot(final Location loc) { @@ -139,8 +139,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return null; } final World world = loc.getWorld(); - if (PlotMain.getPlots(world).containsKey(id)) { - return PlotMain.getPlots(world).get(id); + if (PlotSquared.getPlots(world).containsKey(id)) { + return PlotSquared.getPlots(world).get(id); } return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld().getName()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index 6aceec9d0..73101e27d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -46,7 +46,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; @@ -195,7 +195,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(trespasser))) { return; } - if (PlotMain.hasPermission(trespasser, "plots.flag.notify-enter.bypass")) { + if (PlotSquared.hasPermission(trespasser, "plots.flag.notify-enter.bypass")) { return; } if (player.isOnline()) { @@ -238,7 +238,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(trespasser))) { return; } - if (PlotMain.hasPermission(trespasser, "plots.flag.notify-leave.bypass")) { + if (PlotSquared.hasPermission(trespasser, "plots.flag.notify-leave.bypass")) { return; } if (player.isOnline()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index 2a1ca7ed2..8b1d0eb5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -40,7 +40,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -68,14 +68,14 @@ public class WorldEditListener implements Listener { public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); private boolean isPlotWorld(final Location l) { - return (PlotMain.isPlotWorld(l.getWorld())); + return (PlotSquared.isPlotWorld(l.getWorld())); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDelete(final PlotDeleteEvent e) { final String world = e.getWorld(); final PlotId id = e.getPlotId(); - final Plot plot = PlotMain.getPlots(world).get(id); + final Plot plot = PlotSquared.getPlots(world).get(id); if ((plot == null) || (plot.owner == null)) { return; } @@ -86,7 +86,7 @@ public class WorldEditListener implements Listener { if (!world.equals(player.getWorld().getName())) { return; } - if (PlotMain.hasPermission(player, "plots.worldedit.bypass")) { + if (PlotSquared.hasPermission(player, "plots.worldedit.bypass")) { return; } PWE.setNoMask(player); @@ -118,7 +118,7 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent e) { final Player p = e.getPlayer(); - if (!PlotMain.isPlotWorld(p.getWorld()) || PlotMain.hasPermission(p, "plots.worldedit.bypass")) { + if (!PlotSquared.isPlotWorld(p.getWorld()) || PlotSquared.hasPermission(p, "plots.worldedit.bypass")) { return; } String cmd = e.getMessage().toLowerCase(); @@ -141,14 +141,14 @@ public class WorldEditListener implements Listener { } for (final String c : this.monitored) { if (cmd.equals("//" + c) || cmd.equals("/" + c) || cmd.equals("/worldedit:/" + c)) { - final Selection selection = PlotMain.worldEdit.getSelection(p); + final Selection selection = PlotSquared.worldEdit.getSelection(p); if (selection == null) { return; } final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector(); final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector(); - final LocalSession session = PlotMain.worldEdit.getSession(p); + final LocalSession session = PlotSquared.worldEdit.getSession(p); final Mask mask = session.getMask(); if (mask == null) { PlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Both points"); @@ -171,7 +171,7 @@ public class WorldEditListener implements Listener { public void onPlayerJoin(final PlayerJoinEvent e) { final Player p = e.getPlayer(); final Location l = p.getLocation(); - if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) { + if (PlotSquared.hasPermission(p, "plots.worldedit.bypass")) { if (isPlotWorld(l)) { PWE.removeMask(p); } @@ -192,7 +192,7 @@ public class WorldEditListener implements Listener { } final Location f = e.getFrom(); final Player p = e.getPlayer(); - if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) { + if (PlotSquared.hasPermission(p, "plots.worldedit.bypass")) { if (!PWE.hasMask(p)) { return; } @@ -208,7 +208,7 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPortal(final PlayerPortalEvent e) { - if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + if (PlotSquared.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { return; } final Player p = e.getPlayer(); @@ -230,7 +230,7 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent e) { final Player p = e.getPlayer(); - if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + if (PlotSquared.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { if (!PWE.hasMask(p)) { return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java index 5154a1182..08bcd96e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -33,7 +33,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; @@ -62,7 +62,7 @@ public class WorldGuardListener implements Listener { public final ArrayList str_flags; public final ArrayList> flags; - public WorldGuardListener(final PlotMain plugin) { + public WorldGuardListener(final PlotSquared plugin) { this.str_flags = new ArrayList<>(); this.flags = new ArrayList<>(); for (final Flag flag : DefaultFlag.getFlags()) { @@ -73,7 +73,7 @@ public class WorldGuardListener implements Listener { public void changeOwner(final Player requester, final UUID owner, final World world, final Plot plot) { try { - final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); DefaultDomain owners = new DefaultDomain(); owners.addPlayer(UUIDHandler.getName(owner)); @@ -86,7 +86,7 @@ public class WorldGuardListener implements Listener { final boolean op = requester.isOp(); requester.setOp(true); try { - final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); manager.getRegion(plot.id.x + "-" + plot.id.y); for (final Flag flag : this.flags) { if (flag.getName().equalsIgnoreCase(key)) { @@ -104,7 +104,7 @@ public class WorldGuardListener implements Listener { final boolean op = requester.isOp(); requester.setOp(true); try { - final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); manager.getRegion(plot.id.x + "-" + plot.id.y); for (final Flag flag : this.flags) { if (flag.getName().equalsIgnoreCase(key)) { @@ -123,7 +123,7 @@ public class WorldGuardListener implements Listener { final Plot main = event.getPlot(); final ArrayList plots = event.getPlots(); final World world = event.getWorld(); - final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); for (final PlotId plot : plots) { if (!plot.equals(main.getId())) { manager.removeRegion(plot.x + "-" + plot.y); @@ -156,9 +156,9 @@ public class WorldGuardListener implements Listener { try { final World w = event.getWorld(); final ArrayList plots = event.getPlots(); - final Plot main = PlotMain.getPlots(w).get(plots.get(0)); + final Plot main = PlotSquared.getPlots(w).get(plots.get(0)); - final RegionManager manager = PlotMain.worldGuard.getRegionManager(w); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(w); final ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y); final DefaultDomain owner = region.getOwners(); @@ -192,7 +192,7 @@ public class WorldGuardListener implements Listener { try { final Player player = event.getPlayer(); final Plot plot = event.getPlot(); - final RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld()); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(plot.getWorld()); final Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId()); final Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId()); @@ -203,7 +203,7 @@ public class WorldGuardListener implements Listener { final ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2); final DefaultDomain owner = new DefaultDomain(); - owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player)); + owner.addPlayer(PlotSquared.worldGuard.wrapPlayer(player)); region.setOwners(owner); @@ -218,14 +218,14 @@ public class WorldGuardListener implements Listener { final PlotId plot = event.getPlotId(); final World world = Bukkit.getWorld(event.getWorld()); - final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); manager.removeRegion(plot.x + "-" + plot.y); } catch (final Exception e) { } } public void addUser(final Player requester, final UUID user, final World world, final Plot plot) { - final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); DefaultDomain members = region.getMembers(); members.addPlayer(UUIDHandler.getName(user)); @@ -233,7 +233,7 @@ public class WorldGuardListener implements Listener { } public void removeUser(final Player requester, final UUID user, final World world, final Plot plot) { - final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); DefaultDomain members = region.getMembers(); members.removePlayer(UUIDHandler.getName(user)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 20547a052..70e8e0802 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -31,7 +31,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.util.PlotHelper; @@ -216,7 +216,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; * @return true if the player is added as a helper or is the owner */ public boolean hasRights(final Player player) { - return PlotMain.hasPermission(player, "plots.admin.build.other") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(UUIDHandler.getUUID(player))) || ((this.owner != null) && this.owner.equals(UUIDHandler.getUUID(player))) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(UUIDHandler.getUUID(player)) || this.trusted.contains(DBFunc.everyone))); + return PlotSquared.hasPermission(player, "plots.admin.build.other") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(UUIDHandler.getUUID(player))) || ((this.owner != null) && this.owner.equals(UUIDHandler.getUUID(player))) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(UUIDHandler.getUUID(player)) || this.trusted.contains(DBFunc.everyone))); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 73935683e..1caab0ebb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -23,12 +23,12 @@ package com.intellectualcrafters.plot.object; import org.bukkit.generator.ChunkGenerator; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; public abstract class PlotGenerator extends ChunkGenerator { public PlotGenerator(final String world) { - PlotMain.loadWorld(world, this); + PlotSquared.loadWorld(world, this); } public abstract PlotWorld getNewPlotWorld(final String world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java index bb6b97007..1eab594d2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java @@ -7,7 +7,7 @@ // //import com.gmail.filoghost.holographicdisplays.api.Hologram; //import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; -//import com.intellectualcrafters.plot.PlotMain; +//import com.intellectualcrafters.plot.PlotSquared; //import com.intellectualcrafters.plot.util.PlotHelper; // ///** @@ -25,7 +25,7 @@ // public PlotHologram(final String world, final PlotId id) { // this.id = id; // this.world = world; -// this.hologram = createHologram(PlotMain.getPlotManager(world).getSignLoc(Bukkit.getWorld(world), PlotMain.getWorldSettings(world), PlotHelper.getPlot(Bukkit.getWorld(world), id))); +// this.hologram = createHologram(PlotSquared.getPlotManager(world).getSignLoc(Bukkit.getWorld(world), PlotSquared.getWorldSettings(world), PlotHelper.getPlot(Bukkit.getWorld(world), id))); // } // // public static Hologram createHologram(final org.bukkit.Location location) { @@ -34,7 +34,7 @@ // // public static JavaPlugin getPlugin() { // if (plugin == null) { -// plugin = JavaPlugin.getPlugin(PlotMain.class); +// plugin = JavaPlugin.getPlugin(PlotSquared.class); // } // return plugin; // } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 8fc2813c4..b769d79ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -30,7 +30,7 @@ import org.bukkit.Material; import org.bukkit.block.Biome; import org.bukkit.configuration.ConfigurationSection; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; @@ -137,7 +137,7 @@ public abstract class PlotWorld { this.DEFAULT_FLAGS = FlagManager.parseFlags(flags); } catch (Exception e) { - PlotMain.sendConsoleSenderMessage("&cInvalid default flags for "+this.worldname+": "+StringUtils.join(flags,",")); + PlotSquared.sendConsoleSenderMessage("&cInvalid default flags for "+this.worldname+": "+StringUtils.join(flags,",")); this.DEFAULT_FLAGS = new Flag[]{}; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java index da7740b57..6f2cf7099 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java @@ -30,7 +30,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; public class EntityWrapper { @@ -227,7 +227,7 @@ public class EntityWrapper { return; } default: { - PlotMain.sendConsoleSenderMessage("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); + PlotSquared.sendConsoleSenderMessage("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); return; } @@ -443,7 +443,7 @@ public class EntityWrapper { return entity; } default: { - PlotMain.sendConsoleSenderMessage("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); + PlotSquared.sendConsoleSenderMessage("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); return entity; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java index b348c37dc..da8798dec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java @@ -3,7 +3,7 @@ package com.intellectualcrafters.plot.titles; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Settings; public class HackTitle extends AbstractTitle { @@ -16,7 +16,7 @@ public class HackTitle extends AbstractTitle { title.send(player); } catch (Throwable e) { - PlotMain.sendConsoleSenderMessage("&cYour server version does not support titles!"); + PlotSquared.sendConsoleSenderMessage("&cYour server version does not support titles!"); Settings.TITLES = false; AbstractTitle.TITLE_CLASS = null; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java deleted file mode 100644 index 0a865b5e7..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.intellectualcrafters.plot.util; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.World; - -import com.intellectualcrafters.plot.object.PlotBlock; - -public class BukkitUtil extends BlockManager { - - private static HashMap worlds = new HashMap<>(); - private static String lastString = null; - private static World lastWorld = null; - - public static World getWorld(String string) { - if (lastString == string) { - return lastWorld; - } - World world = worlds.get(string); - if (world == null) { - world = Bukkit.getWorld(string); - worlds.put(string, world); - } - return world; - } - - public static Chunk getChunkAt(String worldname, int x, int z) { - World world = getWorld(worldname); - return world.getChunkAt(x, z); - } - - public static void update(String world, int x, int z) { - ArrayList chunks = new ArrayList<>(); - final int distance = Bukkit.getViewDistance(); - for (int cx = -distance; cx < distance; cx++) { - for (int cz = -distance; cz < distance; cz++) { - final Chunk chunk = getChunkAt(world, (x >> 4) + cx, (z >> 4) + cz); - chunks.add(chunk); - } - } - SetBlockManager.setBlockManager.update(chunks); - } - - public static void setBlock(World world, int x, int y, int z, int id, byte data) { - try { - SetBlockManager.setBlockManager.set(world, x, y, z, id, data); - } - catch (Throwable e) { - SetBlockManager.setBlockManager = new SetBlockSlow(); - SetBlockManager.setBlockManager.set(world, x, y, z, id, data); - } - } - - @Override - public void functionSetBlock(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) { - World world = getWorld(worldname); - for (int i = 0; i < x.length; i++) { - BukkitUtil.setBlock(world, x[i], y[i], z[i], id[i], data[i]); - } - } - -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index 349f340ee..5353fb1ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -40,7 +40,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; @@ -100,7 +100,7 @@ public class ChunkManager { public void run() { String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca"; File file = new File(directory); - PlotMain.sendConsoleSenderMessage("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)"); + PlotSquared.sendConsoleSenderMessage("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)"); if (file.exists()) { file.delete(); } @@ -189,7 +189,7 @@ public class ChunkManager { } } - final Plugin plugin = (Plugin) PlotMain.getMain(); + final Plugin plugin = (Plugin) PlotSquared.getMain(); final Integer currentIndex = index.toInteger(); final int loadTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override @@ -269,7 +269,7 @@ public class ChunkManager { public static boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { index.increment(); - final Plugin plugin = (Plugin) PlotMain.getMain(); + final Plugin plugin = (Plugin) PlotSquared.getMain(); final World world = pos1.getWorld(); Chunk c1 = world.getChunkAt(pos1); @@ -446,7 +446,7 @@ public class ChunkManager { chest.getInventory().setContents(chestContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate chest: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate chest: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: signContents.keySet()) { @@ -461,7 +461,7 @@ public class ChunkManager { } state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate sign: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate sign: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: dispenserContents.keySet()) { @@ -471,7 +471,7 @@ public class ChunkManager { ((Dispenser) (state)).getInventory().setContents(dispenserContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: dropperContents.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -480,7 +480,7 @@ public class ChunkManager { ((Dropper) (state)).getInventory().setContents(dropperContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: beaconContents.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -489,7 +489,7 @@ public class ChunkManager { ((Beacon) (state)).getInventory().setContents(beaconContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate beacon: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate beacon: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: jukeDisc.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -498,7 +498,7 @@ public class ChunkManager { ((Jukebox) (state)).setPlaying(Material.getMaterial(jukeDisc.get(loc))); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore jukebox: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore jukebox: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: skullData.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -516,7 +516,7 @@ public class ChunkManager { } state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore jukebox: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore jukebox: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: hopperContents.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -525,7 +525,7 @@ public class ChunkManager { ((Hopper) (state)).getInventory().setContents(hopperContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate hopper: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate hopper: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: noteBlockContents.keySet()) { @@ -535,7 +535,7 @@ public class ChunkManager { ((NoteBlock) (state)).setNote(noteBlockContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate note block: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate note block: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: brewTime.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -543,7 +543,7 @@ public class ChunkManager { if (state instanceof BrewingStand) { ((BrewingStand) (state)).setBrewingTime(brewTime.get(loc)); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore brewing stand cooking: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore brewing stand cooking: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: spawnerData.keySet()) { @@ -553,7 +553,7 @@ public class ChunkManager { ((CreatureSpawner) (state)).setCreatureTypeId(spawnerData.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore spawner type: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore spawner type: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: cmdData.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -562,7 +562,7 @@ public class ChunkManager { ((CommandBlock) (state)).setCommand(cmdData.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore command block: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore command block: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: brewingStandContents.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -571,7 +571,7 @@ public class ChunkManager { ((BrewingStand) (state)).getInventory().setContents(brewingStandContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate brewing stand: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate brewing stand: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: furnaceTime.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -581,7 +581,7 @@ public class ChunkManager { ((Furnace) (state)).setBurnTime(time[0]); ((Furnace) (state)).setCookTime(time[1]); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore furnace cooking: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore furnace cooking: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: furnaceContents.keySet()) { Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -590,7 +590,7 @@ public class ChunkManager { ((Furnace) (state)).getInventory().setContents(furnaceContents.get(loc)); state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate furnace: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate furnace: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } for (BlockLoc loc: bannerBase.keySet()) { @@ -606,7 +606,7 @@ public class ChunkManager { } state.update(true); } - else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate banner: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate banner: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 964274af4..307311fcd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -14,7 +14,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.BlockLoc; @@ -58,8 +58,8 @@ public class ClusterManager { PlotId center = getCenterPlot(cluster); toReturn = PlotHelper.getPlotHome(world, center); if (toReturn.getBlockY() == 0) { - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final Location loc = manager.getSignLoc(world, plotworld, PlotHelper.getPlot(world, center)); toReturn.setY(loc.getY()); } @@ -82,15 +82,15 @@ public class ClusterManager { public static Location getClusterBottom(PlotCluster cluster) { String world = cluster.world; - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); } public static Location getClusterTop(PlotCluster cluster) { String world = cluster.world; - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, cluster.getP2()); } @@ -108,8 +108,8 @@ public class ClusterManager { public static boolean contains(PlotCluster cluster, Location loc) { String world = loc.getWorld().getName(); - PlotManager manager = PlotMain.getPlotManager(world); - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotManager manager = PlotSquared.getPlotManager(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1); if (bot.getBlockX() < loc.getBlockX() && bot.getBlockZ() < loc.getBlockZ() && top.getBlockX() > loc.getBlockX() && top.getBlockZ() > loc.getBlockZ()) { @@ -223,13 +223,13 @@ public class ClusterManager { int zw; String world = loc.getWorld().getName(); - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (plotworld == null) { xw = 39; zw = 39; } else { - PlotManager manager = PlotMain.getPlotManager(world); + PlotManager manager = PlotSquared.getPlotManager(world); Location al = manager.getPlotBottomLocAbs(plotworld, a); Location bl = manager.getPlotBottomLocAbs(plotworld, b); @@ -252,7 +252,7 @@ public class ClusterManager { int i = 0; final Random rand = new Random(); final World world = Bukkit.getWorld(cluster.world); - final PlotWorld plotworld = PlotMain.getWorldSettings(cluster.world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world); Location bot = getClusterBottom(cluster); Location top = getClusterTop(cluster); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 13db69eee..dd83d9ccd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -13,7 +13,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.commands.Unlink; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -50,7 +50,7 @@ public class ExpireManager { @Override public void run() { HashMap plots = getOldPlots(world); - PlotMain.sendConsoleSenderMessage("&cFound " + plots.size() + " expired plots for " + world + "!"); + PlotSquared.sendConsoleSenderMessage("&cFound " + plots.size() + " expired plots for " + world + "!"); expiredPlots.put(world, plots); updatingPlots.put(world, false); } @@ -64,10 +64,10 @@ public class ExpireManager { } public static void runTask() { - ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() { + ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { @Override public void run() { - for (String world : PlotMain.getPlotWorldsString()) { + for (String world : PlotSquared.getPlotWorldsString()) { if (!ExpireManager.updatingPlots.containsKey(world)) { ExpireManager.updatingPlots.put(world, false); } @@ -110,23 +110,23 @@ public class ExpireManager { } } final World worldobj = Bukkit.getWorld(world); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotManager manager = PlotSquared.getPlotManager(world); if (plot.settings.isMerged()) { Unlink.unlinkPlot(Bukkit.getWorld(world), plot); } - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); manager.clearPlot(worldobj, plotworld, plot, false, null); PlotHelper.removeSign(worldobj, plot); DBFunc.delete(world, plot); - PlotMain.removePlot(world, plot.id, true); + PlotSquared.removePlot(world, plot.id, true); expiredPlots.get(world).remove(plot); - PlotMain.sendConsoleSenderMessage("&cDeleted expired plot: " + plot.id); - PlotMain.sendConsoleSenderMessage("&3 - World: "+plot.world); + PlotSquared.sendConsoleSenderMessage("&cDeleted expired plot: " + plot.id); + PlotSquared.sendConsoleSenderMessage("&3 - World: "+plot.world); if (plot.hasOwner()) { - PlotMain.sendConsoleSenderMessage("&3 - Owner: "+UUIDHandler.getName(plot.owner)); + PlotSquared.sendConsoleSenderMessage("&3 - Owner: "+UUIDHandler.getName(plot.owner)); } else { - PlotMain.sendConsoleSenderMessage("&3 - Owner: Unowned"); + PlotSquared.sendConsoleSenderMessage("&3 - Owner: Unowned"); } return; } @@ -150,7 +150,7 @@ public class ExpireManager { } public static HashMap getOldPlots(String world) { - final Collection plots = PlotMain.getPlots(world).values(); + final Collection plots = PlotSquared.getPlots(world).values(); final HashMap toRemove = new HashMap<>(); HashMap remove = new HashMap<>(); Set keep = new HashSet<>(); @@ -186,7 +186,7 @@ public class ExpireManager { String worldname = Bukkit.getWorlds().get(0).getName(); String foldername; String filename = null; - if (PlotMain.checkVersion(1, 7, 5)) { + if (PlotSquared.checkVersion(1, 7, 5)) { foldername = "playerdata"; try { filename = op.getUniqueId() +".dat"; @@ -205,7 +205,7 @@ public class ExpireManager { if (filename != null) { File playerFile = new File(worldname + File.separator + foldername + File.separator + filename); if (!playerFile.exists()) { - PlotMain.sendConsoleSenderMessage("Could not find file: " + filename); + PlotSquared.sendConsoleSenderMessage("Could not find file: " + filename); } else { try { @@ -217,7 +217,7 @@ public class ExpireManager { } } catch (Exception e) { - PlotMain.sendConsoleSenderMessage("Please disable disk checking in old plot auto clearing; Could not read file: " + filename); + PlotSquared.sendConsoleSenderMessage("Please disable disk checking in old plot auto clearing; Could not read file: " + filename); } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java index 29ae1f4ca..aa85ebb72 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java @@ -29,7 +29,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Date; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; /** @@ -53,7 +53,7 @@ public class Logger { } reader.close(); } catch (final IOException e) { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup"); + PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup"); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 7245fade4..76f150717 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -1,6 +1,6 @@ package com.intellectualcrafters.plot.util; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; public class MainUtil { @@ -12,6 +12,6 @@ public class MainUtil { * @param c message */ public static void sendConsoleSenderMessage(final C c) { - PlotMain.MAIN_IMP.sendConsoleSenderMessage(c.s()); + PlotSquared.MAIN_IMP.sendConsoleSenderMessage(c.s()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java index 15b97b7b6..8f92d628f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -25,7 +25,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; @@ -48,17 +48,17 @@ import com.sk89q.worldedit.regions.CuboidRegion; public static void setMask(final Player p, final Location l, boolean force) { try { LocalSession s; - if (PlotMain.worldEdit == null) { + if (PlotSquared.worldEdit == null) { s = WorldEdit.getInstance().getSession(p.getName()); } else { - s = PlotMain.worldEdit.getSession(p); + s = PlotSquared.worldEdit.getSession(p); } - if (!PlotMain.isPlotWorld(p.getWorld())) { + if (!PlotSquared.isPlotWorld(p.getWorld())) { removeMask(p); } final PlotId id = PlayerFunctions.getPlot(l); if (id != null) { - final Plot plot = PlotMain.getPlots(l.getWorld()).get(id); + final Plot plot = PlotSquared.getPlots(l.getWorld()).get(id); if (plot != null) { if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) { return; @@ -73,7 +73,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; final Vector bvec = new Vector(bloc.getBlockX() + 1, bloc.getBlockY(), bloc.getBlockZ() + 1); final Vector tvec = new Vector(tloc.getBlockX(), tloc.getBlockY(), tloc.getBlockZ()); - final LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p).getWorld(); + final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(p).getWorld(); final CuboidRegion region = new CuboidRegion(lw, bvec, tvec); final RegionMask mask = new RegionMask(region); @@ -82,8 +82,8 @@ import com.sk89q.worldedit.regions.CuboidRegion; } } } - if (force ^ (noMask(s) && !PlotMain.hasPermission(p, "plots.worldedit.bypass"))) { - final BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p); + if (force ^ (noMask(s) && !PlotSquared.hasPermission(p, "plots.worldedit.bypass"))) { + final BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(p); final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); } @@ -97,10 +97,10 @@ import com.sk89q.worldedit.regions.CuboidRegion; public static boolean hasMask(final Player p) { LocalSession s; - if (PlotMain.worldEdit == null) { + if (PlotSquared.worldEdit == null) { s = WorldEdit.getInstance().getSession(p.getName()); } else { - s = PlotMain.worldEdit.getSession(p); + s = PlotSquared.worldEdit.getSession(p); } return !noMask(s); } @@ -113,12 +113,12 @@ import com.sk89q.worldedit.regions.CuboidRegion; public static void setNoMask(final Player p) { try { LocalSession s; - if (PlotMain.worldEdit == null) { + if (PlotSquared.worldEdit == null) { s = WorldEdit.getInstance().getSession(p.getName()); } else { - s = PlotMain.worldEdit.getSession(p); + s = PlotSquared.worldEdit.getSession(p); } - final BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p); + final BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(p); final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); } catch (final Exception e) { @@ -134,10 +134,10 @@ import com.sk89q.worldedit.regions.CuboidRegion; public static void removeMask(final Player p) { try { LocalSession s; - if (PlotMain.worldEdit == null) { + if (PlotSquared.worldEdit == null) { s = WorldEdit.getInstance().getSession(p.getName()); } else { - s = PlotMain.worldEdit.getSession(p); + s = PlotSquared.worldEdit.getSession(p); } removeMask(p, s); } catch (final Exception e) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java index 39d0ac3a4..ddfec80b9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -21,7 +21,7 @@ package com.intellectualcrafters.plot.util; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; @@ -69,8 +69,8 @@ import java.util.UUID; public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { - final Plot plot1 = PlotMain.getPlots(world).get(pos1); - final Plot plot2 = PlotMain.getPlots(world).get(pos2); + final Plot plot1 = PlotSquared.getPlots(world).get(pos1); + final Plot plot2 = PlotSquared.getPlots(world).get(pos2); if (plot1 != null) { pos1 = getBottomPlot(world, plot1).id; @@ -92,14 +92,14 @@ import java.util.UUID; public static Plot getBottomPlot(final String world, final Plot plot) { if (plot.settings.getMerged(0)) { - final Plot p = PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)); + final Plot p = PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)); if (p == null) { return plot; } return getBottomPlot(world, p); } if (plot.settings.getMerged(3)) { - final Plot p = PlotMain.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)); + final Plot p = PlotSquared.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)); if (p == null) { return plot; } @@ -111,10 +111,10 @@ import java.util.UUID; public static Plot getTopPlot(final String world, final Plot plot) { if (plot.settings.getMerged(2)) { - return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); + return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); } if (plot.settings.getMerged(1)) { - return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); + return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); } return plot; } @@ -128,11 +128,11 @@ import java.util.UUID; */ public static PlotId getPlotAbs(final Location loc) { final String world = loc.getWorld().getName(); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotManager manager = PlotSquared.getPlotManager(world); if (manager == null) { return null; } - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); return manager.getPlotIdAbs(plotworld, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } @@ -146,11 +146,11 @@ import java.util.UUID; */ public static PlotId getPlot(final Location loc) { final String world = loc.getWorld().getName(); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotManager manager = PlotSquared.getPlotManager(world); if (manager == null) { return null; } - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); PlotId id = manager.getPlotId(plotworld, loc.getBlockX(),loc.getBlockY(), loc.getBlockZ()); if (id!=null && plotworld.TYPE == 2) { @@ -169,7 +169,7 @@ import java.util.UUID; * @return */ public static Plot getCurrentPlot(final Player player) { - if (!PlotMain.isPlotWorld(player.getWorld())) { + if (!PlotSquared.isPlotWorld(player.getWorld())) { return null; } final PlotId id = getPlot(player.getLocation()); @@ -177,8 +177,8 @@ import java.util.UUID; if (id == null) { return null; } - if (PlotMain.getPlots(world).containsKey(id)) { - return PlotMain.getPlots(world).get(id); + if (PlotSquared.getPlots(world).containsKey(id)) { + return PlotSquared.getPlots(world).get(id); } return new Plot(id, null, new ArrayList(), new ArrayList(), world.getName()); @@ -193,7 +193,7 @@ import java.util.UUID; */ @Deprecated public static void set(final Plot plot) { - PlotMain.updatePlot(plot); + PlotSquared.updatePlot(plot); } /** @@ -204,7 +204,7 @@ import java.util.UUID; * @return */ public static Set getPlayerPlots(final World world, final Player plr) { - final Set p = PlotMain.getPlots(world, plr); + final Set p = PlotSquared.getPlots(world, plr); if (p == null) { return new HashSet<>(); } @@ -221,7 +221,7 @@ import java.util.UUID; public static int getPlayerPlotCount(final World world, final Player plr) { final UUID uuid = UUIDHandler.getUUID(plr); int count = 0; - for (final Plot plot : PlotMain.getPlots(world).values()) { + for (final Plot plot : PlotSquared.getPlots(world).values()) { if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { count++; } @@ -237,17 +237,17 @@ import java.util.UUID; * @return */ public static int getAllowedPlots(final Player p) { - return PlotMain.MAIN_IMP.(p, "plots.plot", Settings.MAX_PLOTS); + return PlotSquared.MAIN_IMP.(p, "plots.plot", Settings.MAX_PLOTS); } /** - * @return PlotMain.getPlots(); + * @return PlotSquared.getPlots(); * * @deprecated */ @Deprecated public static Set getPlots() { - return PlotMain.getPlots(); + return PlotSquared.getPlots(); } /** @@ -286,7 +286,7 @@ import java.util.UUID; public static boolean sendMessage(final Player plr, final String msg, final boolean prefix) { if ((msg.length() > 0) && !msg.equals("")) { if (plr == null) { - PlotMain.MAIN_IMP.sendConsoleSenderMessage(C.PREFIX.s() + msg); + PlotSquared.MAIN_IMP.sendConsoleSenderMessage(C.PREFIX.s() + msg); } else { sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); } @@ -313,7 +313,7 @@ import java.util.UUID; } } if (plr == null) { - PlotMain.sendConsoleSenderMessage(msg); + PlotSquared.sendConsoleSenderMessage(msg); } else { sendMessage(plr, msg, c.usePrefix()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java index 9029e156d..ee1005597 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -41,7 +41,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.listeners.PlotListener; @@ -70,21 +70,21 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; public static int getBorder(String worldname) { if (worldBorder.containsKey(worldname)) { - PlotWorld plotworld = PlotMain.getWorldSettings(worldname); + PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); return worldBorder.get(worldname) + 16; } return Integer.MAX_VALUE; } public static void setupBorder(String world) { - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (!plotworld.WORLD_BORDER) { return; } if (!worldBorder.containsKey(world)) { worldBorder.put(world,0); } - for (Plot plot : PlotMain.getPlots(world).values()) { + for (Plot plot : PlotSquared.getPlots(world).values()) { updateWorldBorder(plot); } } @@ -136,11 +136,11 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - if (PlotMain.useEconomy && plotworld.USE_ECONOMY) { + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + if (PlotSquared.useEconomy && plotworld.USE_ECONOMY) { final double cost = plotIds.size() * plotworld.MERGE_PRICE; if (cost > 0d) { - final Economy economy = PlotMain.economy; + final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < cost) { PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost); return false; @@ -171,8 +171,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; final PlotId pos1 = plotIds.get(0); final PlotId pos2 = plotIds.get(plotIds.size() - 1); - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); manager.startPlotMerge(plotworld, plotIds); @@ -189,7 +189,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; final PlotId id = new PlotId(x, y); - final Plot plot = PlotMain.getPlots(world).get(id); + final Plot plot = PlotSquared.getPlots(world).get(id); Plot plot2 = null; @@ -208,7 +208,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; } if (!plot.settings.getMerged(1)) { changed = true; - plot2 = PlotMain.getPlots(world).get(new PlotId(x + 1, y)); + plot2 = PlotSquared.getPlots(world).get(new PlotId(x + 1, y)); mergePlot(world, plot, plot2, removeRoads); plot.settings.setMerged(1, true); plot2.settings.setMerged(3, true); @@ -217,7 +217,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; if (ly) { if (!plot.settings.getMerged(2)) { changed = true; - plot2 = PlotMain.getPlots(world).get(new PlotId(x, y + 1)); + plot2 = PlotSquared.getPlots(world).get(new PlotId(x, y + 1)); mergePlot(world, plot, plot2, removeRoads); plot.settings.setMerged(2, true); plot2.settings.setMerged(0, true); @@ -229,7 +229,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { final PlotId id = new PlotId(x, y); - final Plot plot = PlotMain.getPlots(world).get(id); + final Plot plot = PlotSquared.getPlots(world).get(id); DBFunc.setMerged(world, plot, plot.settings.getMerged()); } @@ -252,8 +252,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, boolean removeRoads) { - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (lesserPlot.id.x.equals(greaterPlot.id.x)) { if (!lesserPlot.settings.getMerged(2)) { @@ -278,8 +278,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; public static void removeSign(final Plot p) { String world = p.world; - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final Location loc = manager.getSignLoc(plotworld, p); BlockManager.setBlocks(world, new int[] { loc.getX()}, new int[] { loc.getY()}, new int[] { loc.getZ()}, new int[] { 0 }, new byte[] { 0 }); } @@ -289,8 +289,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; if (name == null) { name = "unknown"; } - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final Location loc = manager.getSignLoc(plotworld, p); final Block bs = loc.getBlock(); @@ -387,7 +387,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; final PlotId id_min = plots.get(0); final PlotId id_max = plots.get(plots.size() - 1); for (final PlotId myid : plots) { - final Plot myplot = PlotMain.getPlots(world).get(myid); + final Plot myplot = PlotSquared.getPlots(world).get(myid); if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(player)))) { return false; } @@ -408,8 +408,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; return; } String world = plot.world; - PlotManager manager = PlotMain.getPlotManager(world); - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotManager manager = PlotSquared.getPlotManager(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id); Location top = manager.getPlotTopLocAbs(plotworld, plot.id); int border = worldBorder.get(plot.world); @@ -431,7 +431,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; World w = player.getWorld(); UUID uuid = UUIDHandler.getUUID(player); Plot p = createPlotAbs(uuid, plot); - final PlotWorld plotworld = PlotMain.getWorldSettings(w); + final PlotWorld plotworld = PlotSquared.getWorldSettings(w); if (plotworld.AUTO_MERGE) { autoMerge(w, p, player); } @@ -444,7 +444,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; public static Plot createPlotAbs(final UUID uuid, final Plot plot) { final World w = plot.getWorld(); final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList(), new ArrayList(), w.getName()); - PlotMain.updatePlot(p); + PlotSquared.updatePlot(p); DBFunc.createPlotAndSettings(p); return p; } @@ -461,7 +461,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; public static int getTileEntities(final String world) { - PlotMain.getWorldSettings(world); + PlotSquared.getWorldSettings(world); int x = 0; for (final Chunk chunk : world.getLoadedChunks()) { x += chunk.getTileEntities().length; @@ -502,7 +502,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - PlotMain.teleportPlayer(player, entity.getLocation(), plot); + PlotSquared.teleportPlayer(player, entity.getLocation(), plot); PlotListener.plotExit(player, plot); } else { entity.remove(); @@ -524,7 +524,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return; } - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotManager manager = PlotSquared.getPlotManager(world); final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); @@ -536,7 +536,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; final long start = System.currentTimeMillis(); final Location location = PlotHelper.getPlotHomeDefault(plot); - PlotWorld plotworld = PlotMain.getWorldSettings(world); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); runners.put(plot, 1); if (plotworld.TERRAIN != 0) { final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); @@ -693,12 +693,12 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; Plot plot = getPlot(w, plotid); BlockLoc home = plot.settings.getPosition(); final Location bot = getPlotBottomLoc(w, plotid); - PlotManager manager = PlotMain.getPlotManager(w); + PlotManager manager = PlotSquared.getPlotManager(w); if (home == null || (home.x == 0 && home.z == 0)) { final Location top = getPlotTopLoc(w, plotid); final int x = ((top.getBlockX() - bot.getBlockX())/2) + bot.getBlockX(); final int z = ((top.getBlockZ() - bot.getBlockZ())/2) + bot.getBlockZ(); - final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotMain.getWorldSettings(w), plot).getBlockY()); + final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY()); return new Location(w, x, y, z); } else { @@ -787,8 +787,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static Location getPlotTopLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } @@ -803,8 +803,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static Location getPlotBottomLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); } @@ -832,12 +832,12 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static Location getPlotTopLoc(final String world, PlotId id) { - final Plot plot = PlotMain.getPlots(world).get(id); + final Plot plot = PlotSquared.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getTopPlot(world, plot).id; } - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } @@ -852,12 +852,12 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static Location getPlotBottomLoc(final String world, PlotId id) { - final Plot plot = PlotMain.getPlots(world).get(id); + final Plot plot = PlotSquared.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getBottomPlot(world, plot).id; } - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); } @@ -866,8 +866,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { final PlotId id = new PlotId(x, y); - if (PlotMain.getPlots(world).get(id) != null) { - if (PlotMain.getPlots(world).get(id).owner != null) { + if (PlotSquared.getPlots(world).get(id) != null) { + if (PlotSquared.getPlots(world).get(id).owner != null) { return false; } } @@ -899,11 +899,11 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; String worldname = world.getName(); for (PlotId id : selection) { DBFunc.movePlot(world.getName(), new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); - Plot plot = PlotMain.getPlots(worldname).get(id); - PlotMain.getPlots(worldname).remove(id); + Plot plot = PlotSquared.getPlots(worldname).get(id); + PlotSquared.getPlots(worldname).remove(id); plot.id.x += offset_x; plot.id.y += offset_y; - PlotMain.getPlots(worldname).put(plot.id, plot); + PlotSquared.getPlots(worldname).put(plot.id, plot); } ChunkManager.copyRegion(bot1, top, bot2, new Runnable() { @Override @@ -940,8 +940,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; if (id == null) { return null; } - if (PlotMain.getPlots(world).containsKey(id)) { - return PlotMain.getPlots(world).get(id); + if (PlotSquared.getPlots(world).containsKey(id)) { + return PlotSquared.getPlots(world).get(id); } return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), world.getName()); } @@ -958,8 +958,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; if (id == null) { return null; } - if (PlotMain.getPlots(loc.getWorld()).containsKey(id)) { - return PlotMain.getPlots(loc.getWorld()).get(id); + if (PlotSquared.getPlots(loc.getWorld()).containsKey(id)) { + return PlotSquared.getPlots(loc.getWorld()).get(id); } return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld().getName()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java index 3c14270de..3be409a39 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java @@ -21,7 +21,7 @@ package com.intellectualcrafters.plot.util; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; /** * Created 2014-09-29 for PlotSquared @@ -32,11 +32,11 @@ public class PlotSquaredException extends RuntimeException { public PlotSquaredException(final PlotError error, final String details) { super("PlotError >> " + error.getHeader() + ": " + details); - PlotMain.sendConsoleSenderMessage("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details); + PlotSquared.sendConsoleSenderMessage("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details); } public static enum PlotError { - PLOTMAIN_NULL("The PlotMain instance was null"), + PLOTMAIN_NULL("The PlotSquared instance was null"), MISSING_DEPENDENCY("Missing Dependency"); private final String errorHeader; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 020d2a2b8..4f1f39cd6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -47,7 +47,7 @@ import com.intellectualcrafters.jnbt.NBTOutputStream; import com.intellectualcrafters.jnbt.ShortTag; import com.intellectualcrafters.jnbt.StringTag; import com.intellectualcrafters.jnbt.Tag; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -69,7 +69,7 @@ public class SchematicHandler { */ public static boolean paste(final Location location, final Schematic schematic, final Plot plot, final int x_offset, final int z_offset) { if (schematic == null) { - PlotMain.sendConsoleSenderMessage("Schematic == null :|"); + PlotSquared.sendConsoleSenderMessage("Schematic == null :|"); return false; } try { @@ -170,16 +170,16 @@ public class SchematicHandler { */ public static Schematic getSchematic(final String name) { { - final File parent = new File(PlotMain.getMain().getDirectory() + File.separator + "schematics"); + final File parent = new File(PlotSquared.getMain().getDirectory() + File.separator + "schematics"); if (!parent.exists()) { if (!parent.mkdir()) { throw new RuntimeException("Could not create schematic parent directory"); } } } - final File file = new File(PlotMain.getMain().getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); + final File file = new File(PlotSquared.getMain().getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); if (!file.exists()) { - PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist"); + PlotSquared.sendConsoleSenderMessage(file.toString() + " doesn't exist"); return null; } @@ -191,7 +191,7 @@ public class SchematicHandler { return getSchematic(tag, file); } catch (final Exception e) { - PlotMain.sendConsoleSenderMessage(file.toString() + " is not in GZIP format"); + PlotSquared.sendConsoleSenderMessage(file.toString() + " is not in GZIP format"); return null; } } @@ -206,7 +206,7 @@ public class SchematicHandler { */ public static boolean save(final CompoundTag tag, final String path) { if (tag == null) { - PlotMain.sendConsoleSenderMessage("&cCannot save empty tag"); + PlotSquared.sendConsoleSenderMessage("&cCannot save empty tag"); return false; } try { @@ -233,7 +233,7 @@ public class SchematicHandler { * @return tag */ public static CompoundTag getCompoundTag(final World world, PlotId id) { - if (!PlotMain.getPlots(world).containsKey(id)) { + if (!PlotSquared.getPlots(world).containsKey(id)) { return null; } @@ -265,7 +265,7 @@ public class SchematicHandler { } } } catch (final Exception e) { - PlotMain.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at " + (i / 16) + ", " + (j / 16)); + PlotSquared.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at " + (i / 16) + ", " + (j / 16)); return null; } final int width = (pos2.getBlockX() - pos1.getBlockX()) + 1; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java index abbe37868..da5eff74c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -16,6 +16,8 @@ public abstract class TaskManager { public abstract void taskLater(final Runnable r, int delay); + public abstract void taskLaterAsync(final Runnable r, int delay); + public static void runTaskRepeat(final Runnable r, int interval) { if (r != null) PlotSquared.TASK.taskRepeat(r, interval); @@ -35,4 +37,9 @@ public abstract class TaskManager { if (r != null) PlotSquared.TASK.taskLater(r, delay); } + + public static void runTaskLaterAsync(final Runnable r, int delay) { + if (r != null) + PlotSquared.TASK.taskLaterAsync(r, delay); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index 3193e796f..b6c7cb8f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -12,7 +12,8 @@ import org.bukkit.entity.Player; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -80,7 +81,10 @@ public class UUIDHandler { } public static void cacheAll() { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&6Starting player data caching"); + if (CACHED) { + return; + } + PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching"); UUIDHandler.CACHED = true; HashSet worlds = new HashSet<>(); worlds.add(Bukkit.getWorlds().get(0).getName()); @@ -105,7 +109,7 @@ public class UUIDHandler { uuids.add(uuid); } catch (Exception e) { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "Invalid playerdata: "+current); + PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "Invalid playerdata: "+current); } } } @@ -132,7 +136,7 @@ public class UUIDHandler { add(name, uuid); } catch (Throwable e) { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&6Invalid playerdata: "+uuid.toString() + ".dat"); + PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&6Invalid playerdata: "+uuid.toString() + ".dat"); } } for (String name : names) { @@ -145,7 +149,7 @@ public class UUIDHandler { // add the Everyone '*' UUID add(new StringWrapper("*"), DBFunc.everyone); - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); + PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); } public static UUID getUUID(Player player) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java index 822008283..47cbf69c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java @@ -3,7 +3,7 @@ package com.intellectualcrafters.plot.util.bukkit; import java.util.HashSet; import com.intellectualcrafters.plot.BukkitMain; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.util.TaskManager; public class BukkitTaskManager extends TaskManager { diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java index 1728acfb0..d22c83fa9 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java @@ -3,8 +3,8 @@ package com.intellectualsites.translation.bukkit; import java.io.File; import org.bukkit.Material; -import org.bukkit.plugin.java.JavaPlugin; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualsites.translation.TranslationAsset; import com.intellectualsites.translation.TranslationLanguage; import com.intellectualsites.translation.TranslationManager; @@ -36,8 +36,8 @@ public class BukkitTranslation { * * @return parent folder */ - public static File getParent(final JavaPlugin plugin) { - return new File(plugin.getDataFolder() + File.separator + "translations"); + public static File getParent() { + return new File(PlotSquared.IMP.getDirectory() + File.separator + "translations"); } /** diff --git a/PlotSquared/src/main/resources/plugin.yml b/PlotSquared/src/main/resources/plugin.yml index b23508692..e0ba9b747 100644 --- a/PlotSquared/src/main/resources/plugin.yml +++ b/PlotSquared/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ${project.name} -main: com.intellectualcrafters.plot.PlotMain +main: com.intellectualcrafters.plot.PlotSquared version: ${project.version} load: STARTUP description: > @@ -9,7 +9,7 @@ softdepend: [WorldEdit, BarAPI, CameraAPI, Vault] database: false commands: plots: - description: PlotMain PlotSquared command. + description: PlotSquared PlotSquared command. aliases: [p,plot,ps,plotsquared,p2] permission: plots.use permission-message: "You are lacking the permission node 'plots.use'"