From 4a314144c67deaf8ccc16dfdc5bc9271f08b52f8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 14:24:05 +1100 Subject: [PATCH 001/124] Starting work on sponge --- .gitignore | 5 +- .../intellectualcrafters/plot/BukkitMain.java | 8 + .../intellectualcrafters/plot/PlotMain.java | 32 ++++ .../plot/commands/DebugRoadRegen.java | 8 + .../plot/commands/Template.java | 62 +++++++ .../plot/database/SQLManager.java | 45 +++++ .../plot/generator/AugmentedPopulator.java | 44 +++++ .../plot/generator/ClassicPlotManager.java | 23 +++ .../plot/generator/HybridPlotManager.java | 8 + .../plot/listeners/PlayerEvents.java | 25 +++ .../plot/object/Location.java | 80 +++++++++ .../plot/object/PlotManager.java | 37 ++++ .../plot/util/BlockManager.java | 64 +++++++ .../plot/util/BukkitUtil.java | 65 +++++++ .../plot/util/ChunkManager.java | 12 ++ .../plot/util/ClusterManager.java | 4 + .../plot/util/PlayerFunctions.java | 20 +++ .../plot/util/PlotHelper.java | 160 ++++++++++++++++++ .../plot/util/SetBlockFast.java | 11 ++ .../plot/util/SetBlockFast_1_8.java | 11 ++ .../plot/util/SetBlockManager.java | 16 ++ .../plot/util/SetBlockSlow.java | 10 ++ 22 files changed, 748 insertions(+), 2 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java diff --git a/.gitignore b/.gitignore index 9ead3a473..71dadcdda 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +PlotSquared/.project # Created by https://www.gitignore.io ### Intellij ### @@ -48,6 +49,8 @@ com_crashlytics_export_strings.xml ### Eclipse ### +.classpath +.project *.pydevproject .metadata .gradle @@ -93,8 +96,6 @@ local.properties # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* -.classpath -.project /target /plotsquared/target *.MF \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java new file mode 100644 index 000000000..957591066 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -0,0 +1,8 @@ +package com.intellectualcrafters.plot; + +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; + +public class BukkitMain extends JavaPlugin implements Listener { + +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 4d99365cd..2edef2195 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -53,6 +53,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import me.confuser.barapi.BarAPI; import net.milkbowl.vault.economy.Economy; +<<<<<<< Updated upstream import org.bukkit.*; import org.bukkit.Location; import org.bukkit.command.PluginCommand; @@ -68,6 +69,8 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +======= +>>>>>>> Stashed changes import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -84,7 +87,11 @@ import java.util.Map.Entry; * @author Citymonstret * @author Empire92 */ +<<<<<<< Updated upstream public class PlotMain extends JavaPlugin implements Listener { +======= +public class PlotMain { +>>>>>>> Stashed changes /** * Permission that allows for "everything" */ @@ -928,9 +935,13 @@ public class PlotMain extends JavaPlugin implements Listener { } public static void loadWorld(final String world, final ChunkGenerator generator) { +<<<<<<< Updated upstream System.out.print(2); if (getWorldSettings(world) != null) { System.out.print(3); +======= + if (getWorldSettings(world) != null) { +>>>>>>> Stashed changes return; } @@ -942,7 +953,10 @@ public class PlotMain extends JavaPlugin implements Listener { final String path = "worlds." + world; if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) { +<<<<<<< Updated upstream System.out.print(4); +======= +>>>>>>> Stashed changes plotGenerator = (PlotGenerator) generator; plotWorld = plotGenerator.getNewPlotWorld(world); plotManager = plotGenerator.getPlotManager(); @@ -966,9 +980,13 @@ public class PlotMain extends JavaPlugin implements Listener { addPlotWorld(world, plotWorld, plotManager); PlotHelper.setupBorder(world); } else { +<<<<<<< Updated upstream System.out.print(5 + " | " + (generator instanceof PlotGenerator)); if (!worlds.contains(world)) { System.out.print(6); +======= + if (!worlds.contains(world)) { +>>>>>>> Stashed changes return; } if (!LOADING_WORLD) { @@ -1598,18 +1616,32 @@ public class PlotMain extends JavaPlugin implements Listener { { if (checkVersion(1, 8, 0)) { try { +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager = new SetBlockSlow(); } catch (Throwable e) { e.printStackTrace(); AbstractSetBlock.setBlockManager = new SetBlockSlow(); +======= + SetBlockManager.setBlockManager = new SetBlockSlow(); + } + catch (Throwable e) { + e.printStackTrace(); + SetBlockManager.setBlockManager = new SetBlockSlow(); +>>>>>>> Stashed changes } } else { try { +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager = new SetBlockFast(); } catch (Throwable e) { AbstractSetBlock.setBlockManager = new SetBlockSlow(); +======= + SetBlockManager.setBlockManager = new SetBlockFast(); + } catch (Throwable e) { + SetBlockManager.setBlockManager = new SetBlockSlow(); +>>>>>>> Stashed changes } } try { 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 6cac063f6..099327e0a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -30,7 +30,11 @@ import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; +<<<<<<< Updated upstream import com.intellectualcrafters.plot.util.AbstractSetBlock; +======= +import com.intellectualcrafters.plot.util.SetBlockManager; +>>>>>>> Stashed changes import com.intellectualcrafters.plot.util.PlayerFunctions; public class DebugRoadRegen extends SubCommand { @@ -49,7 +53,11 @@ public class DebugRoadRegen extends SubCommand { Chunk chunk = player.getLocation().getChunk(); boolean result = manager.regenerateRoad(chunk); if (result) { +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.update(Arrays.asList(new Chunk[] {chunk})); +======= + SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] {chunk})); +>>>>>>> Stashed changes } PlayerFunctions.sendMessage(player, "&6Regenerating chunk: "+chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return true; 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 410535b17..7e4888cc5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.commands; +<<<<<<< Updated upstream import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; @@ -32,12 +33,53 @@ public class Template extends SubCommand { super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true); } +======= +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.GZIPOutputStream; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.PlayerFunctions; + +public class Template extends SubCommand { + + public Template() { + super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true); + } + +>>>>>>> Stashed changes @Override public boolean execute(final Player plr, final String... args) { if (args.length != 2) { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); return false; } +<<<<<<< Updated upstream +======= + World world = Bukkit.getWorld(args[1]); + PlotWorld plotworld = PlotMain.getWorldSettings(args[1]); + if (world == null || plotworld == null) { + PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); + return false; + } + switch (args[0].toLowerCase()) { + case "import": { + // TODO import template + PlayerFunctions.sendMessage(plr, "TODO"); + return true; + } + case "export": { + PlayerFunctions.sendMessage(plr, "TODO"); + } + } +>>>>>>> Stashed changes // TODO allow world settings (including schematics to be packed into a single file) @@ -45,4 +87,24 @@ public class Template extends SubCommand { return true; } +<<<<<<< Updated upstream +======= + + public void gzipIt(String output, String input) { + byte[] buffer = new byte[1024]; + try { + GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(output)); + FileInputStream in = new FileInputStream(input); + int len; + while ((len = in.read(buffer)) > 0) { + gzos.write(buffer, 0, len); + } + in.close(); + gzos.finish(); + gzos.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } +>>>>>>> Stashed changes } 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 12d7c865b..b196c60a4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -161,6 +161,10 @@ public class SQLManager implements AbstractDB { } stored.get(world).put(new PlotId(idx, idz), id); } +<<<<<<< Updated upstream +======= + result.close(); +>>>>>>> Stashed changes stmt.close(); } catch (final SQLException e) { e.printStackTrace(); @@ -482,6 +486,10 @@ public class SQLManager implements AbstractDB { while (r.next()) { id = r.getInt("id"); } +<<<<<<< Updated upstream +======= + r.close(); +>>>>>>> Stashed changes stmt.close(); return id; } catch (final SQLException e) { @@ -515,6 +523,10 @@ public class SQLManager implements AbstractDB { final Statement statement = this.connection.createStatement(); statement.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD `merged` int(11) DEFAULT NULL"); statement.executeBatch(); +<<<<<<< Updated upstream +======= + rs.close(); +>>>>>>> Stashed changes statement.close(); } } catch (final Exception e) { @@ -706,6 +718,10 @@ public class SQLManager implements AbstractDB { } } stmt.close(); +<<<<<<< Updated upstream +======= + r.close(); +>>>>>>> Stashed changes for (final Plot plot : plots.values()) { final String world = plot.world; if (!newplots.containsKey(world)) { @@ -951,6 +967,11 @@ public class SQLManager implements AbstractDB { } } purgeIds(world, ids); +<<<<<<< Updated upstream +======= + stmt.close(); + r.close(); +>>>>>>> Stashed changes } catch (SQLException e) { e.printStackTrace(); PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); @@ -1026,6 +1047,10 @@ public class SQLManager implements AbstractDB { h.put(var, val); } stmt.close(); +<<<<<<< Updated upstream +======= + r.close(); +>>>>>>> Stashed changes } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for plot: " + id); e.printStackTrace(); @@ -1087,6 +1112,10 @@ public class SQLManager implements AbstractDB { comments.add(comment); } statement.close(); +<<<<<<< Updated upstream +======= + set.close(); +>>>>>>> Stashed changes } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch comment"); e.printStackTrace(); @@ -1283,6 +1312,10 @@ public class SQLManager implements AbstractDB { rating = set.getDouble("rating"); } statement.close(); +<<<<<<< Updated upstream +======= + set.close(); +>>>>>>> Stashed changes return rating; } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString()); @@ -1338,6 +1371,10 @@ public class SQLManager implements AbstractDB { c_id = r.getInt("id"); } stmt.close(); +<<<<<<< Updated upstream +======= + r.close(); +>>>>>>> Stashed changes return c_id; } catch (final SQLException e) { e.printStackTrace(); @@ -1516,6 +1553,10 @@ public class SQLManager implements AbstractDB { } } stmt.close(); +<<<<<<< Updated upstream +======= + r.close(); +>>>>>>> Stashed changes for (final PlotCluster c : clusters.values()) { final String world = c.world; if (!newClusters.containsKey(world)) { @@ -1745,6 +1786,10 @@ public class SQLManager implements AbstractDB { h.put(var, val); } stmt.close(); +<<<<<<< Updated upstream +======= + r.close(); +>>>>>>> Stashed changes } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for cluster: " + id); e.printStackTrace(); 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 c6a4627a6..5e67198ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -5,19 +5,30 @@ import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.Chunk; +<<<<<<< Updated upstream import org.bukkit.Location; +======= +>>>>>>> Stashed changes import org.bukkit.World; import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.object.BlockWrapper; +<<<<<<< Updated upstream +======= +import com.intellectualcrafters.plot.object.Location; +>>>>>>> Stashed changes 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.object.RegionWrapper; +<<<<<<< Updated upstream import com.intellectualcrafters.plot.util.AbstractSetBlock; +======= +import com.intellectualcrafters.plot.util.SetBlockManager; +>>>>>>> Stashed changes import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.TaskManager; @@ -38,7 +49,11 @@ public class AugmentedPopulator extends BlockPopulator { private final int tx; private final int tz; +<<<<<<< Updated upstream public BlockWrapper getBlock(int X, int Z, int i, int j, short[][] r, boolean c) { +======= + public BlockWrapper get(int X, int Z, int i, int j, short[][] r, boolean c) { +>>>>>>> Stashed changes int y = (i << 4) + (j >> 8); int a = (j - ((y & 0xF) << 8)); int z = (a >> 4); @@ -66,11 +81,19 @@ public class AugmentedPopulator extends BlockPopulator { Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); Location tl = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1); +<<<<<<< Updated upstream this.bx = bl.getBlockX(); this.bz = bl.getBlockZ(); this.tx = tl.getBlockX(); this.tz = tl.getBlockZ(); +======= + this.bx = bl.getX(); + this.bz = bl.getZ(); + + this.tx = tl.getX(); + this.tz = tl.getZ(); +>>>>>>> Stashed changes } else { this.bx = Integer.MIN_VALUE; @@ -118,8 +141,13 @@ public class AugmentedPopulator extends BlockPopulator { check = false; } if (plotworld.TERRAIN == 2) { +<<<<<<< Updated upstream PlotId plot1 = manager.getPlotIdAbs(plotworld, new Location(world, x, 0, z)); PlotId plot2 = manager.getPlotIdAbs(plotworld, new Location(world, x2, 0, z2)); +======= + PlotId plot1 = manager.getPlotIdAbs(plotworld, x, 0, z); + PlotId plot2 = manager.getPlotIdAbs(plotworld, x2, 0, z2); +>>>>>>> Stashed changes if (plot1 != null && plot2 != null && plot1.equals(plot2)) { return; } @@ -132,7 +160,11 @@ public class AugmentedPopulator extends BlockPopulator { public void run() { populateBiome(world, x, z); chunk.unload(true, true); +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +======= + SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +>>>>>>> Stashed changes } }, 20); } @@ -149,7 +181,11 @@ public class AugmentedPopulator extends BlockPopulator { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); chunk.unload(true, true); +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +======= + SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +>>>>>>> Stashed changes } }, 40 + rand.nextInt(40)); } @@ -170,7 +206,11 @@ public class AugmentedPopulator extends BlockPopulator { int length = result[0].length; for(int i = 0; i < result.length; i++) { for(int j = 0; j < length; j++) { +<<<<<<< Updated upstream BlockWrapper blockInfo = getBlock(x, z, i, j, result, check); +======= + BlockWrapper blockInfo = get(x, z, i, j, result, check); +>>>>>>> Stashed changes if (blockInfo == null) { continue; } @@ -182,7 +222,11 @@ public class AugmentedPopulator extends BlockPopulator { continue; } } +<<<<<<< Updated upstream else if (manager.getPlotIdAbs(plotworld, new Location(world, xx, 0, zz)) != null) { +======= + else if (manager.getPlotIdAbs(plotworld, xx, 0, zz) != null) { +>>>>>>> Stashed changes continue; } } 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 4309b6234..7f966791a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -48,7 +48,11 @@ public abstract class ClassicPlotManager extends SquarePlotManager { public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; +<<<<<<< Updated upstream final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1); +======= + final Location pos1 = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); +>>>>>>> Stashed changes final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid); PlotHelper.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks); return true; @@ -59,7 +63,11 @@ public abstract class ClassicPlotManager extends SquarePlotManager { if (dpw.ROAD_WIDTH == 0) { return false; } +<<<<<<< Updated upstream final Location bottom = PlotHelper.getPlotBottomLoc(w, plotid); +======= + final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); +>>>>>>> Stashed changes final Location top = PlotHelper.getPlotTopLoc(w, plotid); int x, z; @@ -97,7 +105,11 @@ public abstract class ClassicPlotManager extends SquarePlotManager { if (dpw.ROAD_WIDTH == 0) { return false; } +<<<<<<< Updated upstream final Location bottom = PlotHelper.getPlotBottomLoc(w, plotid); +======= + final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); +>>>>>>> Stashed changes final Location top = PlotHelper.getPlotTopLoc(w, plotid); int x, z; @@ -318,7 +330,11 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } @Override +<<<<<<< Updated upstream public String[] getPlotComponents(World world, PlotWorld plotworld, PlotId plotid) { +======= + public String[] getPlotComponents(PlotWorld plotworld, PlotId plotid) { +>>>>>>> Stashed changes return new String[] { "floor", "wall", @@ -330,8 +346,15 @@ public abstract class ClassicPlotManager extends SquarePlotManager { * Remove sign for a plot */ @Override +<<<<<<< Updated upstream public Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1); +======= + public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) { + final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; + Location bot = PlotHelper.getPlotBottomLoc(plotworld.worldname, plot.id); + return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getBlockX(), dpw.ROAD_HEIGHT + 1, bot.getBlockZ() - 1); +>>>>>>> Stashed changes } } 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 187ae8c37..d81ada939 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -41,7 +41,11 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; +<<<<<<< Updated upstream import com.intellectualcrafters.plot.util.AbstractSetBlock; +======= +import com.intellectualcrafters.plot.util.SetBlockManager; +>>>>>>> Stashed changes import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; @@ -196,7 +200,11 @@ import com.intellectualcrafters.plot.util.UUIDHandler; regenerateRoad(chunk); } } +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.update(chunks2); +======= + SetBlockManager.setBlockManager.update(chunks2); +>>>>>>> Stashed changes } public boolean scheduleRoadUpdate(final World world) { 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 5715d2821..0da53c8e9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -160,8 +160,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location f = event.getFrom(); final Location t = event.getTo(); final Location q = new Location(t.getWorld(), t.getBlockX(), 0, t.getZ()); +<<<<<<< Updated upstream if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { +======= + if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { + System.out.print("========================="); + System.out.print("4. " + f); +>>>>>>> Stashed changes if (Settings.TELEPORT_DELAY != 0 && TaskManager.TELEPORT_QUEUE.size() > 0) { String name = player.getName(); if (TaskManager.TELEPORT_QUEUE.contains(name)) { @@ -192,6 +198,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi passed = true; } if (passed) { +<<<<<<< Updated upstream +======= + q.setY(t.getBlockY()); +>>>>>>> Stashed changes event.setTo(q); PlayerFunctions.sendMessage(player, C.BORDER); return; @@ -199,6 +209,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = getCurrentPlot(q); if (plot != null) { +<<<<<<< Updated upstream if (!plot.equals(getCurrentPlot(f))) { if (plot.deny_entry(player)) { if (!PlotMain.hasPermission(player, "plots.admin.entry.denied")) { @@ -207,6 +218,20 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } +======= + if (plot.deny_entry(player)) { + if (!PlotMain.hasPermission(player, "plots.admin.entry.denied")) { + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); + System.out.print("DENY ENTRY"); + System.out.print("5. " + f); + event.setCancelled(true); + return; + } + } + System.out.print("6. " + f); + if (!plot.equals(getCurrentPlot(f))) { + System.out.print("7. " + f); +>>>>>>> Stashed changes plotEntry(player, plot); } } else if (leftPlot(f, event.getTo())) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java index 4f5540496..f61e5f042 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -11,13 +11,21 @@ import java.lang.reflect.Method; */ public class Location implements Cloneable, Comparable { +<<<<<<< Updated upstream private double x, y, z; +======= + private int x, y, z; +>>>>>>> Stashed changes private float yaw, pitch; private String world; private boolean built; private Object o; +<<<<<<< Updated upstream public Location(final String world, final double x, final double y, final double z, final float yaw, final float pitch) { +======= + public Location(final String world, final int x, final int y, final int z, final float yaw, final float pitch) { +>>>>>>> Stashed changes this.world = world; this.x = x; this.y = y; @@ -29,6 +37,7 @@ public class Location implements Cloneable, Comparable { } public Location() { +<<<<<<< Updated upstream this("", 0d, 0d, 0d, 0f, 0f); } @@ -41,24 +50,54 @@ public class Location implements Cloneable, Comparable { } public void setX(final double x) { +======= + this("", 0, 0, 0, 0, 0); + } + + public Location(final String world, final int x, final int y, final int z) { + this(world, x, y, z, 0f, 0f); + } + + public int getX() { + return this.x; + } + + public void setX(final int x) { +>>>>>>> Stashed changes this.x = x; this.built = false; } +<<<<<<< Updated upstream public double getY() { return this.y; } public void setY(final double y) { +======= + public int getY() { + return this.y; + } + + public void setY(final int y) { +>>>>>>> Stashed changes this.y = y; this.built = false; } +<<<<<<< Updated upstream public double getZ() { return this.z; } public void setZ(final double z) { +======= + public int getZ() { + return this.z; + } + + public void setZ(final int z) { +>>>>>>> Stashed changes this.z = z; this.built = false; } @@ -90,11 +129,19 @@ public class Location implements Cloneable, Comparable { this.built = false; } +<<<<<<< Updated upstream public void add(double x, double y, double z) { +======= + public Location add(int x, int y, int z) { +>>>>>>> Stashed changes this.x += x; this.y += y; this.z += z; this.built = false; +<<<<<<< Updated upstream +======= + return this; +>>>>>>> Stashed changes } public double getEuclideanDistanceSquared(final Location l2) { @@ -128,7 +175,11 @@ public class Location implements Cloneable, Comparable { y <= max.getY() && z >= min.getX() && z < max.getZ(); } +<<<<<<< Updated upstream public void lookTowards(double x, double y) { +======= + public void lookTowards(int x, int y) { +>>>>>>> Stashed changes double l = this.x - x; double w = this.z - z; double c = Math.sqrt(l * l + w * w); @@ -140,17 +191,34 @@ public class Location implements Cloneable, Comparable { this.built = false; } +<<<<<<< Updated upstream public void subtract(double x, double y, double z) { +======= + public Location subtract(int x, int y, int z) { +>>>>>>> Stashed changes this.x -= x; this.y -= y; this.z -= z; this.built = false; +<<<<<<< Updated upstream +======= + return this; +>>>>>>> Stashed changes } @Override public boolean equals(Object o) { +<<<<<<< Updated upstream if (!(o instanceof Location)) return false; +======= + if (o == null) { + return false; + } + if (!(o instanceof Location)) { + return false; + } +>>>>>>> Stashed changes Location l = (Location) o; return x == l.getX() && y == l.getY() && z == l.getZ() && world.equals(l.getWorld()) && @@ -183,6 +251,12 @@ public class Location implements Cloneable, Comparable { } } +<<<<<<< Updated upstream +======= + /** + * Please use utility class as this is not efficient + */ +>>>>>>> Stashed changes public Object toBukkitLocation() { if (built) { return o; @@ -196,6 +270,12 @@ public class Location implements Cloneable, Comparable { } } +<<<<<<< Updated upstream +======= + /** + * Please use utility class as this is not efficient + */ +>>>>>>> Stashed changes public void teleport(final Object o) throws Exception { if (o.getClass().getName().contains("org.bukkit.entity")) { Method m = o.getClass().getMethod("teleport", Class.forName("org.bukkit.Location")); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 71c71dba5..48907692b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -23,7 +23,10 @@ package com.intellectualcrafters.plot.object; import java.util.ArrayList; +<<<<<<< Updated upstream import org.bukkit.Location; +======= +>>>>>>> Stashed changes import org.bukkit.World; import org.bukkit.block.Biome; @@ -34,9 +37,15 @@ public abstract class PlotManager { * plots) */ +<<<<<<< Updated upstream public abstract PlotId getPlotIdAbs(final PlotWorld plotworld, final Location loc); public abstract PlotId getPlotId(final PlotWorld plotworld, final Location loc); +======= + public abstract PlotId getPlotIdAbs(final PlotWorld plotworld, final int x, final int y, final int z); + + public abstract PlotId getPlotId(final PlotWorld plotworld, final int x, final int y, final int z); +>>>>>>> Stashed changes // If you have a circular plot, just return the corner if it were a square public abstract Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid); @@ -46,6 +55,7 @@ public abstract class PlotManager { /* * Plot clearing (return false if you do not support some method) */ +<<<<<<< Updated upstream public abstract boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone); public abstract boolean claimPlot(final World world, final PlotWorld plotworld, final Plot plot); @@ -53,17 +63,34 @@ public abstract class PlotManager { public abstract boolean unclaimPlot(final World world, final PlotWorld plotworld, final Plot plot); public abstract Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot); +======= + public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone); + + public abstract boolean claimPlot(final PlotWorld plotworld, final Plot plot); + + public abstract boolean unclaimPlot(final PlotWorld plotworld, final Plot plot); + + public abstract Location getSignLoc(final PlotWorld plotworld, final Plot plot); +>>>>>>> Stashed changes /* * Plot set functions (return false if you do not support the specific set * method) */ +<<<<<<< Updated upstream public abstract String[] getPlotComponents(final World world, final PlotWorld plotworld, final PlotId plotid); public abstract boolean setComponent(final World world, final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks); public abstract boolean setBiome(final World world, final Plot plot, final Biome biome); +======= + public abstract String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid); + + public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks); + + public abstract boolean setBiome(final Plot plot, final Biome biome); +>>>>>>> Stashed changes /* * PLOT MERGING (return false if your generator does not support plot @@ -81,6 +108,7 @@ public abstract class PlotManager { public abstract boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot); +<<<<<<< Updated upstream public abstract boolean startPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds); public abstract boolean startPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds); @@ -88,5 +116,14 @@ public abstract class PlotManager { public abstract boolean finishPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds); public abstract boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds); +======= + public abstract boolean startPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); + + public abstract boolean startPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); + + public abstract boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); + + public abstract boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); +>>>>>>> Stashed changes } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java new file mode 100644 index 000000000..3ca64496b --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -0,0 +1,64 @@ +package com.intellectualcrafters.plot.util; + +import org.bukkit.World; + +import com.intellectualcrafters.plot.object.PlotBlock; + +public abstract class BlockManager { + + private static BlockManager manager = new BukkitUtil(); + + private static long state = 1; + + public static long nextLong() { + final long a = state; + state = xorShift64(a); + return a; + } + + public static long xorShift64(long a) { + a ^= (a << 21); + a ^= (a >>> 35); + a ^= (a << 4); + return a; + } + + public static int random(final int n) { + if (n == 1) { + return 0; + } + final long r = ((nextLong() >>> 32) * n) >> 32; + return (int) r; + } + + public abstract void functionSetBlock(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data); + + public abstract void setSign(String worldname, int x, int y, int z); + + + public static void setBlocks(String worldname, int[] x, int y[], int z[], PlotBlock[][] blocks) { + int[] id = new int[blocks.length]; + byte[] data = new byte[blocks.length]; + for (int i = 0; i < blocks.length; i++) { + PlotBlock[] current = blocks[i]; + int n = random(current.length); + id[i] = current[n].id; + data[i] = current[n].data; + } + setBlocks(worldname, x, y, z, id, data); + } + + public static void setBlocks(String worldname, int[] x, int y[], int z[], PlotBlock[] blocks) { + int[] id = new int[blocks.length]; + byte[] data = new byte[blocks.length]; + for (int i = 0; i < blocks.length; i++) { + PlotBlock current = blocks[i]; + id[i] = current.id; + data[i] = current.data; + } + setBlocks(worldname, x, y, z, id, data); + } + + public static void setBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) { + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java new file mode 100644 index 000000000..0a865b5e7 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java @@ -0,0 +1,65 @@ +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 12ae3cdc9..453590190 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -229,13 +229,21 @@ public class ChunkManager { Block block = world.getBlockAt(x, y, z); int id = block.getTypeId(); byte data = block.getData(); +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.set(world, x + relX, y, z + relZ, id, data); +======= + SetBlockManager.setBlockManager.set(world, x + relX, y, z + relZ, id, data); +>>>>>>> Stashed changes } } mx.increment(); if (x == ex) { // done! restoreBlocks(world, relX, relZ); +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.update(chunks); +======= + SetBlockManager.setBlockManager.update(chunks); +>>>>>>> Stashed changes for (Chunk chunk : chunks) { chunk.unload(true, true); } @@ -351,7 +359,11 @@ public class ChunkManager { restoreEntities(world, 0, 0); } chunk.unload(true, true); +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +======= + SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +>>>>>>> Stashed changes } CURRENT_PLOT_CLEAR = null; } 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 374ea83ea..0d5a5835f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -288,7 +288,11 @@ public class ClusterManager { @Override public void run() { if (populator == null || plotworld.TYPE == 0) { +<<<<<<< Updated upstream AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +======= + SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); +>>>>>>> Stashed changes world.regenerateChunk(chunk.getX(), chunk.getZ()); chunk.unload(true, true); } 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 8fdce0acb..b8fc3d8da 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -65,7 +65,11 @@ import java.util.UUID; return myplots; } +<<<<<<< Updated upstream public static ArrayList getMaxPlotSelectionIds(final World world, PlotId pos1, PlotId pos2) { +======= + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { +>>>>>>> Stashed changes final Plot plot1 = PlotMain.getPlots(world).get(pos1); final Plot plot2 = PlotMain.getPlots(world).get(pos2); @@ -87,7 +91,11 @@ import java.util.UUID; return myplots; } +<<<<<<< Updated upstream public static Plot getBottomPlot(final World world, final Plot plot) { +======= + public static Plot getBottomPlot(final String world, final Plot plot) { +>>>>>>> Stashed changes if (plot.settings.getMerged(0)) { final Plot p = PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)); if (p == null) { @@ -105,7 +113,11 @@ import java.util.UUID; return plot; } +<<<<<<< Updated upstream public static Plot getTopPlot(final World world, final Plot plot) { +======= + public static Plot getTopPlot(final String world, final Plot plot) { +>>>>>>> Stashed changes if (plot.settings.getMerged(2)) { return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); } @@ -129,7 +141,11 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotMain.getWorldSettings(world); +<<<<<<< Updated upstream return manager.getPlotIdAbs(plotworld, loc); +======= + return manager.getPlotIdAbs(plotworld, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); +>>>>>>> Stashed changes } /** @@ -146,7 +162,11 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotMain.getWorldSettings(world); +<<<<<<< Updated upstream PlotId id = manager.getPlotId(plotworld, loc); +======= + PlotId id = manager.getPlotId(plotworld, loc.getBlockX(),loc.getBlockY(), loc.getBlockZ()); +>>>>>>> Stashed changes if (id!=null && plotworld.TYPE == 2) { if (ClusterManager.getCluster(world, id) == null) { return null; 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 7d354657c..596ab8030 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -31,7 +31,10 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.Chunk; +<<<<<<< Updated upstream import org.bukkit.Location; +======= +>>>>>>> Stashed changes import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.World; @@ -47,6 +50,10 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; +<<<<<<< Updated upstream +======= +import com.intellectualcrafters.plot.object.Location; +>>>>>>> Stashed changes import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; @@ -133,7 +140,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ +<<<<<<< Updated upstream public static boolean mergePlots(final Player plr, final World world, final ArrayList plotIds) { +======= + public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { +>>>>>>> Stashed changes final PlotWorld plotworld = PlotMain.getWorldSettings(world); if (PlotMain.useEconomy && plotworld.USE_ECONOMY) { final double cost = plotIds.size() * plotworld.MERGE_PRICE; @@ -161,7 +172,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return boolean (success) */ +<<<<<<< Updated upstream public static boolean mergePlots(final World world, final ArrayList plotIds, boolean removeRoads) { +======= + public static boolean mergePlots(final String world, final ArrayList plotIds, boolean removeRoads) { +>>>>>>> Stashed changes if (plotIds.size() < 2) { return false; } @@ -171,7 +186,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; final PlotManager manager = PlotMain.getPlotManager(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world); +<<<<<<< Updated upstream manager.startPlotMerge(world, plotworld, plotIds); +======= + manager.startPlotMerge(plotworld, plotIds); +>>>>>>> Stashed changes boolean result = false; @@ -190,7 +209,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; Plot plot2 = null; if (removeRoads) { +<<<<<<< Updated upstream removeSign(world, plot); +======= + removeSign(plot); +>>>>>>> Stashed changes } if (lx) { if (ly) { @@ -225,12 +248,20 @@ import com.intellectualcrafters.plot.object.PlotWorld; for (int y = pos1.y; y <= pos2.y; y++) { final PlotId id = new PlotId(x, y); final Plot plot = PlotMain.getPlots(world).get(id); +<<<<<<< Updated upstream DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged()); +======= + DBFunc.setMerged(world, plot, plot.settings.getMerged()); +>>>>>>> Stashed changes } } +<<<<<<< Updated upstream manager.finishPlotMerge(world, plotworld, plotIds); +======= + manager.finishPlotMerge(plotworld, plotIds); +>>>>>>> Stashed changes return result; } @@ -243,7 +274,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param lesserPlot * @param greaterPlot */ +<<<<<<< Updated upstream public static void mergePlot(final World world, final Plot lesserPlot, final Plot greaterPlot, boolean removeRoads) { +======= + public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, boolean removeRoads) { +>>>>>>> Stashed changes final PlotManager manager = PlotMain.getPlotManager(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world); @@ -265,6 +300,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } } +<<<<<<< Updated upstream /* * Random number gen section @@ -310,12 +346,30 @@ import com.intellectualcrafters.plot.object.PlotWorld; @SuppressWarnings("deprecation") public static void setSign(final World world, String name, final Plot p) { +======= + + + + public static void removeSign(final Plot p) { + String world = p.world; + final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotMain.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 }); + } + + public static void setSign(String name, final Plot p) { +>>>>>>> Stashed changes if (name == null) { name = "unknown"; } final PlotManager manager = PlotMain.getPlotManager(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world); +<<<<<<< Updated upstream final Location loc = manager.getSignLoc(world, plotworld, p); +======= + final Location loc = manager.getSignLoc(plotworld, p); +>>>>>>> Stashed changes final Block bs = loc.getBlock(); bs.setType(Material.AIR); bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); @@ -346,6 +400,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; return string; } +<<<<<<< Updated upstream public static boolean setBlock(World world, int x, int y, int z, int id, byte data) { try { return AbstractSetBlock.setBlockManager.set(world, x, y, z, id, data); @@ -381,6 +436,9 @@ import com.intellectualcrafters.plot.object.PlotWorld; } public static void autoMerge(final World world, final Plot plot, final Player player) { +======= + public static void autoMerge(final String world, final Plot plot, final Player player) { +>>>>>>> Stashed changes if (plot == null) { return; } @@ -438,7 +496,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; update(player.getLocation()); } +<<<<<<< Updated upstream private static boolean ownsPlots(final World world, final ArrayList plots, final Player player, final int dir) { +======= + private static boolean ownsPlots(final String world, final ArrayList plots, final Player player, final int dir) { +>>>>>>> Stashed changes final PlotId id_min = plots.get(0); final PlotId id_max = plots.get(plots.size() - 1); for (final PlotId myid : plots) { @@ -504,16 +566,28 @@ import com.intellectualcrafters.plot.object.PlotWorld; return p; } +<<<<<<< Updated upstream public static int getLoadedChunks(final World world) { return world.getLoadedChunks().length; } public static int getEntities(final World world) { +======= + public static int getLoadedChunks(final String world) { + return world.getLoadedChunks().length; + } + + public static int getEntities(final String world) { +>>>>>>> Stashed changes return world.getEntities().size(); } +<<<<<<< Updated upstream public static int getTileEntities(final World world) { +======= + public static int getTileEntities(final String world) { +>>>>>>> Stashed changes PlotMain.getWorldSettings(world); int x = 0; for (final Chunk chunk : world.getLoadedChunks()) { @@ -522,7 +596,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; return x; } +<<<<<<< Updated upstream public static double getWorldFolderSize(final World world) { +======= + public static double getWorldFolderSize(final String world) { +>>>>>>> Stashed changes // long size = FileUtil.sizeOfDirectory(world.getWorldFolder()); final File folder = world.getWorldFolder(); final long size = folder.length(); @@ -545,7 +623,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; return new short[]{Short.parseShort(block), 0}; } +<<<<<<< Updated upstream public static void clearAllEntities(final World world, final Plot plot, final boolean tile) { +======= + public static void clearAllEntities(final String world, final Plot plot, final boolean tile) { +>>>>>>> Stashed changes final List entities = world.getEntities(); for (final Entity entity : entities) { @@ -569,7 +651,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param plot * @param isDelete */ +<<<<<<< Updated upstream public static void clear(final Player player, final World world, final Plot plot, final boolean isDelete) { +======= + public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { +>>>>>>> Stashed changes if (runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return; @@ -635,7 +721,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); +<<<<<<< Updated upstream final World world; +======= + final String world; +>>>>>>> Stashed changes world = requester.getWorld(); clearAllEntities(world, plot, false); @@ -643,7 +733,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; removeSign(world, plot); } +<<<<<<< Updated upstream public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) { +======= + public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { +>>>>>>> Stashed changes for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { @@ -656,7 +750,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } +<<<<<<< Updated upstream public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { +======= + public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { +>>>>>>> Stashed changes if (blocks.length == 1) { setCuboid(world, pos1, pos2, blocks[0]); return; @@ -675,7 +773,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } +<<<<<<< Updated upstream public static void setSimpleCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) { +======= + public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { +>>>>>>> Stashed changes for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { @@ -688,7 +790,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } +<<<<<<< Updated upstream public static void setBiome(final World world, final Plot plot, final Biome b) { +======= + public static void setBiome(final String world, final Plot plot, final Biome b) { +>>>>>>> Stashed changes final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); final int topX = getPlotTopLoc(world, plot.id).getBlockX() + 1; final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ(); @@ -714,7 +820,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } +<<<<<<< Updated upstream public static int getHeighestBlock(final World world, final int x, final int z) { +======= + public static int getHeighestBlock(final String world, final int x, final int z) { +>>>>>>> Stashed changes boolean safe = false; int id; for (int i = 1; i < world.getMaxHeight(); i++) { @@ -788,7 +898,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param world World in which the plot is located * @param plot Plot Object */ +<<<<<<< Updated upstream public static void refreshPlotChunks(final World world, final Plot plot) { +======= + public static void refreshPlotChunks(final String world, final Plot plot) { +>>>>>>> Stashed changes final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); final int topX = getPlotTopLoc(world, plot.id).getBlockX(); final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ(); @@ -832,7 +946,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ +<<<<<<< Updated upstream public static Location getPlotTopLocAbs(final World world, final PlotId id) { +======= + public static Location getPlotTopLocAbs(final String world, final PlotId id) { +>>>>>>> Stashed changes final PlotWorld plotworld = PlotMain.getWorldSettings(world); final PlotManager manager = PlotMain.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); @@ -847,7 +965,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ +<<<<<<< Updated upstream public static Location getPlotBottomLocAbs(final World world, final PlotId id) { +======= + public static Location getPlotBottomLocAbs(final String world, final PlotId id) { +>>>>>>> Stashed changes final PlotWorld plotworld = PlotMain.getWorldSettings(world); final PlotManager manager = PlotMain.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); @@ -861,7 +983,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ +<<<<<<< Updated upstream public static int getPlotWidth(final World world, final PlotId id) { +======= + public static int getPlotWidth(final String world, final PlotId id) { +>>>>>>> Stashed changes return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX(); } @@ -874,7 +1000,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ +<<<<<<< Updated upstream public static Location getPlotTopLoc(final World world, PlotId id) { +======= + public static Location getPlotTopLoc(final String world, PlotId id) { +>>>>>>> Stashed changes final Plot plot = PlotMain.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getTopPlot(world, plot).id; @@ -893,7 +1023,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ +<<<<<<< Updated upstream public static Location getPlotBottomLoc(final World world, PlotId id) { +======= + public static Location getPlotBottomLoc(final String world, PlotId id) { +>>>>>>> Stashed changes final Plot plot = PlotMain.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getBottomPlot(world, plot).id; @@ -903,7 +1037,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; return manager.getPlotBottomLocAbs(plotworld, id); } +<<<<<<< Updated upstream public static boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) { +======= + public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { +>>>>>>> Stashed changes 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); @@ -917,6 +1055,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; return true; } +<<<<<<< Updated upstream public static boolean move(final World world, final PlotId current, PlotId newPlot, final Runnable whenDone) { final Location bot1 = PlotHelper.getPlotBottomLoc(world, current); Location bot2 = PlotHelper.getPlotBottomLoc(world, newPlot); @@ -927,6 +1066,19 @@ import com.intellectualcrafters.plot.object.PlotWorld; } Plot pos1 = PlayerFunctions.getBottomPlot(world, currentPlot); Plot pos2 = PlayerFunctions.getTopPlot(world, currentPlot); +======= + public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { + String worldname = world.getName(); + final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current); + com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot); + final Location top = PlotHelper.getPlotTopLoc(worldname, current); + final Plot currentPlot = PlotHelper.getPlot(worldname, current); + if (currentPlot.owner == null) { + return false; + } + Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot); + Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot); +>>>>>>> Stashed changes PlotId size = PlotHelper.getSize(world, currentPlot); if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { return false; @@ -955,7 +1107,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; return true; } +<<<<<<< Updated upstream public static PlotId getSize(World world, Plot plot) { +======= + public static PlotId getSize(String world, Plot plot) { +>>>>>>> Stashed changes PlotSettings settings = plot.settings; if (!settings.isMerged()) { return new PlotId(1,1); @@ -973,7 +1129,11 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ +<<<<<<< Updated upstream public static Plot getPlot(final World world, final PlotId id) { +======= + public static Plot getPlot(final String world, final PlotId id) { +>>>>>>> Stashed changes if (id == null) { return null; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java index 756b5c323..93365241a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java @@ -36,7 +36,11 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * * @author Empire92 */ +<<<<<<< Updated upstream public class SetBlockFast extends AbstractSetBlock { +======= +public class SetBlockFast extends SetBlockManager { +>>>>>>> Stashed changes private static final RefClass classBlock = getRefClass("{nms}.Block"); private static final RefClass classChunk = getRefClass("{nms}.Chunk"); @@ -73,13 +77,20 @@ public class SetBlockFast extends AbstractSetBlock { * @return true */ @Override +<<<<<<< Updated upstream public boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) { +======= + public void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) { +>>>>>>> Stashed changes final Object w = methodGetHandle.of(world).call(); final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); final Object block = methodGetById.of(null).call(blockId); methodA.of(chunk).call(x & 0x0f, y, z & 0x0f, block, data); +<<<<<<< Updated upstream return true; +======= +>>>>>>> Stashed changes } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java index 6464081cb..ce5483eea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java @@ -37,7 +37,11 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * * @author Empire92 */ +<<<<<<< Updated upstream public class SetBlockFast_1_8 extends AbstractSetBlock { +======= +public class SetBlockFast_1_8 extends SetBlockManager { +>>>>>>> Stashed changes private static final RefClass classBlock = getRefClass("{nms}.Block"); private static final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); @@ -85,13 +89,20 @@ public class SetBlockFast_1_8 extends AbstractSetBlock { * @return true */ @Override +<<<<<<< Updated upstream public boolean set(final World world, final int x, final int y, final int z, final int blockId, final byte data) { +======= + public void set(final World world, final int x, final int y, final int z, final int blockId, final byte data) { +>>>>>>> Stashed changes final Object w = methodGetHandle.of(world).call(); final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); final Object pos = constructorBlockPosition.create((int) (x & 0x0f), y, (int) (z & 0x0f)); final Object id = methodGetByCombinedId.of(null).call(blockId + (data << 12)); methodA.of(chunk).call(pos, id); +<<<<<<< Updated upstream return true; +======= +>>>>>>> Stashed changes } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java new file mode 100644 index 000000000..0c1ddd854 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java @@ -0,0 +1,16 @@ +package com.intellectualcrafters.plot.util; + +import java.util.List; + +import org.bukkit.Chunk; +import org.bukkit.World; + +import com.intellectualcrafters.plot.object.PlotBlock; + +public abstract class SetBlockManager { + public static SetBlockManager setBlockManager = null; + + public abstract void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data); + + public abstract void update(List list); +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java index 1dda70743..8a6863b76 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java @@ -6,10 +6,17 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Block; +<<<<<<< Updated upstream public class SetBlockSlow extends AbstractSetBlock { @Override public boolean set(World world, int x, int y, int z, int id, byte data) { +======= +public class SetBlockSlow extends SetBlockManager { + + @Override + public void set(World world, int x, int y, int z, int id, byte data) { +>>>>>>> Stashed changes Block block = world.getBlockAt(x, y, z); if (block.getData() == data) { if (block.getTypeId() != id) { @@ -22,7 +29,10 @@ public class SetBlockSlow extends AbstractSetBlock { block.setTypeIdAndData(id, data, false); } } +<<<<<<< Updated upstream return false; +======= +>>>>>>> Stashed changes } @Override From f154754e1b657dc5777baedf409bba1ae532ee7b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 14:38:49 +1100 Subject: [PATCH 002/124] yay, conflicts --- .../intellectualcrafters/plot/PlotMain.java | 52 ---- .../plot/commands/DebugRoadRegen.java | 8 - .../plot/commands/Template.java | 20 -- .../plot/database/SQLManager.java | 33 --- .../plot/generator/AugmentedPopulator.java | 44 --- .../plot/generator/ClassicPlotManager.java | 22 -- .../plot/generator/HybridPlotManager.java | 8 - .../plot/listeners/PlayerEvents.java | 25 -- .../plot/object/Location.java | 74 ----- .../plot/object/PlotManager.java | 38 --- .../plot/util/ChunkManager.java | 15 +- .../plot/util/ClusterManager.java | 5 +- .../plot/util/PlayerFunctions.java | 25 +- .../plot/util/PlotHelper.java | 260 +++--------------- .../plot/util/SetBlockFast.java | 14 +- .../plot/util/SetBlockFast_1_8.java | 15 +- .../plot/util/SetBlockSlow.java | 13 +- 17 files changed, 46 insertions(+), 625 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 2edef2195..5327239f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -53,24 +53,6 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import me.confuser.barapi.BarAPI; import net.milkbowl.vault.economy.Economy; -<<<<<<< Updated upstream -import org.bukkit.*; -import org.bukkit.Location; -import org.bukkit.command.PluginCommand; -import org.bukkit.configuration.file.YamlConfiguration; -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.WorldLoadEvent; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.RegisteredServiceProvider; -import org.bukkit.plugin.java.JavaPlugin; - -======= ->>>>>>> Stashed changes import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -87,11 +69,7 @@ import java.util.Map.Entry; * @author Citymonstret * @author Empire92 */ -<<<<<<< Updated upstream -public class PlotMain extends JavaPlugin implements Listener { -======= public class PlotMain { ->>>>>>> Stashed changes /** * Permission that allows for "everything" */ @@ -935,13 +913,7 @@ public class PlotMain { } public static void loadWorld(final String world, final ChunkGenerator generator) { -<<<<<<< Updated upstream - System.out.print(2); if (getWorldSettings(world) != null) { - System.out.print(3); -======= - if (getWorldSettings(world) != null) { ->>>>>>> Stashed changes return; } @@ -953,10 +925,6 @@ public class PlotMain { final String path = "worlds." + world; if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) { -<<<<<<< Updated upstream - System.out.print(4); -======= ->>>>>>> Stashed changes plotGenerator = (PlotGenerator) generator; plotWorld = plotGenerator.getNewPlotWorld(world); plotManager = plotGenerator.getPlotManager(); @@ -980,13 +948,7 @@ public class PlotMain { addPlotWorld(world, plotWorld, plotManager); PlotHelper.setupBorder(world); } else { -<<<<<<< Updated upstream - System.out.print(5 + " | " + (generator instanceof PlotGenerator)); if (!worlds.contains(world)) { - System.out.print(6); -======= - if (!worlds.contains(world)) { ->>>>>>> Stashed changes return; } if (!LOADING_WORLD) { @@ -1616,32 +1578,18 @@ public class PlotMain { { if (checkVersion(1, 8, 0)) { try { -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager = new SetBlockSlow(); - } - catch (Throwable e) { - e.printStackTrace(); - AbstractSetBlock.setBlockManager = new SetBlockSlow(); -======= SetBlockManager.setBlockManager = new SetBlockSlow(); } catch (Throwable e) { e.printStackTrace(); SetBlockManager.setBlockManager = new SetBlockSlow(); ->>>>>>> Stashed changes } } else { try { -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager = new SetBlockFast(); - } catch (Throwable e) { - AbstractSetBlock.setBlockManager = new SetBlockSlow(); -======= SetBlockManager.setBlockManager = new SetBlockFast(); } catch (Throwable e) { SetBlockManager.setBlockManager = new SetBlockSlow(); ->>>>>>> Stashed changes } } try { 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 099327e0a..5cb30cdcb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -30,11 +30,7 @@ import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; -<<<<<<< Updated upstream -import com.intellectualcrafters.plot.util.AbstractSetBlock; -======= import com.intellectualcrafters.plot.util.SetBlockManager; ->>>>>>> Stashed changes import com.intellectualcrafters.plot.util.PlayerFunctions; public class DebugRoadRegen extends SubCommand { @@ -53,11 +49,7 @@ public class DebugRoadRegen extends SubCommand { Chunk chunk = player.getLocation().getChunk(); boolean result = manager.regenerateRoad(chunk); if (result) { -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.update(Arrays.asList(new Chunk[] {chunk})); -======= SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] {chunk})); ->>>>>>> Stashed changes } PlayerFunctions.sendMessage(player, "&6Regenerating chunk: "+chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return true; 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 7e4888cc5..7357addb8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -21,19 +21,6 @@ package com.intellectualcrafters.plot.commands; -<<<<<<< Updated upstream -import org.bukkit.entity.Player; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.util.PlayerFunctions; - -public class Template extends SubCommand { - - public Template() { - super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true); - } - -======= import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -54,15 +41,12 @@ public class Template extends SubCommand { super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true); } ->>>>>>> Stashed changes @Override public boolean execute(final Player plr, final String... args) { if (args.length != 2) { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); return false; } -<<<<<<< Updated upstream -======= World world = Bukkit.getWorld(args[1]); PlotWorld plotworld = PlotMain.getWorldSettings(args[1]); if (world == null || plotworld == null) { @@ -79,7 +63,6 @@ public class Template extends SubCommand { PlayerFunctions.sendMessage(plr, "TODO"); } } ->>>>>>> Stashed changes // TODO allow world settings (including schematics to be packed into a single file) @@ -87,8 +70,6 @@ public class Template extends SubCommand { return true; } -<<<<<<< Updated upstream -======= public void gzipIt(String output, String input) { byte[] buffer = new byte[1024]; @@ -106,5 +87,4 @@ public class Template extends SubCommand { ex.printStackTrace(); } } ->>>>>>> Stashed changes } 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 b196c60a4..1db8dc90c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -161,10 +161,7 @@ public class SQLManager implements AbstractDB { } stored.get(world).put(new PlotId(idx, idz), id); } -<<<<<<< Updated upstream -======= result.close(); ->>>>>>> Stashed changes stmt.close(); } catch (final SQLException e) { e.printStackTrace(); @@ -486,10 +483,7 @@ public class SQLManager implements AbstractDB { while (r.next()) { id = r.getInt("id"); } -<<<<<<< Updated upstream -======= r.close(); ->>>>>>> Stashed changes stmt.close(); return id; } catch (final SQLException e) { @@ -523,10 +517,7 @@ public class SQLManager implements AbstractDB { final Statement statement = this.connection.createStatement(); statement.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD `merged` int(11) DEFAULT NULL"); statement.executeBatch(); -<<<<<<< Updated upstream -======= rs.close(); ->>>>>>> Stashed changes statement.close(); } } catch (final Exception e) { @@ -718,10 +709,7 @@ public class SQLManager implements AbstractDB { } } stmt.close(); -<<<<<<< Updated upstream -======= r.close(); ->>>>>>> Stashed changes for (final Plot plot : plots.values()) { final String world = plot.world; if (!newplots.containsKey(world)) { @@ -967,11 +955,8 @@ public class SQLManager implements AbstractDB { } } purgeIds(world, ids); -<<<<<<< Updated upstream -======= stmt.close(); r.close(); ->>>>>>> Stashed changes } catch (SQLException e) { e.printStackTrace(); PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); @@ -1047,10 +1032,7 @@ public class SQLManager implements AbstractDB { h.put(var, val); } stmt.close(); -<<<<<<< Updated upstream -======= r.close(); ->>>>>>> Stashed changes } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for plot: " + id); e.printStackTrace(); @@ -1112,10 +1094,7 @@ public class SQLManager implements AbstractDB { comments.add(comment); } statement.close(); -<<<<<<< Updated upstream -======= set.close(); ->>>>>>> Stashed changes } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch comment"); e.printStackTrace(); @@ -1312,10 +1291,7 @@ public class SQLManager implements AbstractDB { rating = set.getDouble("rating"); } statement.close(); -<<<<<<< Updated upstream -======= set.close(); ->>>>>>> Stashed changes return rating; } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString()); @@ -1371,10 +1347,7 @@ public class SQLManager implements AbstractDB { c_id = r.getInt("id"); } stmt.close(); -<<<<<<< Updated upstream -======= r.close(); ->>>>>>> Stashed changes return c_id; } catch (final SQLException e) { e.printStackTrace(); @@ -1553,10 +1526,7 @@ public class SQLManager implements AbstractDB { } } stmt.close(); -<<<<<<< Updated upstream -======= r.close(); ->>>>>>> Stashed changes for (final PlotCluster c : clusters.values()) { final String world = c.world; if (!newClusters.containsKey(world)) { @@ -1786,10 +1756,7 @@ public class SQLManager implements AbstractDB { h.put(var, val); } stmt.close(); -<<<<<<< Updated upstream -======= r.close(); ->>>>>>> Stashed changes } catch (final SQLException e) { PlotMain.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for cluster: " + id); e.printStackTrace(); 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 5e67198ca..0e0bee151 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -5,30 +5,19 @@ import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.Chunk; -<<<<<<< Updated upstream -import org.bukkit.Location; -======= ->>>>>>> Stashed changes import org.bukkit.World; import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.object.BlockWrapper; -<<<<<<< Updated upstream -======= import com.intellectualcrafters.plot.object.Location; ->>>>>>> Stashed changes 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.object.RegionWrapper; -<<<<<<< Updated upstream -import com.intellectualcrafters.plot.util.AbstractSetBlock; -======= import com.intellectualcrafters.plot.util.SetBlockManager; ->>>>>>> Stashed changes import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.TaskManager; @@ -49,11 +38,7 @@ public class AugmentedPopulator extends BlockPopulator { private final int tx; private final int tz; -<<<<<<< Updated upstream - public BlockWrapper getBlock(int X, int Z, int i, int j, short[][] r, boolean c) { -======= public BlockWrapper get(int X, int Z, int i, int j, short[][] r, boolean c) { ->>>>>>> Stashed changes int y = (i << 4) + (j >> 8); int a = (j - ((y & 0xF) << 8)); int z = (a >> 4); @@ -81,19 +66,11 @@ public class AugmentedPopulator extends BlockPopulator { Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); Location tl = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1); -<<<<<<< Updated upstream - this.bx = bl.getBlockX(); - this.bz = bl.getBlockZ(); - - this.tx = tl.getBlockX(); - this.tz = tl.getBlockZ(); -======= this.bx = bl.getX(); this.bz = bl.getZ(); this.tx = tl.getX(); this.tz = tl.getZ(); ->>>>>>> Stashed changes } else { this.bx = Integer.MIN_VALUE; @@ -141,13 +118,8 @@ public class AugmentedPopulator extends BlockPopulator { check = false; } if (plotworld.TERRAIN == 2) { -<<<<<<< Updated upstream - PlotId plot1 = manager.getPlotIdAbs(plotworld, new Location(world, x, 0, z)); - PlotId plot2 = manager.getPlotIdAbs(plotworld, new Location(world, x2, 0, z2)); -======= PlotId plot1 = manager.getPlotIdAbs(plotworld, x, 0, z); PlotId plot2 = manager.getPlotIdAbs(plotworld, x2, 0, z2); ->>>>>>> Stashed changes if (plot1 != null && plot2 != null && plot1.equals(plot2)) { return; } @@ -160,11 +132,7 @@ public class AugmentedPopulator extends BlockPopulator { public void run() { populateBiome(world, x, z); chunk.unload(true, true); -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); -======= SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); ->>>>>>> Stashed changes } }, 20); } @@ -181,11 +149,7 @@ public class AugmentedPopulator extends BlockPopulator { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); chunk.unload(true, true); -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); -======= SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); ->>>>>>> Stashed changes } }, 40 + rand.nextInt(40)); } @@ -206,11 +170,7 @@ public class AugmentedPopulator extends BlockPopulator { int length = result[0].length; for(int i = 0; i < result.length; i++) { for(int j = 0; j < length; j++) { -<<<<<<< Updated upstream - BlockWrapper blockInfo = getBlock(x, z, i, j, result, check); -======= BlockWrapper blockInfo = get(x, z, i, j, result, check); ->>>>>>> Stashed changes if (blockInfo == null) { continue; } @@ -222,11 +182,7 @@ public class AugmentedPopulator extends BlockPopulator { continue; } } -<<<<<<< Updated upstream - else if (manager.getPlotIdAbs(plotworld, new Location(world, xx, 0, zz)) != null) { -======= else if (manager.getPlotIdAbs(plotworld, xx, 0, zz) != null) { ->>>>>>> Stashed changes continue; } } 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 7f966791a..b47eb342c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -48,11 +48,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; -<<<<<<< Updated upstream - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1); -======= final Location pos1 = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); ->>>>>>> Stashed changes final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid); PlotHelper.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks); return true; @@ -63,11 +59,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { if (dpw.ROAD_WIDTH == 0) { return false; } -<<<<<<< Updated upstream - final Location bottom = PlotHelper.getPlotBottomLoc(w, plotid); -======= final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); ->>>>>>> Stashed changes final Location top = PlotHelper.getPlotTopLoc(w, plotid); int x, z; @@ -105,11 +97,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { if (dpw.ROAD_WIDTH == 0) { return false; } -<<<<<<< Updated upstream - final Location bottom = PlotHelper.getPlotBottomLoc(w, plotid); -======= final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); ->>>>>>> Stashed changes final Location top = PlotHelper.getPlotTopLoc(w, plotid); int x, z; @@ -330,11 +318,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } @Override -<<<<<<< Updated upstream - public String[] getPlotComponents(World world, PlotWorld plotworld, PlotId plotid) { -======= public String[] getPlotComponents(PlotWorld plotworld, PlotId plotid) { ->>>>>>> Stashed changes return new String[] { "floor", "wall", @@ -346,15 +330,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { * Remove sign for a plot */ @Override -<<<<<<< Updated upstream - public Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot) { - final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1); -======= public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; Location bot = PlotHelper.getPlotBottomLoc(plotworld.worldname, plot.id); return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getBlockX(), dpw.ROAD_HEIGHT + 1, bot.getBlockZ() - 1); ->>>>>>> Stashed changes } } 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 d81ada939..223d1e4af 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -41,11 +41,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -<<<<<<< Updated upstream -import com.intellectualcrafters.plot.util.AbstractSetBlock; -======= import com.intellectualcrafters.plot.util.SetBlockManager; ->>>>>>> Stashed changes import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; @@ -200,11 +196,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; regenerateRoad(chunk); } } -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.update(chunks2); -======= SetBlockManager.setBlockManager.update(chunks2); ->>>>>>> Stashed changes } public boolean scheduleRoadUpdate(final World world) { 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 0da53c8e9..356aa1eda 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -160,14 +160,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location f = event.getFrom(); final Location t = event.getTo(); final Location q = new Location(t.getWorld(), t.getBlockX(), 0, t.getZ()); -<<<<<<< Updated upstream - if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { -======= - if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { - System.out.print("========================="); - System.out.print("4. " + f); ->>>>>>> Stashed changes if (Settings.TELEPORT_DELAY != 0 && TaskManager.TELEPORT_QUEUE.size() > 0) { String name = player.getName(); if (TaskManager.TELEPORT_QUEUE.contains(name)) { @@ -198,10 +191,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi passed = true; } if (passed) { -<<<<<<< Updated upstream -======= q.setY(t.getBlockY()); ->>>>>>> Stashed changes event.setTo(q); PlayerFunctions.sendMessage(player, C.BORDER); return; @@ -209,29 +199,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = getCurrentPlot(q); if (plot != null) { -<<<<<<< Updated upstream - if (!plot.equals(getCurrentPlot(f))) { - if (plot.deny_entry(player)) { - if (!PlotMain.hasPermission(player, "plots.admin.entry.denied")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); - event.setCancelled(true); - return; - } - } -======= if (plot.deny_entry(player)) { if (!PlotMain.hasPermission(player, "plots.admin.entry.denied")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); - System.out.print("DENY ENTRY"); - System.out.print("5. " + f); event.setCancelled(true); return; } } - System.out.print("6. " + f); if (!plot.equals(getCurrentPlot(f))) { - System.out.print("7. " + f); ->>>>>>> Stashed changes plotEntry(player, plot); } } else if (leftPlot(f, event.getTo())) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java index f61e5f042..1dd3dffd2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -11,21 +11,13 @@ import java.lang.reflect.Method; */ public class Location implements Cloneable, Comparable { -<<<<<<< Updated upstream - private double x, y, z; -======= private int x, y, z; ->>>>>>> Stashed changes private float yaw, pitch; private String world; private boolean built; private Object o; -<<<<<<< Updated upstream - public Location(final String world, final double x, final double y, final double z, final float yaw, final float pitch) { -======= public Location(final String world, final int x, final int y, final int z, final float yaw, final float pitch) { ->>>>>>> Stashed changes this.world = world; this.x = x; this.y = y; @@ -37,20 +29,6 @@ public class Location implements Cloneable, Comparable { } public Location() { -<<<<<<< Updated upstream - this("", 0d, 0d, 0d, 0f, 0f); - } - - public Location(final String world, final double x, final double y, final double z) { - this(world, x, y, z, 0f, 0f); - } - - public double getX() { - return this.x; - } - - public void setX(final double x) { -======= this("", 0, 0, 0, 0, 0); } @@ -63,41 +41,24 @@ public class Location implements Cloneable, Comparable { } public void setX(final int x) { ->>>>>>> Stashed changes this.x = x; this.built = false; } -<<<<<<< Updated upstream - public double getY() { - return this.y; - } - - public void setY(final double y) { -======= public int getY() { return this.y; } public void setY(final int y) { ->>>>>>> Stashed changes this.y = y; this.built = false; } -<<<<<<< Updated upstream - public double getZ() { - return this.z; - } - - public void setZ(final double z) { -======= public int getZ() { return this.z; } public void setZ(final int z) { ->>>>>>> Stashed changes this.z = z; this.built = false; } @@ -129,19 +90,11 @@ public class Location implements Cloneable, Comparable { this.built = false; } -<<<<<<< Updated upstream - public void add(double x, double y, double z) { -======= - public Location add(int x, int y, int z) { ->>>>>>> Stashed changes this.x += x; this.y += y; this.z += z; this.built = false; -<<<<<<< Updated upstream -======= return this; ->>>>>>> Stashed changes } public double getEuclideanDistanceSquared(final Location l2) { @@ -175,11 +128,6 @@ public class Location implements Cloneable, Comparable { y <= max.getY() && z >= min.getX() && z < max.getZ(); } -<<<<<<< Updated upstream - public void lookTowards(double x, double y) { -======= - public void lookTowards(int x, int y) { ->>>>>>> Stashed changes double l = this.x - x; double w = this.z - z; double c = Math.sqrt(l * l + w * w); @@ -191,34 +139,21 @@ public class Location implements Cloneable, Comparable { this.built = false; } -<<<<<<< Updated upstream - public void subtract(double x, double y, double z) { -======= - public Location subtract(int x, int y, int z) { ->>>>>>> Stashed changes this.x -= x; this.y -= y; this.z -= z; this.built = false; -<<<<<<< Updated upstream -======= return this; ->>>>>>> Stashed changes } @Override public boolean equals(Object o) { -<<<<<<< Updated upstream - if (!(o instanceof Location)) - return false; -======= if (o == null) { return false; } if (!(o instanceof Location)) { return false; } ->>>>>>> Stashed changes Location l = (Location) o; return x == l.getX() && y == l.getY() && z == l.getZ() && world.equals(l.getWorld()) && @@ -251,12 +186,6 @@ public class Location implements Cloneable, Comparable { } } -<<<<<<< Updated upstream -======= - /** - * Please use utility class as this is not efficient - */ ->>>>>>> Stashed changes public Object toBukkitLocation() { if (built) { return o; @@ -270,12 +199,9 @@ public class Location implements Cloneable, Comparable { } } -<<<<<<< Updated upstream -======= /** * Please use utility class as this is not efficient */ ->>>>>>> Stashed changes public void teleport(final Object o) throws Exception { if (o.getClass().getName().contains("org.bukkit.entity")) { Method m = o.getClass().getMethod("teleport", Class.forName("org.bukkit.Location")); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 48907692b..80c6dc9c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -23,10 +23,6 @@ package com.intellectualcrafters.plot.object; import java.util.ArrayList; -<<<<<<< Updated upstream -import org.bukkit.Location; -======= ->>>>>>> Stashed changes import org.bukkit.World; import org.bukkit.block.Biome; @@ -37,15 +33,9 @@ public abstract class PlotManager { * plots) */ -<<<<<<< Updated upstream - public abstract PlotId getPlotIdAbs(final PlotWorld plotworld, final Location loc); - - public abstract PlotId getPlotId(final PlotWorld plotworld, final Location loc); -======= public abstract PlotId getPlotIdAbs(final PlotWorld plotworld, final int x, final int y, final int z); public abstract PlotId getPlotId(final PlotWorld plotworld, final int x, final int y, final int z); ->>>>>>> Stashed changes // If you have a circular plot, just return the corner if it were a square public abstract Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid); @@ -55,15 +45,6 @@ public abstract class PlotManager { /* * Plot clearing (return false if you do not support some method) */ -<<<<<<< Updated upstream - public abstract boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone); - - public abstract boolean claimPlot(final World world, final PlotWorld plotworld, final Plot plot); - - public abstract boolean unclaimPlot(final World world, final PlotWorld plotworld, final Plot plot); - - public abstract Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot); -======= public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone); public abstract boolean claimPlot(final PlotWorld plotworld, final Plot plot); @@ -71,26 +52,17 @@ public abstract class PlotManager { public abstract boolean unclaimPlot(final PlotWorld plotworld, final Plot plot); public abstract Location getSignLoc(final PlotWorld plotworld, final Plot plot); ->>>>>>> Stashed changes /* * Plot set functions (return false if you do not support the specific set * method) */ -<<<<<<< Updated upstream - public abstract String[] getPlotComponents(final World world, final PlotWorld plotworld, final PlotId plotid); - - public abstract boolean setComponent(final World world, final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks); - - public abstract boolean setBiome(final World world, final Plot plot, final Biome biome); -======= public abstract String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid); public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks); public abstract boolean setBiome(final Plot plot, final Biome biome); ->>>>>>> Stashed changes /* * PLOT MERGING (return false if your generator does not support plot @@ -108,15 +80,6 @@ public abstract class PlotManager { public abstract boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot); -<<<<<<< Updated upstream - public abstract boolean startPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds); - - public abstract boolean startPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds); - - public abstract boolean finishPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds); - - public abstract boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds); -======= public abstract boolean startPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); public abstract boolean startPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); @@ -124,6 +87,5 @@ public abstract class PlotManager { public abstract boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); public abstract boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); ->>>>>>> Stashed changes } 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 453590190..6831d5014 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -229,21 +229,15 @@ public class ChunkManager { Block block = world.getBlockAt(x, y, z); int id = block.getTypeId(); byte data = block.getData(); -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.set(world, x + relX, y, z + relZ, id, data); -======= SetBlockManager.setBlockManager.set(world, x + relX, y, z + relZ, id, data); ->>>>>>> Stashed changes + } } mx.increment(); if (x == ex) { // done! restoreBlocks(world, relX, relZ); -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.update(chunks); -======= SetBlockManager.setBlockManager.update(chunks); ->>>>>>> Stashed changes + for (Chunk chunk : chunks) { chunk.unload(true, true); } @@ -359,11 +353,8 @@ public class ChunkManager { restoreEntities(world, 0, 0); } chunk.unload(true, true); -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); -======= SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); ->>>>>>> Stashed changes + } CURRENT_PLOT_CLEAR = null; } 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 0d5a5835f..3c26fcae9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -288,11 +288,8 @@ public class ClusterManager { @Override public void run() { if (populator == null || plotworld.TYPE == 0) { -<<<<<<< Updated upstream - AbstractSetBlock.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); -======= SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); ->>>>>>> Stashed changes + world.regenerateChunk(chunk.getX(), chunk.getZ()); chunk.unload(true, true); } 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 b8fc3d8da..e3083971e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -65,11 +65,8 @@ import java.util.UUID; return myplots; } -<<<<<<< Updated upstream - public static ArrayList getMaxPlotSelectionIds(final World world, PlotId pos1, PlotId pos2) { -======= public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { ->>>>>>> Stashed changes + final Plot plot1 = PlotMain.getPlots(world).get(pos1); final Plot plot2 = PlotMain.getPlots(world).get(pos2); @@ -91,11 +88,8 @@ import java.util.UUID; return myplots; } -<<<<<<< Updated upstream - public static Plot getBottomPlot(final World world, final Plot plot) { -======= public static Plot getBottomPlot(final String world, final Plot plot) { ->>>>>>> Stashed changes + if (plot.settings.getMerged(0)) { final Plot p = PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)); if (p == null) { @@ -113,11 +107,8 @@ import java.util.UUID; return plot; } -<<<<<<< Updated upstream - public static Plot getTopPlot(final World world, final Plot plot) { -======= public static Plot getTopPlot(final String world, final Plot plot) { ->>>>>>> Stashed changes + if (plot.settings.getMerged(2)) { return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); } @@ -141,11 +132,8 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotMain.getWorldSettings(world); -<<<<<<< Updated upstream - return manager.getPlotIdAbs(plotworld, loc); -======= return manager.getPlotIdAbs(plotworld, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); ->>>>>>> Stashed changes + } /** @@ -162,11 +150,8 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotMain.getWorldSettings(world); -<<<<<<< Updated upstream - PlotId id = manager.getPlotId(plotworld, loc); -======= PlotId id = manager.getPlotId(plotworld, loc.getBlockX(),loc.getBlockY(), loc.getBlockZ()); ->>>>>>> Stashed changes + if (id!=null && plotworld.TYPE == 2) { if (ClusterManager.getCluster(world, id) == null) { return null; 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 596ab8030..1e00a51fe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -31,10 +31,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.Chunk; -<<<<<<< Updated upstream -import org.bukkit.Location; -======= ->>>>>>> Stashed changes + import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.World; @@ -50,10 +47,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; -<<<<<<< Updated upstream -======= import com.intellectualcrafters.plot.object.Location; ->>>>>>> Stashed changes + import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; @@ -140,11 +135,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ -<<<<<<< Updated upstream - public static boolean mergePlots(final Player plr, final World world, final ArrayList plotIds) { -======= public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { ->>>>>>> Stashed changes + final PlotWorld plotworld = PlotMain.getWorldSettings(world); if (PlotMain.useEconomy && plotworld.USE_ECONOMY) { final double cost = plotIds.size() * plotworld.MERGE_PRICE; @@ -172,11 +164,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return boolean (success) */ -<<<<<<< Updated upstream - public static boolean mergePlots(final World world, final ArrayList plotIds, boolean removeRoads) { -======= public static boolean mergePlots(final String world, final ArrayList plotIds, boolean removeRoads) { ->>>>>>> Stashed changes + if (plotIds.size() < 2) { return false; } @@ -186,11 +175,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; final PlotManager manager = PlotMain.getPlotManager(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world); -<<<<<<< Updated upstream - manager.startPlotMerge(world, plotworld, plotIds); -======= manager.startPlotMerge(plotworld, plotIds); ->>>>>>> Stashed changes + boolean result = false; @@ -209,11 +195,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; Plot plot2 = null; if (removeRoads) { -<<<<<<< Updated upstream - removeSign(world, plot); -======= removeSign(plot); ->>>>>>> Stashed changes + } if (lx) { if (ly) { @@ -248,20 +231,14 @@ import com.intellectualcrafters.plot.object.PlotWorld; for (int y = pos1.y; y <= pos2.y; y++) { final PlotId id = new PlotId(x, y); final Plot plot = PlotMain.getPlots(world).get(id); -<<<<<<< Updated upstream - DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged()); -======= DBFunc.setMerged(world, plot, plot.settings.getMerged()); ->>>>>>> Stashed changes + } } -<<<<<<< Updated upstream - manager.finishPlotMerge(world, plotworld, plotIds); -======= manager.finishPlotMerge(plotworld, plotIds); ->>>>>>> Stashed changes + return result; } @@ -274,11 +251,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param lesserPlot * @param greaterPlot */ -<<<<<<< Updated upstream - public static void mergePlot(final World world, final Plot lesserPlot, final Plot greaterPlot, boolean removeRoads) { -======= public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, boolean removeRoads) { ->>>>>>> Stashed changes + final PlotManager manager = PlotMain.getPlotManager(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world); @@ -300,53 +274,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } } -<<<<<<< Updated upstream - - /* - * Random number gen section - */ - public static long nextLong() { - final long a = state; - state = xorShift64(a); - return a; - } - - /* - * End of random number gen section - */ - - public static long xorShift64(long a) { - a ^= (a << 21); - a ^= (a >>> 35); - a ^= (a << 4); - return a; - } - - public static int random(final int n) { - if (n == 1) { - return 0; - } - final long r = ((nextLong() >>> 32) * n) >> 32; - return (int) r; - } - - public static void removeSign(final World world, final Plot p) { - final PlotManager manager = PlotMain.getPlotManager(world); - final PlotWorld plotworld = PlotMain.getWorldSettings(world); - final Location loc = manager.getSignLoc(world, plotworld, p); - final Block bs = loc.getBlock(); - if (bs.getType() == Material.WALL_SIGN) { - bs.setType(Material.AIR); - } - } - - public static void setSign(final Player player, final Plot p) { - setSign(Bukkit.getWorld(p.world), player.getName(), p); - } - - @SuppressWarnings("deprecation") - public static void setSign(final World world, String name, final Plot p) { -======= @@ -359,17 +286,14 @@ import com.intellectualcrafters.plot.object.PlotWorld; } public static void setSign(String name, final Plot p) { ->>>>>>> Stashed changes + if (name == null) { name = "unknown"; } final PlotManager manager = PlotMain.getPlotManager(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world); -<<<<<<< Updated upstream - final Location loc = manager.getSignLoc(world, plotworld, p); -======= final Location loc = manager.getSignLoc(plotworld, p); ->>>>>>> Stashed changes + final Block bs = loc.getBlock(); bs.setType(Material.AIR); bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); @@ -400,45 +324,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; return string; } -<<<<<<< Updated upstream - public static boolean setBlock(World world, int x, int y, int z, int id, byte data) { - try { - return AbstractSetBlock.setBlockManager.set(world, x, y, z, id, data); - } - catch (Throwable e) { - AbstractSetBlock.setBlockManager = new SetBlockSlow(); - return AbstractSetBlock.setBlockManager.set(world, x, y, z, id, data); - } - } - - public static boolean setBlock(World world, int x, int y, int z, PlotBlock[] blocks) { - final int i = random(blocks.length); - final PlotBlock newblock = blocks[i]; - try { - return AbstractSetBlock.setBlockManager.set(world, x, y, z, newblock.id, newblock.data); - } - catch (Throwable e) { - AbstractSetBlock.setBlockManager = new SetBlockSlow(); - return AbstractSetBlock.setBlockManager.set(world, x, y, z, newblock.id, newblock.data); - } - } - - public static void update(Location loc) { - 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 = loc.getWorld().getChunkAt(loc.getChunk().getX() + cx, loc.getChunk().getZ() + cz); - chunks.add(chunk); - } - } - AbstractSetBlock.setBlockManager.update(chunks); - } - - public static void autoMerge(final World world, final Plot plot, final Player player) { -======= public static void autoMerge(final String world, final Plot plot, final Player player) { ->>>>>>> Stashed changes + if (plot == null) { return; } @@ -496,11 +383,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; update(player.getLocation()); } -<<<<<<< Updated upstream - private static boolean ownsPlots(final World world, final ArrayList plots, final Player player, final int dir) { -======= private static boolean ownsPlots(final String world, final ArrayList plots, final Player player, final int dir) { ->>>>>>> Stashed changes + final PlotId id_min = plots.get(0); final PlotId id_max = plots.get(plots.size() - 1); for (final PlotId myid : plots) { @@ -566,28 +450,18 @@ import com.intellectualcrafters.plot.object.PlotWorld; return p; } -<<<<<<< Updated upstream - public static int getLoadedChunks(final World world) { - return world.getLoadedChunks().length; - } - - public static int getEntities(final World world) { -======= public static int getLoadedChunks(final String world) { return world.getLoadedChunks().length; } public static int getEntities(final String world) { ->>>>>>> Stashed changes + return world.getEntities().size(); } -<<<<<<< Updated upstream - public static int getTileEntities(final World world) { -======= public static int getTileEntities(final String world) { ->>>>>>> Stashed changes + PlotMain.getWorldSettings(world); int x = 0; for (final Chunk chunk : world.getLoadedChunks()) { @@ -596,11 +470,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; return x; } -<<<<<<< Updated upstream - public static double getWorldFolderSize(final World world) { -======= public static double getWorldFolderSize(final String world) { ->>>>>>> Stashed changes + // long size = FileUtil.sizeOfDirectory(world.getWorldFolder()); final File folder = world.getWorldFolder(); final long size = folder.length(); @@ -623,11 +494,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; return new short[]{Short.parseShort(block), 0}; } -<<<<<<< Updated upstream - public static void clearAllEntities(final World world, final Plot plot, final boolean tile) { -======= public static void clearAllEntities(final String world, final Plot plot, final boolean tile) { ->>>>>>> Stashed changes + final List entities = world.getEntities(); for (final Entity entity : entities) { @@ -651,11 +519,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param plot * @param isDelete */ -<<<<<<< Updated upstream - public static void clear(final Player player, final World world, final Plot plot, final boolean isDelete) { -======= public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { ->>>>>>> Stashed changes + if (runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return; @@ -721,11 +586,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); -<<<<<<< Updated upstream - final World world; -======= - final String world; ->>>>>>> Stashed changes world = requester.getWorld(); clearAllEntities(world, plot, false); @@ -733,11 +593,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; removeSign(world, plot); } -<<<<<<< Updated upstream - public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) { -======= - public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { ->>>>>>> Stashed changes for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { @@ -750,11 +605,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } -<<<<<<< Updated upstream - public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { -======= public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { ->>>>>>> Stashed changes + if (blocks.length == 1) { setCuboid(world, pos1, pos2, blocks[0]); return; @@ -773,11 +625,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } -<<<<<<< Updated upstream - public static void setSimpleCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) { -======= public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { ->>>>>>> Stashed changes + for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { @@ -790,11 +639,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } -<<<<<<< Updated upstream - public static void setBiome(final World world, final Plot plot, final Biome b) { -======= public static void setBiome(final String world, final Plot plot, final Biome b) { ->>>>>>> Stashed changes + final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); final int topX = getPlotTopLoc(world, plot.id).getBlockX() + 1; final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ(); @@ -820,11 +666,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; } } -<<<<<<< Updated upstream - public static int getHeighestBlock(final World world, final int x, final int z) { -======= public static int getHeighestBlock(final String world, final int x, final int z) { ->>>>>>> Stashed changes + boolean safe = false; int id; for (int i = 1; i < world.getMaxHeight(); i++) { @@ -898,11 +741,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param world World in which the plot is located * @param plot Plot Object */ -<<<<<<< Updated upstream - public static void refreshPlotChunks(final World world, final Plot plot) { -======= public static void refreshPlotChunks(final String world, final Plot plot) { ->>>>>>> Stashed changes + final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); final int topX = getPlotTopLoc(world, plot.id).getBlockX(); final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ(); @@ -946,11 +786,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ -<<<<<<< Updated upstream - public static Location getPlotTopLocAbs(final World world, final PlotId id) { -======= public static Location getPlotTopLocAbs(final String world, final PlotId id) { ->>>>>>> Stashed changes + final PlotWorld plotworld = PlotMain.getWorldSettings(world); final PlotManager manager = PlotMain.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); @@ -965,11 +802,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ -<<<<<<< Updated upstream - public static Location getPlotBottomLocAbs(final World world, final PlotId id) { -======= public static Location getPlotBottomLocAbs(final String world, final PlotId id) { ->>>>>>> Stashed changes + final PlotWorld plotworld = PlotMain.getWorldSettings(world); final PlotManager manager = PlotMain.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); @@ -983,11 +817,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ -<<<<<<< Updated upstream - public static int getPlotWidth(final World world, final PlotId id) { -======= public static int getPlotWidth(final String world, final PlotId id) { ->>>>>>> Stashed changes + return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX(); } @@ -1000,11 +831,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ -<<<<<<< Updated upstream - public static Location getPlotTopLoc(final World world, PlotId id) { -======= public static Location getPlotTopLoc(final String world, PlotId id) { ->>>>>>> Stashed changes + final Plot plot = PlotMain.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getTopPlot(world, plot).id; @@ -1023,11 +851,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ -<<<<<<< Updated upstream - public static Location getPlotBottomLoc(final World world, PlotId id) { -======= public static Location getPlotBottomLoc(final String world, PlotId id) { ->>>>>>> Stashed changes + final Plot plot = PlotMain.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getBottomPlot(world, plot).id; @@ -1037,11 +862,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; return manager.getPlotBottomLocAbs(plotworld, id); } -<<<<<<< Updated upstream - public static boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) { -======= public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { ->>>>>>> Stashed changes + 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); @@ -1055,18 +877,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; return true; } -<<<<<<< Updated upstream - public static boolean move(final World world, final PlotId current, PlotId newPlot, final Runnable whenDone) { - final Location bot1 = PlotHelper.getPlotBottomLoc(world, current); - Location bot2 = PlotHelper.getPlotBottomLoc(world, newPlot); - final Location top = PlotHelper.getPlotTopLoc(world, current); - final Plot currentPlot = PlotHelper.getPlot(world, current); - if (currentPlot.owner == null) { - return false; - } - Plot pos1 = PlayerFunctions.getBottomPlot(world, currentPlot); - Plot pos2 = PlayerFunctions.getTopPlot(world, currentPlot); -======= public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { String worldname = world.getName(); final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current); @@ -1078,7 +888,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; } Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot); Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot); ->>>>>>> Stashed changes + PlotId size = PlotHelper.getSize(world, currentPlot); if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { return false; @@ -1107,11 +917,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; return true; } -<<<<<<< Updated upstream - public static PlotId getSize(World world, Plot plot) { -======= public static PlotId getSize(String world, Plot plot) { ->>>>>>> Stashed changes + PlotSettings settings = plot.settings; if (!settings.isMerged()) { return new PlotId(1,1); @@ -1129,11 +936,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return */ -<<<<<<< Updated upstream - public static Plot getPlot(final World world, final PlotId id) { -======= public static Plot getPlot(final String world, final PlotId id) { ->>>>>>> Stashed changes + if (id == null) { return null; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java index 93365241a..125021c6e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java @@ -36,11 +36,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * * @author Empire92 */ -<<<<<<< Updated upstream -public class SetBlockFast extends AbstractSetBlock { -======= public class SetBlockFast extends SetBlockManager { ->>>>>>> Stashed changes + private static final RefClass classBlock = getRefClass("{nms}.Block"); private static final RefClass classChunk = getRefClass("{nms}.Chunk"); @@ -77,20 +74,11 @@ public class SetBlockFast extends SetBlockManager { * @return true */ @Override -<<<<<<< Updated upstream - public boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) { - -======= public void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) { ->>>>>>> Stashed changes final Object w = methodGetHandle.of(world).call(); final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); final Object block = methodGetById.of(null).call(blockId); methodA.of(chunk).call(x & 0x0f, y, z & 0x0f, block, data); -<<<<<<< Updated upstream - return true; -======= ->>>>>>> Stashed changes } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java index ce5483eea..811eef19b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java @@ -37,11 +37,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * * @author Empire92 */ -<<<<<<< Updated upstream -public class SetBlockFast_1_8 extends AbstractSetBlock { -======= public class SetBlockFast_1_8 extends SetBlockManager { ->>>>>>> Stashed changes + private static final RefClass classBlock = getRefClass("{nms}.Block"); private static final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); @@ -89,20 +86,14 @@ public class SetBlockFast_1_8 extends SetBlockManager { * @return true */ @Override -<<<<<<< Updated upstream - public boolean set(final World world, final int x, final int y, final int z, final int blockId, final byte data) { -======= public void set(final World world, final int x, final int y, final int z, final int blockId, final byte data) { ->>>>>>> Stashed changes + final Object w = methodGetHandle.of(world).call(); final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); final Object pos = constructorBlockPosition.create((int) (x & 0x0f), y, (int) (z & 0x0f)); final Object id = methodGetByCombinedId.of(null).call(blockId + (data << 12)); methodA.of(chunk).call(pos, id); -<<<<<<< Updated upstream - return true; -======= ->>>>>>> Stashed changes + } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java index 8a6863b76..fc9531063 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java @@ -6,17 +6,11 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Block; -<<<<<<< Updated upstream -public class SetBlockSlow extends AbstractSetBlock { - - @Override - public boolean set(World world, int x, int y, int z, int id, byte data) { -======= public class SetBlockSlow extends SetBlockManager { @Override public void set(World world, int x, int y, int z, int id, byte data) { ->>>>>>> Stashed changes + Block block = world.getBlockAt(x, y, z); if (block.getData() == data) { if (block.getTypeId() != id) { @@ -29,16 +23,11 @@ public class SetBlockSlow extends SetBlockManager { block.setTypeIdAndData(id, data, false); } } -<<<<<<< Updated upstream - return false; -======= ->>>>>>> Stashed changes } @Override public void update(List chunks) { // TODO Auto-generated method stub - } } From d227bcc73999336fdac91ac75c6e017d8aa6e1b6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 17:08:15 +1100 Subject: [PATCH 003/124] more changes --- .../intellectualcrafters/plot/BukkitMain.java | 206 ++++++- .../intellectualcrafters/plot/IPlotMain.java | 35 ++ .../intellectualcrafters/plot/PlotMain.java | 417 ++++++-------- .../plot/PlotSquared.java | 514 ++++++++++++++++++ .../plot/commands/DebugExec.java | 2 +- .../plot/commands/Move.java | 2 +- .../plot/commands/Reload.java | 2 +- .../plot/commands/Trim.java | 8 +- .../plot/database/Database.java | 10 +- .../plot/database/MySQL.java | 7 +- .../plot/database/SQLManager.java | 64 +-- .../plot/database/SQLite.java | 8 +- .../plot/generator/AugmentedPopulator.java | 8 +- .../plot/generator/HybridPlotManager.java | 6 +- .../plot/listeners/PlayerEvents.java | 14 +- .../plot/util/BlockManager.java | 3 +- .../plot/util/ChunkManager.java | 9 +- .../plot/util/ClusterManager.java | 5 +- .../plot/util/ExpireManager.java | 3 +- .../intellectualcrafters/plot/util/Lag.java | 1 - .../plot/util/MainUtil.java | 17 + .../plot/util/PlayerFunctions.java | 8 +- .../plot/util/PlotHelper.java | 3 +- .../plot/util/SchematicHandler.java | 4 +- .../plot/util/TaskManager.java | 31 +- .../plot/util/bukkit/BukkitTaskManager.java | 29 + .../plot/util/bukkit/BukkitUtil.java | 86 +++ 27 files changed, 1151 insertions(+), 351 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 957591066..cafc78387 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -1,8 +1,212 @@ package com.intellectualcrafters.plot; +import java.io.File; +import java.util.Arrays; + +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.Bukkit; +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.Listener; +import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; -public class BukkitMain extends JavaPlugin implements Listener { +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.Settings; +import com.intellectualcrafters.plot.listeners.ForceFieldListener; +import com.intellectualcrafters.plot.listeners.InventoryListener; +import com.intellectualcrafters.plot.listeners.PlayerEvents; +import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; +import com.intellectualcrafters.plot.listeners.PlotListener; +import com.intellectualcrafters.plot.listeners.PlotPlusListener; +import com.intellectualcrafters.plot.listeners.WorldEditListener; +import com.intellectualcrafters.plot.util.Metrics; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; + +public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { + public static BukkitMain THIS = null; + public static PlotSquared MAIN = null; + + @Override + public void onEnable() { + MAIN = new PlotSquared(this); + THIS = this; + + if (Settings.METRICS) { + try { + final Metrics metrics = new Metrics(this); + metrics.start(); + log(C.PREFIX.s() + "&6Metrics enabled."); + } catch (final Exception e) { + log(C.PREFIX.s() + "&cFailed to load up metrics."); + } + } else { + log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); + } + + // TODO world load event + } + + @Override + public void onDisable() { + MAIN.disable(); + MAIN = null; + THIS = null; + } + + @Override + public void log(String message) { + // TODO Auto-generated method stub + } + + @Override + public void disable() { + onDisable(); + } + + @Override + public String getVersion() { + return this.getDescription().getVersion(); + } + + @Override + public void registerCommands() { + final MainCommand command = new MainCommand(); + final PluginCommand plotCommand = getCommand("plots"); + plotCommand.setExecutor(command); + plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot")); + plotCommand.setTabCompleter(command); + } + + @Override + public File getDirectory() { + return getDataFolder(); + } + + @Override + public TaskManager getTaskManager() { + return new BukkitTaskManager(); + } + + @Override + public void runEntityTask() { + log(C.PREFIX.s() + "KillAllEntities started."); + TaskManager.runTaskRepeat(new Runnable() { + long ticked = 0l; + long error = 0l; + @Override + public void run() { + if (this.ticked > 36_000L) { + this.ticked = 0l; + if (this.error > 0) { + log(C.PREFIX.s() + "KillAllEntities has been running for 6 hours. Errors: " + this.error); + } + this.error = 0l; + } + World world; + for (final String w : PlotSquared.getPlotWorlds()) { + world = Bukkit.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; + } + } + } + }, 20); + } + + 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; + } + } + + @Override + public void registerPlayerEvents() { + getServer().getPluginManager().registerEvents(new PlayerEvents(), this); + if (checkVersion(1, 8, 0)) { + getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); + } + } + + @Override + public void registerInventoryEvents() { + getServer().getPluginManager().registerEvents(new InventoryListener(), this); + } + + @Override + public void registerPlotPlusEvents() { + PlotPlusListener.startRunnable(this); + getServer().getPluginManager().registerEvents(new PlotPlusListener(), this); + } + + @Override + public void registerForceFieldEvents() { + getServer().getPluginManager().registerEvents(new ForceFieldListener(), this); + } + + @Override + public void registerWorldEditEvents() { + if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { + WorldEditPlugin worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + + final String version = worldEdit.getDescription().getVersion(); + if ((version != null) && version.startsWith("5.")) { + log("&cThis version of WorldEdit does not support PlotSquared."); + log("&cPlease use WorldEdit 6+ for masking support"); + log("&c - http://builds.enginehub.org/job/worldedit"); + } else { + getServer().getPluginManager().registerEvents(new WorldEditListener(), this); + MainCommand.subCommands.add(new WE_Anywhere()); + } + } + } + + @Override + public Economy getEconomy() { + 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) { + MainCommand.subCommands.add(new Buy()); + return economyProvider.getProvider(); + } + } + return null; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java new file mode 100644 index 000000000..8df37227d --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -0,0 +1,35 @@ +package com.intellectualcrafters.plot; + +import java.io.File; + +import net.milkbowl.vault.economy.Economy; + +import com.intellectualcrafters.plot.util.TaskManager; + +public interface IPlotMain { + public void log(String message); + + public File getDirectory(); + + public void disable(); + + public String getVersion(); + + public TaskManager getTaskManager(); + + public void runEntityTask(); + + public void registerCommands(); + + public void registerPlayerEvents(); + + public void registerInventoryEvents(); + + public void registerPlotPlusEvents(); + + public void registerForceFieldEvents(); + + public void registerWorldEditEvents(); + + public Economy getEconomy(); +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 5327239f9..64c3e3c10 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -45,6 +45,7 @@ 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; @@ -63,6 +64,11 @@ 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; + /** * PlotMain class. * @@ -70,6 +76,23 @@ import java.util.Map.Entry; * @author Empire92 */ public class PlotMain { + + /** + * 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 IPlotMain MAIN_IMP = new BukkitMain(); + /** * Permission that allows for "everything" */ @@ -86,27 +109,15 @@ public class PlotMain { * All world managers */ private final static HashMap managers = new HashMap<>(); - /** - * style - */ - public static File styleFile; - public static YamlConfiguration styleConfig; /** * settings.properties */ public static File configFile; - /** - * The main configuration file - */ - public static YamlConfiguration config; + /** * storage.properties */ public static File storageFile; - /** - * Contains storage options - */ - public static YamlConfiguration storage; /** * MySQL Connection */ @@ -152,92 +163,6 @@ public class PlotMain { public static MySQL getMySQL() { return mySQL; } - /** - * 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 static int hasPermissionRange(final Player player, final String stub, final int range) { - if ((player == null) || player.isOp() || player.hasPermission(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 static boolean hasPermissions(final Player player, final String[] perms) { - // Assumes null player is console. - if ((player == null) || player.isOp() || player.hasPermission(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 static boolean hasPermission(final Player player, final String perm) { - if ((player == null) || player.isOp() || player.hasPermission(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; - } /** * Get all plots @@ -265,36 +190,13 @@ public class PlotMain { return new LinkedHashSet<>(_plots); } - /** - * @param player player - * - * @return Set Containing the players plots - * - ignores non plot worlds - */ - public static Set getPlots(final Player player) { - final UUID uuid = UUIDHandler.getUUID(player); - final ArrayList myplots = new ArrayList<>(); - for (final String world : plots.keySet()) { - if (isPlotWorld(world)) { - for (final Plot plot : plots.get(world).values()) { - if (plot.hasOwner()) { - if (plot.getOwner().equals(uuid)) { - myplots.add(plot); - } - } - } - } - } - return new HashSet<>(myplots); - } - /** * @param world plot world * @param player plot owner * * @return players plots */ - public static Set getPlots(final World world, final Player player) { + public static Set getPlots(final String world, final String player) { final UUID uuid = UUIDHandler.getUUID(player); return getPlots(world, uuid); } @@ -305,7 +207,7 @@ public class PlotMain { * * @return players plots */ - public static Set getPlots(final World world, final UUID 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()) { @@ -317,28 +219,14 @@ public class PlotMain { return new HashSet<>(myplots); } - /** - * Get plots for the specified world - * - * @param world A world, in which you want to search for plots - * - * @return HashMap containing Plot IDs and Plot Objects - */ - public static HashMap getPlots(final String world) { - if (plots.containsKey(world)) { - return plots.get(world); - } - return new HashMap<>(); - } - /** * @param world plot world * * @return plots in world */ - public static HashMap getPlots(final World world) { - if (plots.containsKey(world.getName())) { - return plots.get(world.getName()); + public static HashMap getPlots(final String world) { + if (plots.containsKey(world)) { + return plots.get(world); } return new HashMap<>(); } @@ -359,15 +247,6 @@ public class PlotMain { return strings.toArray(new String[strings.size()]); } - /** - * @param world plotworld(?) - * - * @return true if the world is a plotworld - */ - public static boolean isPlotWorld(final World world) { - return (worlds.containsKey(world.getName())); - } - /** * @param world plotworld(?) * @@ -378,19 +257,7 @@ public class PlotMain { } /** - * @param world World to get manager for - * - * @return manager for world - */ - public static PlotManager getPlotManager(final World world) { - if (managers.containsKey(world.getName())) { - return managers.get(world.getName()); - } - return null; - } - - /** - * @param world world + * @param String world * * @return PlotManager */ @@ -401,17 +268,6 @@ public class PlotMain { return null; } - /** - * @param world to search - * - * @return PlotWorld object - */ - public static PlotWorld getWorldSettings(final World world) { - if (worlds.containsKey(world.getName())) { - return worlds.get(world.getName()); - } - return null; - } /** * @param world to search @@ -426,12 +282,12 @@ public class PlotMain { } /** - * @param world world to search + * @param String world to search * * @return set containing the plots for a world */ - public static Plot[] getWorldPlots(final World world) { - final Collection values = plots.get(world.getName()).values(); + public static Plot[] getWorldPlots(final String world) { + final Collection values = plots.get(world).values(); return (values.toArray(new Plot[values.size()])); } @@ -446,15 +302,11 @@ public class PlotMain { */ public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) { if (callEvent) { - final PlotDeleteEvent event = new PlotDeleteEvent(world, id); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - event.setCancelled(true); + 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); @@ -464,7 +316,6 @@ public class PlotMain { PlotHelper.lastPlot.put(world, id); } } - return true; } @@ -500,22 +351,6 @@ public class PlotMain { return connection; } - /** - * Send a message to the console. - * - * @param string message - */ - public static void sendConsoleSenderMessage(final String string) { - if (PlotMain.main == null || getMain().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); - } - getMain().getServer().getConsoleSender().sendMessage(message); - } - } /** * Teleport a player to a plot @@ -526,26 +361,30 @@ public class PlotMain { * * @return true if successful */ - public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) { - Plot bot = PlayerFunctions.getBottomPlot(player.getWorld(), plot); + 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); - if ((location.getBlockX() >= 29999999) || (location.getBlockX() <= -29999999) || (location.getBlockZ() >= 299999999) || (location.getBlockZ() <= -29999999)) { + + 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 World world = player.getWorld(); - final int x = loc.getBlockX(); - final int z = loc.getBlockZ(); + final String world = player.getWorld(); final String name = player.getName(); TaskManager.TELEPORT_QUEUE.add(name); TaskManager.runTaskLater(new Runnable() { @@ -576,25 +415,7 @@ public class PlotMain { } return !event.isCancelled(); } - - /** - * Send a message to the console - * - * @param c message - */ - public static void sendConsoleSenderMessage(final C c) { - sendConsoleSenderMessage(c.s()); - } - - /** - * Broadcast publicly - * - * @param c message - */ - public static void Broadcast(final C c) { - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())); - } - + /** * Returns the main class. * @@ -762,7 +583,7 @@ public class PlotMain { } this.error = 0l; } - World world; + String world; for (final String w : getPlotWorlds()) { getWorldSettings(w); world = Bukkit.getServer().getWorld(w); @@ -803,7 +624,6 @@ public class PlotMain { 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("worldguard.enabled", Settings.WORLDGUARD); 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); @@ -815,14 +635,9 @@ public class PlotMain { 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.api.location", Settings.API_URL); -// options.put("uuid.api.custom", Settings.CUSTOM_API); -// options.put("uuid.fecthing", Settings.UUID_FECTHING); 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("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED); -// options.put("perm-based-mob-cap.max", Settings.MOB_CAP); options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); for (final Entry node : options.entrySet()) { @@ -841,7 +656,6 @@ public class PlotMain { 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.WORLDGUARD = config.getBoolean("worldguard.enabled"); Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding"); Settings.METRICS = config.getBoolean("metrics"); @@ -850,15 +664,11 @@ public class PlotMain { Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area"); Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.TITLES = config.getBoolean("titles"); -// Settings.MOB_CAP_ENABLED = config.getBoolean("perm-based-mob-cap.enabled"); -// Settings.MOB_CAP = config.getInt("perm-based-mob-cap.max"); 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"); @@ -870,7 +680,7 @@ public class PlotMain { /** * Create a plotworld config section * - * @param plotworld World to create the section for + * @param plotString world to create the section for */ public static void createConfiguration(final PlotWorld plotworld) { final Map options = new HashMap<>(); @@ -1010,12 +820,12 @@ public class PlotMain { * * @param world to load */ - public static void loadWorld(final World world) { + public static void loadWorld(final String world) { if (world == null) { return; } final ChunkGenerator generator = world.getGenerator(); - loadWorld(world.getName(), generator); + loadWorld(world, generator); } public static void setupStyle() { @@ -1170,7 +980,7 @@ public class PlotMain { /** * Remove a plot world * - * @param world World to remove + * @param String world to remove */ public static void removePlotWorld(final String world) { plots.remove(world); @@ -1348,34 +1158,117 @@ public class PlotMain { } /** - * Setup the logger mechanics + * 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 */ - private void setupLogger() { - final File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log"); - if (!log.exists()) { - try { - if (!new File(getMain().getDataFolder() + File.separator + "logs").mkdirs()) { - sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create logs folder. Do it manually."); - } - if (log.createNewFile()) { - final FileWriter writer = new FileWriter(log); - writer.write("Created at: " + new Date().toString() + "\n\n\n"); - writer.close(); - } - } catch (final IOException e) { - - e.printStackTrace(); + public int hasPermissionRange(final Player player, final String stub, final int range) { + if ((player == null) || player.isOp() || player.hasPermission(PlotMain.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; } } - Logger.setup(log); - Logger.add(LogLevel.GENERAL, "Logger enabled"); + 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(PlotMain.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(PlotMain.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. */ - @Override - final public void onEnable() { + public PlotMain() { PlotMain.main = this; // Setup the logger mechanics setupLogger(); @@ -1638,12 +1531,10 @@ public class PlotMain { Broadcast(C.ENABLED); } } - /** * On unload */ - @Override - final public void onDisable() { + public void disable() { Logger.add(LogLevel.GENERAL, "Logger disabled"); try { Logger.write(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java new file mode 100644 index 000000000..14d66d1fb --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -0,0 +1,514 @@ +package com.intellectualcrafters.plot; + +import java.io.File; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.ChatColor; +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.Settings; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.database.MySQL; +import com.intellectualcrafters.plot.database.SQLManager; +import com.intellectualcrafters.plot.database.SQLite; +import com.intellectualcrafters.plot.flag.AbstractFlag; +import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.flag.FlagValue; +import com.intellectualcrafters.plot.object.Plot; +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.Logger.LogLevel; +import com.intellectualcrafters.plot.util.TaskManager; + +public class PlotSquared { + + public static File styleFile; + public static YamlConfiguration style; + + public static File configFile; + public static YamlConfiguration config; + + public static File storageFile; + public static YamlConfiguration storage; + + public static PlotSquared THIS = null; // This class + public static IPlotMain IMP = null; // Specific implementation of PlotSquared + public static String VERSION = null; + public static TaskManager TASK = null; + public static Economy economy = null; + + private final static HashMap plotworlds = new HashMap<>(); + private final static HashMap plotmanagers = new HashMap<>(); + private static LinkedHashMap> plots; + + private static MySQL mySQL; + public static Connection connection; + + public static MySQL getMySQL() { + return mySQL; + } + + public static Connection getConnection() { + return connection; + } + + public PlotSquared(IPlotMain imp_class) { + THIS = this; + IMP = imp_class; + VERSION = IMP.getVersion(); + + C.setupTranslations(); + C.saveTranslations(); + + if (getJavaVersion() < 1.7) { + log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); + // Didn't know of any other link :D + log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); + IMP.disable(); + return; + } + if (getJavaVersion() < 1.8) { + log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); + } + + TASK = IMP.getTaskManager(); + if (Settings.KILL_ROAD_MOBS) { + IMP.runEntityTask(); + } + if (C.ENABLED.s().length() > 0) { + log(C.ENABLED.s()); + } + + setupConfigs(); + setupDefaultFlags(); + setupDatabase(); + + // Events + IMP.registerCommands(); + IMP.registerPlayerEvents(); + IMP.registerInventoryEvents(); + IMP.registerPlotPlusEvents(); + IMP.registerForceFieldEvents(); + IMP.registerWorldEditEvents(); + + if (Settings.AUTO_CLEAR) { + ExpireManager.runTask(); + } + + economy = IMP.getEconomy(); + } + + public void disable() { + try { + connection.close(); + mySQL.closeConnection(); + } catch (NullPointerException | SQLException e) { + if (connection != null) { + log("&cCould not close mysql connection!"); + } + } + } + + public static void log(String message) { + IMP.log(message); + } + + public void setupDatabase() { + 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"}; + } + 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); + } + } + } + } + } catch (final Exception e) { + log("&c[Plots] MySQL is not setup correctly. The plugin will disable itself."); + if ((config == null) || config.getBoolean("debug")) { + log("&d==== Here is an ugly stacktrace if you are interested in those things ===="); + e.printStackTrace(); + log("&d==== End of stacktrace ===="); + log("&6Please go to the PlotSquared 'storage.yml' and configure MySQL correctly."); + } + IMP.disable(); + return; + } + plots = DBFunc.getPlots(); + if (Settings.ENABLE_CLUSTERS) { + ClusterManager.clusters = DBFunc.getClusters(); + } + } + else if (Settings.DB.USE_MONGO) { + // DBFunc.dbManager = new MongoManager(); + log(C.PREFIX.s() + "MongoDB is not yet implemented"); + } + else if (Settings.DB.USE_SQLITE) { + try { + connection = new SQLite(THIS, IMP.getDirectory() + 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) { + log(C.PREFIX.s() + "&cFailed to open SQLite connection. The plugin will disable itself."); + log("&9==== Here is an ugly stacktrace, if you are interested in those things ==="); + e.printStackTrace(); + IMP.disable(); + return; + } + plots = DBFunc.getPlots(); + if (Settings.ENABLE_CLUSTERS) { + ClusterManager.clusters = DBFunc.getClusters(); + } + } else { + log(C.PREFIX + "&cNo storage type is set!"); + IMP.disable(); + return; + } + + } + + public static void setupDefaultFlags() { + 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())); + } + 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'"; + } + }); + } + + public static void setupConfig() { + config.set("version", VERSION); + 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) { + log(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) { + log("&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"); + } + + public static void setupConfigs() { + final File folder = new File(IMP.getDirectory() + File.separator + "config"); + if (!folder.exists() && !folder.mkdirs()) { + log(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually."); + } + try { + styleFile = new File(IMP.getDirectory() + File.separator + "translations" + File.separator + "style.yml"); + if (!styleFile.exists()) { + if (!styleFile.createNewFile()) { + log("Could not create the style file, please create \"translations/style.yml\" manually"); + } + } + style = 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(IMP.getDirectory() + File.separator + "config" + File.separator + "settings.yml"); + if (!configFile.exists()) { + if (!configFile.createNewFile()) { + log("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(IMP.getDirectory() + File.separator + "config" + File.separator + "storage.yml"); + if (!storageFile.exists()) { + if (!storageFile.createNewFile()) { + log("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 { + style.save(styleFile); + config.save(configFile); + storage.save(storageFile); + } catch (final IOException e) { + Logger.add(LogLevel.DANGER, "Configuration file saving failed"); + e.printStackTrace(); + } + } + + private static void setupStorage() { + storage.set("version", VERSION); + 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()); + } + } + } + + public static void showDebug() { + 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(style.getString("color.1")); + C.COLOR_2 = ChatColor.getByChar(style.getString("color.2")); + C.COLOR_3 = ChatColor.getByChar(style.getString("color.3")); + C.COLOR_4 = ChatColor.getByChar(style.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()) { + log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue())); + } + } + } + + private static void setupStyle() { + style.set("version", VERSION); + 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 (!style.contains(node.getKey())) { + style.set(node.getKey(), node.getValue()); + } + } + } + + public static double getJavaVersion() { + return Double.parseDouble(System.getProperty("java.specification.version")); + } + + public static Set getPlotWorlds() { + return plotworlds.keySet(); + } +} 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 38f4ff9b3..8df871d1c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -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().getDataFolder() + File.separator + "trim.txt"); + final File file = new File(PlotMain.getMain().getDirectory() + File.separator + "trim.txt"); PrintWriter writer; try { writer = new PrintWriter(file); 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 a5c945204..7a9b9b61d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; /** * Created 2014-08-01 for PlotSquared 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 023e072c1..157fea4fe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -46,7 +46,7 @@ public class Reload extends SubCommand { final PlotWorld plotworld = PlotMain.getWorldSettings(pw); plotworld.loadDefaultConfiguration(PlotMain.config.getConfigurationSection("worlds." + pw)); } - PlotMain.BroadcastWithPerms(C.RELOADED_CONFIGS); + MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); } catch (final Exception e) { PlayerFunctions.sendMessage(plr, C.RELOAD_FAILED); } 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 b3e200b1c..0dc6d56cd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -46,7 +46,7 @@ import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; public class Trim extends SubCommand { @@ -122,7 +122,7 @@ public class Trim extends SubCommand { if (Trim.TASK) { return false; } - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { String directory = world.getName() + File.separator + "region"; @@ -169,7 +169,7 @@ public class Trim extends SubCommand { } } Trim.TASK = false; - TaskManager.runTaskAsync(whenDone); + BukkitTaskManager.runTaskAsync(whenDone); } }); Trim.TASK = true; @@ -197,7 +197,7 @@ public class Trim extends SubCommand { empty.addAll(chunks); System.out.print("DONE!"); Trim.TASK = false; - TaskManager.runTaskAsync(whenDone); + BukkitTaskManager.runTaskAsync(whenDone); Bukkit.getScheduler().cancelTask(Trim.TASK_ID); return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java index 5d45248e1..b9e14899d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java @@ -27,6 +27,8 @@ import java.sql.SQLException; import org.bukkit.plugin.Plugin; +import com.intellectualcrafters.plot.PlotSquared; + /** * Abstract Database class, serves as a base for any connection method (MySQL, SQLite, etc.) * @@ -38,15 +40,15 @@ public abstract class Database { /** * Plugin instance, use for plugin.getDataFolder() */ - protected final Plugin plugin; + protected final PlotSquared plotsquared; /** * Creates a new Database * - * @param plugin Plugin instance + * @param plotsquared Plugin instance */ - protected Database(final Plugin plugin) { - this.plugin = plugin; + protected Database(final PlotSquared plotsquared) { + this.plotsquared = plotsquared; } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index 4ba7bc7ad..2dd5a0f3c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -29,6 +29,8 @@ import java.sql.Statement; import org.bukkit.plugin.Plugin; +import com.intellectualcrafters.plot.PlotSquared; + /** * Connects to and uses a MySQL database * @@ -54,8 +56,8 @@ public class MySQL extends Database { * @param username Username * @param password Password */ - public MySQL(final Plugin plugin, final String hostname, final String port, final String database, final String username, final String password) { - super(plugin); + public MySQL(final PlotSquared plotsquared, final String hostname, final String port, final String database, final String username, final String password) { + super(plotsquared); this.hostname = hostname; this.port = port; this.database = database; @@ -64,6 +66,7 @@ public class MySQL extends Database { this.connection = null; } + public Connection forceConnection() throws SQLException, ClassNotFoundException { Class.forName("com.mysql.jdbc.Driver"); this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); 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 1db8dc90c..25de2b636 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -49,7 +49,7 @@ import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; /** * @author Citymonstret @@ -114,7 +114,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setOwner(final Plot plot, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -310,7 +310,7 @@ public class SQLManager implements AbstractDB { */ @Override public void createPlot(final Plot plot) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -332,7 +332,7 @@ public class SQLManager implements AbstractDB { @Override public void createPlotAndSettings(final Plot plot) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -412,7 +412,7 @@ public class SQLManager implements AbstractDB { @Override public void delete(final String world, final Plot plot) { PlotMain.removePlot(world, plot.id, false); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -453,7 +453,7 @@ public class SQLManager implements AbstractDB { */ @Override public void createPlotSettings(final int id, final Plot plot) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -735,7 +735,7 @@ public class SQLManager implements AbstractDB { @Override public void setMerged(final String world, final Plot plot, final boolean[] merged) { plot.settings.setMerged(merged); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -758,7 +758,7 @@ public class SQLManager implements AbstractDB { @Override public void swapPlots(final Plot p1, final Plot p2) { - TaskManager.runTaskAsync( + BukkitTaskManager.runTaskAsync( new Runnable() { @Override public void run() { @@ -795,7 +795,7 @@ public class SQLManager implements AbstractDB { @Override public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { - TaskManager.runTaskAsync( + BukkitTaskManager.runTaskAsync( new Runnable() { @Override public void run() { @@ -826,7 +826,7 @@ public class SQLManager implements AbstractDB { flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4")); i++; } - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -851,7 +851,7 @@ public class SQLManager implements AbstractDB { } } final String flag_string = StringUtils.join(newflags, ","); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -875,7 +875,7 @@ public class SQLManager implements AbstractDB { @Override public void setAlias(final String world, final Plot plot, final String alias) { plot.settings.setAlias(alias); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -969,7 +969,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setPosition(final String world, final Plot plot, final String position) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1042,7 +1042,7 @@ public class SQLManager implements AbstractDB { @Override public void removeComment(final String world, final Plot plot, final PlotComment comment) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1104,7 +1104,7 @@ public class SQLManager implements AbstractDB { @Override public void setComment(final String world, final Plot plot, final PlotComment comment) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1130,7 +1130,7 @@ public class SQLManager implements AbstractDB { */ @Override public void removeHelper(final String world, final Plot plot, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1153,7 +1153,7 @@ public class SQLManager implements AbstractDB { */ @Override public void removeTrusted(final String world, final Plot plot, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1176,7 +1176,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setHelper(final String world, final Plot plot, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1194,7 +1194,7 @@ public class SQLManager implements AbstractDB { } public void setHelper(final int id, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1217,7 +1217,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setTrusted(final String world, final Plot plot, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1240,7 +1240,7 @@ public class SQLManager implements AbstractDB { */ @Override public void removeDenied(final String world, final Plot plot, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1263,7 +1263,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setDenied(final String world, final Plot plot, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1303,7 +1303,7 @@ public class SQLManager implements AbstractDB { @Override public void delete(final PlotCluster cluster) { ClusterManager.removeCluster(cluster); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1560,7 +1560,7 @@ public class SQLManager implements AbstractDB { flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4")); i++; } - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1581,7 +1581,7 @@ public class SQLManager implements AbstractDB { @Override public void setClusterName(final PlotCluster cluster, final String name) { cluster.settings.setAlias(name); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1602,7 +1602,7 @@ public class SQLManager implements AbstractDB { @Override public void removeHelper(final PlotCluster cluster, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1621,7 +1621,7 @@ public class SQLManager implements AbstractDB { @Override public void setHelper(final PlotCluster cluster, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1640,7 +1640,7 @@ public class SQLManager implements AbstractDB { @Override public void createCluster(final PlotCluster cluster) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1675,7 +1675,7 @@ public class SQLManager implements AbstractDB { final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y); current.setP1(resize.pos1); current.setP2(resize.pos2); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1698,7 +1698,7 @@ public class SQLManager implements AbstractDB { @Override public void setPosition(final PlotCluster cluster, final String position) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1766,7 +1766,7 @@ public class SQLManager implements AbstractDB { @Override public void removeInvited(final PlotCluster cluster, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1786,7 +1786,7 @@ public class SQLManager implements AbstractDB { @Override public void setInvited(String world, final PlotCluster cluster, final UUID uuid) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index d029259b5..392381d04 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -32,6 +32,8 @@ import java.util.logging.Level; import org.bukkit.plugin.Plugin; +import com.intellectualcrafters.plot.PlotSquared; + /** * Connects to and uses a SQLite database * @@ -49,8 +51,8 @@ public class SQLite extends Database { * @param plugin Plugin instance * @param dbLocation Location of the Database (Must end in .db) */ - public SQLite(final Plugin plugin, final String dbLocation) { - super(plugin); + public SQLite(final PlotSquared plotsquared, final String dbLocation) { + super(plotsquared); this.dbLocation = dbLocation; } @@ -59,7 +61,7 @@ public class SQLite extends Database { if (checkConnection()) { return this.connection; } - if (!this.plugin.getDataFolder().exists()) { + if (!this.plotsquared.IMP.getDirectory().exists()) { this.plugin.getDataFolder().mkdirs(); } final File file = new File(this.dbLocation); 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 0e0bee151..38b69c74b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -20,7 +20,7 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; public class AugmentedPopulator extends BlockPopulator { @@ -127,7 +127,7 @@ public class AugmentedPopulator extends BlockPopulator { if (this.o) { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); - TaskManager.runTaskLater(new Runnable() { + BukkitTaskManager.runTaskLater(new Runnable() { @Override public void run() { populateBiome(world, x, z); @@ -137,13 +137,13 @@ public class AugmentedPopulator extends BlockPopulator { }, 20); } else { - TaskManager.runTaskLater(new Runnable() { + BukkitTaskManager.runTaskLater(new Runnable() { @Override public void run() { populateBiome(world, x, z); } }, 20 + rand.nextInt(10)); - TaskManager.runTaskLater(new Runnable() { + BukkitTaskManager.runTaskLater(new Runnable() { @Override public void run() { chunk.load(true); 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 223d1e4af..581a8fa33 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -46,8 +46,8 @@ import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; @SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager { @@ -147,7 +147,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2); CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4); - String dir = PlotMain.getMain().getDataFolder() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator; + String dir = PlotMain.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"); @@ -734,7 +734,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; @Override public void run() { PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); - TaskManager.runTask(whenDone); + BukkitTaskManager.runTask(whenDone); } }, 1L); } 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 356aa1eda..6f4d317db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -99,8 +99,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; /** * Player Events involving plots @@ -161,10 +161,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location t = event.getTo(); final Location q = new Location(t.getWorld(), t.getBlockX(), 0, t.getZ()); if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { - if (Settings.TELEPORT_DELAY != 0 && TaskManager.TELEPORT_QUEUE.size() > 0) { + if (Settings.TELEPORT_DELAY != 0 && BukkitTaskManager.TELEPORT_QUEUE.size() > 0) { String name = player.getName(); - if (TaskManager.TELEPORT_QUEUE.contains(name)) { - TaskManager.TELEPORT_QUEUE.remove(name); + if (BukkitTaskManager.TELEPORT_QUEUE.contains(name)) { + BukkitTaskManager.TELEPORT_QUEUE.remove(name); } } if (!isPlotWorld(player.getWorld())) { @@ -925,11 +925,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Entity d = e.getDamager(); final Entity a = e.getEntity(); - if (Settings.TELEPORT_DELAY != 0 && TaskManager.TELEPORT_QUEUE.size() > 0 && a instanceof Player) { + if (Settings.TELEPORT_DELAY != 0 && BukkitTaskManager.TELEPORT_QUEUE.size() > 0 && a instanceof Player) { Player player = (Player) a; String name = player.getName(); - if (TaskManager.TELEPORT_QUEUE.contains(name)) { - TaskManager.TELEPORT_QUEUE.remove(name); + if (BukkitTaskManager.TELEPORT_QUEUE.contains(name)) { + BukkitTaskManager.TELEPORT_QUEUE.remove(name); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 3ca64496b..302bd8f90 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util; import org.bukkit.World; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class BlockManager { @@ -33,7 +34,7 @@ public abstract class BlockManager { public abstract void functionSetBlock(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data); - public abstract void setSign(String worldname, int x, int y, int z); + public abstract void setSign(String worldname, int x, int y, int z, String[] lines); public static void setBlocks(String worldname, int[] x, int y[], int z[], PlotBlock[][] blocks) { 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 6831d5014..349f340ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -46,6 +46,7 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; public class ChunkManager { @@ -94,7 +95,7 @@ public class ChunkManager { } public static void deleteRegionFile(final String world, final ChunkLoc loc) { - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca"; @@ -198,7 +199,7 @@ public class ChunkManager { if (toGenerate.size() == 0) { Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); tasks.remove(currentIndex); - TaskManager.runTask(new Runnable() { + BukkitTaskManager.runTask(new Runnable() { @Override public void run() { index.increment(); @@ -241,7 +242,7 @@ public class ChunkManager { for (Chunk chunk : chunks) { chunk.unload(true, true); } - TaskManager.runTaskLater(whenDone, 1); + BukkitTaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); tasks.remove(currentIndex); return; @@ -298,7 +299,7 @@ public class ChunkManager { @Override public void run() { if (chunks.size() == 0) { - TaskManager.runTaskLater(whenDone, 1); + BukkitTaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); tasks.remove(currentIndex); return; 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 3c26fcae9..964274af4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; public class ClusterManager { public static HashMap> clusters; @@ -264,7 +265,7 @@ public class ClusterManager { final AugmentedPopulator populator = getPopulator(cluster); final ArrayList chunks = new ArrayList<>(); - TaskManager.runTaskLater(new Runnable() { + BukkitTaskManager.runTaskLater(new Runnable() { @Override public void run() { ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName()); @@ -284,7 +285,7 @@ public class ClusterManager { } for (final Chunk chunk : chunks) { i+=interval; - TaskManager.runTaskLater(new Runnable() { + BukkitTaskManager.runTaskLater(new Runnable() { @Override public void run() { if (populator == null || plotworld.TYPE == 0) { 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 1ddccba7a..13db69eee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -22,6 +22,7 @@ import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; public class ExpireManager { @@ -45,7 +46,7 @@ public class ExpireManager { long now = System.currentTimeMillis(); if (now > getTimeStamp(world)) { timestamp.put(world, now + 86400000l); - TaskManager.runTaskAsync(new Runnable() { + BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { HashMap plots = getOldPlots(world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java index aab5b37cc..14ed465bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java @@ -74,7 +74,6 @@ public class Lag implements Runnable { * * @return number of ticks since $tI */ - @SuppressWarnings("unused") public static long getElapsed(final int tI) { final long t = T[tI % T.length]; return System.currentTimeMillis() - t; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java new file mode 100644 index 000000000..7245fade4 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -0,0 +1,17 @@ +package com.intellectualcrafters.plot.util; + +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.config.C; + +public class MainUtil { + // TODO messages / permission stuff + + /** + * Send a message to the console + * + * @param c message + */ + public static void sendConsoleSenderMessage(final C c) { + PlotMain.MAIN_IMP.sendConsoleSenderMessage(c.s()); + } +} 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 e3083971e..39d0ac3a4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -28,6 +28,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; + import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; @@ -236,7 +237,7 @@ import java.util.UUID; * @return */ public static int getAllowedPlots(final Player p) { - return PlotMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); + return PlotMain.MAIN_IMP.(p, "plots.plot", Settings.MAX_PLOTS); } /** @@ -248,7 +249,7 @@ import java.util.UUID; public static Set getPlots() { return PlotMain.getPlots(); } - + /** * \\previous\\ * @@ -285,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.sendConsoleSenderMessage(C.PREFIX.s() + msg); + PlotMain.MAIN_IMP.sendConsoleSenderMessage(C.PREFIX.s() + msg); } else { sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); } @@ -320,4 +321,5 @@ import java.util.UUID; } return true; } + } 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 1e00a51fe..9029e156d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -31,7 +31,6 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.Chunk; - import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.World; @@ -48,13 +47,13 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Location; - import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.bukkit.TaskManager; /** * plot functions 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 b0b28b22f..020d2a2b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -170,14 +170,14 @@ public class SchematicHandler { */ public static Schematic getSchematic(final String name) { { - final File parent = new File(PlotMain.getMain().getDataFolder() + File.separator + "schematics"); + final File parent = new File(PlotMain.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().getDataFolder() + File.separator + "schematics" + File.separator + name + ".schematic"); + final File file = new File(PlotMain.getMain().getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); if (!file.exists()) { PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist"); return null; 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 60640aa27..abbe37868 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -2,24 +2,37 @@ package com.intellectualcrafters.plot.util; import java.util.HashSet; -import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSquared; -public class TaskManager { +public abstract class TaskManager { - public static HashSet TELEPORT_QUEUE = new HashSet<>(); + public HashSet TELEPORT_QUEUE = new HashSet<>(); + + public abstract void taskRepeat(final Runnable r, int interval); + + public abstract void taskAsync(final Runnable r); + + public abstract void task(final Runnable r); + + public abstract void taskLater(final Runnable r, int delay); + + public static void runTaskRepeat(final Runnable r, int interval) { + if (r != null) + PlotSquared.TASK.taskRepeat(r, interval); + } public static void runTaskAsync(final Runnable r) { - PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), r); + if (r != null) + PlotSquared.TASK.taskAsync(r); } public static void runTask(final Runnable r) { - PlotMain.getMain().getServer().getScheduler().runTask(PlotMain.getMain(), r); + if (r != null) + PlotSquared.TASK.task(r); } public static void runTaskLater(final Runnable r, int delay) { - if (r == null) { - return; - } - PlotMain.getMain().getServer().getScheduler().runTaskLater(PlotMain.getMain(), r, delay); + if (r != null) + PlotSquared.TASK.taskLater(r, delay); } } 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 new file mode 100644 index 000000000..822008283 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java @@ -0,0 +1,29 @@ +package com.intellectualcrafters.plot.util.bukkit; + +import java.util.HashSet; + +import com.intellectualcrafters.plot.BukkitMain; +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.util.TaskManager; + +public class BukkitTaskManager extends TaskManager { + + public void taskRepeat(final Runnable r, int interval) { + BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval); + } + + public void taskAsync(final Runnable r) { + BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r); + } + + public void task(final Runnable r) { + BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r); + } + + public void taskLater(final Runnable r, int delay) { + if (r == null) { + return; + } + BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay); + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java new file mode 100644 index 000000000..fe5ff42a2 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -0,0 +1,86 @@ +package com.intellectualcrafters.plot.util.bukkit; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.block.Sign; + +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.SetBlockManager; +import com.intellectualcrafters.plot.util.SetBlockSlow; + +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]); + } + } + + @Override + public void setSign(String worldname, int x, int y, int z, String[] lines) { + World world = getWorld(worldname); + Block block = world.getBlockAt(x, y, z); + block.setType(Material.AIR); + block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); + BlockState blockstate = block.getState(); + if ((blockstate instanceof Sign)) { + for (int i = 0; i < lines.length; i++) { + ((Sign) blockstate).setLine(i, lines[i]); + } + } + } + +} From fde378c96563473b4d522d2cd3664c99d8b7be35 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 19:51:10 +1100 Subject: [PATCH 004/124] More changes --- .../intellectualcrafters/plot/BukkitMain.java | 143 +- .../intellectualcrafters/plot/IPlotMain.java | 11 +- .../plot/PlotSquared.java | 331 ++++ .../intellectualcrafters/plot/_PlotMain.java | 1553 +++++++++++++++++ .../plot/api/PlotAPI.java | 1186 ++++++------- .../plot/commands/Auto.java | 23 +- .../plot/commands/Buy.java | 10 +- .../plot/commands/Claim.java | 18 +- .../plot/commands/Clear.java | 16 +- .../plot/commands/Cluster.java | 56 +- .../plot/commands/CommandPermission.java | 4 +- .../plot/commands/Comment.java | 4 +- .../plot/commands/Condense.java | 10 +- .../plot/commands/Copy.java | 4 +- .../plot/commands/CreateRoadSchematic.java | 6 +- .../plot/commands/Database.java | 12 +- .../plot/commands/Debug.java | 8 +- .../plot/commands/DebugClaimTest.java | 14 +- .../plot/commands/DebugClear.java | 20 +- .../plot/commands/DebugExec.java | 6 +- .../plot/commands/DebugFixFlags.java | 6 +- .../plot/commands/DebugLoadTest.java | 8 +- .../plot/commands/DebugRoadRegen.java | 6 +- .../plot/commands/DebugSaveTest.java | 4 +- .../plot/commands/Delete.java | 12 +- .../plot/commands/Denied.java | 4 +- .../plot/commands/FlagCmd.java | 20 +- .../plot/commands/Helpers.java | 4 +- .../plot/commands/Home.java | 10 +- .../plot/commands/Inbox.java | 6 +- .../plot/commands/Info.java | 6 +- .../plot/commands/Kick.java | 4 +- .../plot/commands/MainCommand.java | 11 +- .../plot/commands/Merge.java | 12 +- .../plot/commands/Move.java | 2 +- .../plot/commands/Paste.java | 4 +- .../plot/commands/Purge.java | 12 +- .../plot/commands/RegenAllRoads.java | 14 +- .../plot/commands/Reload.java | 12 +- .../plot/commands/Schematic.java | 28 +- .../plot/commands/Set.java | 32 +- .../plot/commands/SetOwner.java | 12 +- .../plot/commands/Setup.java | 14 +- .../plot/commands/Swap.java | 8 +- .../plot/commands/TP.java | 12 +- .../plot/commands/Target.java | 4 +- .../plot/commands/Template.java | 4 +- .../plot/commands/Trim.java | 16 +- .../plot/commands/Trusted.java | 4 +- .../plot/commands/Unclaim.java | 14 +- .../plot/commands/Unlink.java | 12 +- .../plot/commands/Visit.java | 8 +- .../plot/commands/WE_Anywhere.java | 6 +- .../plot/commands/list.java | 26 +- .../plot/commands/plugin.java | 6 +- .../intellectualcrafters/plot/config/C.java | 8 +- .../plot/database/PlotMeConverter.java | 65 +- .../plot/database/SQLManager.java | 132 +- .../plot/flag/FlagManager.java | 12 +- .../plot/generator/AugmentedPopulator.java | 4 +- .../plot/generator/ClassicPlotManager.java | 2 +- .../plot/generator/ClassicPlotWorld.java | 4 +- .../plot/generator/HybridGen.java | 4 +- .../plot/generator/HybridPlotManager.java | 26 +- .../plot/generator/HybridPlotWorld.java | 8 +- .../plot/generator/HybridPop.java | 4 +- .../plot/generator/SquarePlotManager.java | 10 +- .../plot/generator/SquarePlotWorld.java | 4 +- .../plot/listeners/PlayerEvents.java | 96 +- .../plot/listeners/PlayerEvents_1_8.java | 8 +- .../plot/listeners/PlotListener.java | 14 +- .../plot/listeners/PlotPlusListener.java | 6 +- .../plot/listeners/WorldEditListener.java | 22 +- .../plot/listeners/WorldGuardListener.java | 26 +- .../plot/object/Plot.java | 4 +- .../plot/object/PlotGenerator.java | 4 +- .../plot/object/PlotHologram.java | 6 +- .../plot/object/PlotWorld.java | 4 +- .../plot/object/entity/EntityWrapper.java | 6 +- .../plot/titles/HackTitle.java | 4 +- .../plot/util/BukkitUtil.java | 65 - .../plot/util/ChunkManager.java | 40 +- .../plot/util/ClusterManager.java | 24 +- .../plot/util/ExpireManager.java | 30 +- .../plot/util/Logger.java | 4 +- .../plot/util/MainUtil.java | 4 +- .../intellectualcrafters/plot/util/PWE.java | 30 +- .../plot/util/PlayerFunctions.java | 44 +- .../plot/util/PlotHelper.java | 98 +- .../plot/util/PlotSquaredException.java | 6 +- .../plot/util/SchematicHandler.java | 18 +- .../plot/util/TaskManager.java | 7 + .../plot/util/UUIDHandler.java | 14 +- .../plot/util/bukkit/BukkitTaskManager.java | 2 +- .../translation/bukkit/BukkitTranslation.java | 6 +- PlotSquared/src/main/resources/plugin.yml | 4 +- 96 files changed, 3323 insertions(+), 1354 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitUtil.java 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'" From e7342d5a5e055f8f12e0dcc1ab9c850f63b42e91 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 19:51:48 +1100 Subject: [PATCH 005/124] . --- .../intellectualcrafters/plot/PlotMain.java | 1553 ----------------- 1 file changed, 1553 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java deleted file mode 100644 index 64c3e3c10..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ /dev/null @@ -1,1553 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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; - -/** - * PlotMain class. - * - * @author Citymonstret - * @author Empire92 - */ -public class PlotMain { - - /** - * 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 IPlotMain 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 PlotMain 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 PlotMain getMain() { - return PlotMain.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(PlotMain.configFile); - } catch (final IOException e) { - PlotMain.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(PlotMain.getMain()).runAsync(); - } catch (final Exception e) { - e.printStackTrace(); - } - } - } - } - - public static void loadWorld(final String world, final ChunkGenerator 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) { - PlotMain.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) { - PlotMain.plots = plots; - } - - /** - * Set all plots - * - * @param plots New Plot HashMap - */ - public static void setAllPlotsRaw(final HashMap> plots) { - PlotMain.plots = new LinkedHashMap<>(plots); - // PlotMain.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(PlotMain.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(PlotMain.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(PlotMain.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 PlotMain() { - PlotMain.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.")) { - PlotMain.sendConsoleSenderMessage("&cThis version of WorldEdit does not support PlotSquared."); - PlotMain.sendConsoleSenderMessage("&cPlease use WorldEdit 6+ for masking support"); - PlotMain.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"); - } - } - } -} From fcdbd341d87b7488fb900eda694f7bc75b4cd788 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 20:04:47 +1100 Subject: [PATCH 006/124] Permission checks --- .../plot/commands/Auto.java | 2 +- .../plot/commands/Claim.java | 2 +- .../plot/commands/Clear.java | 2 +- .../plot/commands/Cluster.java | 38 ++++----- .../plot/commands/CommandPermission.java | 2 +- .../plot/commands/Comment.java | 2 +- .../plot/commands/Copy.java | 2 +- .../plot/commands/DebugClear.java | 2 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/Denied.java | 2 +- .../plot/commands/FlagCmd.java | 18 ++-- .../plot/commands/Helpers.java | 2 +- .../plot/commands/Inbox.java | 2 +- .../plot/commands/Kick.java | 2 +- .../plot/commands/Merge.java | 2 +- .../plot/commands/Paste.java | 2 +- .../plot/commands/Schematic.java | 6 +- .../plot/commands/Set.java | 6 +- .../plot/commands/SetOwner.java | 2 +- .../plot/commands/Swap.java | 4 +- .../plot/commands/Trusted.java | 2 +- .../plot/commands/Unclaim.java | 2 +- .../plot/commands/Unlink.java | 2 +- .../plot/commands/WE_Anywhere.java | 2 +- .../plot/listeners/PlayerEvents.java | 82 +++++++++---------- .../plot/listeners/PlayerEvents_1_8.java | 6 +- .../plot/listeners/PlotPlusListener.java | 4 +- .../plot/listeners/WorldEditListener.java | 12 +-- .../plot/object/Plot.java | 2 +- .../intellectualcrafters/plot/util/PWE.java | 2 +- 30 files changed, 109 insertions(+), 109 deletions(-) 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 999172e68..5bab03572 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -154,7 +154,7 @@ public class Auto extends SubCommand { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return true; } - if (!PlotSquared.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { + if (!BukkitMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return true; } 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 8b6b5120f..2f1db2f48 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -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 (!PlotSquared.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { + if (!BukkitMain.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 b1cb3642a..8614b6a6d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -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))) && !PlotSquared.hasPermission(plr, "plots.admin.command.clear")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.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 f91e5f63a..437509315 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -64,7 +64,7 @@ public class Cluster extends SubCommand { switch (sub) { case "l": case "list": { - if (!PlotSquared.hasPermission(plr, "plots.cluster.list")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.create")) { + if (!BukkitMain.hasPermission(plr, "plots.cluster.create")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create"); return false; } @@ -153,7 +153,7 @@ public class Cluster extends SubCommand { case "disband": case "del": case "delete": { - if (!PlotSquared.hasPermission(plr, "plots.cluster.delete")) { + if (!BukkitMain.hasPermission(plr, "plots.cluster.delete")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); return false; } @@ -177,7 +177,7 @@ public class Cluster extends SubCommand { } } if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { - if (!PlotSquared.hasPermission(plr, "plots.cluster.delete.other")) { + if (!BukkitMain.hasPermission(plr, "plots.cluster.delete.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); return false; } @@ -216,7 +216,7 @@ public class Cluster extends SubCommand { } case "res": case "resize": { - if (!PlotSquared.hasPermission(plr, "plots.cluster.resize")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.resize.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.delete")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.regen.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.invite")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.invite.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.kick")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.kick.other")) { + if (!BukkitMain.hasPermission(plr, "plots.cluster.kick.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); return false; } @@ -388,7 +388,7 @@ public class Cluster extends SubCommand { } case "quit": case "leave": { - if (!PlotSquared.hasPermission(plr, "plots.cluster.leave")) { + if (!BukkitMain.hasPermission(plr, "plots.cluster.leave")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); return false; } @@ -439,7 +439,7 @@ public class Cluster extends SubCommand { case "admin": case "helper": case "helpers": { - if (!PlotSquared.hasPermission(plr, "plots.cluster.helpers")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.tp")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.tp.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.info")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.sethome")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.cluster.sethome.other")) { + if (!BukkitMain.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 cec179db2..9e17b4b1c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -50,6 +50,6 @@ public class CommandPermission { * @return true of player has the required permission node */ public boolean hasPermission(final Player player) { - return PlotSquared.hasPermission(player, this.permission); + return BukkitMain.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 b4d7883dc..f8040b252 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -54,7 +54,7 @@ public class Comment extends SubCommand { if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) { - if (PlotSquared.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) { + if (BukkitMain.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/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index 82cdcbff4..bb492b5e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -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))) && !PlotSquared.hasPermission(plr, "plots.admin.command.copy")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.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/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index ad5d70e13..02987fd26 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -91,7 +91,7 @@ public class DebugClear 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))) && !PlotSquared.hasPermission(plr, "plots.admin.command.debugclear")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.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/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index fdc86b7bf..7d41ddd31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -48,7 +48,7 @@ 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)))) && !PlotSquared.hasPermission(plr, "plots.admin.command.delete")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !BukkitMain.hasPermission(plr, "plots.admin.command.delete")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; 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 861380467..63ca9c501 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -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)) && !PlotSquared.hasPermission(plr, "plots.admin.command.denied")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.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 d2007c374..972bc5a10 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -67,13 +67,13 @@ public class FlagCmd extends SubCommand { sendMessage(player, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(player) && !PlotSquared.hasPermission(player, "plots.set.flag.other")) { + if (!plot.hasRights(player) && !BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.set.flag")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.set.flag")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.flag.remove")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.flag.add")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.flag.list")) { + if (!BukkitMain.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 cfc49b3d2..81219107a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -55,7 +55,7 @@ public class Helpers extends SubCommand { PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotSquared.hasPermission(plr, "plots.admin.command.helpers")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.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/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 5e5712432..d1f3d39ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -63,7 +63,7 @@ public class Inbox extends SubCommand { Integer tier; final UUID uuid = UUIDHandler.getUUID(plr); - if (PlotSquared.hasPermission(plr, "plots.comment.admin")) { + if (BukkitMain.hasPermission(plr, "plots.comment.admin")) { tier = 0; } else if (plot != null && plot.owner.equals(uuid)) { tier = 1; 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 81e111c13..e70767edd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -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))) && !PlotSquared.hasPermission(plr, "plots.admin.command.kick")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.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/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index fc849d910..c2330fd1e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -85,7 +85,7 @@ public class Merge extends SubCommand { PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - boolean admin = PlotSquared.hasPermission(plr, "plots.admin.command.merge"); + boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge"); if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; 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 1d5003b0e..343ae313b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -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))) && !PlotSquared.hasPermission(plr, "plots.admin.command.paste")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.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/Schematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java index 986555c73..be7f0aff9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -70,7 +70,7 @@ public class Schematic extends SubCommand { PlotSquared.sendConsoleSenderMessage(C.IS_CONSOLE); return false; } - if (!PlotSquared.hasPermission(plr, "plots.schematic.paste")) { + if (!BukkitMain.hasPermission(plr, "plots.schematic.paste")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); return false; } @@ -158,7 +158,7 @@ public class Schematic extends SubCommand { PlotSquared.sendConsoleSenderMessage(C.IS_CONSOLE); return false; } - if (!PlotSquared.hasPermission(plr, "plots.schematic.test")) { + if (!BukkitMain.hasPermission(plr, "plots.schematic.test")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); return false; } @@ -252,7 +252,7 @@ public class Schematic extends SubCommand { break; case "export": case "save": - if (!PlotSquared.hasPermission(plr, "plots.schematic.save")) { + if (!BukkitMain.hasPermission(plr, "plots.schematic.save")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 249d9e7d6..676fa58c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -78,7 +78,7 @@ public class Set extends SubCommand { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(plr) && !PlotSquared.hasPermission(plr, "plots.admin.command.set")) { + if (!plot.hasRights(plr) && !BukkitMain.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 (!PlotSquared.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { + if (!BukkitMain.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); return false; } @@ -125,7 +125,7 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); return false; } - if (!PlotSquared.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) { + if (!BukkitMain.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 62f59874b..79eb7fb2b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -64,7 +64,7 @@ public class SetOwner extends SubCommand { return false; } - if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !PlotSquared.hasPermission(plr, "plots.admin.command.setowner")) { + if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.setowner")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } 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 6362a2142..57ee354d3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -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))) && !PlotSquared.hasPermission(plr, "plots.admin.command.swap")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.swap")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -71,7 +71,7 @@ public class Swap extends SubCommand { try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); 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")) { + if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !BukkitMain.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/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 910bb1a0c..3d1d493c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -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)) && !PlotSquared.hasPermission(plr, "plots.admin.command.trusted")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.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 aec693ee8..91d534670 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -49,7 +49,7 @@ 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)))) && !PlotSquared.hasPermission(plr, "plots.admin.command.unclaim")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !BukkitMain.hasPermission(plr, "plots.admin.command.unclaim")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; 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 2877d8a7f..50a52bd4b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -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))) && !PlotSquared.hasPermission(plr, "plots.admin.command.unlink")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.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))) { 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 51055f254..eb37026bb 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 @@ -40,7 +40,7 @@ public class WE_Anywhere extends SubCommand { return false; } - if (PlotSquared.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { + if (BukkitMain.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/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 5b1fc18dc..90f271166 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -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 (!PlotSquared.hasPermission(player, "plots.admin.entry.denied")) { + if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; @@ -264,7 +264,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasOwner()) { - if (PlotSquared.hasPermission(player, "plots.admin.destroy.unowned")) { + if (BukkitMain.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 (PlotSquared.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { + if (BukkitMain.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 (PlotSquared.hasPermission(event.getPlayer(), "plots.admin.destroy.road")) { + if (BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.other")) { + if (!BukkitMain.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 (PlotSquared.hasPermission(player, "plots.admin.interact.unowned")) { + if (BukkitMain.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 (PlotSquared.hasPermission(player, "plots.admin.interact.other")) { + if (BukkitMain.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 (PlotSquared.hasPermission(player, "plots.admin.interact.road")) { + if (BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.other")) { + if (!BukkitMain.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 (PlotSquared.hasPermission(p, "plots.admin.build.road")) { + if (BukkitMain.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 (PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { + if (BukkitMain.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 (PlotSquared.hasPermission(p, "plots.admin.build.other")) { + if (BukkitMain.hasPermission(p, "plots.admin.build.other")) { return; } if (isPlotArea(loc)) { @@ -725,7 +725,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(loc)) { Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (PlotSquared.hasPermission(p, "plots.admin.build.road")) { + if (BukkitMain.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 (PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { + if (BukkitMain.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 (PlotSquared.hasPermission(p, "plots.admin.build.other")) { + if (BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.build.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.destroy.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.destroy.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.destroy.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.interact.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.interact.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.interact.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.vehicle.break.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.vehicle.break.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.vehicle.break.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.pve.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.pve.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.pve.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.projectile.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.projectile.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.projectile.other")) { + if (!BukkitMain.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 (PlotSquared.hasPermission(event.getPlayer(), "plots.admin")) { + if (BukkitMain.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 (PlotSquared.hasPermission(player, "plots.admin.build.unowned")) { + if (BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.admin.build.other")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(player, "plots.admin.build.road")) { + if (!BukkitMain.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 c3f6b66b6..4c45a933c 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 @@ -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 (!PlotSquared.hasPermission(p, "plots.admin.interact.road")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.interact.unowned")) { + if (!BukkitMain.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 (!PlotSquared.hasPermission(p, "plots.admin.interact.other")) { + if (!BukkitMain.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/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index 73101e27d..9bd0b376c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -195,7 +195,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(trespasser))) { return; } - if (PlotSquared.hasPermission(trespasser, "plots.flag.notify-enter.bypass")) { + if (BukkitMain.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 (PlotSquared.hasPermission(trespasser, "plots.flag.notify-leave.bypass")) { + if (BukkitMain.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 8b1d0eb5b..443bd91ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -86,7 +86,7 @@ public class WorldEditListener implements Listener { if (!world.equals(player.getWorld().getName())) { return; } - if (PlotSquared.hasPermission(player, "plots.worldedit.bypass")) { + if (BukkitMain.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 (!PlotSquared.isPlotWorld(p.getWorld()) || PlotSquared.hasPermission(p, "plots.worldedit.bypass")) { + if (!PlotSquared.isPlotWorld(p.getWorld()) || BukkitMain.hasPermission(p, "plots.worldedit.bypass")) { return; } String cmd = e.getMessage().toLowerCase(); @@ -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 (PlotSquared.hasPermission(p, "plots.worldedit.bypass")) { + if (BukkitMain.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 (PlotSquared.hasPermission(p, "plots.worldedit.bypass")) { + if (BukkitMain.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 (PlotSquared.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + if (BukkitMain.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 (PlotSquared.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + if (BukkitMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { if (!PWE.hasMask(p)) { return; } 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 70e8e0802..5269fcd42 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -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 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))); + return BukkitMain.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/util/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java index 8f92d628f..d198db9d0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -82,7 +82,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; } } } - if (force ^ (noMask(s) && !PlotSquared.hasPermission(p, "plots.worldedit.bypass"))) { + if (force ^ (noMask(s) && !BukkitMain.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))); From 0d3f6d5e0bc2edccc8297456b7f2c0fa16ccebee Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 21:12:26 +1100 Subject: [PATCH 007/124] uhg --- .../intellectualcrafters/plot/BukkitMain.java | 54 +++++++- .../intellectualcrafters/plot/IPlotMain.java | 4 + .../plot/commands/Auto.java | 19 ++- .../events/PlayerTeleportToPlotEvent.java | 2 +- .../plot/object/Location.java | 3 + .../plot/util/BlockManager.java | 9 +- .../plot/util/PlotHelper.java | 120 ++++++++---------- .../plot/util/TaskManager.java | 2 +- .../plot/util/bukkit/BukkitUtil.java | 28 +++- 9 files changed, 150 insertions(+), 91 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index ce8911fc1..7369471f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -15,7 +15,6 @@ 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; @@ -26,12 +25,11 @@ 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.PlayerTeleportToPlotEvent; 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; @@ -39,8 +37,8 @@ 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.Location; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.Metrics; @@ -53,6 +51,7 @@ 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.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { @@ -60,6 +59,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { public static BukkitMain THIS = null; public static PlotSquared MAIN = null; + // TODO restructure this public static boolean hasPermission(final Player player, final String perm) { if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { return true; @@ -78,6 +78,50 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { return false; } + // TODO restructure this + public static 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")) { + PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT); + BukkitUtil.teleportPlayer(player, location); + return true; + } + PlayerFunctions.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + ""); + 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; + } + PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT); + BukkitUtil.teleportPlayer(player, location); + } + }, Settings.TELEPORT_DELAY * 20); + return true; + } + return !event.isCancelled(); + } + @EventHandler public static void worldLoad(WorldLoadEvent event) { UUIDHandler.cacheAll(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 3129a48ec..780a33d78 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -2,8 +2,12 @@ package com.intellectualcrafters.plot; import java.io.File; +import org.bukkit.entity.Player; + import net.milkbowl.vault.economy.Economy; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.TaskManager; 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 5bab03572..c50e4dcd1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -160,11 +160,11 @@ public class Auto extends SubCommand { } // } } - - PlotWorld plotworld = PlotSquared.getWorldSettings(world); + String worldname = world.getName(); + PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); if (plotworld.TYPE == 2) { Location loc = plr.getLocation(); - Plot plot = PlotHelper.getCurrentPlot(loc); + Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } @@ -183,7 +183,7 @@ public class Auto extends SubCommand { // for (int i = 0; i <= max; i++) { PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); - Plot current = PlotHelper.getPlot(world, currentId); + Plot current = PlotHelper.getPlot(worldname, currentId); if (current != null && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) { Claim.claimPlot(plr, current, true, true); return true; @@ -197,10 +197,9 @@ public class Auto extends SubCommand { } boolean br = false; - String worldname = world.getName(); if ((size_x == 1) && (size_z == 1)) { while (!br) { - final Plot plot = PlotHelper.getPlot(world, getLastPlot(worldname)); + final Plot plot = PlotHelper.getPlot(worldname, getLastPlot(worldname)); if ((plot.owner == null)) { Claim.claimPlot(plr, plot, true, true); br = true; @@ -215,21 +214,21 @@ public class Auto extends SubCommand { PlotHelper.lastPlot.put(worldname, start); if (lastPlot) { } - if ((PlotSquared.getPlots(world).get(start) != null) && (PlotSquared.getPlots(world).get(start).owner != null)) { + if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) { continue; } else { lastPlot = false; } final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1); - if (PlotHelper.isUnowned(world, start, end)) { + if (PlotHelper.isUnowned(worldname, start, end)) { for (int i = start.x; i <= end.x; i++) { for (int j = start.y; j <= end.y; j++) { - final Plot plot = PlotHelper.getPlot(world, new PlotId(i, j)); + final Plot plot = PlotHelper.getPlot(worldname, new PlotId(i, j)); final boolean teleport = ((i == end.x) && (j == end.y)); Claim.claimPlot(plr, plot, teleport, true); } } - if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(start, end))) { + if (!PlotHelper.mergePlots(plr, worldname, PlayerFunctions.getPlotSelectionIds(start, end))) { return false; } br = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java index e3a2ae9a5..032c5c384 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java @@ -21,12 +21,12 @@ package com.intellectualcrafters.plot.events; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java index 1dd3dffd2..4cfcb9da0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -90,6 +90,7 @@ public class Location implements Cloneable, Comparable { this.built = false; } + public Location add(int x, int y, int z) { this.x += x; this.y += y; this.z += z; @@ -128,6 +129,7 @@ public class Location implements Cloneable, Comparable { y <= max.getY() && z >= min.getX() && z < max.getZ(); } + public void lookTowards(int x, int y) { double l = this.x - x; double w = this.z - z; double c = Math.sqrt(l * l + w * w); @@ -139,6 +141,7 @@ public class Location implements Cloneable, Comparable { this.built = false; } + public Location subtract(int x, int y, int z) { this.x -= x; this.y -= y; this.z -= z; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 302bd8f90..9f6c68ade 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -32,9 +32,9 @@ public abstract class BlockManager { return (int) r; } - public abstract void functionSetBlock(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data); + public abstract void functionSetBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data); - public abstract void setSign(String worldname, int x, int y, int z, String[] lines); + public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines); public static void setBlocks(String worldname, int[] x, int y[], int z[], PlotBlock[][] blocks) { @@ -60,6 +60,11 @@ public abstract class BlockManager { setBlocks(worldname, x, y, z, id, data); } + public static void setSign(String worldname, int x, int y, int z, String[] lines) { + manager.functionSetSign(worldname, x, y, z, lines); + } + public static void setBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) { + manager.functionSetBlocks(worldname, x, y, z, id, data); } } 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 ee1005597..655a26fa0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -41,6 +41,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -53,7 +54,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * plot functions @@ -137,7 +138,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - if (PlotSquared.useEconomy && plotworld.USE_ECONOMY) { + if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) { final double cost = plotIds.size() * plotworld.MERGE_PRICE; if (cost > 0d) { final Economy economy = PlotSquared.economy; @@ -289,20 +290,17 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; if (name == null) { name = "unknown"; } - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(p.world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(p.world); final Location loc = manager.getSignLoc(plotworld, p); - - final Block bs = loc.getBlock(); - bs.setType(Material.AIR); - bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); final String id = p.id.x + ";" + p.id.y; - final Sign sign = (Sign) bs.getState(); - sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id)); - sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name)); - sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name)); - sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name)); - sign.update(true); + String[] lines = new String[] { + C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), + C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), + C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), + C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) + }; + BukkitUtil.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines); } public static String getPlayerName(final UUID uuid) { @@ -379,7 +377,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; } merge = false; } - update(player.getLocation()); + update(BukkitUtil.getLocation(player)); } private static boolean ownsPlots(final String world, final ArrayList plots, final Player player, final int dir) { @@ -403,6 +401,18 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; return true; } + public static void update(Location loc) { + ArrayList chunks = new ArrayList<>(); + final int distance = Bukkit.getViewDistance(); + for (int cx = -distance; cx < distance; cx++) { + for (int cz = -distance; cz < distance; cz++) { + Chunk chunk = BukkitUtil.getChunkAt(loc.getWorld(), loc.getX(), loc.getZ()); + chunks.add(chunk); + } + } + AbstractSetBlock.setBlockManager.update(chunks); + } + public static void updateWorldBorder(Plot plot) { if (!worldBorder.containsKey(plot.world)) { return; @@ -413,8 +423,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id); Location top = manager.getPlotTopLocAbs(plotworld, plot.id); int border = worldBorder.get(plot.world); - int botmax = Math.max(Math.abs(bot.getBlockX()), Math.abs(bot.getBlockZ())); - int topmax = Math.max(Math.abs(top.getBlockX()), Math.abs(top.getBlockZ())); + int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ())); + int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ())); int max = Math.max(botmax, topmax); if (max > border ) { worldBorder.put(plot.world, max); @@ -428,7 +438,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; if (PlotHelper.worldBorder.containsKey(plot.world)) { updateWorldBorder(plot); } - World w = player.getWorld(); + String w = BukkitUtil.getWorld(player); UUID uuid = UUIDHandler.getUUID(player); Plot p = createPlotAbs(uuid, plot); final PlotWorld plotworld = PlotSquared.getWorldSettings(w); @@ -449,34 +459,6 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; return p; } - public static int getLoadedChunks(final String world) { - return world.getLoadedChunks().length; - } - - public static int getEntities(final String world) { - - return world.getEntities().size(); - } - - - public static int getTileEntities(final String world) { - - PlotSquared.getWorldSettings(world); - int x = 0; - for (final Chunk chunk : world.getLoadedChunks()) { - x += chunk.getTileEntities().length; - } - return x; - } - - public static double getWorldFolderSize(final String world) { - - // long size = FileUtil.sizeOfDirectory(world.getWorldFolder()); - final File folder = world.getWorldFolder(); - final long size = folder.length(); - return (((size) / 1024) / 1024); - } - public static String createId(final int x, final int z) { return x + ";" + z; } @@ -494,15 +476,13 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; } public static void clearAllEntities(final String world, final Plot plot, final boolean tile) { - - - final List entities = world.getEntities(); + final List entities = BukkitUtil.getEntities(world); for (final Entity entity : entities) { final PlotId id = PlayerFunctions.getPlot(entity.getLocation()); if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - PlotSquared.teleportPlayer(player, entity.getLocation(), plot); + BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); PlotListener.plotExit(player, plot); } else { entity.remove(); @@ -530,8 +510,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; final int prime = 31; int h = 1; - h = (prime * h) + pos1.getBlockX(); - h = (prime * h) + pos1.getBlockZ(); + h = (prime * h) + pos1.getX(); + h = (prime * h) + pos1.getZ(); state = h; final long start = System.currentTimeMillis(); @@ -593,8 +573,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; } for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { - for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { - for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { final Block block = world.getBlockAt(x, y, z); if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { setBlock(world, x, y, z, newblock.id, newblock.data); @@ -611,8 +591,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; return; } for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { - for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { - for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { final int i = random(blocks.length); final PlotBlock newblock = blocks[i]; final Block block = world.getBlockAt(x, y, z); @@ -627,8 +607,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { - for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { - for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { final Block block = world.getBlockAt(x, y, z); if (!((block.getTypeId() == newblock.id))) { setBlock(world, x, y, z, newblock.id, (byte) 0); @@ -640,10 +620,10 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; public static void setBiome(final String world, final Plot plot, final Biome b) { - final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); - final int topX = getPlotTopLoc(world, plot.id).getBlockX() + 1; - final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ(); - final int topZ = getPlotTopLoc(world, plot.id).getBlockZ() + 1; + final int bottomX = getPlotBottomLoc(world, plot.id).getX(); + final int topX = getPlotTopLoc(world, plot.id).getX() + 1; + final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); + final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1; final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1)); final Biome biome = block.getBiome(); @@ -696,8 +676,8 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; 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 x = ((top.getX() - bot.getX())/2) + bot.getX(); + final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY()); return new Location(w, x, y, z); } @@ -716,7 +696,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static Location getPlotHomeDefault(final Plot plot) { final Location l = getPlotBottomLoc(plot.getWorld(), plot.getId()).subtract(0, 0, 0); - l.setY(getHeighestBlock(plot.getWorld(), l.getBlockX(), l.getBlockZ())); + l.setY(getHeighestBlock(plot.getWorld(), l.getX(), l.getZ())); return l; } @@ -742,10 +722,10 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static void refreshPlotChunks(final String world, final Plot plot) { - final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); - final int topX = getPlotTopLoc(world, plot.id).getBlockX(); - final int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ(); - final int topZ = getPlotTopLoc(world, plot.id).getBlockZ(); + final int bottomX = getPlotBottomLoc(world, plot.id).getX(); + final int topX = getPlotTopLoc(world, plot.id).getX(); + final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); + final int topZ = getPlotTopLoc(world, plot.id).getZ(); final int minChunkX = (int) Math.floor((double) bottomX / 16); final int maxChunkX = (int) Math.floor((double) topX / 16); @@ -818,7 +798,7 @@ import com.intellectualcrafters.plot.util.bukkit.TaskManager; */ public static int getPlotWidth(final String world, final PlotId id) { - return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX(); + return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); } /** 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 da5eff74c..eccac27c0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -6,7 +6,7 @@ import com.intellectualcrafters.plot.PlotSquared; public abstract class TaskManager { - public HashSet TELEPORT_QUEUE = new HashSet<>(); + public static HashSet TELEPORT_QUEUE = new HashSet<>(); public abstract void taskRepeat(final Runnable r, int interval); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index fe5ff42a2..df9ec1abe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.util.bukkit; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -10,7 +11,10 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.SetBlockManager; @@ -51,6 +55,19 @@ public class BukkitUtil extends BlockManager { SetBlockManager.setBlockManager.update(chunks); } + public static String getWorld(Entity entity) { + return entity.getWorld().getName(); + } + + public static void teleportPlayer(Player player, Location loc) { + org.bukkit.Location bukkitLoc = new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()); + player.teleport(bukkitLoc); + } + + public static List getEntities(String worldname) { + return getWorld(worldname).getEntities(); + } + 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); @@ -61,8 +78,14 @@ public class BukkitUtil extends BlockManager { } } + public static Location getLocation(Entity entity) { + org.bukkit.Location loc = entity.getLocation(); + String world = loc.getWorld().getName(); + return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } + @Override - public void functionSetBlock(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) { + public void functionSetBlocks(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]); @@ -70,7 +93,7 @@ public class BukkitUtil extends BlockManager { } @Override - public void setSign(String worldname, int x, int y, int z, String[] lines) { + public void functionSetSign(String worldname, int x, int y, int z, String[] lines) { World world = getWorld(worldname); Block block = world.getBlockAt(x, y, z); block.setType(Material.AIR); @@ -80,6 +103,7 @@ public class BukkitUtil extends BlockManager { for (int i = 0; i < lines.length; i++) { ((Sign) blockstate).setLine(i, lines[i]); } + ((Sign) blockstate).update(true); } } From 55e2465bee5cf2bbb95d8386c77d8ed8c2872d1d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 21:23:36 +1100 Subject: [PATCH 008/124] console message --- .../intellectualcrafters/plot/_PlotMain.java | 90 +++++++-------- .../plot/api/PlotAPI.java | 4 +- .../plot/commands/Clear.java | 10 +- .../plot/commands/Condense.java | 2 +- .../plot/commands/Database.java | 4 +- .../plot/commands/DebugClear.java | 12 +- .../plot/commands/DebugLoadTest.java | 4 +- .../plot/commands/RegenAllRoads.java | 10 +- .../plot/commands/Schematic.java | 12 +- .../plot/commands/Trim.java | 2 +- .../plot/commands/Unlink.java | 2 +- .../plot/database/SQLManager.java | 108 +++++++++--------- .../plot/flag/FlagManager.java | 2 +- .../plot/generator/ClassicPlotWorld.java | 2 +- .../plot/generator/HybridPlotManager.java | 12 +- .../plot/generator/HybridPlotWorld.java | 6 +- .../plot/generator/SquarePlotWorld.java | 2 +- .../plot/listeners/PlayerEvents.java | 2 +- .../plot/object/PlotWorld.java | 2 +- .../plot/object/entity/EntityWrapper.java | 4 +- .../plot/titles/HackTitle.java | 2 +- .../plot/util/ChunkManager.java | 34 +++--- .../plot/util/ExpireManager.java | 14 +-- .../plot/util/Logger.java | 2 +- .../plot/util/MainUtil.java | 4 +- .../plot/util/PlayerFunctions.java | 4 +- .../plot/util/PlotSquaredException.java | 2 +- .../plot/util/SchematicHandler.java | 10 +- .../plot/util/UUIDHandler.java | 6 +- 29 files changed, 185 insertions(+), 185 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java index 2eab9284a..5080f75ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java @@ -472,13 +472,13 @@ public class _PlotSquared { 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."); + log(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"); + log("Could not create the style file, please create \"translations/style.yml\" manually"); } } styleConfig = YamlConfiguration.loadConfiguration(styleFile); @@ -491,7 +491,7 @@ public class _PlotSquared { 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."); + log("Could not create the settings file, please create \"settings.yml\" manually."); } } config = YamlConfiguration.loadConfiguration(configFile); @@ -504,7 +504,7 @@ public class _PlotSquared { 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."); + log("Could not the storage settings file, please create \"storage.yml\" manually."); } } storage = YamlConfiguration.loadConfiguration(storageFile); @@ -557,7 +557,7 @@ public class _PlotSquared { 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())); + log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue())); } } } @@ -571,7 +571,7 @@ public class _PlotSquared { long error = 0l; { - sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities started."); + log(C.PREFIX.s() + "KillAllEntities started."); } @Override @@ -579,7 +579,7 @@ public class _PlotSquared { 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); + log(C.PREFIX.s() + "KillAllEntities has been running for 6 hours. Errors: " + this.error); } this.error = 0l; } @@ -648,7 +648,7 @@ public class _PlotSquared { 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."); + log(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"); @@ -666,7 +666,7 @@ public class _PlotSquared { 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."); + log("&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"); @@ -698,7 +698,7 @@ public class _PlotSquared { 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"); + PlotSquared.log("&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"); } } @@ -708,10 +708,10 @@ public class _PlotSquared { 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@'"); + log("&c[IMPORTANT] THIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); + log("&c[IMPORTANT] - Make sure 'UUID.read-from-disk' is disabled (false)!"); + log("&c[IMPORTANT] - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); + log("&c[IMPORTANT] - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml@'"); } try { new PlotMeConverter(PlotSquared.getMain()).runAsync(); @@ -739,10 +739,10 @@ public class _PlotSquared { 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()); + 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); @@ -772,7 +772,7 @@ public class _PlotSquared { new HybridGen(world); } } catch (Exception e) { - PlotSquared.sendConsoleSenderMessage("&d=== Oh no! Please set the generator for the " + world + " ==="); + PlotSquared.log("&d=== Oh no! Please set the generator for the " + world + " ==="); e.printStackTrace(); LOADING_WORLD = false; removePlotWorld(world); @@ -796,7 +796,7 @@ public class _PlotSquared { 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'!"); + 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); @@ -1078,7 +1078,7 @@ public class _PlotSquared { for (String element : split) { String[] pair = element.split("="); if (pair.length != 2) { - sendConsoleSenderMessage("&cNo value provided for: &7" + element); + log("&cNo value provided for: &7" + element); return null; } String key = pair[0].toLowerCase(); @@ -1123,14 +1123,14 @@ public class _PlotSquared { break; } default: { - sendConsoleSenderMessage("&cKey not found: &7" + element); + log("&cKey not found: &7" + element); return null; } } } catch (Exception e) { e.printStackTrace(); - sendConsoleSenderMessage("&cInvalid value: &7" + value + " in arg " + element); + log("&cInvalid value: &7" + value + " in arg " + element); return null; } } @@ -1253,7 +1253,7 @@ public class _PlotSquared { } @Override - public void sendConsoleSenderMessage(String string) { + public void log(String string) { if (BukkitMain.plugin == null || Bukkit.getServer().getConsoleSender() == null) { System.out.println(ChatColor.stripColor(ConsoleColors.fromString(string))); } else { @@ -1277,13 +1277,13 @@ public class _PlotSquared { 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."); + log(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"); + log(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"); + log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); } // Setup configuration configs(); @@ -1293,20 +1293,20 @@ public class _PlotSquared { try { final Metrics metrics = new Metrics(this); metrics.start(); - sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled."); + log(C.PREFIX.s() + "&6Metrics enabled."); } catch (final Exception e) { - sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to load up metrics."); + log(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 :)"); + log("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); + log(C.ENABLED); } final String[] tables; if (Settings.ENABLE_CLUSTERS) { @@ -1345,12 +1345,12 @@ public class _PlotSquared { } } catch (final Exception e) { Logger.add(LogLevel.DANGER, "MySQL connection failed."); - sendConsoleSenderMessage("&c[Plots] MySQL is not setup correctly. The plugin will disable itself."); + log("&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 ===="); + log("&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."); + log("&d==== End of stacktrace ===="); + log("&6Please go to the PlotSquared 'storage.yml' and configure MySQL correctly."); } Bukkit.getPluginManager().disablePlugin(this); return; @@ -1363,7 +1363,7 @@ public class _PlotSquared { // TODO: Implement mongo else if (Settings.DB.USE_MONGO) { // DBFunc.dbManager = new MongoManager(); - sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented"); + log(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(); @@ -1384,8 +1384,8 @@ public class _PlotSquared { } } 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 ==="); + log(C.PREFIX.s() + "&cFailed to open SQLite connection. The plugin will disable itself."); + log("&9==== Here is an ugly stacktrace, if you are interested in those things ==="); e.printStackTrace(); Bukkit.getPluginManager().disablePlugin(this); return; @@ -1396,7 +1396,7 @@ public class _PlotSquared { } } else { Logger.add(LogLevel.DANGER, "No storage type is set."); - sendConsoleSenderMessage(C.PREFIX + "&cNo storage type is set!"); + log(C.PREFIX + "&cNo storage type is set!"); getServer().getPluginManager().disablePlugin(this); return; } @@ -1434,9 +1434,9 @@ public class _PlotSquared { 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"); + PlotSquared.log("&cThis version of WorldEdit does not support PlotSquared."); + PlotSquared.log("&cPlease use WorldEdit 6+ for masking support"); + PlotSquared.log("&c - http://builds.enginehub.org/job/worldedit"); } else { getServer().getPluginManager().registerEvents(new WorldEditListener(), this); MainCommand.subCommands.add(new WE_Anywhere()); @@ -1500,7 +1500,7 @@ public class _PlotSquared { { 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."); + log(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")); } @@ -1520,10 +1520,10 @@ public class _PlotSquared { 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"); + log(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"); + log(C.PREFIX.s()+" &6PlotSquared is using online UUIDs"); } } // Now we're finished :D 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 f7a710779..0cd0e7d97 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -340,10 +340,10 @@ import com.intellectualcrafters.plot.util.UUIDHandler; // * // * @param msg Message that should be sent to the console // * -// * @see PlotSquared#sendConsoleSenderMessage(String) +// * @see PlotSquared#log(String) // */ // public void sendConsoleMessage(final String msg) { -// PlotSquared.sendConsoleSenderMessage(msg); +// PlotSquared.log(msg); // } // // /** 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 8614b6a6d..6cfa00afb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -43,22 +43,22 @@ public class Clear extends SubCommand { if (plr == null) { // Is console if (args.length < 2) { - PlotSquared.sendConsoleSenderMessage("You need to specify two arguments: ID (0;0) & World (world)"); + PlotSquared.log("You need to specify two arguments: ID (0;0) & World (world)"); } else { final PlotId id = PlotId.fromString(args[0]); final String world = args[1]; if (id == null) { - PlotSquared.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); + PlotSquared.log("Invalid Plot ID: " + args[0]); } else { if (!PlotSquared.isPlotWorld(world)) { - PlotSquared.sendConsoleSenderMessage("Invalid plot world: " + world); + PlotSquared.log("Invalid plot world: " + world); } else { final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); if (plot == null) { - PlotSquared.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); + PlotSquared.log("Could not find plot " + args[0] + " in world " + world); } else { plot.clear(null, false); - PlotSquared.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); + PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); } } } 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 9ee003dbc..828d5ce21 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -203,7 +203,7 @@ public class Condense extends SubCommand { } public static void sendMessage(final String message) { - PlotSquared.sendConsoleSenderMessage("&3PlotSquared -> Plot condense&8: &7" + message); + PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message); } } 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 063d48636..9eca4f450 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -33,7 +33,7 @@ public class Database extends SubCommand { private static boolean sendMessageU(final UUID uuid, final String msg) { if (uuid == null) { - PlotSquared.sendConsoleSenderMessage(msg); + PlotSquared.log(msg); } else { final Player p = UUIDHandler.uuidWrapper.getPlayer(uuid); if ((p != null) && p.isOnline()) { @@ -141,7 +141,7 @@ public class Database extends SubCommand { private boolean sendMessage(final Player player, final String msg) { if (player == null) { - PlotSquared.sendConsoleSenderMessage(msg); + PlotSquared.log(msg); } else { PlayerFunctions.sendMessage(player, msg); } 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 02987fd26..1583384cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -47,19 +47,19 @@ public class DebugClear extends SubCommand { if (plr == null) { // Is console if (args.length < 2) { - PlotSquared.sendConsoleSenderMessage("You need to specify two arguments: ID (0;0) & World (world)"); + PlotSquared.log("You need to specify two arguments: ID (0;0) & World (world)"); } else { final PlotId id = PlotId.fromString(args[0]); final String world = args[1]; if (id == null) { - PlotSquared.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); + PlotSquared.log("Invalid Plot ID: " + args[0]); } else { if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getWorldSettings(world) instanceof SquarePlotWorld)) { - PlotSquared.sendConsoleSenderMessage("Invalid plot world: " + world); + PlotSquared.log("Invalid plot world: " + world); } else { final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); if (plot == null) { - PlotSquared.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); + PlotSquared.log("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); - PlotSquared.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); - PlotSquared.sendConsoleSenderMessage("&aDone!"); + PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); + PlotSquared.log("&aDone!"); } }); } 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 8cf301f4b..29a45160d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -46,9 +46,9 @@ public class DebugLoadTest extends SubCommand { fPlots.setAccessible(true); fPlots.set(null, DBFunc.getPlots()); } catch (final Exception e) { - PlotSquared.sendConsoleSenderMessage("&3===FAILED&3==="); + PlotSquared.log("&3===FAILED&3==="); e.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&3===END OF STACKTRACE==="); + PlotSquared.log("&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/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index 2155aef99..a1de3f2d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -66,15 +66,15 @@ public class RegenAllRoads extends SubCommand { World world = Bukkit.getWorld(name); ArrayList chunks = ChunkManager.getChunkChunks(world); - 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"); + PlotSquared.log("&cIf no schematic is set, the following will not do anything"); + PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); + PlotSquared.log("&6Potential chunks to update: &7"+ (chunks.size() * 1024)); + PlotSquared.log("&6Estimated time: &7"+ (chunks.size()) + " seconds"); boolean result = hpm.scheduleRoadUpdate(world); if (!result) { - PlotSquared.sendConsoleSenderMessage("&cCannot schedule mass schematic update! (Is one already in progress?)"); + PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); return false; } 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 be7f0aff9..130edd9ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -67,7 +67,7 @@ public class Schematic extends SubCommand { switch (arg) { case "paste": if (plr == null) { - PlotSquared.sendConsoleSenderMessage(C.IS_CONSOLE); + PlotSquared.log(C.IS_CONSOLE); return false; } if (!BukkitMain.hasPermission(plr, "plots.schematic.paste")) { @@ -155,7 +155,7 @@ public class Schematic extends SubCommand { break; case "test": if (plr == null) { - PlotSquared.sendConsoleSenderMessage(C.IS_CONSOLE); + PlotSquared.log(C.IS_CONSOLE); return false; } if (!BukkitMain.hasPermission(plr, "plots.schematic.test")) { @@ -205,8 +205,8 @@ public class Schematic extends SubCommand { return false; } - 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..."); + PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); + PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); 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) { - PlotSquared.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); + PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); Schematic.this.running = false; Bukkit.getScheduler().cancelTask(Schematic.this.task); return; @@ -305,7 +305,7 @@ public class Schematic extends SubCommand { @Override public void run() { if (Schematic.this.counter >= Schematic.this.plots.length) { - PlotSquared.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); + PlotSquared.log("&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/Trim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java index 47c30e059..57d023160 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -260,7 +260,7 @@ public class Trim extends SubCommand { } public static void sendMessage(final String message) { - PlotSquared.sendConsoleSenderMessage("&3PlotSquared -> World trim&8: &7" + message); + PlotSquared.log("&3PlotSquared -> World trim&8: &7" + message); } } 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 50a52bd4b..7d91e0868 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -73,7 +73,7 @@ public class Unlink extends SubCommand { } catch (final Exception e) { // execute(final Player plr, final String... args) { try { - PlotSquared.sendConsoleSenderMessage("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); + PlotSquared.log("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); } catch (final Exception ex) { ex.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 292bf85ca..a67151f09 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -126,7 +126,7 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Could not set owner for plot " + plot.id); + PlotSquared.log("&c[ERROR] "+"Could not set owner for plot " + plot.id); } } }); @@ -232,7 +232,7 @@ public class SQLManager implements AbstractDB { } } catch (Exception e2) {} - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set all helpers for plots"); + PlotSquared.log("&7[WARN] "+"Failed to set all helpers for plots"); } } } @@ -284,20 +284,20 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&6[WARN] "+"Could not bulk save. Conversion may be slower..."); + PlotSquared.log("&6[WARN] "+"Could not bulk save. Conversion may be slower..."); try { for (Plot plot : plots) { try { createPlot(plot); } catch (Exception e3) { - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot: "+plot.id); + PlotSquared.log("&c[ERROR] "+"Failed to save plot: "+plot.id); } } } catch (Exception e2) { e2.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plots!"); + PlotSquared.log("&c[ERROR] "+"Failed to save plots!"); } } } @@ -324,7 +324,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot " + plot.id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot " + plot.id); + PlotSquared.log("&c[ERROR] "+"Failed to save plot " + plot.id); } } }); @@ -439,7 +439,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] " + "Failed to delete plot " + plot.id); + PlotSquared.log("&c[ERROR] " + "Failed to delete plot " + plot.id); } } }); @@ -582,7 +582,7 @@ public class SQLManager implements AbstractDB { if (plot != null) { plot.addHelper(user); } else { - PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry."); + PlotSquared.log("&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 { - PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry."); + PlotSquared.log("&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 { - PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry."); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted."); + PlotSquared.log("&cPlot " + id + " had an invalid flag. A fix has been attempted."); setFlags(id, flags.toArray(new Flag[0])); } plot.settings.flags = flags; } else { - PlotSquared.sendConsoleSenderMessage("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry."); + PlotSquared.log("&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; - PlotSquared.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'."); + PlotSquared.log("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'."); } if (invalidPlot) { - PlotSquared.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the plots using the purge command"); + PlotSquared.log("&c[WARNING] - Please create the world/s or remove the plots using the purge command"); } } catch (final SQLException e) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load plots."); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set merged for plot " + plot.id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + plot.id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set alias for plot " + plot.id); + PlotSquared.log("&7[WARN] "+"Failed to set alias for plot " + plot.id); e.printStackTrace(); } @@ -930,11 +930,11 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); + PlotSquared.log("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); return; } } - PlotSquared.sendConsoleSenderMessage("&6[INFO] "+"SUCCESSFULLY PURGED WORLD '" + world + "'!"); + PlotSquared.log("&6[INFO] "+"SUCCESSFULLY PURGED WORLD '" + world + "'!"); } @Override public void purge(final String world, Set plots) { @@ -959,7 +959,7 @@ public class SQLManager implements AbstractDB { r.close(); } catch (SQLException e) { e.printStackTrace(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); + PlotSquared.log("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); } } @@ -980,7 +980,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set position for plot " + plot.id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for plot: " + id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for plot " + plot.id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch comment"); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set comment for plot " + plot.id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for plot " + plot.id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove trusted user for plot " + plot.id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for plot " + plot.id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for id " + id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set plot trusted for plot " + plot.id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove denied for plot " + plot.id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set denied for plot " + plot.id); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString()); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2()); + PlotSquared.log("&c[ERROR] "+"Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2()); } } }); @@ -1419,7 +1419,7 @@ public class SQLManager implements AbstractDB { if (cluster != null) { cluster.helpers.add(user); } else { - PlotSquared.sendConsoleSenderMessage("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry."); + PlotSquared.log("&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 { - PlotSquared.sendConsoleSenderMessage("&cCluster " + id + " in cluster_invited does not exist. Please create the cluster or remove this entry."); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted."); + PlotSquared.log("&cPlot " + id + " had an invalid flag. A fix has been attempted."); setFlags(id, flags.toArray(new Flag[0])); } cluster.settings.flags = flags; } else { - PlotSquared.sendConsoleSenderMessage("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry."); + PlotSquared.log("&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; - PlotSquared.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(w) + " clusters in DB for non existant world; '" + w + "'."); + PlotSquared.log("&c[WARNING] Found " + noExist.get(w) + " clusters in DB for non existant world; '" + w + "'."); } if (invalidPlot) { - PlotSquared.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the clusters using the purge command"); + PlotSquared.log("&c[WARNING] - Please create the world/s or remove the clusters using the purge command"); } } catch (final SQLException e) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load clusters."); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Could not set flag for plot " + cluster); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set alias for cluster " + cluster); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove helper for cluster " + cluster); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for cluster " + cluster); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save cluster " + cluster); + PlotSquared.log("&c[ERROR] "+"Failed to save cluster " + cluster); } } }); @@ -1689,7 +1689,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to rezize cluster " + current); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set position for cluster " + cluster); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to load settings for cluster: " + id); + PlotSquared.log("&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(); - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to remove invited for cluster " + cluster); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage("&7[WARN] "+"Failed to set helper for cluster " + cluster); + PlotSquared.log("&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 62aa970a6..38b0533c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -63,7 +63,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @return success? */ public static boolean addFlag(final AbstractFlag af) { - PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&8 - Adding flag: &7" + af); + PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af); String key = af.getKey(); if (PlotSquared.getAllPlotsRaw() != null) { for (Plot plot : PlotSquared.getPlots()) { 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 6df341bb3..9e621ef29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java @@ -50,7 +50,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { @Override public void loadConfiguration(final ConfigurationSection config) { if (!config.contains("plot.height")) { - PlotSquared.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); + PlotSquared.log(" - &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/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index b262d4326..a25ce25de 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -211,23 +211,23 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; public void run() { if (chunks.size() == 0) { HybridPlotManager.UPDATE = false; - PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "Finished road conversion"); + PlotSquared.log(C.PREFIX.s() + "Finished road conversion"); Bukkit.getScheduler().cancelTask(task); return; } else { try { ChunkLoc loc = chunks.get(0); - PlotSquared.sendConsoleSenderMessage("Updating .mcr: " + loc.x + ", "+loc.z + " (aprrox 256 chunks)"); - PlotSquared.sendConsoleSenderMessage("Remaining regions: "+chunks.size()); + PlotSquared.log("Updating .mcr: " + loc.x + ", "+loc.z + " (aprrox 256 chunks)"); + PlotSquared.log("Remaining regions: "+chunks.size()); regenerateChunkChunk(world, loc); chunks.remove(0); } catch (Exception e) { ChunkLoc loc = chunks.get(0); - 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"); + PlotSquared.log("&c[ERROR]&7 Could not update '"+world.getName() + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); + PlotSquared.log("&d - Potentially skipping 256 chunks"); + PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); } } } 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 cee7cc94b..a82aad7e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -62,7 +62,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { @Override public void loadConfiguration(final ConfigurationSection config) { if (!config.contains("plot.height")) { - PlotSquared.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); + PlotSquared.log(" - &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) { - PlotSquared.sendConsoleSenderMessage("&c - road schematics are disabled for this world."); + PlotSquared.log("&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) { - PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&3 - schematic: &7false"); + PlotSquared.log(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/SquarePlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java index 39fd23fa0..64026a72c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java @@ -15,7 +15,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld { @Override public void loadConfiguration(final ConfigurationSection config) { if (!config.contains("plot.height")) { - PlotSquared.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); + PlotSquared.log(" - &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 90f271166..93b6710a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -713,7 +713,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final PlotManager manager = PlotSquared.getPlotManager(plot.getWorld()); manager.clearPlot(null, plotworld, plot, true, null); DBFunc.delete(plot.getWorld().getName(), plot); - PlotSquared.sendConsoleSenderMessage(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); + PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); } } } 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 b769d79ef..55b1ba880 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -137,7 +137,7 @@ public abstract class PlotWorld { this.DEFAULT_FLAGS = FlagManager.parseFlags(flags); } catch (Exception e) { - PlotSquared.sendConsoleSenderMessage("&cInvalid default flags for "+this.worldname+": "+StringUtils.join(flags,",")); + PlotSquared.log("&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 6f2cf7099..fb5bc8760 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 @@ -227,7 +227,7 @@ public class EntityWrapper { return; } default: { - PlotSquared.sendConsoleSenderMessage("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); + PlotSquared.log("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); return; } @@ -443,7 +443,7 @@ public class EntityWrapper { return entity; } default: { - PlotSquared.sendConsoleSenderMessage("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); + PlotSquared.log("&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 da8798dec..69a0404e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java @@ -16,7 +16,7 @@ public class HackTitle extends AbstractTitle { title.send(player); } catch (Throwable e) { - PlotSquared.sendConsoleSenderMessage("&cYour server version does not support titles!"); + PlotSquared.log("&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/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index 5353fb1ae..7efbf52b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -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); - PlotSquared.sendConsoleSenderMessage("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)"); + PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)"); if (file.exists()) { file.delete(); } @@ -446,7 +446,7 @@ public class ChunkManager { chest.getInventory().setContents(chestContents.get(loc)); state.update(true); } - else { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate chest: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate sign: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate beacon: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore jukebox: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore jukebox: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate hopper: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate note block: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore brewing stand cooking: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore spawner type: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore command block: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate brewing stand: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to restore furnace cooking: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate furnace: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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 { PlotSquared.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate banner: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } + else { PlotSquared.log("&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/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index dd83d9ccd..bb364c63d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -50,7 +50,7 @@ public class ExpireManager { @Override public void run() { HashMap plots = getOldPlots(world); - PlotSquared.sendConsoleSenderMessage("&cFound " + plots.size() + " expired plots for " + world + "!"); + PlotSquared.log("&cFound " + plots.size() + " expired plots for " + world + "!"); expiredPlots.put(world, plots); updatingPlots.put(world, false); } @@ -120,13 +120,13 @@ public class ExpireManager { DBFunc.delete(world, plot); PlotSquared.removePlot(world, plot.id, true); expiredPlots.get(world).remove(plot); - PlotSquared.sendConsoleSenderMessage("&cDeleted expired plot: " + plot.id); - PlotSquared.sendConsoleSenderMessage("&3 - World: "+plot.world); + PlotSquared.log("&cDeleted expired plot: " + plot.id); + PlotSquared.log("&3 - World: "+plot.world); if (plot.hasOwner()) { - PlotSquared.sendConsoleSenderMessage("&3 - Owner: "+UUIDHandler.getName(plot.owner)); + PlotSquared.log("&3 - Owner: "+UUIDHandler.getName(plot.owner)); } else { - PlotSquared.sendConsoleSenderMessage("&3 - Owner: Unowned"); + PlotSquared.log("&3 - Owner: Unowned"); } return; } @@ -205,7 +205,7 @@ public class ExpireManager { if (filename != null) { File playerFile = new File(worldname + File.separator + foldername + File.separator + filename); if (!playerFile.exists()) { - PlotSquared.sendConsoleSenderMessage("Could not find file: " + filename); + PlotSquared.log("Could not find file: " + filename); } else { try { @@ -217,7 +217,7 @@ public class ExpireManager { } } catch (Exception e) { - PlotSquared.sendConsoleSenderMessage("Please disable disk checking in old plot auto clearing; Could not read file: " + filename); + PlotSquared.log("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 aa85ebb72..7f60ae108 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java @@ -53,7 +53,7 @@ public class Logger { } reader.close(); } catch (final IOException e) { - PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup"); + PlotSquared.log(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 76f150717..95cc0e546 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -11,7 +11,7 @@ public class MainUtil { * * @param c message */ - public static void sendConsoleSenderMessage(final C c) { - PlotSquared.MAIN_IMP.sendConsoleSenderMessage(c.s()); + public static void log(final C c) { + PlotSquared.MAIN_IMP.log(c.s()); } } 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 ddfec80b9..b0cef2723 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -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) { - PlotSquared.MAIN_IMP.sendConsoleSenderMessage(C.PREFIX.s() + msg); + PlotSquared.MAIN_IMP.log(C.PREFIX.s() + msg); } else { sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); } @@ -313,7 +313,7 @@ import java.util.UUID; } } if (plr == null) { - PlotSquared.sendConsoleSenderMessage(msg); + PlotSquared.log(msg); } else { sendMessage(plr, msg, c.usePrefix()); 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 3be409a39..8a505e394 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java @@ -32,7 +32,7 @@ public class PlotSquaredException extends RuntimeException { public PlotSquaredException(final PlotError error, final String details) { super("PlotError >> " + error.getHeader() + ": " + details); - PlotSquared.sendConsoleSenderMessage("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details); + PlotSquared.log("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details); } public static enum PlotError { 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 4f1f39cd6..9e049fea3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -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) { - PlotSquared.sendConsoleSenderMessage("Schematic == null :|"); + PlotSquared.log("Schematic == null :|"); return false; } try { @@ -179,7 +179,7 @@ public class SchematicHandler { } final File file = new File(PlotSquared.getMain().getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); if (!file.exists()) { - PlotSquared.sendConsoleSenderMessage(file.toString() + " doesn't exist"); + PlotSquared.log(file.toString() + " doesn't exist"); return null; } @@ -191,7 +191,7 @@ public class SchematicHandler { return getSchematic(tag, file); } catch (final Exception e) { - PlotSquared.sendConsoleSenderMessage(file.toString() + " is not in GZIP format"); + PlotSquared.log(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) { - PlotSquared.sendConsoleSenderMessage("&cCannot save empty tag"); + PlotSquared.log("&cCannot save empty tag"); return false; } try { @@ -265,7 +265,7 @@ public class SchematicHandler { } } } catch (final Exception e) { - PlotSquared.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at " + (i / 16) + ", " + (j / 16)); + PlotSquared.log("&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/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index b6c7cb8f6..78ed98bcf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -109,7 +109,7 @@ public class UUIDHandler { uuids.add(uuid); } catch (Exception e) { - PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "Invalid playerdata: "+current); + PlotSquared.log(C.PREFIX.s() + "Invalid playerdata: "+current); } } } @@ -136,7 +136,7 @@ public class UUIDHandler { add(name, uuid); } catch (Throwable e) { - PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&6Invalid playerdata: "+uuid.toString() + ".dat"); + PlotSquared.log(C.PREFIX.s() + "&6Invalid playerdata: "+uuid.toString() + ".dat"); } } for (String name : names) { @@ -149,7 +149,7 @@ public class UUIDHandler { // add the Everyone '*' UUID add(new StringWrapper("*"), DBFunc.everyone); - PlotSquared.sendConsoleSenderMessage(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); + PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); } public static UUID getUUID(Player player) { From eb828639bb84ad74986b96939592463d060011a9 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 21:29:17 +1100 Subject: [PATCH 009/124] loc --- .../intellectualcrafters/plot/IPlotMain.java | 4 -- .../plot/PlotSquared.java | 6 +-- .../intellectualcrafters/plot/_PlotMain.java | 4 +- .../plot/api/PlotAPI.java | 27 +---------- .../plot/commands/Claim.java | 9 ++-- .../plot/commands/Clear.java | 1 + .../plot/commands/Cluster.java | 1 + .../plot/commands/CommandPermission.java | 2 +- .../plot/commands/Comment.java | 2 +- .../plot/commands/Copy.java | 2 +- .../plot/commands/CreateRoadSchematic.java | 2 +- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugClear.java | 1 + .../plot/commands/DebugRoadRegen.java | 4 +- .../plot/commands/Delete.java | 1 + .../plot/commands/Denied.java | 2 +- .../plot/commands/FlagCmd.java | 2 +- .../plot/commands/Helpers.java | 2 +- .../plot/commands/Home.java | 2 +- .../plot/commands/Inbox.java | 1 + .../plot/commands/Kick.java | 2 +- .../plot/commands/Merge.java | 1 + .../plot/commands/Move.java | 9 ---- .../plot/commands/Paste.java | 2 +- .../plot/commands/Reload.java | 1 + .../plot/commands/Schematic.java | 1 + .../plot/commands/Set.java | 4 +- .../plot/commands/SetOwner.java | 1 + .../plot/commands/Swap.java | 1 + .../plot/commands/Trim.java | 4 -- .../plot/commands/Trusted.java | 2 +- .../plot/commands/Unclaim.java | 1 + .../plot/commands/Unlink.java | 1 + .../plot/commands/WE_Anywhere.java | 1 + .../intellectualcrafters/plot/config/C.java | 10 +++-- .../plot/database/Database.java | 2 - .../plot/database/MySQL.java | 2 - .../plot/database/SQLite.java | 2 - .../plot/generator/AugmentedPopulator.java | 2 +- .../plot/generator/ClassicPlotManager.java | 9 ---- .../plot/generator/HybridPlotManager.java | 4 +- .../plot/listeners/PlayerEvents.java | 1 + .../plot/listeners/PlayerEvents_1_8.java | 2 +- .../plot/listeners/PlotPlusListener.java | 2 +- .../plot/listeners/WorldEditListener.java | 1 + .../plot/object/Plot.java | 2 +- .../plot/object/PlotManager.java | 1 - .../plot/util/BlockManager.java | 2 - .../plot/util/ChunkManager.java | 45 ++++++++++--------- .../intellectualcrafters/plot/util/PWE.java | 1 + .../plot/util/PlayerFunctions.java | 2 +- .../plot/util/SetBlockManager.java | 3 -- .../plot/util/UUIDHandler.java | 1 - .../plot/util/bukkit/BukkitTaskManager.java | 11 +++-- .../plot/util/bukkit/BukkitUtil.java | 1 - .../translation/bukkit/TranslationPlugin.java | 2 +- 56 files changed, 83 insertions(+), 133 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 780a33d78..3129a48ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -2,12 +2,8 @@ package com.intellectualcrafters.plot; import java.io.File; -import org.bukkit.entity.Player; - import net.milkbowl.vault.economy.Economy; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.TaskManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index f95ae7d61..877eeaac6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -14,9 +14,9 @@ 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; +import java.util.UUID; import net.milkbowl.vault.economy.Economy; @@ -49,10 +49,10 @@ 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.PlotHelper; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; public class PlotSquared { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java index 5080f75ad..6dd1bffd6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java @@ -383,7 +383,7 @@ public class _PlotSquared { return true; } PlayerFunctions.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + ""); - Location loc = player.getLocation(); + Location loc = BukkitUtil.getLocation(entity); final String world = player.getWorld(); final String name = player.getName(); TaskManager.TELEPORT_QUEUE.add(name); @@ -398,7 +398,7 @@ public class _PlotSquared { if (!player.isOnline()) { return; } - Location loc = player.getLocation(); + Location loc = BukkitUtil.getLocation(entity); if (!loc.getWorld().equals(world)) { PlayerFunctions.sendMessage(player, C.TELEPORT_FAILED); return; 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 0cd0e7d97..66a1241e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -21,31 +21,6 @@ package com.intellectualcrafters.plot.api; -import java.util.ArrayList; -import java.util.Set; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.commands.MainCommand; -import com.intellectualcrafters.plot.commands.SubCommand; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.flag.AbstractFlag; -import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.PlotSquaredException; -import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.UUIDHandler; /** * PlotSquared API @@ -423,7 +398,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; // * @see com.intellectualcrafters.plot.object.Plot // */ // public Plot getPlot(final Player player) { -// return this.getPlot(player.getLocation()); +// return this.getPlot(BukkitUtil.getLocation(entity)); // } // // /** 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 2f1db2f48..cd101a200 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -27,11 +27,10 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; -import com.intellectualcrafters.plot.generator.ClassicPlotWorld; -import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlayerFunctions; @@ -62,7 +61,7 @@ public class Claim extends SubCommand { PlotHelper.setSign(player, plot); PlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { - PlotSquared.teleportPlayer(player, player.getLocation(), plot); + PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } World world = plot.getWorld(); final PlotWorld plotworld = PlotSquared.getWorldSettings(world); @@ -79,10 +78,10 @@ public class Claim extends SubCommand { sch = SchematicHandler.getSchematic(plotworld.SCHEMATIC_FILE); } } - SchematicHandler.paste(player.getLocation(), sch, plot2, 0, 0); + SchematicHandler.paste(BukkitUtil.getLocation(entity), sch, plot2, 0, 0); } PlotSquared.getPlotManager(plot.world).claimPlot(world, plotworld, plot); - PlotHelper.update(player.getLocation()); + PlotHelper.update(BukkitUtil.getLocation(entity)); } return event.isCancelled(); } 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 6cfa00afb..7a84b43bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -24,6 +24,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; 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 437509315..afc71ee3f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -30,6 +30,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.generator.BlockPopulator; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 9e17b4b1c..f104798a3 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; /** * Created by Citymonstret on 2014-08-03. 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 f8040b252..2eb796700 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; 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 bb492b5e4..08f0e17bf 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotSelection; 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 cab2afda7..d9c6bdb64 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -54,7 +54,7 @@ public class CreateRoadSchematic extends SubCommand { HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); - PlotHelper.update(player.getLocation()); + PlotHelper.update(BukkitUtil.getLocation(entity)); PlayerFunctions.sendMessage(player, "&6Saved new road schematic"); return true; 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 5a01d0a0b..0666b82a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -68,7 +68,7 @@ public class DebugClaimTest extends SubCommand { PlotHelper.setSign(player, plot); PlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { - PlotSquared.teleportPlayer(player, player.getLocation(), plot); + PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } } return event.isCancelled(); 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 1583384cb..770f0e1ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -26,6 +26,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; 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 eab28d1ca..da608c3c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -30,8 +30,8 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; -import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.SetBlockManager; public class DebugRoadRegen extends SubCommand { @@ -46,7 +46,7 @@ public class DebugRoadRegen extends SubCommand { } HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); - Chunk chunk = player.getLocation().getChunk(); + Chunk chunk = BukkitUtil.getLocation(entity).getChunk(); boolean result = manager.regenerateRoad(chunk); if (result) { SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] {chunk})); 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 7d41ddd31..626851473 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -25,6 +25,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 63ca9c501..944a413b5 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; 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 972bc5a10..3d2b48088 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; 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 81219107a..85a7baab7 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; 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 e326d5eee..de758bb59 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -88,7 +88,7 @@ public class Home extends SubCommand { } public void teleportPlayer(Player player, Plot plot) { - PlotSquared.teleportPlayer(player, player.getLocation(), plot); + PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), 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 d1f3d39ec..de4b7952e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -29,6 +29,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 e70767edd..4cbb260eb 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; 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 c2330fd1e..ff8989b71 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -30,6 +30,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlotMergeEvent; 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 40ee9422b..c180aba67 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -21,21 +21,12 @@ package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.UUID; - -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; /** * Created 2014-08-01 for PlotSquared 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 343ae313b..b05d85c18 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotSelection; 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 f847acff3..bf604e31e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -26,6 +26,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.PlayerFunctions; public class Reload extends SubCommand { 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 130edd9ce..eaa3a0c2b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -31,6 +31,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.jnbt.CompoundTag; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; 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 676fa58c8..b56466d8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -21,7 +21,6 @@ package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -33,15 +32,14 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; -import com.intellectualcrafters.plot.config.Configuration.SettingValue; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Plot; 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 79eb7fb2b..347a5bef0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -27,6 +27,7 @@ import java.util.UUID; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 57ee354d3..e93c1de94 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -24,6 +24,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 57d023160..cd1c3d193 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -28,7 +28,6 @@ import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.HashSet; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -37,13 +36,10 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.generator.SquarePlotManager; -import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; 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 3d1d493c7..b2618a6d1 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; 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 91d534670..4add6adbb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -26,6 +26,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 7d91e0868..86ad65d27 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -27,6 +27,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 eb37026bb..789fd2812 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,6 +23,7 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.util.PWE; import com.intellectualcrafters.plot.util.PlayerFunctions; 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 9995b1689..92d96cb37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -21,11 +21,15 @@ package com.intellectualcrafters.plot.config; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualsites.translation.*; -import com.intellectualsites.translation.bukkit.BukkitTranslation; import org.bukkit.ChatColor; +import com.intellectualsites.translation.TranslationFile; +import com.intellectualsites.translation.TranslationLanguage; +import com.intellectualsites.translation.TranslationManager; +import com.intellectualsites.translation.TranslationObject; +import com.intellectualsites.translation.YamlTranslationFile; +import com.intellectualsites.translation.bukkit.BukkitTranslation; + /** * Captions class. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java index b9e14899d..0e3b503e9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java @@ -25,8 +25,6 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; -import org.bukkit.plugin.Plugin; - import com.intellectualcrafters.plot.PlotSquared; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index 2dd5a0f3c..6622a85c5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -27,8 +27,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import org.bukkit.plugin.Plugin; - import com.intellectualcrafters.plot.PlotSquared; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index 392381d04..495f2999d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -30,8 +30,6 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; -import org.bukkit.plugin.Plugin; - import com.intellectualcrafters.plot.PlotSquared; /** 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 cd98d066b..030931cb2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -17,9 +17,9 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; public class AugmentedPopulator extends BlockPopulator { 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 c1d93bd85..878fb7589 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -1,25 +1,16 @@ package com.intellectualcrafters.plot.generator; import java.util.ArrayList; -import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; /** 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 a25ce25de..eb07a6f95 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -29,7 +29,6 @@ import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.plugin.Plugin; @@ -41,11 +40,10 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; 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 93b6710a6..1683bfe25 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -83,6 +83,7 @@ import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.WorldInitEvent; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.commands.Setup; import com.intellectualcrafters.plot.config.C; 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 4c45a933c..7edea424e 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; 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 9bd0b376c..bd057d4d8 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; 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 443bd91ef..7ce18627a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -40,6 +40,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; 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 5269fcd42..972ce83f5 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.PlotSquared; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.util.PlotHelper; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 80c6dc9c9..2c63302ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -23,7 +23,6 @@ package com.intellectualcrafters.plot.object; import java.util.ArrayList; -import org.bukkit.World; import org.bukkit.block.Biome; public abstract class PlotManager { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 9f6c68ade..d030ab618 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -1,7 +1,5 @@ package com.intellectualcrafters.plot.util; -import org.bukkit.World; - import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; 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 7efbf52b8..ac6e8d344 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -10,7 +10,6 @@ import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.DyeColor; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Note; import org.bukkit.SkullType; @@ -43,10 +42,12 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class ChunkManager { @@ -57,8 +58,8 @@ public class ChunkManager { public static HashMap tasks = new HashMap<>(); public static ChunkLoc getChunkChunk(Location loc) { - int x = loc.getBlockX() >> 9; - int z = loc.getBlockZ() >> 9; + int x = loc.getX() >> 9; + int z = loc.getZ() >> 9; return new ChunkLoc(x, z); } @@ -153,21 +154,21 @@ public class ChunkManager { */ public static boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) { index.increment(); - final int relX = newPos.getBlockX() - pos1.getBlockX(); - final int relZ = newPos.getBlockZ() - pos1.getBlockZ(); - final RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ()); + final int relX = newPos.getX() - pos1.getX(); + final int relZ = newPos.getZ() - pos1.getZ(); + final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); final World world = pos1.getWorld(); Chunk c1 = world.getChunkAt(pos1); Chunk c2 = world.getChunkAt(pos2); - Chunk c3 = world.getChunkAt((pos1.getBlockX() + relX) >> 4, (pos1.getBlockZ() + relZ) >> 4); - Chunk c4 = world.getChunkAt((pos2.getBlockX() + relX) >> 4, (pos2.getBlockZ() + relZ) >> 4); + Chunk c3 = world.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4); + Chunk c4 = world.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4); - final int sx = pos1.getBlockX(); - final int sz = pos1.getBlockZ(); - final int ex = pos2.getBlockX(); - final int ez = pos2.getBlockZ(); + final int sx = pos1.getX(); + final int sz = pos1.getZ(); + final int ex = pos2.getX(); + final int ez = pos2.getZ(); final int c1x = c1.getX(); final int c1z = c1.getZ(); @@ -275,10 +276,10 @@ public class ChunkManager { Chunk c1 = world.getChunkAt(pos1); Chunk c2 = world.getChunkAt(pos2); - final int sx = pos1.getBlockX(); - final int sz = pos1.getBlockZ(); - final int ex = pos2.getBlockX(); - final int ez = pos2.getBlockZ(); + final int sx = pos1.getX(); + final int sz = pos1.getZ(); + final int ex = pos2.getX(); + final int ez = pos2.getZ(); final int c1x = c1.getX(); final int c1z = c1.getZ(); @@ -304,7 +305,7 @@ public class ChunkManager { tasks.remove(currentIndex); return; } - CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ()); + CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); Chunk chunk = chunks.get(0); chunks.remove(0); int x = chunk.getX(); @@ -396,8 +397,8 @@ public class ChunkManager { public static void saveEntitiesOut(Chunk chunk, RegionWrapper region) { for (Entity entity : chunk.getEntities()) { Location loc = entity.getLocation(); - int x = loc.getBlockX(); - int z = loc.getBlockZ(); + int x = loc.getX(); + int z = loc.getZ(); if (isIn(region, x, z)) { continue; } @@ -411,9 +412,9 @@ public class ChunkManager { public static void saveEntitiesIn(Chunk chunk, RegionWrapper region) { for (Entity entity : chunk.getEntities()) { - Location loc = entity.getLocation(); - int x = loc.getBlockX(); - int z = loc.getBlockZ(); + Location loc = BukkitUtil.getLocation(entity); + int x = loc.getX(); + int z = loc.getZ(); if (!isIn(region, x, z)) { continue; } 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 d198db9d0..683e1b19e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -25,6 +25,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; 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 b0cef2723..c0a66ccb8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -172,7 +172,7 @@ import java.util.UUID; if (!PlotSquared.isPlotWorld(player.getWorld())) { return null; } - final PlotId id = getPlot(player.getLocation()); + final PlotId id = getPlot(BukkitUtil.getLocation(entity)); final World world = player.getWorld(); if (id == null) { return null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java index 0c1ddd854..34755dd02 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java @@ -3,9 +3,6 @@ package com.intellectualcrafters.plot.util; import java.util.List; import org.bukkit.Chunk; -import org.bukkit.World; - -import com.intellectualcrafters.plot.object.PlotBlock; public abstract class SetBlockManager { public static SetBlockManager setBlockManager = null; 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 78ed98bcf..5ed532a3a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -13,7 +13,6 @@ import org.bukkit.entity.Player; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; 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; 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 47cbf69c6..6ba807dc5 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 @@ -1,9 +1,6 @@ package com.intellectualcrafters.plot.util.bukkit; -import java.util.HashSet; - import com.intellectualcrafters.plot.BukkitMain; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.util.TaskManager; public class BukkitTaskManager extends TaskManager { @@ -21,9 +18,11 @@ public class BukkitTaskManager extends TaskManager { } public void taskLater(final Runnable r, int delay) { - if (r == null) { - return; - } BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay); } + + @Override + public void taskLaterAsync(Runnable r, int delay) { + BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index df9ec1abe..2cbd42342 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -15,7 +15,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.SetBlockSlow; diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java index 4fa992155..612307dc2 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java @@ -33,7 +33,7 @@ public class TranslationPlugin extends JavaPlugin { e.printStackTrace(); } // Now let's create some default files :D - this.english = new YamlTranslationFile(BukkitTranslation.getParent(this), TranslationLanguage.englishAmerican, getName(), manager).read().header("Example file", "@author Citymonstret"); + this.english = new YamlTranslationFile(BukkitTranslation.getParent(), TranslationLanguage.englishAmerican, getName(), manager).read().header("Example file", "@author Citymonstret"); // That created the file, read it, and made a default header getLogger().log(Level.INFO, BukkitTranslation.convert(manager.getTranslated("translator_loaded", TranslationLanguage.englishAmerican))); } From 42a95860ae75c6d9a83f0c24c7cb46eb83300670 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 21:47:05 +1100 Subject: [PATCH 010/124] setblock --- .../intellectualcrafters/plot/BukkitMain.java | 3 +- .../plot/util/SchematicHandler.java | 64 +++++++++++-------- .../plot/util/SetBlockFast_1_8.java | 41 ++++++++++-- 3 files changed, 75 insertions(+), 33 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 7369471f9..15ffc7715 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -46,6 +46,7 @@ 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.SetBlockFast_1_8; import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.SetBlockSlow; import com.intellectualcrafters.plot.util.TaskManager; @@ -337,7 +338,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { public void initSetBlockManager() { if (checkVersion(1, 8, 0)) { try { - SetBlockManager.setBlockManager = new SetBlockSlow(); + SetBlockManager.setBlockManager = new SetBlockFast_1_8(); } catch (Throwable e) { e.printStackTrace(); 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 9e049fea3..74a2bcc23 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -34,7 +34,6 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.bukkit.Chunk; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; @@ -48,6 +47,7 @@ import com.intellectualcrafters.jnbt.ShortTag; import com.intellectualcrafters.jnbt.StringTag; import com.intellectualcrafters.jnbt.Tag; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -81,9 +81,9 @@ public class SchematicHandler { final DataCollection[] blocks = schematic.getBlockCollection(); - Location l1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId()); + Location l1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId()); - final int sy = location.getWorld().getHighestBlockYAt(l1.getBlockX() + 1, l1.getBlockZ() + 1); + final int sy = location.getWorld().getHighestBlockYAt(l1.getX() + 1, l1.getZ() + 1); l1 = l1.add(1, sy - 1, 1); @@ -93,7 +93,7 @@ public class SchematicHandler { if (HEIGHT == location.getWorld().getMaxHeight()) { y_offset = 0; } else { - y_offset = l1.getBlockY(); + y_offset = l1.getY(); } for (int x = 0; x < WIDTH; x++) { @@ -107,12 +107,12 @@ public class SchematicHandler { final byte data = block.getData(); // if (block.tag != null) { - // WorldEditUtils.setNBT(world, id, data, l1.getBlockX() - // + x + x_offset, y + y_offset, l1.getBlockZ() + z + + // WorldEditUtils.setNBT(world, id, data, l1.getX() + // + x + x_offset, y + y_offset, l1.getZ() + z + // z_offset, block.tag); // } // else { - PlotHelper.setBlock(world, l1.getBlockX() + x + x_offset, y + y_offset, l1.getBlockZ() + z + z_offset, id, data); + PlotHelper.setBlock(world, l1.getX() + x + x_offset, y + y_offset, l1.getZ() + z + z_offset, id, data); // } } } @@ -252,8 +252,8 @@ public class SchematicHandler { int i = 0; int j = 0; try { - for (i = (pos1.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i += 16) { - for (j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) { + for (i = (pos1.getX() / 16) * 16; i < (16 + ((pos2.getX() / 16) * 16)); i += 16) { + for (j = (pos1.getZ() / 16) * 16; j < (16 + ((pos2.getZ() / 16) * 16)); j += 16) { final Chunk chunk = world.getChunkAt(i, j); final boolean result = chunk.load(false); if (!result) { @@ -268,9 +268,9 @@ public class SchematicHandler { PlotSquared.log("&7 - Cannot save: corrupt chunk at " + (i / 16) + ", " + (j / 16)); return null; } - final int width = (pos2.getBlockX() - pos1.getBlockX()) + 1; - final int height = pos2.getBlockY() - pos1.getBlockY() + 1; - final int length = (pos2.getBlockZ() - pos1.getBlockZ()) + 1; + final int width = (pos2.getX() - pos1.getX()) + 1; + final int height = pos2.getY() - pos1.getY() + 1; + final int length = (pos2.getZ() - pos1.getZ()) + 1; final HashMap schematic = new HashMap<>(); schematic.put("Width", new ShortTag("Width", (short) width)); @@ -287,14 +287,14 @@ public class SchematicHandler { byte[] addBlocks = null; final byte[] blockData = new byte[width * height * length]; - int sx = pos1.getBlockX(); - int ex = pos2.getBlockX(); + int sx = pos1.getX(); + int ex = pos2.getX(); - int sz = pos1.getBlockZ(); - int ez = pos2.getBlockZ(); + int sz = pos1.getZ(); + int ez = pos2.getZ(); - int sy = pos1.getBlockY(); - int ey = pos2.getBlockY(); + int sy = pos1.getY(); + int ey = pos2.getY(); for (int x = 0; x < width; x++) { for (int z = 0; z < length; z++) { @@ -334,30 +334,38 @@ public class SchematicHandler { return new CompoundTag("Schematic", schematic); } - public static boolean pastePart(final World world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) { - boolean result = false; + public static boolean pastePart(final String world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) { + int[] xl = new int[i2]; + int[] yl = new int[i2]; + int[] zl = new int[i2]; + int[] ids = new int[i2]; + byte[] data = new byte[i2]; + for (int i = i1; i <= i2; i++) { - final short id = blocks[i].getBlock(); - final byte data = blocks[i].getData(); + final short id = blocks[i].block; if (id == 0) { continue; } - + final int area = WIDTH * LENGTH; final int r = i % (area); final int x = r % WIDTH; final int y = i / area; final int z = r / WIDTH; + + xl[i] = x; + yl[i] = y; + zl[i] = z; + + ids[i] = id; + data[i] = blocks[i].data; if (y > 256) { break; } - final boolean set = PlotHelper.setBlock(world, l1.getBlockX() + x + x_offset, l1.getBlockY() + y, l1.getBlockZ() + z + z_offset, id, data); - if (!result && set) { - result = true; - } } - return result; + BlockManager.setBlocks(world, xl, yl, zl, ids, data); + return true; } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java index 811eef19b..6169a6bf2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java @@ -27,6 +27,7 @@ import java.util.List; import org.bukkit.Chunk; import org.bukkit.World; +import org.bukkit.block.Block; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; @@ -86,13 +87,45 @@ public class SetBlockFast_1_8 extends SetBlockManager { * @return true */ @Override - public void set(final World world, final int x, final int y, final int z, final int blockId, final byte data) { - + public void set(final World world, final int x, final int y, final int z, final int id, final byte data) { + switch (id) { + case 54: + case 130: + case 146: + case 27: + case 28: + case 66: + case 157: + case 61: + case 62: + case 158: + case 23: + case 123: + case 124: + case 29: + case 33: + case 151: + case 178: { + Block block = world.getBlockAt(x, y, z); + if (block.getData() == data) { + if (block.getTypeId() != id) { + block.setTypeId(id, false); + } + } else { + if (block.getTypeId() == id) { + block.setData(data, false); + } else { + block.setTypeIdAndData(id, data, false); + } + } + return; + } + } final Object w = methodGetHandle.of(world).call(); final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); final Object pos = constructorBlockPosition.create((int) (x & 0x0f), y, (int) (z & 0x0f)); - final Object id = methodGetByCombinedId.of(null).call(blockId + (data << 12)); - methodA.of(chunk).call(pos, id); + final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12)); + methodA.of(chunk).call(pos, combined); } From 70ff6d87c8dbc91f64091333fdbd10f4183802ca Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 22:06:27 +1100 Subject: [PATCH 011/124] schematic --- .../plot/commands/DebugExec.java | 2 +- .../plot/generator/HybridPlotManager.java | 2 +- .../plot/util/SchematicHandler.java | 78 ++++++++++--------- .../plot/util/bukkit/BukkitUtil.java | 18 +++++ 4 files changed, 60 insertions(+), 40 deletions(-) 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 b774f2f59..50ad38b72 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -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(PlotSquared.getMain().getDirectory() + File.separator + "trim.txt"); + final File file = new File(PlotSquared.IMP.getDirectory() + File.separator + "trim.txt"); PrintWriter writer; try { writer = new PrintWriter(file); 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 eb07a6f95..cef663749 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -145,7 +145,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2); CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4); - String dir = PlotSquared.getMain().getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator; + String dir = PlotSquared.IMP.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"); 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 74a2bcc23..20fff2e99 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -50,6 +50,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * Schematic Handler @@ -83,40 +84,38 @@ public class SchematicHandler { Location l1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId()); - final int sy = location.getWorld().getHighestBlockYAt(l1.getX() + 1, l1.getZ() + 1); + final int sy = BukkitUtil.getHeighestBlock(location.getWorld(), l1.getX() + 1, l1.getZ() + 1); l1 = l1.add(1, sy - 1, 1); - final World world = location.getWorld(); - int y_offset; - if (HEIGHT == location.getWorld().getMaxHeight()) { + if (HEIGHT == BukkitUtil.getMaxHeight(location.getWorld())) { y_offset = 0; } else { y_offset = l1.getY(); } + + int[] xl = new int[blocks.length]; + int[] yl = new int[blocks.length]; + int[] zl = new int[blocks.length]; + int[] ids = new int[blocks.length]; + byte[] data = new byte[blocks.length]; for (int x = 0; x < WIDTH; x++) { for (int z = 0; z < LENGTH; z++) { for (int y = 0; y < HEIGHT; y++) { final int index = (y * WIDTH * LENGTH) + (z * WIDTH) + x; - final DataCollection block = blocks[index]; - - final short id = block.getBlock(); - final byte data = block.getData(); - - // if (block.tag != null) { - // WorldEditUtils.setNBT(world, id, data, l1.getX() - // + x + x_offset, y + y_offset, l1.getZ() + z + - // z_offset, block.tag); - // } - // else { - PlotHelper.setBlock(world, l1.getX() + x + x_offset, y + y_offset, l1.getZ() + z + z_offset, id, data); - // } + xl[index] = x; + yl[index] = y; + zl[index] = z; + ids[index] = block.block; + data[index] = block.data; } } } + BlockManager.setBlocks(plot.world, xl, yl, zl, ids, data); + } catch (final Exception e) { return false; } @@ -170,14 +169,14 @@ public class SchematicHandler { */ public static Schematic getSchematic(final String name) { { - final File parent = new File(PlotSquared.getMain().getDirectory() + File.separator + "schematics"); + final File parent = new File(PlotSquared.IMP.getDirectory() + File.separator + "schematics"); if (!parent.exists()) { if (!parent.mkdir()) { throw new RuntimeException("Could not create schematic parent directory"); } } } - final File file = new File(PlotSquared.getMain().getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); + final File file = new File(PlotSquared.IMP.getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); if (!file.exists()) { PlotSquared.log(file.toString() + " doesn't exist"); return null; @@ -244,17 +243,14 @@ public class SchematicHandler { } @SuppressWarnings("deprecation") - public static CompoundTag getCompoundTag(final World world, Location pos1, Location pos2) { - - - + public static CompoundTag getCompoundTag(final String world, Location pos1, Location pos2) { // loading chunks int i = 0; int j = 0; try { for (i = (pos1.getX() / 16) * 16; i < (16 + ((pos2.getX() / 16) * 16)); i += 16) { for (j = (pos1.getZ() / 16) * 16; j < (16 + ((pos2.getZ() / 16) * 16)); j += 16) { - final Chunk chunk = world.getChunkAt(i, j); + final Chunk chunk = BukkitUtil.getChunkAt(world, i, j); final boolean result = chunk.load(false); if (!result) { @@ -301,8 +297,7 @@ public class SchematicHandler { for (int y = 0; y < height; y++) { final int index = (y * width * length) + (z * width) + x; - final Block block = world.getBlockAt(new Location(world, sx + x, sy + y, sz + z)); - + block = BukkitUtil.getBlock(new Location(world, sx + x, sy + y, sz + z)); @SuppressWarnings("deprecation") final int id2 = block.getTypeId(); if (id2 > 255) { @@ -335,17 +330,25 @@ public class SchematicHandler { } public static boolean pastePart(final String world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) { - int[] xl = new int[i2]; - int[] yl = new int[i2]; - int[] zl = new int[i2]; - int[] ids = new int[i2]; - byte[] data = new byte[i2]; - + int length = 0; + for (int i = i1; i <= i2; i++) { + if (blocks[i].block == 0) { + length++; + } + } + length = i2 - length; + int[] xl = new int[length]; + int[] yl = new int[length]; + int[] zl = new int[length]; + int[] ids = new int[length]; + byte[] data = new byte[length]; + int count = 0; for (int i = i1; i <= i2; i++) { final short id = blocks[i].block; if (id == 0) { continue; } + count++; final int area = WIDTH * LENGTH; final int r = i % (area); @@ -353,13 +356,12 @@ public class SchematicHandler { final int y = i / area; final int z = r / WIDTH; - xl[i] = x; - yl[i] = y; - zl[i] = z; + xl[count] = x; + yl[count] = y; + zl[count] = z; - ids[i] = id; - data[i] = blocks[i].data; - + ids[count] = id; + data[count] = blocks[i].data; if (y > 256) { break; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 2cbd42342..e3ba7dba9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -15,6 +15,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.SetBlockSlow; @@ -37,6 +38,14 @@ public class BukkitUtil extends BlockManager { return world; } + public static int getMaxHeight(String world) { + return getWorld(world).getMaxHeight(); + } + + public static int getHeighestBlock(String world, int x, int z) { + return getWorld(world).getHighestBlockYAt(x, z); + } + public static Chunk getChunkAt(String worldname, int x, int z) { World world = getWorld(worldname); return world.getChunkAt(x, z); @@ -76,6 +85,15 @@ public class BukkitUtil extends BlockManager { SetBlockManager.setBlockManager.set(world, x, y, z, id, data); } } + + public static PlotBlock getBlock(Location loc) { + World world = getWorld(loc.getWorld()); + Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); + if (block == null) { + return new PlotBlock((short) 0 , (byte) 0); + } + return new PlotBlock((short) block.getTypeId(), block.getData()); + } public static Location getLocation(Entity entity) { org.bukkit.Location loc = entity.getLocation(); From aefd148bcd99dc44db0ba8675a4fd2925f79af85 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 22:35:45 +1100 Subject: [PATCH 012/124] PWE --- .../com/intellectualcrafters/plot/BukkitMain.java | 7 +++---- .../com/intellectualcrafters/plot/PlotSquared.java | 2 ++ .../com/intellectualcrafters/plot/util/PWE.java | 12 ++++++------ .../plot/util/PlayerFunctions.java | 6 +++--- .../plot/util/SchematicHandler.java | 14 +++++++------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 15ffc7715..33e4ae233 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -127,7 +127,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { public static void worldLoad(WorldLoadEvent event) { UUIDHandler.cacheAll(); } - + @EventHandler public void PlayerCommand(PlayerCommandPreprocessEvent event) { String message = event.getMessage(); @@ -308,9 +308,8 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { @Override public void registerWorldEditEvents() { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { - WorldEditPlugin worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); - - final String version = worldEdit.getDescription().getVersion(); + PlotSquared.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + final String version = PlotSquared.worldEdit.getDescription().getVersion(); if ((version != null) && version.startsWith("5.")) { log("&cThis version of WorldEdit does not support PlotSquared."); log("&cPlease use WorldEdit 6+ for masking support"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 877eeaac6..037d343a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.util.Logger.LogLevel; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class PlotSquared { @@ -74,6 +75,7 @@ public class PlotSquared { public static TaskManager TASK = null; private static boolean LOADING_WORLD = false; public static Economy economy = null; + public static WorldEditPlugin worldEdit = null; private final static HashMap plotworlds = new HashMap<>(); private final static HashMap plotmanagers = new HashMap<>(); 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 683e1b19e..309e19d2a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -21,7 +21,6 @@ package com.intellectualcrafters.plot.util; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; @@ -29,6 +28,7 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.sk89q.worldedit.LocalSession; @@ -44,7 +44,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings("ALL") public class PWE { +public class PWE { public static void setMask(final Player p, final Location l, boolean force) { try { @@ -54,7 +54,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; } else { s = PlotSquared.worldEdit.getSession(p); } - if (!PlotSquared.isPlotWorld(p.getWorld())) { + if (!PlotSquared.isPlotWorld(p.getWorld().getName())) { removeMask(p); } final PlotId id = PlayerFunctions.getPlot(l); @@ -66,13 +66,13 @@ import com.sk89q.worldedit.regions.CuboidRegion; } boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)); if (r) { - final World w = l.getWorld(); + final String w = l.getWorld(); final Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id); final Location tloc = PlotHelper.getPlotTopLoc(w, plot.id); - 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 Vector bvec = new Vector(bloc.getX() + 1, bloc.getY(), bloc.getZ() + 1); + final Vector tvec = new Vector(tloc.getX(), tloc.getY(), tloc.getZ()); final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(p).getWorld(); 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 c0a66ccb8..c33eb0fa1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -24,13 +24,13 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.util.ChatPaginator; @@ -133,7 +133,7 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - return manager.getPlotIdAbs(plotworld, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); } @@ -151,7 +151,7 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - PlotId id = manager.getPlotId(plotworld, loc.getBlockX(),loc.getBlockY(), loc.getBlockZ()); + PlotId id = manager.getPlotId(plotworld, loc.getX(),loc.getY(), loc.getZ()); if (id!=null && plotworld.TYPE == 2) { if (ClusterManager.getCluster(world, id) == null) { 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 20fff2e99..82e21b601 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -49,6 +49,7 @@ import com.intellectualcrafters.jnbt.Tag; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -231,7 +232,7 @@ public class SchematicHandler { * * @return tag */ - public static CompoundTag getCompoundTag(final World world, PlotId id) { + public static CompoundTag getCompoundTag(final String world, PlotId id) { if (!PlotSquared.getPlots(world).containsKey(id)) { return null; } @@ -297,19 +298,18 @@ public class SchematicHandler { for (int y = 0; y < height; y++) { final int index = (y * width * length) + (z * width) + x; - block = BukkitUtil.getBlock(new Location(world, sx + x, sy + y, sz + z)); - @SuppressWarnings("deprecation") final int id2 = block.getTypeId(); + PlotBlock block = BukkitUtil.getBlock(new Location(world, sx + x, sy + y, sz + z)); - if (id2 > 255) { + if (block.id > 255) { if (addBlocks == null) { addBlocks = new byte[(blocks.length >> 1) + 1]; } - addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((id2 >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((id2 >> 8) & 0xF) << 4)); + addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((block.id >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((block.id >> 8) & 0xF) << 4)); } - blocks[index] = (byte) id2; - blockData[index] = block.getData(); + blocks[index] = (byte) block.id; + blockData[index] = block.data; // We need worldedit to save tileentity data or entities // - it uses NMS and CB internal code, which changes every From 96d268803543d0d27ad9a8b719aae3ec62c192b0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 22:39:23 +1100 Subject: [PATCH 013/124] plot --- .../plot/commands/Claim.java | 4 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/Unclaim.java | 2 +- .../plot/database/SQLManager.java | 4 +- .../plot/listeners/PlayerEvents.java | 4 +- .../plot/listeners/WorldGuardListener.java | 8 +- .../plot/object/PlotSettings.java | 2 +- .../plot/util/PlotHelper.java | 754 +++++++++--------- 8 files changed, 390 insertions(+), 390 deletions(-) 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 cd101a200..ef0b09561 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -63,7 +63,7 @@ public class Claim extends SubCommand { if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } - World world = plot.getWorld(); + World world = plot.world; final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id); @@ -102,7 +102,7 @@ public class Claim extends SubCommand { if (plot.hasOwner()) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } - final PlotWorld world = PlotSquared.getWorldSettings(plot.getWorld()); + final PlotWorld world = PlotSquared.getWorldSettings(plot.world); if (PlotSquared.useEconomy && world.USE_ECONOMY) { final double cost = world.PLOT_PRICE; if (cost > 0d) { 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 626851473..cd4f34300 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -53,7 +53,7 @@ public class Delete extends SubCommand { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.getWorld()); + final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.world); 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) { 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 4add6adbb..3b0488b29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -54,7 +54,7 @@ public class Unclaim extends SubCommand { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.getWorld()); + final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.world); if (PlotSquared.useEconomy && pWorld.USE_ECONOMY) { final double c = pWorld.SELL_PRICE; if (c > 0d) { 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 a67151f09..21df6b43d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1078,7 +1078,7 @@ public class SQLManager implements AbstractDB { String comparison = below ? ">=" : "="; if (plot != null) { statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?"); - statement.setInt(1, getId(plot.getWorld().getName(), plot.id)); + statement.setInt(1, getId(plot.world.getName(), plot.id)); statement.setInt(2, tier); } else { @@ -1284,7 +1284,7 @@ public class SQLManager implements AbstractDB { public double getRatings(final Plot plot) { try { final PreparedStatement statement = this.connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `" + this.prefix + "plot_ratings` WHERE `plot_plot_id` = ? "); - statement.setInt(1, getId(plot.getWorld().getName(), plot.id)); + statement.setInt(1, getId(plot.world.getName(), plot.id)); final ResultSet set = statement.executeQuery(); double rating = 0; while (set.next()) { 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 1683bfe25..e0b42ab53 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -711,9 +711,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Set plots = PlotSquared.getPlots(event.getPlayer()); for (final Plot plot : plots) { PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); - final PlotManager manager = PlotSquared.getPlotManager(plot.getWorld()); + final PlotManager manager = PlotSquared.getPlotManager(plot.world); manager.clearPlot(null, plotworld, plot, true, null); - DBFunc.delete(plot.getWorld().getName(), plot); + DBFunc.delete(plot.world.getName(), plot); PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); } } 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 08bcd96e3..d5de3598f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -192,13 +192,13 @@ public class WorldGuardListener implements Listener { try { final Player player = event.getPlayer(); final Plot plot = event.getPlot(); - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(plot.getWorld()); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(plot.world); - final Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId()); - final Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId()); + final Location location1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId()); + final Location location2 = PlotHelper.getPlotTopLoc(plot.world, plot.getId()); final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); - final BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ()); + final BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.world.getMaxHeight(), location2.getBlockZ()); final ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index e0a39f0ad..6ab96bab0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -106,7 +106,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; * @return biome at plot loc */ public Biome getBiome() { - return PlotHelper.getPlotBottomLoc(this.plot.getWorld(), this.plot.getId()).add(1, 0, 1).getBlock().getBiome(); + return PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1).getBlock().getBiome(); } public BlockLoc getPosition() { 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 655a26fa0..c3886fe9a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -452,7 +452,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; * Create a plot without notifying the merge function or world border manager */ public static Plot createPlotAbs(final UUID uuid, final Plot plot) { - final World w = plot.getWorld(); + final World w = plot.world; final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList(), new ArrayList(), w.getName()); PlotSquared.updatePlot(p); DBFunc.createPlotAndSettings(p); @@ -531,7 +531,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; }); return; } - Runnable run = new Runnable() { + Runnable run = new Runnable() { @Override public void run() { PlotHelper.setBiome(world, plot, Biome.FOREST); @@ -553,9 +553,9 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; */ public static void clear(final Player requester, final Plot plot, final boolean isDelete) { if (requester == null) { - clearAllEntities(plot.getWorld(), plot, false); - clear(requester, plot.getWorld(), plot, isDelete); - removeSign(plot.getWorld(), plot); + clearAllEntities(plot.world, plot, false); + clear(requester, plot.world, plot, isDelete); + removeSign(plot.world, plot); return; } if (runners.containsKey(plot)) { @@ -571,376 +571,376 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; clear(requester, world, plot, isDelete); removeSign(world, plot); } - - for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { - for (int x = pos1.getX(); x < pos2.getX(); x++) { - for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - final Block block = world.getBlockAt(x, y, z); - if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { - setBlock(world, x, y, z, newblock.id, newblock.data); - } - } - } - } - } - - public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { - - if (blocks.length == 1) { - setCuboid(world, pos1, pos2, blocks[0]); - return; - } - for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { - for (int x = pos1.getX(); x < pos2.getX(); x++) { - for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - final int i = random(blocks.length); - final PlotBlock newblock = blocks[i]; - final Block block = world.getBlockAt(x, y, z); - if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { - setBlock(world, x, y, z, newblock.id, newblock.data); - } - } - } - } - } - - public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { - - for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { - for (int x = pos1.getX(); x < pos2.getX(); x++) { - for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - final Block block = world.getBlockAt(x, y, z); - if (!((block.getTypeId() == newblock.id))) { - setBlock(world, x, y, z, newblock.id, (byte) 0); - } - } - } - } - } - - public static void setBiome(final String world, final Plot plot, final Biome b) { - - final int bottomX = getPlotBottomLoc(world, plot.id).getX(); - final int topX = getPlotTopLoc(world, plot.id).getX() + 1; - final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); - final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1; - - final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1)); - final Biome biome = block.getBiome(); - - if (biome.equals(b)) { - return; - } - - for (int x = bottomX; x <= topX; x++) { - for (int z = bottomZ; z <= topZ; z++) { - final Block blk = world.getBlockAt(x, 0, z); - final Biome c = blk.getBiome(); - if (c.equals(b)) { - x += 15; - continue; - } - blk.setBiome(b); - } - } - } - - public static int getHeighestBlock(final String world, final int x, final int z) { - - boolean safe = false; - int id; - for (int i = 1; i < world.getMaxHeight(); i++) { - id = world.getBlockAt(x, i, z).getTypeId(); - if (id == 0) { - if (safe) { - return i; - } - safe = true; - } - } - return 64; - } - - /** - * Get plot home - * - * @param w World in which the plot is located - * @param plotid Plot ID - * - * @return Home Location - */ - public static Location getPlotHome(final World w, final PlotId plotid) { - Plot plot = getPlot(w, plotid); - BlockLoc home = plot.settings.getPosition(); - final Location bot = getPlotBottomLoc(w, plotid); - PlotManager manager = PlotSquared.getPlotManager(w); - if (home == null || (home.x == 0 && home.z == 0)) { - final Location top = getPlotTopLoc(w, plotid); - final int x = ((top.getX() - bot.getX())/2) + bot.getX(); - final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); - 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 { - final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); - return bot.add(home.x, y, home.z); - } - } - - /** - * Retrieve the location of the default plot home position - * - * @param plot Plot - * - * @return the location - */ - public static Location getPlotHomeDefault(final Plot plot) { - final Location l = getPlotBottomLoc(plot.getWorld(), plot.getId()).subtract(0, 0, 0); - l.setY(getHeighestBlock(plot.getWorld(), l.getX(), l.getZ())); - return l; - } - - /** - * Get the plot home - * - * @param w World - * @param plot Plot Object - * - * @return Plot Home Location - * - * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) - */ - public static Location getPlotHome(final World w, final Plot plot) { - return getPlotHome(w, plot.id); - } - - /** - * Refresh the plot chunks - * - * @param world World in which the plot is located - * @param plot Plot Object - */ - public static void refreshPlotChunks(final String world, final Plot plot) { - - final int bottomX = getPlotBottomLoc(world, plot.id).getX(); - final int topX = getPlotTopLoc(world, plot.id).getX(); - final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); - final int topZ = getPlotTopLoc(world, plot.id).getZ(); - - final int minChunkX = (int) Math.floor((double) bottomX / 16); - final int maxChunkX = (int) Math.floor((double) topX / 16); - final int minChunkZ = (int) Math.floor((double) bottomZ / 16); - final int maxChunkZ = (int) Math.floor((double) topZ / 16); - - final ArrayList chunks = new ArrayList<>(); - - for (int x = minChunkX; x <= maxChunkX; x++) { - for (int z = minChunkZ; z <= maxChunkZ; z++) { - if (canSendChunk) { - final Chunk chunk = world.getChunkAt(x, z); - chunks.add(chunk); - } else { - world.refreshChunk(x, z); - } - } - } - try { - SendChunk.sendChunk(chunks); - } catch (final Throwable e) { - canSendChunk = false; - for (int x = minChunkX; x <= maxChunkX; x++) { - for (int z = minChunkZ; z <= maxChunkZ; z++) { - world.refreshChunk(x, z); - } - } - } - } - - /** - * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot - * use getPlotTopLoc(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotTopLocAbs(final String world, final PlotId id) { - - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotTopLocAbs(plotworld, id); - } - - /** - * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega - * plot use getPlotBottomLoc(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotBottomLocAbs(final String world, final PlotId id) { - - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotBottomLocAbs(plotworld, id); - } - - /** - * Obtains the width of a plot (x width) - * - * @param world - * @param id - * - * @return - */ - public static int getPlotWidth(final String world, final PlotId id) { - - return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); - } - - /** - * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as - * a small plot use getPlotTopLocAbs(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotTopLoc(final String world, PlotId id) { - - final Plot plot = PlotSquared.getPlots(world).get(id); - if (plot != null) { - id = PlayerFunctions.getTopPlot(world, plot).id; - } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotTopLocAbs(plotworld, id); - } - - /** - * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot - * treated as a small plot use getPlotBottomLocAbs(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotBottomLoc(final String world, PlotId id) { - - final Plot plot = PlotSquared.getPlots(world).get(id); - if (plot != null) { - id = PlayerFunctions.getBottomPlot(world, plot).id; - } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotBottomLocAbs(plotworld, id); - } - - public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { - - 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 (PlotSquared.getPlots(world).get(id) != null) { - if (PlotSquared.getPlots(world).get(id).owner != null) { - return false; - } - } - } - } - return true; - } - - public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { - String worldname = world.getName(); - final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current); - com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot); - final Location top = PlotHelper.getPlotTopLoc(worldname, current); - final Plot currentPlot = PlotHelper.getPlot(worldname, current); - if (currentPlot.owner == null) { - return false; - } - Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot); - Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot); - - PlotId size = PlotHelper.getSize(world, currentPlot); - if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { - return false; - } - - int offset_x = newPlot.x - pos1.id.x; - int offset_y = newPlot.y - pos1.id.y; - final ArrayList selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id); - 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 = PlotSquared.getPlots(worldname).get(id); - PlotSquared.getPlots(worldname).remove(id); - plot.id.x += offset_x; - plot.id.y += offset_y; - PlotSquared.getPlots(worldname).put(plot.id, plot); - } - ChunkManager.copyRegion(bot1, top, bot2, new Runnable() { - @Override - public void run() { - Location bot = bot1.clone().add(1, 0, 1); - ChunkManager.regenerateRegion(bot, top, null); - TaskManager.runTaskLater(whenDone, 1); - } - }); - return true; - } - - public static PlotId getSize(String world, Plot plot) { - - PlotSettings settings = plot.settings; - if (!settings.isMerged()) { - return new PlotId(1,1); - } - Plot top = PlayerFunctions.getTopPlot(world, plot); - Plot bot = PlayerFunctions.getBottomPlot(world, plot); - return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1); - } - - /** - * Fetches the plot from the main class - * - * @param world - * @param id - * - * @return - */ - public static Plot getPlot(final String world, final PlotId id) { - - if (id == null) { - return null; - } - 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()); - } - - /** - * Returns the plot at a given location - * - * @param loc - * - * @return - */ - public static Plot getCurrentPlot(final Location loc) { - final PlotId id = PlayerFunctions.getPlot(loc); - if (id == null) { - return null; - } - 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()); - } +// +// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { +// for (int x = pos1.getX(); x < pos2.getX(); x++) { +// for (int z = pos1.getZ(); z < pos2.getZ(); z++) { +// final Block block = world.getBlockAt(x, y, z); +// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { +// setBlock(world, x, y, z, newblock.id, newblock.data); +// } +// } +// } +// } +// } +// +// public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { +// +// if (blocks.length == 1) { +// setCuboid(world, pos1, pos2, blocks[0]); +// return; +// } +// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { +// for (int x = pos1.getX(); x < pos2.getX(); x++) { +// for (int z = pos1.getZ(); z < pos2.getZ(); z++) { +// final int i = random(blocks.length); +// final PlotBlock newblock = blocks[i]; +// final Block block = world.getBlockAt(x, y, z); +// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { +// setBlock(world, x, y, z, newblock.id, newblock.data); +// } +// } +// } +// } +// } +// +// public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { +// +// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { +// for (int x = pos1.getX(); x < pos2.getX(); x++) { +// for (int z = pos1.getZ(); z < pos2.getZ(); z++) { +// final Block block = world.getBlockAt(x, y, z); +// if (!((block.getTypeId() == newblock.id))) { +// setBlock(world, x, y, z, newblock.id, (byte) 0); +// } +// } +// } +// } +// } +// +// public static void setBiome(final String world, final Plot plot, final Biome b) { +// +// final int bottomX = getPlotBottomLoc(world, plot.id).getX(); +// final int topX = getPlotTopLoc(world, plot.id).getX() + 1; +// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); +// final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1; +// +// final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1)); +// final Biome biome = block.getBiome(); +// +// if (biome.equals(b)) { +// return; +// } +// +// for (int x = bottomX; x <= topX; x++) { +// for (int z = bottomZ; z <= topZ; z++) { +// final Block blk = world.getBlockAt(x, 0, z); +// final Biome c = blk.getBiome(); +// if (c.equals(b)) { +// x += 15; +// continue; +// } +// blk.setBiome(b); +// } +// } +// } +// +// public static int getHeighestBlock(final String world, final int x, final int z) { +// +// boolean safe = false; +// int id; +// for (int i = 1; i < world.getMaxHeight(); i++) { +// id = world.getBlockAt(x, i, z).getTypeId(); +// if (id == 0) { +// if (safe) { +// return i; +// } +// safe = true; +// } +// } +// return 64; +// } +// +// /** +// * Get plot home +// * +// * @param w World in which the plot is located +// * @param plotid Plot ID +// * +// * @return Home Location +// */ +// public static Location getPlotHome(final World w, final PlotId plotid) { +// Plot plot = getPlot(w, plotid); +// BlockLoc home = plot.settings.getPosition(); +// final Location bot = getPlotBottomLoc(w, plotid); +// PlotManager manager = PlotSquared.getPlotManager(w); +// if (home == null || (home.x == 0 && home.z == 0)) { +// final Location top = getPlotTopLoc(w, plotid); +// final int x = ((top.getX() - bot.getX())/2) + bot.getX(); +// final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); +// 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 { +// final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); +// return bot.add(home.x, y, home.z); +// } +// } +// +// /** +// * Retrieve the location of the default plot home position +// * +// * @param plot Plot +// * +// * @return the location +// */ +// public static Location getPlotHomeDefault(final Plot plot) { +// final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0); +// l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); +// return l; +// } +// +// /** +// * Get the plot home +// * +// * @param w World +// * @param plot Plot Object +// * +// * @return Plot Home Location +// * +// * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) +// */ +// public static Location getPlotHome(final World w, final Plot plot) { +// return getPlotHome(w, plot.id); +// } +// +// /** +// * Refresh the plot chunks +// * +// * @param world World in which the plot is located +// * @param plot Plot Object +// */ +// public static void refreshPlotChunks(final String world, final Plot plot) { +// +// final int bottomX = getPlotBottomLoc(world, plot.id).getX(); +// final int topX = getPlotTopLoc(world, plot.id).getX(); +// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); +// final int topZ = getPlotTopLoc(world, plot.id).getZ(); +// +// final int minChunkX = (int) Math.floor((double) bottomX / 16); +// final int maxChunkX = (int) Math.floor((double) topX / 16); +// final int minChunkZ = (int) Math.floor((double) bottomZ / 16); +// final int maxChunkZ = (int) Math.floor((double) topZ / 16); +// +// final ArrayList chunks = new ArrayList<>(); +// +// for (int x = minChunkX; x <= maxChunkX; x++) { +// for (int z = minChunkZ; z <= maxChunkZ; z++) { +// if (canSendChunk) { +// final Chunk chunk = world.getChunkAt(x, z); +// chunks.add(chunk); +// } else { +// world.refreshChunk(x, z); +// } +// } +// } +// try { +// SendChunk.sendChunk(chunks); +// } catch (final Throwable e) { +// canSendChunk = false; +// for (int x = minChunkX; x <= maxChunkX; x++) { +// for (int z = minChunkZ; z <= maxChunkZ; z++) { +// world.refreshChunk(x, z); +// } +// } +// } +// } +// +// /** +// * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot +// * use getPlotTopLoc(...) +// * +// * @param world +// * @param id +// * +// * @return +// */ +// public static Location getPlotTopLocAbs(final String world, final PlotId id) { +// +// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); +// final PlotManager manager = PlotSquared.getPlotManager(world); +// return manager.getPlotTopLocAbs(plotworld, id); +// } +// +// /** +// * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega +// * plot use getPlotBottomLoc(...) +// * +// * @param world +// * @param id +// * +// * @return +// */ +// public static Location getPlotBottomLocAbs(final String world, final PlotId id) { +// +// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); +// final PlotManager manager = PlotSquared.getPlotManager(world); +// return manager.getPlotBottomLocAbs(plotworld, id); +// } +// +// /** +// * Obtains the width of a plot (x width) +// * +// * @param world +// * @param id +// * +// * @return +// */ +// public static int getPlotWidth(final String world, final PlotId id) { +// +// return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); +// } +// +// /** +// * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as +// * a small plot use getPlotTopLocAbs(...) +// * +// * @param world +// * @param id +// * +// * @return +// */ +// public static Location getPlotTopLoc(final String world, PlotId id) { +// +// final Plot plot = PlotSquared.getPlots(world).get(id); +// if (plot != null) { +// id = PlayerFunctions.getTopPlot(world, plot).id; +// } +// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); +// final PlotManager manager = PlotSquared.getPlotManager(world); +// return manager.getPlotTopLocAbs(plotworld, id); +// } +// +// /** +// * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot +// * treated as a small plot use getPlotBottomLocAbs(...) +// * +// * @param world +// * @param id +// * +// * @return +// */ +// public static Location getPlotBottomLoc(final String world, PlotId id) { +// +// final Plot plot = PlotSquared.getPlots(world).get(id); +// if (plot != null) { +// id = PlayerFunctions.getBottomPlot(world, plot).id; +// } +// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); +// final PlotManager manager = PlotSquared.getPlotManager(world); +// return manager.getPlotBottomLocAbs(plotworld, id); +// } +// +// public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { +// +// 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 (PlotSquared.getPlots(world).get(id) != null) { +// if (PlotSquared.getPlots(world).get(id).owner != null) { +// return false; +// } +// } +// } +// } +// return true; +// } +// +// public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { +// String worldname = world.getName(); +// final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current); +// com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot); +// final Location top = PlotHelper.getPlotTopLoc(worldname, current); +// final Plot currentPlot = PlotHelper.getPlot(worldname, current); +// if (currentPlot.owner == null) { +// return false; +// } +// Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot); +// Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot); +// +// PlotId size = PlotHelper.getSize(world, currentPlot); +// if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { +// return false; +// } +// +// int offset_x = newPlot.x - pos1.id.x; +// int offset_y = newPlot.y - pos1.id.y; +// final ArrayList selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id); +// 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 = PlotSquared.getPlots(worldname).get(id); +// PlotSquared.getPlots(worldname).remove(id); +// plot.id.x += offset_x; +// plot.id.y += offset_y; +// PlotSquared.getPlots(worldname).put(plot.id, plot); +// } +// ChunkManager.copyRegion(bot1, top, bot2, new Runnable() { +// @Override +// public void run() { +// Location bot = bot1.clone().add(1, 0, 1); +// ChunkManager.regenerateRegion(bot, top, null); +// TaskManager.runTaskLater(whenDone, 1); +// } +// }); +// return true; +// } +// +// public static PlotId getSize(String world, Plot plot) { +// +// PlotSettings settings = plot.settings; +// if (!settings.isMerged()) { +// return new PlotId(1,1); +// } +// Plot top = PlayerFunctions.getTopPlot(world, plot); +// Plot bot = PlayerFunctions.getBottomPlot(world, plot); +// return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1); +// } +// +// /** +// * Fetches the plot from the main class +// * +// * @param world +// * @param id +// * +// * @return +// */ +// public static Plot getPlot(final String world, final PlotId id) { +// +// if (id == null) { +// return null; +// } +// 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()); +// } +// +// /** +// * Returns the plot at a given location +// * +// * @param loc +// * +// * @return +// */ +// public static Plot getCurrentPlot(final Location loc) { +// final PlotId id = PlayerFunctions.getPlot(loc); +// if (id == null) { +// return null; +// } +// 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()); +// } } From f20a21c1c38c5ba0b7f3d00d797acb3345e552b2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 22:41:48 +1100 Subject: [PATCH 014/124] . --- .../plot/util/PlotHelper.java | 740 +++++++++--------- 1 file changed, 364 insertions(+), 376 deletions(-) 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 c3886fe9a..e67f03c72 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -452,8 +452,8 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; * Create a plot without notifying the merge function or world border manager */ public static Plot createPlotAbs(final UUID uuid, final Plot plot) { - final World w = plot.world; - final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList(), new ArrayList(), w.getName()); + final String w = plot.world; + final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList(), new ArrayList(), w); PlotSquared.updatePlot(p); DBFunc.createPlotAndSettings(p); return p; @@ -478,7 +478,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public static void clearAllEntities(final String world, final Plot plot, final boolean tile) { final List entities = BukkitUtil.getEntities(world); for (final Entity entity : entities) { - final PlotId id = PlayerFunctions.getPlot(entity.getLocation()); + final PlotId id = PlayerFunctions.getPlot(BukkitUtil.getLocation(entity)); if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; @@ -565,382 +565,370 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); - world = requester.getWorld(); + String world = requester.getWorld().getName(); clearAllEntities(world, plot, false); clear(requester, world, plot, isDelete); removeSign(world, plot); } -// -// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { -// for (int x = pos1.getX(); x < pos2.getX(); x++) { -// for (int z = pos1.getZ(); z < pos2.getZ(); z++) { -// final Block block = world.getBlockAt(x, y, z); -// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { -// setBlock(world, x, y, z, newblock.id, newblock.data); -// } -// } -// } -// } -// } -// -// public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { -// -// if (blocks.length == 1) { -// setCuboid(world, pos1, pos2, blocks[0]); -// return; -// } -// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { -// for (int x = pos1.getX(); x < pos2.getX(); x++) { -// for (int z = pos1.getZ(); z < pos2.getZ(); z++) { -// final int i = random(blocks.length); -// final PlotBlock newblock = blocks[i]; -// final Block block = world.getBlockAt(x, y, z); -// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { -// setBlock(world, x, y, z, newblock.id, newblock.data); -// } -// } -// } -// } -// } -// -// public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { -// -// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { -// for (int x = pos1.getX(); x < pos2.getX(); x++) { -// for (int z = pos1.getZ(); z < pos2.getZ(); z++) { -// final Block block = world.getBlockAt(x, y, z); -// if (!((block.getTypeId() == newblock.id))) { -// setBlock(world, x, y, z, newblock.id, (byte) 0); -// } -// } -// } -// } -// } -// -// public static void setBiome(final String world, final Plot plot, final Biome b) { -// -// final int bottomX = getPlotBottomLoc(world, plot.id).getX(); -// final int topX = getPlotTopLoc(world, plot.id).getX() + 1; -// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); -// final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1; -// -// final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1)); -// final Biome biome = block.getBiome(); -// -// if (biome.equals(b)) { -// return; -// } -// -// for (int x = bottomX; x <= topX; x++) { -// for (int z = bottomZ; z <= topZ; z++) { -// final Block blk = world.getBlockAt(x, 0, z); -// final Biome c = blk.getBiome(); -// if (c.equals(b)) { -// x += 15; -// continue; -// } -// blk.setBiome(b); -// } -// } -// } -// -// public static int getHeighestBlock(final String world, final int x, final int z) { -// -// boolean safe = false; -// int id; -// for (int i = 1; i < world.getMaxHeight(); i++) { -// id = world.getBlockAt(x, i, z).getTypeId(); -// if (id == 0) { -// if (safe) { -// return i; -// } -// safe = true; -// } -// } -// return 64; -// } -// -// /** -// * Get plot home -// * -// * @param w World in which the plot is located -// * @param plotid Plot ID -// * -// * @return Home Location -// */ -// public static Location getPlotHome(final World w, final PlotId plotid) { -// Plot plot = getPlot(w, plotid); -// BlockLoc home = plot.settings.getPosition(); -// final Location bot = getPlotBottomLoc(w, plotid); -// PlotManager manager = PlotSquared.getPlotManager(w); -// if (home == null || (home.x == 0 && home.z == 0)) { -// final Location top = getPlotTopLoc(w, plotid); -// final int x = ((top.getX() - bot.getX())/2) + bot.getX(); -// final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); -// 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 { -// final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); -// return bot.add(home.x, y, home.z); -// } -// } -// -// /** -// * Retrieve the location of the default plot home position -// * -// * @param plot Plot -// * -// * @return the location -// */ -// public static Location getPlotHomeDefault(final Plot plot) { -// final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0); -// l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); -// return l; -// } -// -// /** -// * Get the plot home -// * -// * @param w World -// * @param plot Plot Object -// * -// * @return Plot Home Location -// * -// * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) -// */ -// public static Location getPlotHome(final World w, final Plot plot) { -// return getPlotHome(w, plot.id); -// } -// -// /** -// * Refresh the plot chunks -// * -// * @param world World in which the plot is located -// * @param plot Plot Object -// */ -// public static void refreshPlotChunks(final String world, final Plot plot) { -// -// final int bottomX = getPlotBottomLoc(world, plot.id).getX(); -// final int topX = getPlotTopLoc(world, plot.id).getX(); -// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); -// final int topZ = getPlotTopLoc(world, plot.id).getZ(); -// -// final int minChunkX = (int) Math.floor((double) bottomX / 16); -// final int maxChunkX = (int) Math.floor((double) topX / 16); -// final int minChunkZ = (int) Math.floor((double) bottomZ / 16); -// final int maxChunkZ = (int) Math.floor((double) topZ / 16); -// -// final ArrayList chunks = new ArrayList<>(); -// -// for (int x = minChunkX; x <= maxChunkX; x++) { -// for (int z = minChunkZ; z <= maxChunkZ; z++) { -// if (canSendChunk) { -// final Chunk chunk = world.getChunkAt(x, z); -// chunks.add(chunk); -// } else { -// world.refreshChunk(x, z); -// } -// } -// } -// try { -// SendChunk.sendChunk(chunks); -// } catch (final Throwable e) { -// canSendChunk = false; -// for (int x = minChunkX; x <= maxChunkX; x++) { -// for (int z = minChunkZ; z <= maxChunkZ; z++) { -// world.refreshChunk(x, z); -// } -// } -// } -// } -// -// /** -// * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot -// * use getPlotTopLoc(...) -// * -// * @param world -// * @param id -// * -// * @return -// */ -// public static Location getPlotTopLocAbs(final String world, final PlotId id) { -// -// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); -// final PlotManager manager = PlotSquared.getPlotManager(world); -// return manager.getPlotTopLocAbs(plotworld, id); -// } -// -// /** -// * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega -// * plot use getPlotBottomLoc(...) -// * -// * @param world -// * @param id -// * -// * @return -// */ -// public static Location getPlotBottomLocAbs(final String world, final PlotId id) { -// -// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); -// final PlotManager manager = PlotSquared.getPlotManager(world); -// return manager.getPlotBottomLocAbs(plotworld, id); -// } -// -// /** -// * Obtains the width of a plot (x width) -// * -// * @param world -// * @param id -// * -// * @return -// */ -// public static int getPlotWidth(final String world, final PlotId id) { -// -// return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); -// } -// -// /** -// * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as -// * a small plot use getPlotTopLocAbs(...) -// * -// * @param world -// * @param id -// * -// * @return -// */ -// public static Location getPlotTopLoc(final String world, PlotId id) { -// -// final Plot plot = PlotSquared.getPlots(world).get(id); -// if (plot != null) { -// id = PlayerFunctions.getTopPlot(world, plot).id; -// } -// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); -// final PlotManager manager = PlotSquared.getPlotManager(world); -// return manager.getPlotTopLocAbs(plotworld, id); -// } -// -// /** -// * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot -// * treated as a small plot use getPlotBottomLocAbs(...) -// * -// * @param world -// * @param id -// * -// * @return -// */ -// public static Location getPlotBottomLoc(final String world, PlotId id) { -// -// final Plot plot = PlotSquared.getPlots(world).get(id); -// if (plot != null) { -// id = PlayerFunctions.getBottomPlot(world, plot).id; -// } -// final PlotWorld plotworld = PlotSquared.getWorldSettings(world); -// final PlotManager manager = PlotSquared.getPlotManager(world); -// return manager.getPlotBottomLocAbs(plotworld, id); -// } -// -// public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { -// -// 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 (PlotSquared.getPlots(world).get(id) != null) { -// if (PlotSquared.getPlots(world).get(id).owner != null) { -// return false; -// } -// } -// } -// } -// return true; -// } -// -// public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { -// String worldname = world.getName(); -// final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current); -// com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot); -// final Location top = PlotHelper.getPlotTopLoc(worldname, current); -// final Plot currentPlot = PlotHelper.getPlot(worldname, current); -// if (currentPlot.owner == null) { -// return false; -// } -// Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot); -// Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot); -// -// PlotId size = PlotHelper.getSize(world, currentPlot); -// if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { -// return false; -// } -// -// int offset_x = newPlot.x - pos1.id.x; -// int offset_y = newPlot.y - pos1.id.y; -// final ArrayList selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id); -// 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 = PlotSquared.getPlots(worldname).get(id); -// PlotSquared.getPlots(worldname).remove(id); -// plot.id.x += offset_x; -// plot.id.y += offset_y; -// PlotSquared.getPlots(worldname).put(plot.id, plot); -// } -// ChunkManager.copyRegion(bot1, top, bot2, new Runnable() { -// @Override -// public void run() { -// Location bot = bot1.clone().add(1, 0, 1); -// ChunkManager.regenerateRegion(bot, top, null); -// TaskManager.runTaskLater(whenDone, 1); -// } -// }); -// return true; -// } -// -// public static PlotId getSize(String world, Plot plot) { -// -// PlotSettings settings = plot.settings; -// if (!settings.isMerged()) { -// return new PlotId(1,1); -// } -// Plot top = PlayerFunctions.getTopPlot(world, plot); -// Plot bot = PlayerFunctions.getBottomPlot(world, plot); -// return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1); -// } -// -// /** -// * Fetches the plot from the main class -// * -// * @param world -// * @param id -// * -// * @return -// */ -// public static Plot getPlot(final String world, final PlotId id) { -// -// if (id == null) { -// return null; -// } -// 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()); -// } -// -// /** -// * Returns the plot at a given location -// * -// * @param loc -// * -// * @return -// */ -// public static Plot getCurrentPlot(final Location loc) { -// final PlotId id = PlayerFunctions.getPlot(loc); -// if (id == null) { -// return null; -// } -// 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()); -// } + + public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { + + if (blocks.length == 1) { + setCuboid(world, pos1, pos2, blocks[0]); + return; + } + for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { + final int i = random(blocks.length); + final PlotBlock newblock = blocks[i]; + final Block block = world.getBlockAt(x, y, z); + if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { + setBlock(world, x, y, z, newblock.id, newblock.data); + } + } + } + } + } + + public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { + + for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { + final Block block = world.getBlockAt(x, y, z); + if (!((block.getTypeId() == newblock.id))) { + setBlock(world, x, y, z, newblock.id, (byte) 0); + } + } + } + } + } + + public static void setBiome(final String world, final Plot plot, final Biome b) { + + final int bottomX = getPlotBottomLoc(world, plot.id).getX(); + final int topX = getPlotTopLoc(world, plot.id).getX() + 1; + final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); + final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1; + + final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1)); + final Biome biome = block.getBiome(); + + if (biome.equals(b)) { + return; + } + + for (int x = bottomX; x <= topX; x++) { + for (int z = bottomZ; z <= topZ; z++) { + final Block blk = world.getBlockAt(x, 0, z); + final Biome c = blk.getBiome(); + if (c.equals(b)) { + x += 15; + continue; + } + blk.setBiome(b); + } + } + } + + public static int getHeighestBlock(final String world, final int x, final int z) { + + boolean safe = false; + int id; + for (int i = 1; i < world.getMaxHeight(); i++) { + id = world.getBlockAt(x, i, z).getTypeId(); + if (id == 0) { + if (safe) { + return i; + } + safe = true; + } + } + return 64; + } + + /** + * Get plot home + * + * @param w World in which the plot is located + * @param plotid Plot ID + * + * @return Home Location + */ + public static Location getPlotHome(final World w, final PlotId plotid) { + Plot plot = getPlot(w, plotid); + BlockLoc home = plot.settings.getPosition(); + final Location bot = getPlotBottomLoc(w, plotid); + PlotManager manager = PlotSquared.getPlotManager(w); + if (home == null || (home.x == 0 && home.z == 0)) { + final Location top = getPlotTopLoc(w, plotid); + final int x = ((top.getX() - bot.getX())/2) + bot.getX(); + final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); + 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 { + final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); + return bot.add(home.x, y, home.z); + } + } + + /** + * Retrieve the location of the default plot home position + * + * @param plot Plot + * + * @return the location + */ + public static Location getPlotHomeDefault(final Plot plot) { + final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0); + l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); + return l; + } + + /** + * Get the plot home + * + * @param w World + * @param plot Plot Object + * + * @return Plot Home Location + * + * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + */ + public static Location getPlotHome(final World w, final Plot plot) { + return getPlotHome(w, plot.id); + } + + /** + * Refresh the plot chunks + * + * @param world World in which the plot is located + * @param plot Plot Object + */ + public static void refreshPlotChunks(final String world, final Plot plot) { + + final int bottomX = getPlotBottomLoc(world, plot.id).getX(); + final int topX = getPlotTopLoc(world, plot.id).getX(); + final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); + final int topZ = getPlotTopLoc(world, plot.id).getZ(); + + final int minChunkX = (int) Math.floor((double) bottomX / 16); + final int maxChunkX = (int) Math.floor((double) topX / 16); + final int minChunkZ = (int) Math.floor((double) bottomZ / 16); + final int maxChunkZ = (int) Math.floor((double) topZ / 16); + + final ArrayList chunks = new ArrayList<>(); + + for (int x = minChunkX; x <= maxChunkX; x++) { + for (int z = minChunkZ; z <= maxChunkZ; z++) { + if (canSendChunk) { + final Chunk chunk = world.getChunkAt(x, z); + chunks.add(chunk); + } else { + world.refreshChunk(x, z); + } + } + } + try { + SendChunk.sendChunk(chunks); + } catch (final Throwable e) { + canSendChunk = false; + for (int x = minChunkX; x <= maxChunkX; x++) { + for (int z = minChunkZ; z <= maxChunkZ; z++) { + world.refreshChunk(x, z); + } + } + } + } + + /** + * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot + * use getPlotTopLoc(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotTopLocAbs(final String world, final PlotId id) { + + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotTopLocAbs(plotworld, id); + } + + /** + * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega + * plot use getPlotBottomLoc(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotBottomLocAbs(final String world, final PlotId id) { + + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotBottomLocAbs(plotworld, id); + } + + /** + * Obtains the width of a plot (x width) + * + * @param world + * @param id + * + * @return + */ + public static int getPlotWidth(final String world, final PlotId id) { + + return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); + } + + /** + * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as + * a small plot use getPlotTopLocAbs(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotTopLoc(final String world, PlotId id) { + + final Plot plot = PlotSquared.getPlots(world).get(id); + if (plot != null) { + id = PlayerFunctions.getTopPlot(world, plot).id; + } + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotTopLocAbs(plotworld, id); + } + + /** + * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot + * treated as a small plot use getPlotBottomLocAbs(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotBottomLoc(final String world, PlotId id) { + + final Plot plot = PlotSquared.getPlots(world).get(id); + if (plot != null) { + id = PlayerFunctions.getBottomPlot(world, plot).id; + } + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotBottomLocAbs(plotworld, id); + } + + public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { + + 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 (PlotSquared.getPlots(world).get(id) != null) { + if (PlotSquared.getPlots(world).get(id).owner != null) { + return false; + } + } + } + } + return true; + } + + public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { + String worldname = world.getName(); + final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current); + com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot); + final Location top = PlotHelper.getPlotTopLoc(worldname, current); + final Plot currentPlot = PlotHelper.getPlot(worldname, current); + if (currentPlot.owner == null) { + return false; + } + Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot); + Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot); + + PlotId size = PlotHelper.getSize(world, currentPlot); + if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { + return false; + } + + int offset_x = newPlot.x - pos1.id.x; + int offset_y = newPlot.y - pos1.id.y; + final ArrayList selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id); + 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 = PlotSquared.getPlots(worldname).get(id); + PlotSquared.getPlots(worldname).remove(id); + plot.id.x += offset_x; + plot.id.y += offset_y; + PlotSquared.getPlots(worldname).put(plot.id, plot); + } + ChunkManager.copyRegion(bot1, top, bot2, new Runnable() { + @Override + public void run() { + Location bot = bot1.clone().add(1, 0, 1); + ChunkManager.regenerateRegion(bot, top, null); + TaskManager.runTaskLater(whenDone, 1); + } + }); + return true; + } + + public static PlotId getSize(String world, Plot plot) { + + PlotSettings settings = plot.settings; + if (!settings.isMerged()) { + return new PlotId(1,1); + } + Plot top = PlayerFunctions.getTopPlot(world, plot); + Plot bot = PlayerFunctions.getBottomPlot(world, plot); + return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1); + } + + /** + * Fetches the plot from the main class + * + * @param world + * @param id + * + * @return + */ + public static Plot getPlot(final String world, final PlotId id) { + + if (id == null) { + return null; + } + 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()); + } + + /** + * Returns the plot at a given location + * + * @param loc + * + * @return + */ + public static Plot getCurrentPlot(final Location loc) { + final PlotId id = PlayerFunctions.getPlot(loc); + if (id == null) { + return null; + } + 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()); + } } From fa822dcf29fbc5bd8578d6e86f413740726417c1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 00:01:36 +1100 Subject: [PATCH 015/124] dsakjldjsakljksld jdsiklsadjklsad jk --- .../plot/commands/Auto.java | 3 +- .../plot/util/PlotHelper.java | 93 ++++++++++--------- .../plot/util/bukkit/BukkitUtil.java | 16 ++++ 3 files changed, 68 insertions(+), 44 deletions(-) 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 c50e4dcd1..0792354b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -39,6 +39,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Auto extends SubCommand { public Auto() { @@ -163,7 +164,7 @@ public class Auto extends SubCommand { String worldname = world.getName(); PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); if (plotworld.TYPE == 2) { - Location loc = plr.getLocation(); + Location loc = BukkitUtil.getLocation(plr); Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); 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 e67f03c72..91d33447a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -542,7 +542,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; update(location); } }; - manager.clearPlot(world, plotworld, plot, isDelete, run); + manager.clearPlot(plotworld, plot, isDelete, run); } /** @@ -555,7 +555,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; if (requester == null) { clearAllEntities(plot.world, plot, false); clear(requester, plot.world, plot, isDelete); - removeSign(plot.world, plot); + removeSign(plot); return; } if (runners.containsKey(plot)) { @@ -569,72 +569,79 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; clearAllEntities(world, plot, false); clear(requester, world, plot, isDelete); - removeSign(world, plot); + removeSign(plot); } public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { - if (blocks.length == 1) { - setCuboid(world, pos1, pos2, blocks[0]); + setSimpleCuboid(world, pos1, pos2, blocks[0]); return; } - for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { + int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); + int[] xl = new int[length]; + int[] yl = new int[length]; + int[] zl = new int[length]; + + int[] ids = new int[length]; + byte[] data = new byte[length]; + + int index = 0; + + for (int y = pos1.getY(); y < pos2.getY(); y++) { for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - final int i = random(blocks.length); - final PlotBlock newblock = blocks[i]; - final Block block = world.getBlockAt(x, y, z); - if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { - setBlock(world, x, y, z, newblock.id, newblock.data); - } + int i = BlockManager.random(blocks.length); + xl[index] = x; + yl[index] = y; + zl[index] = z; + + PlotBlock block = blocks[i]; + ids[index] = block.id; + data[index] = block.data; + index++; } } } + BlockManager.setBlocks(world, xl, yl, zl, ids, data); } public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { - - for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { + int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); + int[] xl = new int[length]; + int[] yl = new int[length]; + int[] zl = new int[length]; + + int[] ids = new int[length]; + byte[] data = new byte[length]; + + int index = 0; + + for (int y = pos1.getY(); y < pos2.getY(); y++) { for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - final Block block = world.getBlockAt(x, y, z); - if (!((block.getTypeId() == newblock.id))) { - setBlock(world, x, y, z, newblock.id, (byte) 0); - } + xl[index] = x; + yl[index] = y; + zl[index] = z; + + ids[index] = newblock.id; + data[index] = newblock.data; + index++; } } } + BlockManager.setBlocks(world, xl, yl, zl, ids, data); } public static void setBiome(final String world, final Plot plot, final Biome b) { - final int bottomX = getPlotBottomLoc(world, plot.id).getX(); - final int topX = getPlotTopLoc(world, plot.id).getX() + 1; - final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); - final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1; - - final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1)); - final Biome biome = block.getBiome(); - - if (biome.equals(b)) { - return; - } - - for (int x = bottomX; x <= topX; x++) { - for (int z = bottomZ; z <= topZ; z++) { - final Block blk = world.getBlockAt(x, 0, z); - final Biome c = blk.getBiome(); - if (c.equals(b)) { - x += 15; - continue; - } - blk.setBiome(b); - } - } + final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; + final int topX = getPlotTopLoc(world, plot.id).getX(); + final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; + final int topZ = getPlotTopLoc(world, plot.id).getZ(); + BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, b); } public static int getHeighestBlock(final String world, final int x, final int z) { - boolean safe = false; int id; for (int i = 1; i < world.getMaxHeight(); i++) { @@ -666,7 +673,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; final Location top = getPlotTopLoc(w, plotid); final int x = ((top.getX() - bot.getX())/2) + bot.getX(); final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); - final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY()); + final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getY()); return new Location(w, x, y, z); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index e3ba7dba9..6a8d7d7d1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; @@ -86,6 +87,21 @@ public class BukkitUtil extends BlockManager { } } + public static void setBiome(String worldname, int pos1_x, int pos1_z, int pos2_x, int pos2_z, Biome b) { + World world = getWorld(worldname); + for (int x = pos1_x; x<= pos2_x; x++) { + for (int z = pos1_z; z<= pos2_z; z++) { + final Block blk = world.getBlockAt(x, 0, z); + final Biome c = blk.getBiome(); + if (c.equals(b)) { + x += 15; + continue; + } + blk.setBiome(b); + } + } + } + public static PlotBlock getBlock(Location loc) { World world = getWorld(loc.getWorld()); Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); From 219d4ad469bde64aff614314384ebce95e95f631 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 01:47:15 +1100 Subject: [PATCH 016/124] jkldasasdjklsadkl --- .../intellectualcrafters/plot/BukkitMain.java | 2 +- .../plot/object/Location.java | 4 ++ .../plot/util/PlotHelper.java | 61 ++++++++++--------- .../plot/util/bukkit/BukkitUtil.java | 4 ++ 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 33e4ae233..8b02be968 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -85,7 +85,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { 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); + final Location location = PlotHelper.getPlotHome(bot.world, bot); int x = location.getX(); int z = location.getZ(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java index 4cfcb9da0..887a6d4b9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -17,6 +17,10 @@ public class Location implements Cloneable, Comparable { private boolean built; private Object o; + public Location clone() { + return new Location(world, x, y, z, yaw, pitch); + } + public Location(final String world, final int x, final int y, final int z, final float yaw, final float pitch) { this.world = world; this.x = x; 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 91d33447a..f5a646256 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -644,16 +644,21 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public static int getHeighestBlock(final String world, final int x, final int z) { boolean safe = false; int id; - for (int i = 1; i < world.getMaxHeight(); i++) { - id = world.getBlockAt(x, i, z).getTypeId(); - if (id == 0) { - if (safe) { - return i; - } - safe = true; - } + int result = BukkitUtil.getHeighestBlock(world, x, z); + if (result == 0) { + return 64; } - return 64; + return result; +// for (int i = 1; i < world.getMaxHeight(); i++) { +// id = world.getBlockAt(x, i, z).getTypeId(); +// if (id == 0) { +// if (safe) { +// return i; +// } +// safe = true; +// } +// } +// return 64; } /** @@ -664,7 +669,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; * * @return Home Location */ - public static Location getPlotHome(final World w, final PlotId plotid) { + public static Location getPlotHome(final String w, final PlotId plotid) { Plot plot = getPlot(w, plotid); BlockLoc home = plot.settings.getPosition(); final Location bot = getPlotBottomLoc(w, plotid); @@ -673,7 +678,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; final Location top = getPlotTopLoc(w, plotid); final int x = ((top.getX() - bot.getX())/2) + bot.getX(); final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); - final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getY()); + final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getWorldSettings(w), plot).getY()); return new Location(w, x, y, z); } else { @@ -705,7 +710,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; * * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) */ - public static Location getPlotHome(final World w, final Plot plot) { + public static Location getPlotHome(final String w, final Plot plot) { return getPlotHome(w, plot.id); } @@ -732,10 +737,10 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; for (int x = minChunkX; x <= maxChunkX; x++) { for (int z = minChunkZ; z <= maxChunkZ; z++) { if (canSendChunk) { - final Chunk chunk = world.getChunkAt(x, z); + final Chunk chunk = BukkitUtil.getChunkAt(world, x, z); chunks.add(chunk); } else { - world.refreshChunk(x, z); + BukkitUtil.refreshChunk(world, x, z); } } } @@ -745,7 +750,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; canSendChunk = false; for (int x = minChunkX; x <= maxChunkX; x++) { for (int z = minChunkZ; z <= maxChunkZ; z++) { - world.refreshChunk(x, z); + BukkitUtil.refreshChunk(world, x, z); } } } @@ -852,16 +857,15 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; } public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { - String worldname = world.getName(); - final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current); - com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot); - final Location top = PlotHelper.getPlotTopLoc(worldname, current); - final Plot currentPlot = PlotHelper.getPlot(worldname, current); + final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(world, current); + com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(world, newPlot); + final Location top = PlotHelper.getPlotTopLoc(world, current); + final Plot currentPlot = PlotHelper.getPlot(world, current); if (currentPlot.owner == null) { return false; } - Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot); - Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot); + Plot pos1 = PlayerFunctions.getBottomPlot(world, currentPlot); + Plot pos2 = PlayerFunctions.getTopPlot(world, currentPlot); PlotId size = PlotHelper.getSize(world, currentPlot); if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { @@ -871,14 +875,13 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; int offset_x = newPlot.x - pos1.id.x; int offset_y = newPlot.y - pos1.id.y; final ArrayList selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id); - 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 = PlotSquared.getPlots(worldname).get(id); - PlotSquared.getPlots(worldname).remove(id); + DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); + Plot plot = PlotSquared.getPlots(world).get(id); + PlotSquared.getPlots(world).remove(id); plot.id.x += offset_x; plot.id.y += offset_y; - PlotSquared.getPlots(worldname).put(plot.id, plot); + PlotSquared.getPlots(world).put(plot.id, plot); } ChunkManager.copyRegion(bot1, top, bot2, new Runnable() { @Override @@ -918,7 +921,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; 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()); + return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), world); } /** @@ -936,6 +939,6 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; 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()); + return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 6a8d7d7d1..37ccc71a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -102,6 +102,10 @@ public class BukkitUtil extends BlockManager { } } + public static void refreshChunk(String world, int x, int z) { + getWorld(world).refreshChunk(x, z); + } + public static PlotBlock getBlock(Location loc) { World world = getWorld(loc.getWorld()); Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); From c09179e9cd3f08cdc292962ab4d3abd3941d892f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 02:13:43 +1100 Subject: [PATCH 017/124] em --- .../intellectualcrafters/plot/BukkitMain.java | 16 +++++++++++++ .../intellectualcrafters/plot/_PlotMain.java | 24 ------------------- .../plot/util/ExpireManager.java | 11 +++++---- .../plot/util/MainUtil.java | 17 ------------- .../plot/util/PlayerFunctions.java | 24 ++++++++++--------- 5 files changed, 35 insertions(+), 57 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 8b02be968..1da734d56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -79,6 +79,22 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { return false; } + // TODO restructure this + public static 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; + } + // TODO restructure this public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) { Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java index 6dd1bffd6..dd46e7a6a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java @@ -1157,30 +1157,6 @@ public class _PlotSquared { 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 * 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 bb364c63d..c94e5587f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -13,6 +13,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.commands.Unlink; import com.intellectualcrafters.plot.config.C; @@ -23,6 +24,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class ExpireManager { @@ -64,7 +66,7 @@ public class ExpireManager { } public static void runTask() { - ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { + ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, new Runnable() { @Override public void run() { for (String world : PlotSquared.getPlotWorldsString()) { @@ -109,14 +111,13 @@ public class ExpireManager { PlayerFunctions.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString()); } } - final World worldobj = Bukkit.getWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); if (plot.settings.isMerged()) { Unlink.unlinkPlot(Bukkit.getWorld(world), plot); } PlotWorld plotworld = PlotSquared.getWorldSettings(world); - manager.clearPlot(worldobj, plotworld, plot, false, null); - PlotHelper.removeSign(worldobj, plot); + manager.clearPlot(plotworld, plot, false, null); + PlotHelper.removeSign(plot); DBFunc.delete(world, plot); PlotSquared.removePlot(world, plot.id, true); expiredPlots.get(world).remove(plot); @@ -186,7 +187,7 @@ public class ExpireManager { String worldname = Bukkit.getWorlds().get(0).getName(); String foldername; String filename = null; - if (PlotSquared.checkVersion(1, 7, 5)) { + if (BukkitMain.checkVersion(1, 7, 5)) { foldername = "playerdata"; try { filename = op.getUniqueId() +".dat"; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java deleted file mode 100644 index 95cc0e546..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.intellectualcrafters.plot.util; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; - -public class MainUtil { - // TODO messages / permission stuff - - /** - * Send a message to the console - * - * @param c message - */ - public static void log(final C c) { - PlotSquared.MAIN_IMP.log(c.s()); - } -} 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 c33eb0fa1..95859cc86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.util; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -29,6 +30,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import org.bukkit.ChatColor; import org.bukkit.World; @@ -127,7 +129,7 @@ import java.util.UUID; * @return */ public static PlotId getPlotAbs(final Location loc) { - final String world = loc.getWorld().getName(); + final String world = loc.getWorld(); final PlotManager manager = PlotSquared.getPlotManager(world); if (manager == null) { return null; @@ -145,7 +147,7 @@ import java.util.UUID; * @return */ public static PlotId getPlot(final Location loc) { - final String world = loc.getWorld().getName(); + final String world = loc.getWorld(); final PlotManager manager = PlotSquared.getPlotManager(world); if (manager == null) { return null; @@ -169,18 +171,18 @@ import java.util.UUID; * @return */ public static Plot getCurrentPlot(final Player player) { - if (!PlotSquared.isPlotWorld(player.getWorld())) { + if (!PlotSquared.isPlotWorld(player.getWorld().getName())) { return null; } - final PlotId id = getPlot(BukkitUtil.getLocation(entity)); - final World world = player.getWorld(); + final PlotId id = getPlot(BukkitUtil.getLocation(player)); + final String world = player.getWorld().getName(); if (id == null) { return null; } if (PlotSquared.getPlots(world).containsKey(id)) { return PlotSquared.getPlots(world).get(id); } - return new Plot(id, null, new ArrayList(), new ArrayList(), world.getName()); + return new Plot(id, null, new ArrayList(), new ArrayList(), world); } @@ -203,8 +205,8 @@ import java.util.UUID; * * @return */ - public static Set getPlayerPlots(final World world, final Player plr) { - final Set p = PlotSquared.getPlots(world, plr); + public static Set getPlayerPlots(final String world, final Player plr) { + final Set p = PlotSquared.getPlots(world, plr.getName()); if (p == null) { return new HashSet<>(); } @@ -218,7 +220,7 @@ import java.util.UUID; * * @return */ - public static int getPlayerPlotCount(final World world, final Player plr) { + public static int getPlayerPlotCount(final String world, final Player plr) { final UUID uuid = UUIDHandler.getUUID(plr); int count = 0; for (final Plot plot : PlotSquared.getPlots(world).values()) { @@ -237,7 +239,7 @@ import java.util.UUID; * @return */ public static int getAllowedPlots(final Player p) { - return PlotSquared.MAIN_IMP.(p, "plots.plot", Settings.MAX_PLOTS); + return BukkitMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); } /** @@ -286,7 +288,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) { - PlotSquared.MAIN_IMP.log(C.PREFIX.s() + msg); + PlotSquared.log(C.PREFIX.s() + msg); } else { sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); } From c55961e299017ff689c7b42cf8cd7f8cbe42f2e6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 02:30:29 +1100 Subject: [PATCH 018/124] clusters --- .../plot/util/ClusterManager.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) 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 307311fcd..b70e66e3f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -9,7 +9,6 @@ import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.Chunk; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.generator.BlockPopulator; @@ -18,6 +17,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; @@ -25,6 +25,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class ClusterManager { public static HashMap> clusters; @@ -50,25 +51,24 @@ public class ClusterManager { } public static Location getHome(PlotCluster cluster) { - World world = Bukkit.getWorld(cluster.world); BlockLoc home = cluster.settings.getPosition(); Location toReturn; if (home.y == 0) { // default pos PlotId center = getCenterPlot(cluster); - toReturn = PlotHelper.getPlotHome(world, center); - if (toReturn.getBlockY() == 0) { - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final Location loc = manager.getSignLoc(world, plotworld, PlotHelper.getPlot(world, center)); + toReturn = PlotHelper.getPlotHome(cluster.world, center); + if (toReturn.getY() == 0) { + final PlotManager manager = PlotSquared.getPlotManager(cluster.world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world); + final Location loc = manager.getSignLoc(plotworld, PlotHelper.getPlot(cluster.world, center)); toReturn.setY(loc.getY()); } } else { toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z); } - int max = world.getHighestBlockAt(toReturn).getY(); - if (max > toReturn.getBlockY()) { + int max = BukkitUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ()); + if (max > toReturn.getY()) { toReturn.setY(max); } return toReturn; @@ -107,12 +107,12 @@ public class ClusterManager { } public static boolean contains(PlotCluster cluster, Location loc) { - String world = loc.getWorld().getName(); + String world = loc.getWorld(); 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()) { + if (bot.getX() < loc.getX() && bot.getZ() < loc.getZ() && top.getX() > loc.getX() && top.getZ() > loc.getZ()) { return true; } return false; @@ -145,7 +145,7 @@ public class ClusterManager { } public static PlotCluster getCluster(Location loc) { - String world = loc.getWorld().getName(); + String world = loc.getWorld(); if (last != null && last.world.equals(world)) { if (contains(last, loc)) { return last; @@ -222,7 +222,7 @@ public class ClusterManager { int xw; int zw; - String world = loc.getWorld().getName(); + String world = loc.getWorld(); PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (plotworld == null) { xw = 39; @@ -233,12 +233,12 @@ public class ClusterManager { Location al = manager.getPlotBottomLocAbs(plotworld, a); Location bl = manager.getPlotBottomLocAbs(plotworld, b); - xw = bl.getBlockX() - al.getBlockX(); - zw = bl.getBlockZ() - al.getBlockZ(); + xw = bl.getX() - al.getX(); + zw = bl.getZ() - al.getZ(); } - int x = loc.getBlockX(); - int z = loc.getBlockZ(); + int x = loc.getX(); + int z = loc.getZ(); return new PlotId((x/xw) + 1,(z/zw) + 1); } @@ -257,10 +257,10 @@ public class ClusterManager { Location bot = getClusterBottom(cluster); Location top = getClusterTop(cluster); - int minChunkX = bot.getBlockX() >> 4; - int maxChunkX = (top.getBlockX() >> 4) + 1; - int minChunkZ = bot.getBlockZ() >> 4; - int maxChunkZ = (top.getBlockZ() >> 4) + 1; + int minChunkX = bot.getX() >> 4; + int maxChunkX = (top.getX() >> 4) + 1; + int minChunkZ = bot.getZ() >> 4; + int maxChunkZ = (top.getZ() >> 4) + 1; final AugmentedPopulator populator = getPopulator(cluster); final ArrayList chunks = new ArrayList<>(); From d836286b6f3e320022aa24d04a3639d16222cb05 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 13:37:46 +1100 Subject: [PATCH 019/124] chunk --- .../plot/listeners/PlayerEvents.java | 1 - .../plot/object/PlotSelection.java | 136 ------------------ .../plot/object/PlotSettings.java | 4 +- .../plot/util/AChunkManager.java | 38 +++++ .../plot/util/ChunkManager.java | 57 ++++---- .../plot/util/ExpireManager.java | 1 - .../plot/util/PlotHelper.java | 6 +- .../plot/util/bukkit/BukkitUtil.java | 4 + 8 files changed, 72 insertions(+), 175 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java 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 e0b42ab53..37615c08a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -95,7 +95,6 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotSelection; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.PlayerFunctions; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java deleted file mode 100644 index 69fa04bb4..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java +++ /dev/null @@ -1,136 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.object; - -import java.util.HashMap; - -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; - -import com.intellectualcrafters.plot.util.PlotHelper; - -/** - * Created 2014-10-12 for PlotSquared - * - * @author Citymonstret - */ -@SuppressWarnings("deprecation") public class PlotSelection { - - public final static HashMap currentSelection = new HashMap<>(); - - private final PlotBlock[] plotBlocks; - - private final int width; - - private final Plot plot; - - private final Biome biome; - - public PlotSelection(final int width, final World world, final Plot plot) { - this.width = width; - this.plot = plot; - - this.plotBlocks = new PlotBlock[(width * width) * (world.getMaxHeight() - 1)]; - - final Location bot = PlotHelper.getPlotBottomLocAbs(world, plot.getId()), top = PlotHelper.getPlotTopLocAbs(world, plot.getId()); - final int minX = bot.getBlockX(), maxX = top.getBlockX(), minZ = bot.getBlockZ(), maxZ = top.getBlockZ(), minY = 1, maxY = world.getMaxHeight(); - Block current; - - this.biome = world.getBiome(minX, minZ); - - int index = 0; - for (int x = minX; x < maxX; x++) { - for (int z = minZ; z < maxZ; z++) { - for (int y = minY; y < maxY; y++) { - current = world.getBlockAt(x + 1, y, z + 1); - this.plotBlocks[index++] = new PlotBlock((short) current.getTypeId(), current.getData()); - } - } - } - - // Yay :D - } - - public static boolean swap(final World world, final PlotId id1, final PlotId id2) { - - final Location bot2 = PlotHelper.getPlotBottomLocAbs(world, id2).add(1, 0, 1); - final Location bot1 = PlotHelper.getPlotBottomLocAbs(world, id1).add(1, 0, 1); - final Location top1 = PlotHelper.getPlotTopLocAbs(world, id1); - final int minX = bot1.getBlockX(), maxX = top1.getBlockX(), minZ = bot1.getBlockZ(), maxZ = top1.getBlockZ(), minX2 = bot2.getBlockX(), minZ2 = bot2.getBlockZ(); - for (int x = 0; x <= (maxX - minX); x++) { - for (int z = 0; z <= (maxZ - minZ); z++) { - for (int y = 1; y <= world.getMaxHeight(); y++) { - - final Block block1 = world.getBlockAt(x + minX, y, z + minZ); - final Block block2 = world.getBlockAt(x + minX2, y, z + minZ2); - - final BlockWrapper b1 = wrapBlock(block1); - final BlockWrapper b2 = wrapBlock(block2); - - if ((b1.id != b2.id) || (b1.data != b2.data)) { - PlotHelper.setBlock(world, b1.x, b1.y, b1.z, b2.id, b2.data); - } - } - } - } - return true; - } - - private static BlockWrapper wrapBlock(final Block block) { - return new BlockWrapper(block.getX(), block.getY(), block.getZ(), (short) block.getTypeId(), block.getData()); - } - - public PlotBlock[] getBlocks() { - return this.plotBlocks; - } - - public int getWidth() { - return this.width; - } - - public Plot getPlot() { - return this.plot; - } - - public void paste(final World world, final Plot plot) { - - final Location bot = PlotHelper.getPlotBottomLocAbs(world, plot.getId()), top = PlotHelper.getPlotTopLocAbs(world, plot.getId()); - final int minX = bot.getBlockX(), maxX = top.getBlockX(), minZ = bot.getBlockZ(), maxZ = top.getBlockZ(), minY = 1, maxY = world.getMaxHeight(); - - if (this.biome != world.getBiome(minX, minZ)) { - PlotHelper.setBiome(world, plot, this.biome); - } - - int index = 0; - PlotBlock current; - for (int x = minX; x < maxX; x++) { - for (int z = minZ; z < maxZ; z++) { - for (int y = minY; y < maxY; y++) { - current = this.plotBlocks[index++]; - world.getBlockAt(x + 1, y, z + 1).setTypeIdAndData(current.id, current.data, true); - } - } - } - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 6ab96bab0..6a4a65829 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -29,6 +29,7 @@ import org.bukkit.block.Biome; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * plot settings @@ -106,7 +107,8 @@ import com.intellectualcrafters.plot.util.PlotHelper; * @return biome at plot loc */ public Biome getBiome() { - return PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1).getBlock().getBiome(); + Location loc = PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); + return BukkitUtil.getBiome(loc); } public BlockLoc getPosition() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java new file mode 100644 index 000000000..b29fe35fc --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -0,0 +1,38 @@ +package com.intellectualcrafters.plot.util; + +import java.util.HashMap; +import java.util.List; + + + + + + +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.RegionWrapper; + +public abstract class AChunkManager { + + public static AChunkManager manager = null; + public static RegionWrapper CURRENT_PLOT_CLEAR = null; + public static HashMap> GENERATE_BLOCKS = new HashMap<>(); + public static HashMap> GENERATE_DATA = new HashMap<>(); + + public static ChunkLoc getChunkChunk(Location loc) { + int x = loc.getX() >> 9; + int z = loc.getZ() >> 9; + return new ChunkLoc(x, z); + } + + public abstract List getChunkChunks(String world); + + public abstract void deleteRegionFile(final String world, final ChunkLoc loc); + + public abstract Plot hasPlot(String world, ChunkLoc chunk); + + public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone); + + public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone); +} 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 ac6e8d344..d0e2c9e36 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -39,6 +39,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; @@ -49,22 +50,13 @@ import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -public class ChunkManager { +public class ChunkManager extends AChunkManager { - public static RegionWrapper CURRENT_PLOT_CLEAR = null; - public static HashMap> GENERATE_BLOCKS = new HashMap<>(); - public static HashMap> GENERATE_DATA = new HashMap<>(); public static MutableInt index = new MutableInt(0); public static HashMap tasks = new HashMap<>(); - public static ChunkLoc getChunkChunk(Location loc) { - int x = loc.getX() >> 9; - int z = loc.getZ() >> 9; - return new ChunkLoc(x, z); - } - - public static ArrayList getChunkChunks(World world) { - String directory = new File(".").getAbsolutePath() + File.separator + world.getName() + File.separator + "region"; + public ArrayList getChunkChunks(String world) { + String directory = new File(".").getAbsolutePath() + File.separator + world + File.separator + "region"; File folder = new File(directory); File[] regionFiles = folder.listFiles(); @@ -84,8 +76,7 @@ public class ChunkManager { catch (Exception e) { } } } - - for (Chunk chunk : world.getLoadedChunks()) { + for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) { ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5); if (!chunks.contains(loc)) { chunks.add(loc); @@ -95,7 +86,7 @@ public class ChunkManager { return chunks; } - public static void deleteRegionFile(final String world, final ChunkLoc loc) { + public void deleteRegionFile(final String world, final ChunkLoc loc) { BukkitTaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -109,9 +100,9 @@ public class ChunkManager { }); } - public static Plot hasPlot(World world, Chunk chunk) { - int x1 = chunk.getX() << 4; - int z1 = chunk.getZ() << 4; + public Plot hasPlot(String world, ChunkLoc chunk) { + int x1 = chunk.x << 4; + int z1 = chunk.z << 4; int x2 = x1 + 15; int z2 = z1 + 15; @@ -152,18 +143,18 @@ public class ChunkManager { /** * Copy a region to a new location (in the same world) */ - public static boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) { + public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) { index.increment(); final int relX = newPos.getX() - pos1.getX(); final int relZ = newPos.getZ() - pos1.getZ(); final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); - final World world = pos1.getWorld(); - Chunk c1 = world.getChunkAt(pos1); - Chunk c2 = world.getChunkAt(pos2); - - Chunk c3 = world.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4); - Chunk c4 = world.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4); + final World world = Bukkit.getWorld(pos1.getWorld()); + Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); + Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); + + Chunk c3 = world.getChunkAt((pos1.getX() + relX), (pos1.getZ() + relZ)); + Chunk c4 = world.getChunkAt((pos2.getX() + relX), (pos2.getZ() + relZ)); final int sx = pos1.getX(); final int sz = pos1.getZ(); @@ -185,12 +176,12 @@ public class ChunkManager { // Load chunks for (int x = c1x; x <= c2x; x ++) { for (int z = c1z; z <= c2z; z ++) { - Chunk chunk = world.getChunkAt(x, z); + Chunk chunk = world.getChunkAt(x << 4, z << 4); toGenerate.add(chunk); } } - final Plugin plugin = (Plugin) PlotSquared.getMain(); + final Plugin plugin = (Plugin) BukkitMain.THIS; final Integer currentIndex = index.toInteger(); final int loadTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override @@ -268,13 +259,13 @@ public class ChunkManager { return true; } - public static boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { + public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { index.increment(); - final Plugin plugin = (Plugin) PlotSquared.getMain(); + final Plugin plugin = (Plugin) BukkitMain.THIS; - final World world = pos1.getWorld(); - Chunk c1 = world.getChunkAt(pos1); - Chunk c2 = world.getChunkAt(pos2); + final World world = Bukkit.getWorld(pos1.getWorld()); + Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); + Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); final int sx = pos1.getX(); final int sz = pos1.getZ(); @@ -396,7 +387,7 @@ public class ChunkManager { public static void saveEntitiesOut(Chunk chunk, RegionWrapper region) { for (Entity entity : chunk.getEntities()) { - Location loc = entity.getLocation(); + Location loc = BukkitUtil.getLocation(entity); int x = loc.getX(); int z = loc.getZ(); if (isIn(region, x, z)) { 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 c94e5587f..a69962ae8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -10,7 +10,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.World; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; 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 f5a646256..282ef4ed0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -520,7 +520,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; runners.put(plot, 1); if (plotworld.TERRAIN != 0) { final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); - ChunkManager.regenerateRegion(pos1, pos2, new Runnable() { + AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { if (player != null && player.isOnline()) { @@ -883,11 +883,11 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; plot.id.y += offset_y; PlotSquared.getPlots(world).put(plot.id, plot); } - ChunkManager.copyRegion(bot1, top, bot2, new Runnable() { + AChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { @Override public void run() { Location bot = bot1.clone().add(1, 0, 1); - ChunkManager.regenerateRegion(bot, top, null); + AChunkManager.manager.regenerateRegion(bot, top, null); TaskManager.runTaskLater(whenDone, 1); } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 37ccc71a8..8da1bc20a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -27,6 +27,10 @@ public class BukkitUtil extends BlockManager { private static String lastString = null; private static World lastWorld = null; + public static Biome getBiome(Location loc) { + return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()); + } + public static World getWorld(String string) { if (lastString == string) { return lastWorld; From d11679aa1e5dc9af3db30f978848ffacd4d9f8ae Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 15:32:40 +1100 Subject: [PATCH 020/124] SQL --- .../com/intellectualcrafters/plot/commands/Database.java | 6 +++--- .../intellectualcrafters/plot/database/SQLManager.java | 9 +++++---- .../com/intellectualcrafters/plot/database/SQLite.java | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) 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 9eca4f450..d6f5e7c1f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; /** @@ -46,9 +47,8 @@ public class Database extends SubCommand { } public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) { - final Plugin p = PlotSquared.getMain(); final java.util.Set plots = PlotSquared.getPlots(); - p.getServer().getScheduler().runTaskAsynchronously(p, new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -94,7 +94,7 @@ public class Database extends SubCommand { } Connection n; try { - n = new MySQL(PlotSquared.getMain(), host, port, database, username, password).openConnection(); + n = new MySQL(PlotSquared.THIS, host, port, database, username, password).openConnection(); // Connection if (n.isClosed()) { return sendMessage(plr, "Failed to open connection"); 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 21df6b43d..2dc454402 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -49,6 +49,7 @@ import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.ClusterManager; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; /** @@ -92,7 +93,7 @@ public class SQLManager implements AbstractDB { // schedule reconnect if (PlotSquared.getMySQL() != null) { - Bukkit.getScheduler().runTaskTimer(PlotSquared.getMain(), new Runnable() { + TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { try { @@ -101,7 +102,7 @@ public class SQLManager implements AbstractDB { e.printStackTrace(); } } - }, 11000, 11000); + }, 11000); } } @@ -1078,7 +1079,7 @@ public class SQLManager implements AbstractDB { String comparison = below ? ">=" : "="; if (plot != null) { statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?"); - statement.setInt(1, getId(plot.world.getName(), plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); statement.setInt(2, tier); } else { @@ -1284,7 +1285,7 @@ public class SQLManager implements AbstractDB { public double getRatings(final Plot plot) { try { final PreparedStatement statement = this.connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `" + this.prefix + "plot_ratings` WHERE `plot_plot_id` = ? "); - statement.setInt(1, getId(plot.world.getName(), plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); final ResultSet set = statement.executeQuery(); double rating = 0; while (set.next()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index 495f2999d..f18e60065 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -59,15 +59,15 @@ public class SQLite extends Database { if (checkConnection()) { return this.connection; } - if (!this.plotsquared.IMP.getDirectory().exists()) { - this.plugin.getDataFolder().mkdirs(); + if (!PlotSquared.IMP.getDirectory().exists()) { + PlotSquared.IMP.getDirectory().mkdirs(); } final File file = new File(this.dbLocation); if (!(file.exists())) { try { file.createNewFile(); } catch (final IOException e) { - this.plugin.getLogger().log(Level.SEVERE, "Unable to create database!"); + PlotSquared.log("&cUnable to create database!"); } } Class.forName("org.sqlite.JDBC"); From 2b7053895cc822e949062e4d83977c3b504234e6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 16:40:51 +1100 Subject: [PATCH 021/124] h --- .../intellectualcrafters/plot/BukkitMain.java | 2 +- .../plot/PlotSquared.java | 4 + .../plot/listeners/PlayerEvents.java | 26 ++- .../plot/listeners/PlotListener.java | 38 ++-- .../plot/util/AChunkManager.java | 5 + .../plot/util/ChunkManager.java | 33 ++++ .../plot/util/PlayerFunctions.java | 108 +++++++++-- .../plot/util/PlotHelper.java | 180 ++++-------------- 8 files changed, 206 insertions(+), 190 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 1da734d56..0f230d246 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -256,7 +256,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { 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())) { + if (!((entity = entities[i]) instanceof Player) && !.isInPlot(entity.getLocation())) { entity.remove(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 037d343a0..3cbc7e1ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -118,6 +118,10 @@ public class PlotSquared { plotworlds.remove(world); } + public static HashMap> getAllPlotsRaw() { + return plots; + } + public static void setAllPlotsRaw(final LinkedHashMap> plots) { PlotSquared.plots = plots; } 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 37615c08a..8fb1f6ba2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.listeners; +import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -82,6 +83,7 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.WorldInitEvent; +import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; @@ -93,6 +95,7 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; @@ -101,6 +104,7 @@ import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * Player Events involving plots @@ -112,7 +116,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onWorldInit(final WorldInitEvent event) { - PlotSquared.loadWorld(event.getWorld()); + World world = event.getWorld(); + ChunkGenerator gen = world.getGenerator(); + if (gen instanceof PlotGenerator) { + PlotSquared.loadWorld(world.getName(), (PlotGenerator) gen); + } + else { + PlotSquared.loadWorld(world.getName(), null); + } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -145,7 +156,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi // textures(event.getPlayer()); if (isInPlot(event.getPlayer().getLocation())) { if (Settings.TELEPORT_ON_LOGIN) { - event.getPlayer().teleport(PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer()))); + BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer()))); PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); } else { plotEntry(event.getPlayer(), getCurrentPlot(event.getPlayer().getLocation())); @@ -225,7 +236,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world.getName()); if (!plotworld.PLOT_CHAT) { return; } @@ -700,19 +711,16 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public static void onLeave(final PlayerQuitEvent event) { - if (PlotSelection.currentSelection.containsKey(event.getPlayer().getName())) { - PlotSelection.currentSelection.remove(event.getPlayer().getName()); - } if (Setup.setupMap.containsKey(event.getPlayer().getName())) { Setup.setupMap.remove(event.getPlayer().getName()); } if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { - final Set plots = PlotSquared.getPlots(event.getPlayer()); + final Collection plots = PlotSquared.getPlots(event.getPlayer().getName()).values(); for (final Plot plot : plots) { PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); final PlotManager manager = PlotSquared.getPlotManager(plot.world); - manager.clearPlot(null, plotworld, plot, true, null); - DBFunc.delete(plot.world.getName(), plot); + manager.clearPlot(plotworld, plot, true, null); + DBFunc.delete(plot.world, plot); PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); } } 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 3b0165a98..8c702e6b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -25,15 +25,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.WeatherType; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -41,6 +32,7 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; @@ -56,7 +48,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; @SuppressWarnings({"unused", "deprecation"}) public class PlotListener { public static void textures(final Player p) { - if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld())) { + if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld().getName())) { p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); } } @@ -73,15 +65,11 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return defaultValue; } - public static boolean isInPlot(final Player player) { - return PlayerFunctions.isInPlot(player); + public static boolean isInPlot(String world, int x, int y, int z) { + return (PlayerFunctions.getPlot(new Location(world, x, y, z)) != null); } - public static Plot getPlot(final Player player) { - return PlayerFunctions.getCurrentPlot(player); - } - - public static boolean isPlotWorld(final World world) { + public static boolean isPlotWorld(final String world) { return PlotSquared.isPlotWorld(world); } @@ -93,10 +81,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return true; } - public static PlotWorld getPlotWorld(final World world) { - return PlotSquared.getWorldSettings(world); - } - private static String getName(final UUID id) { if (id == null) { return "none"; @@ -113,15 +97,15 @@ import com.intellectualcrafters.plot.util.UUIDHandler; } public static boolean enteredPlot(final Location l1, final Location l2) { - final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 0, l1.getBlockZ())); - final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 0, l2.getBlockZ())); + final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ())); + final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ())); return (p2 != null) && ((p1 == null) || !p1.equals(p2)); } public static boolean leftPlot(final Location l1, final Location l2) { - final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 0, l1.getBlockZ())); - final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 0, l2.getBlockZ())); + final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ())); + final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ())); return (p1 != null) && ((p2 == null) || !p1.equals(p2)); } @@ -138,11 +122,11 @@ import com.intellectualcrafters.plot.util.UUIDHandler; if (id == null) { return null; } - final World world = loc.getWorld(); + final String world = loc.getWorld(); 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()); + return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld()); } private static WeatherType getWeatherType(String str) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java index b29fe35fc..1d0bd0ee2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -8,6 +8,7 @@ import java.util.List; + import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -35,4 +36,8 @@ public abstract class AChunkManager { public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone); public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone); + + public abstract void update(Location loc); + + public abstract void clearAllEntities(final Plot plot); } 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 d0e2c9e36..0afa818da 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; @@ -35,16 +36,19 @@ import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; @@ -741,4 +745,33 @@ public class ChunkManager extends AChunkManager { } return 0; } + + public void clearAllEntities(final Plot plot) { + final List entities = BukkitUtil.getEntities(plot.world); + for (final Entity entity : entities) { + final PlotId id = PlayerFunctions.getPlot(BukkitUtil.getLocation(entity)); + if (plot.id.equals(id)) { + if (entity instanceof Player) { + final Player player = (Player) entity; + BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); + PlotListener.plotExit(player, plot); + } else { + entity.remove(); + } + } + } + } + + @Override + public void update(Location loc) { + ArrayList chunks = new ArrayList<>(); + final int distance = Bukkit.getViewDistance(); + for (int cx = -distance; cx < distance; cx++) { + for (int cz = -distance; cz < distance; cz++) { + Chunk chunk = BukkitUtil.getChunkAt(loc.getWorld(), loc.getX(), loc.getZ()); + chunks.add(chunk); + } + } + AbstractSetBlock.setBlockManager.update(chunks); + } } 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 95859cc86..652698557 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -32,10 +32,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import org.bukkit.ChatColor; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.ChatPaginator; +import net.milkbowl.vault.economy.Economy; import java.util.ArrayList; import java.util.HashSet; @@ -49,6 +46,99 @@ import java.util.UUID; */ @SuppressWarnings("javadoc") public class PlayerFunctions { + + /** + * Clear a plot. Use null player if no player is present + * @param player + * @param world + * @param plot + * @param isDelete + */ + public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { + + if (runners.containsKey(plot)) { + PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); + return; + } + final PlotManager manager = PlotSquared.getPlotManager(world); + + final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + + final int prime = 31; + int h = 1; + h = (prime * h) + pos1.getX(); + h = (prime * h) + pos1.getZ(); + state = h; + + final long start = System.currentTimeMillis(); + final Location location = PlotHelper.getPlotHomeDefault(plot); + PlotWorld plotworld = PlotSquared.getWorldSettings(world); + runners.put(plot, 1); + if (plotworld.TERRAIN != 0) { + final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); + AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { + @Override + public void run() { + if (player != null && player.isOnline()) { + PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); + } + runners.remove(plot); + } + }); + return; + } + Runnable run = new Runnable() { + @Override + public void run() { + PlotHelper.setBiome(world, plot, Biome.FOREST); + runners.remove(plot); + if (player != null && player.isOnline()) { + PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); + } + update(location); + } + }; + manager.clearPlot(plotworld, plot, isDelete, run); + } + + /** + * Merges all plots in the arraylist (with cost) + * + * @param plr + * @param world + * @param plotIds + * + * @return + */ + public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { + + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) { + final double cost = plotIds.size() * plotworld.MERGE_PRICE; + if (cost > 0d) { + final Economy economy = PlotSquared.economy; + if (economy.getBalance(plr) < cost) { + PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost); + return false; + } + economy.withdrawPlayer(plr, cost); + PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + ""); + } + } + return mergePlots(world, plotIds, true); + } + + public static String getPlayerName(final UUID uuid) { + if (uuid == null) { + return "unknown"; + } + final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); + if (!plr.hasPlayedBefore()) { + return "unknown"; + } + return plr.getName(); + } + /** * @param player player * @@ -58,16 +148,6 @@ import java.util.UUID; return getCurrentPlot(player) != null; } - public static ArrayList getPlotSelectionIds(PlotId pos1, final PlotId pos2) { - final ArrayList myplots = new ArrayList<>(); - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - myplots.add(new PlotId(x, y)); - } - } - return myplots; - } - public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { 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 282ef4ed0..cdd28e87d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -27,19 +27,10 @@ import java.util.HashMap; import java.util.List; import java.util.UUID; -import net.milkbowl.vault.economy.Economy; - -import org.bukkit.Bukkit; import org.bukkit.Chunk; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.World; import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.block.Sign; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; + +import net.milkbowl.vault.economy.Economy; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; @@ -126,33 +117,16 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; return id; } - /** - * Merges all plots in the arraylist (with cost) - * - * @param plr - * @param world - * @param plotIds - * - * @return - */ - public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { - - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) { - final double cost = plotIds.size() * plotworld.MERGE_PRICE; - if (cost > 0d) { - final Economy economy = PlotSquared.economy; - if (economy.getBalance(plr) < cost) { - PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost); - return false; - } - economy.withdrawPlayer(plr, cost); - PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + ""); + public static ArrayList getPlotSelectionIds(PlotId pos1, final PlotId pos2) { + final ArrayList myplots = new ArrayList<>(); + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + myplots.add(new PlotId(x, y)); } } - return mergePlots(world, plotIds, true); + return myplots; } - + /** * Completely merges a set of plots
(There are no checks to make sure you supply the correct * arguments)
- Misuse of this method can result in unusable plots
- the set of plots must belong to one @@ -303,17 +277,6 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; BukkitUtil.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines); } - public static String getPlayerName(final UUID uuid) { - if (uuid == null) { - return "unknown"; - } - final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if (!plr.hasPlayedBefore()) { - return "unknown"; - } - return plr.getName(); - } - public static String getStringSized(final int max, final String string) { if (string.length() > max) { return string.substring(0, max); @@ -321,18 +284,16 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; return string; } - public static void autoMerge(final String world, final Plot plot, final Player player) { - + public static void autoMerge(final String world, final Plot plot, final UUID uuid) { if (plot == null) { return; } if (plot.owner == null) { return; } - if (!plot.owner.equals(UUIDHandler.getUUID(player))) { + if (!plot.owner.equals(uuid)) { return; } - ArrayList plots; boolean merge = true; int count = 0; @@ -343,32 +304,32 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; count++; final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id; final PlotId top = PlayerFunctions.getTopPlot(world, plot).id; - plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); - if (ownsPlots(world, plots, player, 0)) { + plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); + if (ownsPlots(world, plots, uuid, 0)) { final boolean result = mergePlots(world, plots, true); if (result) { merge = true; continue; } } - plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); - if (ownsPlots(world, plots, player, 1)) { + plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); + if (ownsPlots(world, plots, uuid, 1)) { final boolean result = mergePlots(world, plots, true); if (result) { merge = true; continue; } } - plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); - if (ownsPlots(world, plots, player, 2)) { + plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); + if (ownsPlots(world, plots, uuid, 2)) { final boolean result = mergePlots(world, plots, true); if (result) { merge = true; continue; } } - plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); - if (ownsPlots(world, plots, player, 3)) { + plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); + if (ownsPlots(world, plots, uuid, 3)) { final boolean result = mergePlots(world, plots, true); if (result) { merge = true; @@ -377,16 +338,16 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; } merge = false; } - update(BukkitUtil.getLocation(player)); + AChunkManager.manager.update(getPlotHome(world, plot)); } - private static boolean ownsPlots(final String world, final ArrayList plots, final Player player, final int dir) { + private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { final PlotId id_min = plots.get(0); final PlotId id_max = plots.get(plots.size() - 1); for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(player)))) { + if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) { return false; } final PlotId top = PlayerFunctions.getTopPlot(world, myplot).id; @@ -401,18 +362,6 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; return true; } - public static void update(Location loc) { - ArrayList chunks = new ArrayList<>(); - final int distance = Bukkit.getViewDistance(); - for (int cx = -distance; cx < distance; cx++) { - for (int cz = -distance; cz < distance; cz++) { - Chunk chunk = BukkitUtil.getChunkAt(loc.getWorld(), loc.getX(), loc.getZ()); - chunks.add(chunk); - } - } - AbstractSetBlock.setBlockManager.update(chunks); - } - public static void updateWorldBorder(Plot plot) { if (!worldBorder.containsKey(plot.world)) { return; @@ -434,16 +383,14 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * Create a plot and notify the world border and plot merger */ - public static boolean createPlot(final Player player, final Plot plot) { + public static boolean createPlot(final UUID uuid, final Plot plot) { if (PlotHelper.worldBorder.containsKey(plot.world)) { updateWorldBorder(plot); } - String w = BukkitUtil.getWorld(player); - UUID uuid = UUIDHandler.getUUID(player); Plot p = createPlotAbs(uuid, plot); - final PlotWorld plotworld = PlotSquared.getWorldSettings(w); + final PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); if (plotworld.AUTO_MERGE) { - autoMerge(w, p, player); + autoMerge(plot.world, p, uuid); } return true; } @@ -475,39 +422,25 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; return new short[]{Short.parseShort(block), 0}; } - public static void clearAllEntities(final String world, final Plot plot, final boolean tile) { - final List entities = BukkitUtil.getEntities(world); - for (final Entity entity : entities) { - final PlotId id = PlayerFunctions.getPlot(BukkitUtil.getLocation(entity)); - if (plot.id.equals(id)) { - if (entity instanceof Player) { - final Player player = (Player) entity; - BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); - PlotListener.plotExit(player, plot); - } else { - entity.remove(); - } - } - } - } - /** - * Clear a plot. Use null player if no player is present - * @param player - * @param world + * Clear a plot and associated sections: [sign, entities, border] + * + * @param requester * @param plot - * @param isDelete */ - public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { - + public static boolean clear(UUID uuid, final Plot plot, final boolean isDelete, final Runnable whenDone) { if (runners.containsKey(plot)) { - PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); - return; + return false; } + AChunkManager.manager.clearAllEntities(plot); + clear(plot.world, plot, isDelete, whenDone); + removeSign(plot); + return true; + } + + public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { final PlotManager manager = PlotSquared.getPlotManager(world); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final int prime = 31; int h = 1; h = (prime * h) + pos1.getX(); @@ -523,10 +456,8 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { - if (player != null && player.isOnline()) { - PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); - } runners.remove(plot); + TaskManager.runTask(whenDone); } }); return; @@ -536,42 +467,13 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public void run() { PlotHelper.setBiome(world, plot, Biome.FOREST); runners.remove(plot); - if (player != null && player.isOnline()) { - PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); - } - update(location); + TaskManager.runTask(whenDone); + AChunkManager.manager.update(location); } }; manager.clearPlot(plotworld, plot, isDelete, run); } - /** - * Clear a plot and associated sections: [sign, entities, border] - * - * @param requester - * @param plot - */ - public static void clear(final Player requester, final Plot plot, final boolean isDelete) { - if (requester == null) { - clearAllEntities(plot.world, plot, false); - clear(requester, plot.world, plot, isDelete); - removeSign(plot); - return; - } - if (runners.containsKey(plot)) { - PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER); - return; - } - - PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); - - String world = requester.getWorld().getName(); - - clearAllEntities(world, plot, false); - clear(requester, world, plot, isDelete); - removeSign(plot); - } - public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { if (blocks.length == 1) { setSimpleCuboid(world, pos1, pos2, blocks[0]); @@ -874,7 +776,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; int offset_x = newPlot.x - pos1.id.x; int offset_y = newPlot.y - pos1.id.y; - final ArrayList selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id); + final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); for (PlotId id : selection) { DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); Plot plot = PlotSquared.getPlots(world).get(id); From 3f71e0e7729e46781514b8ea0bc564919ac95b40 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 16:53:00 +1100 Subject: [PATCH 022/124] sendchunk --- .../intellectualcrafters/plot/util/PlotHelper.java | 7 ++++--- .../com/intellectualcrafters/plot/util/SendChunk.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) 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 cdd28e87d..bc358bd02 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; @@ -634,12 +635,12 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; final int minChunkZ = (int) Math.floor((double) bottomZ / 16); final int maxChunkZ = (int) Math.floor((double) topZ / 16); - final ArrayList chunks = new ArrayList<>(); + final ArrayList chunks = new ArrayList<>(); for (int x = minChunkX; x <= maxChunkX; x++) { for (int z = minChunkZ; z <= maxChunkZ; z++) { if (canSendChunk) { - final Chunk chunk = BukkitUtil.getChunkAt(world, x, z); + final ChunkLoc chunk = new ChunkLoc(x, z); chunks.add(chunk); } else { BukkitUtil.refreshChunk(world, x, z); @@ -647,7 +648,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; } } try { - SendChunk.sendChunk(chunks); + SendChunk.sendChunk(world, chunks); } catch (final Throwable e) { canSendChunk = false; for (int x = minChunkX; x <= maxChunkX; x++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java index 3800ca585..f4157d461 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java @@ -2,11 +2,15 @@ package com.intellectualcrafters.plot.util; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Chunk; +import org.bukkit.World; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; @@ -57,7 +61,12 @@ public class SendChunk { ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); } - public static void sendChunk(final List chunks) { + public static void sendChunk(String worldname, List locs) { + World myworld = Bukkit.getWorld(worldname); + HashSet chunks = new HashSet<>(); + for (ChunkLoc loc : locs) { + chunks.add(myworld.getChunkAt(loc.x, loc.z)); + } int diffx, diffz; final int view = Bukkit.getServer().getViewDistance() << 4; for (final Chunk chunk : chunks) { From 80af1907188a0558241ad909c5a9d30f2dccec40 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:09:53 +1100 Subject: [PATCH 023/124] . --- .../plot/config/Permissions.java | 18 ++++ .../plot/object/Plot.java | 96 ++----------------- .../plot/util/PlotHelper.java | 9 +- .../plot/util/SendChunk.java | 1 - .../plot/util/bukkit/BukkitUtil.java | 3 +- 5 files changed, 30 insertions(+), 97 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java new file mode 100644 index 000000000..97a8c8593 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java @@ -0,0 +1,18 @@ +package com.intellectualcrafters.plot.config; + +public class Permissions { + // ADMIN + public static String ADMIN = "plots.admin"; + // BUILD + public static String BUILD_OTHER = "plots.admin.build.other"; + public static String BUILD_ROAD = "plots.admin.build.road"; + public static String BUILD_UNOWNED = "plots.admin.build.unowned"; + // INTERACT + public static String INTERACT_OTHER = "plots.admin.interact.other"; + public static String INTERACT_ROAD = "plots.admin.interact.road"; + public static String INTERACT_UNOWNED = "plots.admin.interact.unowned"; + // BREAK + public static String BREAK_OTHER = "plots.admin.break.other"; + public static String BREAK_ROAD = "plots.admin.break.road"; + public static String BREAK_UNOWNED = "plots.admin.break.unowned"; +} 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 972ce83f5..43d566514 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -26,11 +26,6 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; @@ -87,33 +82,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; public boolean hasChanged = false; public boolean countsTowardsMax = true; - /** - * Primary constructor - * - * @param id - * @param owner - * @param plotBiome - * @param helpers - * @param denied - * - * @deprecated - */ - @Deprecated - @SuppressWarnings("unused") - public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList denied, final String world) { - this.id = id; - this.settings = new PlotSettings(this); - this.owner = owner; - this.deny_entry = this.owner == null; - this.helpers = helpers; - this.denied = denied; - this.trusted = new ArrayList<>(); - this.settings.setAlias(""); - this.delete = false; - this.settings.flags = new HashSet(); - this.world = world; - } - /** * Primary constructor * @@ -136,40 +104,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; this.world = world; } - /** - * Constructor for saved plots - * - * @param id - * @param owner - * @param plotBiome - * @param helpers - * @param denied - * @param merged - * - * @deprecated - */ - @Deprecated - @SuppressWarnings("unused") - public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) { - this.id = id; - this.settings = new PlotSettings(this); - this.owner = owner; - this.deny_entry = this.owner != null; - this.trusted = trusted; - this.helpers = helpers; - this.denied = denied; - this.settings.setAlias(alias); - this.settings.setPosition(position); - this.settings.setMerged(merged); - this.delete = false; - if (flags != null) { - this.settings.flags = flags; - } else { - this.settings.flags = new HashSet(); - } - this.world = world; - } - /** * Constructor for saved plots * @@ -215,8 +149,8 @@ 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 BukkitMain.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))); + public boolean isAdded(final UUID uuid) { + return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone))); } /** @@ -226,8 +160,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler; * * @return false if the player is allowed to enter */ - public boolean deny_entry(final Player player) { - return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(UUIDHandler.getUUID(player)))); + public boolean isDenied(final UUID uuid) { + return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); } /** @@ -242,8 +176,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler; * * @param player */ - public void setOwner(final Player player) { - this.owner = UUIDHandler.getUUID(player); + public void setOwner(final UUID uuid) { + this.owner = uuid; } /** @@ -253,13 +187,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return this.id; } - /** - * Get the plot World - */ - public World getWorld() { - return Bukkit.getWorld(this.world); - } - /** * Get a clone of the plot * @@ -269,7 +196,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; public Object clone() throws CloneNotSupportedException { final Plot p = (Plot) super.clone(); if (!p.equals(this) || (p != this)) { - return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, getWorld().getName(), this.settings.getMerged()); + return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); } return p; } @@ -340,15 +267,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; this.trusted.remove(uuid); } - /** - * Clear a plot - * - * @param plr initiator - */ - public void clear(final Player plr, final boolean isDelete) { - PlotHelper.clear(plr, this, isDelete); - } - @Override public boolean equals(final Object obj) { if (this == obj) { 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 bc358bd02..91f4a785f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -27,9 +27,6 @@ import java.util.HashMap; import java.util.List; import java.util.UUID; -import org.bukkit.Chunk; -import org.bukkit.block.Biome; - import net.milkbowl.vault.economy.Economy; import com.intellectualcrafters.plot.BukkitMain; @@ -466,7 +463,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; Runnable run = new Runnable() { @Override public void run() { - PlotHelper.setBiome(world, plot, Biome.FOREST); + PlotHelper.setBiome(world, plot, "FOREST"); runners.remove(plot); TaskManager.runTask(whenDone); AChunkManager.manager.update(location); @@ -535,13 +532,13 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; BlockManager.setBlocks(world, xl, yl, zl, ids, data); } - public static void setBiome(final String world, final Plot plot, final Biome b) { + public static void setBiome(final String world, final Plot plot, final String biome) { final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; final int topX = getPlotTopLoc(world, plot.id).getX(); final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; final int topZ = getPlotTopLoc(world, plot.id).getZ(); - BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, b); + BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); } public static int getHeighestBlock(final String world, final int x, final int z) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java index f4157d461..923bbc35f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java @@ -4,7 +4,6 @@ import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import java.util.HashSet; import java.util.List; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Chunk; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 8da1bc20a..76fe85727 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -91,7 +91,8 @@ public class BukkitUtil extends BlockManager { } } - public static void setBiome(String worldname, int pos1_x, int pos1_z, int pos2_x, int pos2_z, Biome b) { + public static void setBiome(String worldname, int pos1_x, int pos1_z, int pos2_x, int pos2_z, String biome) { + Biome b = Biome.valueOf(biome.toUpperCase()); World world = getWorld(worldname); for (int x = pos1_x; x<= pos2_x; x++) { for (int z = pos1_z; z<= pos2_z; z++) { From 2046dffb0b7f51fbcd8de6b4fcafeb28049356d7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:11:32 +1100 Subject: [PATCH 024/124] not needed anymore --- .../intellectualcrafters/plot/_PlotMain.java | 1529 ----------------- 1 file changed, 1529 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java deleted file mode 100644 index dd46e7a6a..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java +++ /dev/null @@ -1,1529 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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 = BukkitUtil.getLocation(entity); - 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 = BukkitUtil.getLocation(entity); - 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()) { - log(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()) { - log("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()) { - log("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()) { - log("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()) { - log(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; - - { - log(C.PREFIX.s() + "KillAllEntities started."); - } - - @Override - public void run() { - if (this.ticked > 36_000L) { - this.ticked = 0l; - if (this.error > 0) { - log(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) { - log(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) { - log("&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.log("&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) { - log("&c[IMPORTANT] THIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); - log("&c[IMPORTANT] - Make sure 'UUID.read-from-disk' is disabled (false)!"); - log("&c[IMPORTANT] - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); - log("&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")) { - 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"); - 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.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); - } - } - } - } - - /** - * 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) { - log("&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: { - log("&cKey not found: &7" + element); - return null; - } - } - } - catch (Exception e) { - e.printStackTrace(); - log("&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 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 log(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) { - log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); - // Didn't know of any other link :D - log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); - Bukkit.getPluginManager().disablePlugin(this); - return; - } else if (getJavaVersion() < 1.8) { - log(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(); - log(C.PREFIX.s() + "&6Metrics enabled."); - } catch (final Exception e) { - log(C.PREFIX.s() + "&cFailed to load up metrics."); - } - } else { - // We should at least make them feel bad. - log("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) { - log(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."); - log("&c[Plots] MySQL is not setup correctly. The plugin will disable itself."); - if ((config == null) || config.getBoolean("debug")) { - log("&d==== Here is an ugly stacktrace if you are interested in those things ===="); - e.printStackTrace(); - log("&d==== End of stacktrace ===="); - log("&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(); - log(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"); - log(C.PREFIX.s() + "&cFailed to open SQLite connection. The plugin will disable itself."); - log("&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."); - log(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.log("&cThis version of WorldEdit does not support PlotSquared."); - PlotSquared.log("&cPlease use WorldEdit 6+ for masking support"); - PlotSquared.log("&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) { - log(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) { - log(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 { - log(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"); - } - } - } -} From c615f27b688024e7d95a575df6fd777c085f7cd0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:16:07 +1100 Subject: [PATCH 025/124] Need to redo API... --- .../plot/api/PlotAPI.java | 626 ------------------ 1 file changed, 626 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java deleted file mode 100644 index 66a1241e4..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ /dev/null @@ -1,626 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.api; - - -/** - * PlotSquared API - * - * @author Citymonstret - * @author Empire92 - * @version API 2.0 - */ - -@SuppressWarnings("unused") public class PlotAPI { - // 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#log(String) -// */ -// public void sendConsoleMessage(final String msg) { -// PlotSquared.log(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(BukkitUtil.getLocation(entity)); -// } -// -// /** -// * 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); -// } -} From dea6e8440764e817636e3eb862249118e9dda5d8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:28:21 +1100 Subject: [PATCH 026/124] move --- .../intellectualcrafters/plot/BukkitMain.java | 16 +++++----- .../plot/PlotSquared.java | 2 +- .../plot/commands/Auto.java | 2 +- .../plot/commands/Ban.java | 2 +- .../plot/commands/Buy.java | 4 +-- .../plot/commands/Claim.java | 2 +- .../plot/commands/Clear.java | 4 +-- .../plot/commands/Clipboard.java | 5 +-- .../plot/commands/Cluster.java | 4 +-- .../plot/commands/Comment.java | 2 +- .../plot/commands/Condense.java | 2 +- .../plot/commands/Copy.java | 5 ++- .../plot/commands/CreateRoadSchematic.java | 2 +- .../plot/commands/DEOP.java | 2 +- .../plot/commands/Database.java | 5 ++- .../plot/commands/Debug.java | 2 +- .../plot/commands/DebugClaimTest.java | 4 +-- .../plot/commands/DebugClear.java | 6 ++-- .../plot/commands/DebugExec.java | 4 +-- .../plot/commands/DebugFixFlags.java | 2 +- .../plot/commands/DebugLoadTest.java | 2 +- .../plot/commands/DebugRoadRegen.java | 4 +-- .../plot/commands/DebugSaveTest.java | 2 +- .../plot/commands/Delete.java | 4 +-- .../plot/commands/Denied.java | 4 +-- .../plot/commands/FlagCmd.java | 2 +- .../plot/commands/Helpers.java | 4 +-- .../plot/commands/Home.java | 4 +-- .../plot/commands/Inbox.java | 4 +-- .../plot/commands/Info.java | 4 +-- .../plot/commands/Kick.java | 4 +-- .../plot/commands/MainCommand.java | 2 +- .../plot/commands/Merge.java | 4 +-- .../plot/commands/Move.java | 2 +- .../plot/commands/MusicSubcommand.java | 2 +- .../plot/commands/OP.java | 2 +- .../plot/commands/Paste.java | 5 ++- .../plot/commands/Purge.java | 4 +-- .../plot/commands/Rate.java | 4 +-- .../plot/commands/RegenAllRoads.java | 2 +- .../plot/commands/Reload.java | 3 +- .../plot/commands/Schematic.java | 4 +-- .../plot/commands/Set.java | 4 +-- .../plot/commands/SetOwner.java | 4 +-- .../plot/commands/Setup.java | 2 +- .../plot/commands/SubCommand.java | 4 +-- .../plot/commands/Swap.java | 5 ++- .../plot/commands/TP.java | 2 +- .../plot/commands/Target.java | 2 +- .../plot/commands/Template.java | 2 +- .../plot/commands/Trim.java | 4 +-- .../plot/commands/Trusted.java | 4 +-- .../plot/commands/Unban.java | 2 +- .../plot/commands/Unclaim.java | 4 +-- .../plot/commands/Unlink.java | 4 +-- .../plot/commands/Visit.java | 2 +- .../plot/commands/WE_Anywhere.java | 4 +-- .../plot/commands/list.java | 4 +-- .../plot/commands/plugin.java | 2 +- .../plot/database/PlotMeConverter.java | 2 +- .../plot/database/SQLManager.java | 1 - .../plot/database/SQLite.java | 1 - .../plot/generator/AugmentedPopulator.java | 4 +-- .../plot/generator/HybridGen.java | 2 +- .../plot/generator/HybridPlotManager.java | 6 ++-- .../plot/generator/HybridPop.java | 2 +- .../plot/generator/SquarePlotManager.java | 4 +-- .../plot/listeners/ForceFieldListener.java | 2 +- .../plot/listeners/InventoryListener.java | 2 +- .../plot/listeners/PlayerEvents.java | 4 +-- .../plot/listeners/PlayerEvents_1_8.java | 2 +- .../plot/listeners/PlotListener.java | 10 ++++-- .../plot/listeners/PlotPlusListener.java | 4 +-- .../plot/listeners/WorldEditListener.java | 6 ++-- .../plot/listeners/WorldGuardListener.java | 2 +- .../plot/object/InfoInventory.java | 2 +- .../plot/object/Plot.java | 4 +-- .../plot/util/AChunkManager.java | 8 ----- .../plot/util/AbstractSetBlock.java | 4 +-- .../plot/util/ClusterManager.java | 3 ++ .../plot/util/ExpireManager.java | 3 +- .../plot/util/PlotHelper.java | 31 ++++++++++++------- .../plot/util/SchematicHandler.java | 2 -- .../plot/util/bukkit/BukkitUtil.java | 6 ++-- .../plot/util/{ => bukkit}/ChunkManager.java | 19 ++---------- .../plot/util/{ => bukkit}/Metrics.java | 2 +- .../plot/util/{ => bukkit}/PWE.java | 4 +-- .../util/{ => bukkit}/PlayerFunctions.java | 25 +++++++++------ .../plot/util/{ => bukkit}/SendChunk.java | 22 +++++++------ .../plot/util/{ => bukkit}/SetBlockFast.java | 3 +- .../util/{ => bukkit}/SetBlockFast_1_8.java | 3 +- .../util/{ => bukkit}/SetBlockManager.java | 2 +- .../plot/util/{ => bukkit}/SetBlockSlow.java | 2 +- .../plot/util/{ => bukkit}/UUIDHandler.java | 13 +------- .../plot/uuid/OfflineUUIDWrapper.java | 2 +- 95 files changed, 203 insertions(+), 215 deletions(-) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/ChunkManager.java (98%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/Metrics.java (99%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/PWE.java (98%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/PlayerFunctions.java (97%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/SendChunk.java (93%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/SetBlockFast.java (97%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/SetBlockFast_1_8.java (98%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/SetBlockManager.java (87%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/SetBlockSlow.java (93%) rename PlotSquared/src/main/java/com/intellectualcrafters/plot/util/{ => bukkit}/UUIDHandler.java (94%) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 0f230d246..deca2ddb5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -41,18 +41,18 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; 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.SetBlockFast_1_8; -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.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.Metrics; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.SendChunk; +import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; +import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; +import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 3cbc7e1ea..18c9daee5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -52,7 +52,7 @@ import com.intellectualcrafters.plot.util.Logger; import com.intellectualcrafters.plot.util.Logger.LogLevel; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class PlotSquared { 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 0792354b8..a49188996 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -37,9 +37,9 @@ import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Auto extends SubCommand { public Auto() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java index 6b9b2c751..b55153375 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * Created 2014-11-09 for PlotSquared 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 7b0aa6dae..67a0d5798 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -34,9 +34,9 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 ef0b09561..a33e0bf26 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -33,9 +33,9 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * @author Citymonstret 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 7a84b43bf..a1a4a127f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -29,9 +29,9 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Clear extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java index 90245da2f..1ba785605 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java @@ -21,14 +21,11 @@ package com.intellectualcrafters.plot.commands; -import static com.intellectualcrafters.plot.object.PlotSelection.currentSelection; - import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotSelection; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Clipboard extends SubCommand { 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 afc71ee3f..b4753d0dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -42,9 +42,9 @@ import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Cluster extends SubCommand { 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 2eb796700..f05d92945 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Comment extends SubCommand { 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 828d5ce21..db047b480 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -36,8 +36,8 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Condense extends SubCommand { 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 08f0e17bf..f04c6138c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -26,10 +26,9 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotSelection; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Copy extends SubCommand { 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 d9c6bdb64..514c87d0f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -28,8 +28,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class CreateRoadSchematic extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java index 7acd4c1f1..42e502f1f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * Created 2014-11-09 for PlotSquared 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 d6f5e7c1f..8f33c9a73 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -8,16 +8,15 @@ import java.util.ArrayList; import java.util.UUID; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Created 2014-11-15 for PlotSquared 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 536ebe94f..4e6b0bac1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -28,9 +28,9 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.util.Lag; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.RUtils; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Debug extends SubCommand { 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 0666b82a0..0b71855b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -42,9 +42,9 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 770f0e1ce..e4dc89bdf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -32,10 +32,10 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugClear extends SubCommand { 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 50ad38b72..e79c8edf4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -42,8 +42,8 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.ExpireManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugExec extends SubCommand { 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 a95569da3..86db84da9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class DebugFixFlags extends SubCommand { 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 29a45160d..bcdcdbe9f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -27,7 +27,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * @author Citymonstret 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 da608c3c9..512213e08 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -30,8 +30,8 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.SetBlockManager; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class DebugRoadRegen extends SubCommand { 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 a28f8f515..d9157f693 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -28,7 +28,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * @author Citymonstret 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 cd4f34300..4165c9b7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -31,8 +31,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Delete extends SubCommand { 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 944a413b5..7f8de1f69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -31,8 +31,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") public class Denied extends SubCommand { 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 3d2b48088..33094ce99 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -37,7 +37,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class FlagCmd extends SubCommand { 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 85a7baab7..134c233d0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -31,8 +31,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Helpers extends SubCommand { 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 de758bb59..5e44c4d3a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -26,8 +26,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 de4b7952e..e89a9d953 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -35,8 +35,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Inbox extends SubCommand { 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 0ec16f5a1..32dc175c4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -39,9 +39,9 @@ import com.intellectualcrafters.plot.object.InfoInventory; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 4cbb260eb..e7411639b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -27,8 +27,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({"unused", "deprecation", "javadoc"}) public class Kick extends SubCommand { 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 5eee15788..b40fdb5b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -35,8 +35,8 @@ import org.bukkit.entity.Player; 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; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * PlotSquared command class 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 ff8989b71..80aecf2c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -37,9 +37,9 @@ import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 c180aba67..0689f9234 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -25,8 +25,8 @@ import org.bukkit.World; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * Created 2014-08-01 for PlotSquared diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index b8622f16c..a9462438c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -32,7 +32,7 @@ import org.bukkit.inventory.meta.ItemMeta; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class MusicSubcommand extends SubCommand { public MusicSubcommand() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java index 38a3b6487..e383b0e1f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * Created 2014-11-09 for PlotSquared 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 b05d85c18..1ec3d2395 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -26,10 +26,9 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotSelection; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Paste extends SubCommand { 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 6af070d69..22eed2844 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -35,8 +35,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({"javadoc"}) public class Purge extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index e3705a4ea..3bb333161 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -26,8 +26,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Rate extends SubCommand { 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 a1de3f2d4..f6ab45617 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; public class RegenAllRoads extends SubCommand { 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 bf604e31e..aa11a9d74 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -26,8 +26,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Reload extends SubCommand { 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 eaa3a0c2b..04d1fbc5c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -37,12 +37,12 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Schematic extends SubCommand { 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 b56466d8d..f2b1d314b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -47,10 +47,10 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 347a5bef0..c4a829396 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -33,9 +33,9 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class SetOwner extends SubCommand { 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 3acd85a14..ea4e5fcaf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -42,7 +42,7 @@ import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Setup extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 027e4a78e..3f1485f27 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -27,7 +27,7 @@ import java.util.Arrays; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * SubCommand class @@ -146,7 +146,7 @@ import com.intellectualcrafters.plot.util.PlayerFunctions; * @param c Caption * @param args Arguments (%s's) * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, + * @see com.intellectualcrafters.plot.util.bukkit.PlayerFunctions#sendMessage(org.bukkit.entity.Player, * com.intellectualcrafters.plot.config.C, String...) */ public boolean sendMessage(final Player plr, final C c, final String... args) { 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 e93c1de94..8a05962db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -30,10 +30,9 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotSelection; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Created 2014-08-01 for PlotSquared 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 9c1c6d2a1..2a7c67c70 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -30,8 +30,8 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * @author Citymonstret 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 73526d3b5..f84d90866 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -27,8 +27,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Target extends SubCommand { 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 319820bab..826c27ca4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -33,7 +33,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Template extends SubCommand { 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 cd1c3d193..5a1056a51 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -39,10 +39,10 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Trim extends SubCommand { 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 b2618a6d1..8fededa8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -31,8 +31,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") public class Trusted extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java index 6598d4c6e..8e869667c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * Created 2014-11-09 for PlotSquared 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 3b0488b29..c98fefb5e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -32,8 +32,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Unclaim extends SubCommand { 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 86ad65d27..e9e356d9e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -36,9 +36,9 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Created 2014-08-01 for PlotSquared 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 18df569ab..0901ed1fc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -30,7 +30,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Visit extends SubCommand { public Visit() { 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 789fd2812..6630ead8f 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 @@ -25,8 +25,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.util.PWE; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PWE; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class WE_Anywhere extends SubCommand { 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 40d6f0755..8697d8b41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -33,9 +33,9 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 c368a2238..831fe4520 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -32,7 +32,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class plugin extends SubCommand { 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 da470b5c7..6bfc55e3e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -45,7 +45,7 @@ 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; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Created 2014-08-17 for PlotSquared 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 2dc454402..38201d4ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -36,7 +36,6 @@ import java.util.Set; import java.util.UUID; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; import org.bukkit.block.Biome; import com.intellectualcrafters.plot.PlotSquared; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index f18e60065..9f75cf13f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -28,7 +28,6 @@ import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.logging.Level; import com.intellectualcrafters.plot.PlotSquared; 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 030931cb2..3d0f43331 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -17,10 +17,10 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class AugmentedPopulator extends BlockPopulator { 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 2eec00495..7cd5078ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; /** * The default generator is very messy, as we have decided to try externalize all calculations from within the loop. - 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 cef663749..a56c0ffa3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -40,12 +40,12 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.SetBlockManager; -import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager { 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 d66b0b75a..a3638cb86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; /** * @author Citymonstret 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 6b73512c4..b59fede0e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -10,9 +10,9 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * A plot manager with a square grid layout, with square shaped plots diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index 2a829e93f..de1b6a62d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -34,7 +34,7 @@ import org.bukkit.util.Vector; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * @author Citymonstret diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index 149a0ef86..a56e27a3b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -9,7 +9,7 @@ import org.bukkit.event.inventory.InventoryInteractEvent; import org.bukkit.inventory.Inventory; import com.intellectualcrafters.plot.object.InfoInventory; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** * Created 2014-11-18 for PlotSquared 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 8fb1f6ba2..775add2b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -100,11 +100,11 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Player Events involving plots 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 7edea424e..cb94b8fb5 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 @@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class PlayerEvents_1_8 extends PlotListener implements Listener { 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 8c702e6b8..163ee17e2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -25,6 +25,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.WeatherType; +import org.bukkit.block.Biome; + import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -38,8 +44,8 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 bd057d4d8..f2c4101ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -52,8 +52,8 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Created 2014-10-30 for PlotSquared 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 7ce18627a..6a09fddc5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -48,10 +48,10 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PWE; -import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.PWE; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.bukkit.selections.Selection; 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 d5de3598f..5ef523eae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.events.PlotUnlinkEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.protection.flags.DefaultFlag; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index eb85f740a..f3cbe891f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -13,7 +13,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Created 2014-11-18 for PlotSquared 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 43d566514..b3be4d640 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -26,11 +26,9 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; -import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * The plot class diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java index 1d0bd0ee2..599227770 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -3,12 +3,6 @@ package com.intellectualcrafters.plot.util; import java.util.HashMap; import java.util.List; - - - - - - import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -37,7 +31,5 @@ public abstract class AChunkManager { public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone); - public abstract void update(Location loc); - public abstract void clearAllEntities(final Plot plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java index 9ce8d8eed..0f7eb9f1f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java @@ -2,12 +2,12 @@ package com.intellectualcrafters.plot.util; import java.util.List; -import org.bukkit.Chunk; +import com.intellectualcrafters.plot.object.ChunkLoc; public abstract class AbstractSetBlock { public static AbstractSetBlock setBlockManager = null; public abstract boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data); - public abstract void update(List list); + public abstract void update(String world, List chunks); } 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 b70e66e3f..04281120b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -26,6 +26,9 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ClusterManager { public static HashMap> clusters; 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 a69962ae8..04419cc52 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -23,7 +23,8 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ExpireManager { 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 91f4a785f..81e9a52d2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -21,19 +21,13 @@ package com.intellectualcrafters.plot.util; -import java.io.File; import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.UUID; -import net.milkbowl.vault.economy.Economy; - -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; @@ -44,6 +38,8 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.SendChunk; /** * plot functions @@ -79,6 +75,19 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; } } + public static void update(Location loc) { + String world = loc.getWorld(); + ArrayList chunks = new ArrayList<>(); + final int distance = BukkitUtil.getViewDistance(); + for (int cx = -distance; cx < distance; cx++) { + for (int cz = -distance; cz < distance; cz++) { + ChunkLoc chunk = new ChunkLoc(cx, cz); + chunks.add(chunk); + } + } + AbstractSetBlock.setBlockManager.update(world, chunks); + } + public static void createWorld(String world, String generator) { } @@ -336,7 +345,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; } merge = false; } - AChunkManager.manager.update(getPlotHome(world, plot)); + update(getPlotHome(world, plot)); } private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { @@ -398,7 +407,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; */ public static Plot createPlotAbs(final UUID uuid, final Plot plot) { final String w = plot.world; - final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList(), new ArrayList(), w); + final Plot p = new Plot(plot.id, uuid, new ArrayList(), new ArrayList(), w); PlotSquared.updatePlot(p); DBFunc.createPlotAndSettings(p); return p; @@ -466,7 +475,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; PlotHelper.setBiome(world, plot, "FOREST"); runners.remove(plot); TaskManager.runTask(whenDone); - AChunkManager.manager.update(location); + update(location); } }; manager.clearPlot(plotworld, plot, isDelete, run); @@ -821,7 +830,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; if (PlotSquared.getPlots(world).containsKey(id)) { return PlotSquared.getPlots(world).get(id); } - return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), world); + return new Plot(id, null, new ArrayList(), new ArrayList(), world); } /** @@ -839,6 +848,6 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; 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()); + return new Plot(id, null, new ArrayList(), new ArrayList(), loc.getWorld()); } } 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 82e21b601..bebbdb757 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -34,8 +34,6 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.bukkit.Chunk; -import org.bukkit.World; -import org.bukkit.block.Block; import com.intellectualcrafters.jnbt.ByteArrayTag; import com.intellectualcrafters.jnbt.CompoundTag; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 76fe85727..b8a4928c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -18,8 +18,6 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.SetBlockManager; -import com.intellectualcrafters.plot.util.SetBlockSlow; public class BukkitUtil extends BlockManager { @@ -148,5 +146,9 @@ public class BukkitUtil extends BlockManager { ((Sign) blockstate).update(true); } } + + public static int getViewDistance() { + return Bukkit.getViewDistance(); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java similarity index 98% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 0afa818da..302651ddb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -1,4 +1,4 @@ -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import java.io.File; import java.util.ArrayList; @@ -51,8 +51,8 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.PlotHelper; public class ChunkManager extends AChunkManager { @@ -761,17 +761,4 @@ public class ChunkManager extends AChunkManager { } } } - - @Override - public void update(Location loc) { - ArrayList chunks = new ArrayList<>(); - final int distance = Bukkit.getViewDistance(); - for (int cx = -distance; cx < distance; cx++) { - for (int cz = -distance; cz < distance; cz++) { - Chunk chunk = BukkitUtil.getChunkAt(loc.getWorld(), loc.getX(), loc.getZ()); - chunks.add(chunk); - } - } - AbstractSetBlock.setBlockManager.update(chunks); - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Metrics.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java similarity index 99% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Metrics.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java index d4af7d53e..ef940ce24 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Metrics.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java @@ -19,7 +19,7 @@ // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java similarity index 98% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index 309e19d2a..bd038bb43 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -19,9 +19,8 @@ // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; -import org.bukkit.World; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; @@ -31,6 +30,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.PlotHelper; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.Vector; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java similarity index 97% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java index 652698557..ade190a48 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java @@ -19,7 +19,19 @@ // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.block.Biome; +import org.bukkit.util.ChatPaginator; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; @@ -30,14 +42,9 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; - -import net.milkbowl.vault.economy.Economy; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; +import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.ClusterManager; +import com.intellectualcrafters.plot.util.PlotHelper; /** * Functions involving players, plots and locations. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java similarity index 93% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java index 923bbc35f..e6c2d2178 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java @@ -1,8 +1,8 @@ -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; -import java.util.HashSet; +import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; @@ -59,13 +59,8 @@ public class SendChunk { ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); } - - public static void sendChunk(String worldname, List locs) { - World myworld = Bukkit.getWorld(worldname); - HashSet chunks = new HashSet<>(); - for (ChunkLoc loc : locs) { - chunks.add(myworld.getChunkAt(loc.x, loc.z)); - } + + public static void sendChunk(List chunks) { int diffx, diffz; final int view = Bukkit.getServer().getViewDistance() << 4; for (final Chunk chunk : chunks) { @@ -87,4 +82,13 @@ public class SendChunk { } } } + + public static void sendChunk(String worldname, List locs) { + World myworld = Bukkit.getWorld(worldname); + ArrayList chunks = new ArrayList<>(); + for (ChunkLoc loc : locs) { + chunks.add(myworld.getChunkAt(loc.x, loc.z)); + } + sendChunk(chunks); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java similarity index 97% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index 125021c6e..7cd76e171 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -19,7 +19,7 @@ // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; @@ -28,6 +28,7 @@ import java.util.List; import org.bukkit.Chunk; import org.bukkit.World; +import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java similarity index 98% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 6169a6bf2..b1ed0ca6f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -19,7 +19,7 @@ // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; @@ -29,6 +29,7 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Block; +import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockManager.java similarity index 87% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockManager.java index 34755dd02..209b9a59b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockManager.java @@ -1,4 +1,4 @@ -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import java.util.List; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java similarity index 93% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java index fc9531063..2fbce500a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockSlow.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java @@ -1,4 +1,4 @@ -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import java.util.List; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java similarity index 94% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index 5ed532a3a..c818ce8c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -1,4 +1,4 @@ -package com.intellectualcrafters.plot.util; +package com.intellectualcrafters.plot.util.bukkit; import java.io.File; import java.io.FilenameFilter; @@ -8,7 +8,6 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -175,16 +174,6 @@ public class UUIDHandler { if (name != null) { return name.value; } - - // check drive - if (Settings.UUID_FROM_DISK) { - OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - String string = op.getName(); - StringWrapper sw = new StringWrapper(string); - add(sw, uuid); - return string; - } - return null; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java index d21f2a502..45580f52c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java @@ -12,7 +12,7 @@ import org.bukkit.entity.Player; import com.google.common.base.Charsets; import com.google.common.collect.BiMap; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class OfflineUUIDWrapper extends UUIDWrapper { From 0d382ac9c3fcde8497a9820a0e46452db2bdf9dc Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:34:19 +1100 Subject: [PATCH 027/124] cleanup --- .../jnbt/ByteArrayTag.java | 10 +- .../intellectualcrafters/jnbt/ByteTag.java | 10 +- .../jnbt/CompoundTag.java | 66 +- .../jnbt/CompoundTagBuilder.java | 34 +- .../intellectualcrafters/jnbt/DoubleTag.java | 10 +- .../com/intellectualcrafters/jnbt/EndTag.java | 6 +- .../intellectualcrafters/jnbt/FloatTag.java | 10 +- .../jnbt/IntArrayTag.java | 10 +- .../com/intellectualcrafters/jnbt/IntTag.java | 10 +- .../intellectualcrafters/jnbt/ListTag.java | 66 +- .../jnbt/ListTagBuilder.java | 19 +- .../intellectualcrafters/jnbt/LongTag.java | 10 +- .../jnbt/NBTConstants.java | 9 +- .../jnbt/NBTInputStream.java | 17 +- .../jnbt/NBTOutputStream.java | 39 +- .../intellectualcrafters/jnbt/NBTUtils.java | 10 +- .../intellectualcrafters/jnbt/ShortTag.java | 11 +- .../intellectualcrafters/jnbt/StringTag.java | 10 +- .../com/intellectualcrafters/jnbt/Tag.java | 11 +- .../jnbt/WorldEditUtils.java | 3 - .../com/intellectualcrafters/json/CDL.java | 27 +- .../com/intellectualcrafters/json/Cookie.java | 9 +- .../intellectualcrafters/json/CookieList.java | 3 +- .../com/intellectualcrafters/json/HTTP.java | 14 +- .../json/HTTPTokener.java | 7 +- .../intellectualcrafters/json/JSONArray.java | 107 +-- .../json/JSONException.java | 6 +- .../com/intellectualcrafters/json/JSONML.java | 44 +- .../intellectualcrafters/json/JSONObject.java | 166 ++-- .../json/JSONStringer.java | 2 +- .../json/JSONTokener.java | 52 +- .../intellectualcrafters/json/JSONWriter.java | 29 +- .../com/intellectualcrafters/json/Kim.java | 29 +- .../intellectualcrafters/json/Property.java | 3 +- .../com/intellectualcrafters/json/XML.java | 62 +- .../intellectualcrafters/json/XMLTokener.java | 48 +- .../intellectualcrafters/plot/BukkitMain.java | 95 +- .../intellectualcrafters/plot/IPlotMain.java | 2 +- .../plot/PlotSquared.java | 238 ++--- .../plot/commands/Auto.java | 79 +- .../plot/commands/Ban.java | 3 +- .../plot/commands/Buy.java | 28 +- .../plot/commands/Claim.java | 19 +- .../plot/commands/Clear.java | 8 +- .../plot/commands/Clipboard.java | 9 +- .../plot/commands/Cluster.java | 166 ++-- .../plot/commands/Command.java | 21 +- .../plot/commands/CommandPermission.java | 6 +- .../plot/commands/Comment.java | 7 +- .../plot/commands/Condense.java | 60 +- .../plot/commands/Copy.java | 4 +- .../plot/commands/CreateRoadSchematic.java | 12 +- .../plot/commands/DEOP.java | 3 +- .../plot/commands/Database.java | 15 +- .../plot/commands/Debug.java | 8 +- .../plot/commands/DebugClaimTest.java | 26 +- .../plot/commands/DebugClear.java | 20 +- .../plot/commands/DebugExec.java | 193 ++-- .../plot/commands/DebugFixFlags.java | 21 +- .../plot/commands/DebugLoadTest.java | 4 +- .../plot/commands/DebugRoadRegen.java | 15 +- .../plot/commands/DebugSaveTest.java | 4 +- .../plot/commands/Delete.java | 4 +- .../plot/commands/Denied.java | 8 +- .../plot/commands/FlagCmd.java | 54 +- .../plot/commands/Help.java | 3 +- .../plot/commands/Helpers.java | 4 +- .../plot/commands/Home.java | 13 +- .../plot/commands/Inbox.java | 66 +- .../plot/commands/Info.java | 32 +- .../plot/commands/Inventory.java | 6 +- .../plot/commands/Kick.java | 7 +- .../plot/commands/MainCommand.java | 42 +- .../plot/commands/Merge.java | 36 +- .../plot/commands/Move.java | 15 +- .../plot/commands/MusicSubcommand.java | 3 +- .../plot/commands/OP.java | 3 +- .../plot/commands/Paste.java | 5 +- .../plot/commands/Purge.java | 71 +- .../plot/commands/Rate.java | 9 +- .../plot/commands/RegenAllRoads.java | 32 +- .../plot/commands/Reload.java | 5 +- .../plot/commands/Schematic.java | 25 +- .../plot/commands/Set.java | 82 +- .../plot/commands/SetOwner.java | 18 +- .../plot/commands/Setup.java | 123 +-- .../plot/commands/SubCommand.java | 24 +- .../plot/commands/Swap.java | 6 +- .../plot/commands/TP.java | 10 +- .../plot/commands/Target.java | 8 +- .../plot/commands/Template.java | 21 +- .../plot/commands/Trim.java | 164 ++-- .../plot/commands/Trusted.java | 8 +- .../plot/commands/Unban.java | 3 +- .../plot/commands/Unclaim.java | 8 +- .../plot/commands/Unlink.java | 27 +- .../plot/commands/Visit.java | 5 +- .../plot/commands/WE_Anywhere.java | 8 +- .../plot/commands/list.java | 30 +- .../plot/commands/plugin.java | 13 +- .../intellectualcrafters/plot/config/C.java | 28 +- .../plot/config/Configuration.java | 51 +- .../plot/config/ConfigurationNode.java | 27 +- .../plot/config/Settings.java | 31 +- .../plot/database/AbstractDB.java | 69 +- .../plot/database/DBFunc.java | 76 +- .../plot/database/Database.java | 16 +- .../plot/database/MySQL.java | 24 +- .../plot/database/PlotMeConverter.java | 54 +- .../plot/database/SQLManager.java | 597 ++++++------ .../plot/database/SQLite.java | 20 +- .../plot/events/PlayerClaimPlotEvent.java | 18 +- .../plot/events/PlayerEnterPlotEvent.java | 12 +- .../plot/events/PlayerLeavePlotEvent.java | 10 +- .../plot/events/PlayerPlotDeniedEvent.java | 16 +- .../plot/events/PlayerPlotHelperEvent.java | 16 +- .../plot/events/PlayerPlotTrustedEvent.java | 16 +- .../events/PlayerTeleportToPlotEvent.java | 17 +- .../plot/events/PlotClearEvent.java | 15 +- .../plot/events/PlotDeleteEvent.java | 15 +- .../plot/events/PlotFlagAddEvent.java | 15 +- .../plot/events/PlotFlagRemoveEvent.java | 15 +- .../plot/events/PlotMergeEvent.java | 17 +- .../plot/events/PlotUnlinkEvent.java | 15 +- .../plot/flag/AbstractFlag.java | 17 +- .../intellectualcrafters/plot/flag/Flag.java | 27 +- .../plot/flag/FlagManager.java | 113 ++- .../plot/flag/FlagValue.java | 321 +++---- .../plot/generator/AugmentedPopulator.java | 267 +++--- .../plot/generator/ClassicPlotManager.java | 118 +-- .../plot/generator/ClassicPlotWorld.java | 6 +- .../plot/generator/GridPlotManager.java | 1 - .../plot/generator/GridPlotWorld.java | 3 +- .../plot/generator/HybridGen.java | 131 +-- .../plot/generator/HybridPlotManager.java | 368 +++---- .../plot/generator/HybridPlotWorld.java | 125 +-- .../plot/generator/HybridPop.java | 117 +-- .../plot/generator/SquarePlotManager.java | 25 +- .../plot/generator/SquarePlotWorld.java | 4 +- .../plot/listeners/ForceFieldListener.java | 8 +- .../plot/listeners/InventoryListener.java | 7 +- .../plot/listeners/PlayerEvents.java | 374 ++++---- .../plot/listeners/PlayerEvents_1_8.java | 8 +- .../plot/listeners/PlotListener.java | 76 +- .../plot/listeners/PlotPlusListener.java | 44 +- .../plot/listeners/WorldEditListener.java | 24 +- .../plot/listeners/WorldGuardListener.java | 60 +- .../plot/object/BlockLoc.java | 10 +- .../plot/object/BlockWrapper.java | 16 +- .../plot/object/ChunkLoc.java | 9 +- .../plot/object/InfoInventory.java | 15 +- .../plot/object/Location.java | 137 ++- .../plot/object/Plot.java | 42 +- .../plot/object/PlotBlock.java | 11 +- .../plot/object/PlotCluster.java | 116 ++- .../plot/object/PlotClusterId.java | 15 +- .../plot/object/PlotComment.java | 3 +- .../plot/object/PlotGenerator.java | 6 +- .../plot/object/PlotId.java | 12 +- .../plot/object/PlotLoc.java | 6 +- .../plot/object/PlotManager.java | 38 +- .../plot/object/PlotSettings.java | 50 +- .../plot/object/PlotWorld.java | 43 +- .../plot/object/RegionWrapper.java | 3 +- .../plot/object/StringWrapper.java | 12 +- .../plot/object/entity/AgeableStats.java | 2 - .../plot/object/entity/EntityWrapper.java | 78 +- .../plot/object/entity/HorseStats.java | 1 - .../plot/object/entity/LivingEntityStats.java | 4 - .../plot/object/entity/TameableStats.java | 2 - .../plot/titles/AbstractTitle.java | 6 +- .../plot/titles/DefaultTitle.java | 25 +- .../plot/titles/DefaultTitleManager.java | 773 ++++++++------- .../plot/titles/HackTitle.java | 27 +- .../plot/titles/HackTitleManager.java | 907 +++++++++--------- .../plot/util/AChunkManager.java | 7 +- .../plot/util/BlockManager.java | 29 +- .../plot/util/ClusterManager.java | 470 +++++---- .../plot/util/ConsoleColors.java | 19 +- .../plot/util/EconHandler.java | 1 - .../plot/util/ExpireManager.java | 109 +-- .../plot/util/LSetCube.java | 23 +- .../intellectualcrafters/plot/util/Lag.java | 14 +- .../plot/util/Logger.java | 16 +- .../plot/util/PlotHelper.java | 334 +++---- .../plot/util/PlotSquaredException.java | 10 +- .../plot/util/RUtils.java | 25 +- .../plot/util/ReflectionUtils.java | 112 ++- .../plot/util/SchematicHandler.java | 122 +-- .../plot/util/StringComparison.java | 24 +- .../plot/util/TaskManager.java | 24 +- .../plot/util/bukkit/BukkitTaskManager.java | 13 +- .../plot/util/bukkit/BukkitUtil.java | 81 +- .../plot/util/bukkit/ChunkManager.java | 488 +++++----- .../plot/util/bukkit/Metrics.java | 66 +- .../plot/util/bukkit/PWE.java | 24 +- .../plot/util/bukkit/PlayerFunctions.java | 73 +- .../plot/util/bukkit/SendChunk.java | 23 +- .../plot/util/bukkit/SetBlockFast.java | 16 +- .../plot/util/bukkit/SetBlockFast_1_8.java | 26 +- .../plot/util/bukkit/SetBlockSlow.java | 11 +- .../plot/util/bukkit/UUIDHandler.java | 91 +- .../plot/uuid/DefaultUUIDWrapper.java | 12 +- .../plot/uuid/OfflineUUIDWrapper.java | 38 +- .../plot/uuid/UUIDWrapper.java | 6 +- .../translation/Translation.java | 6 +- .../translation/TranslationAsset.java | 9 +- .../translation/TranslationFile.java | 8 +- .../translation/TranslationLanguage.java | 15 +- .../translation/TranslationManager.java | 41 +- .../translation/TranslationObject.java | 13 +- .../translation/YamlTranslationFile.java | 19 +- .../translation/bukkit/BukkitTranslation.java | 7 +- .../translation/bukkit/TranslationPlugin.java | 9 +- PlotSquared/src/main/resources/LICENSE | 121 --- 215 files changed, 4930 insertions(+), 6474 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java index 32cdf131b..a73ecb9ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java @@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt; * The {@code TAG_Byte_Array} tag. */ public final class ByteArrayTag extends Tag { - private final byte[] value; - + /** * Creates the tag with an empty name. * @@ -16,7 +15,7 @@ public final class ByteArrayTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -27,12 +26,12 @@ public final class ByteArrayTag extends Tag { super(name); this.value = value; } - + @Override public byte[] getValue() { return this.value; } - + @Override public String toString() { final StringBuilder hex = new StringBuilder(); @@ -50,5 +49,4 @@ public final class ByteArrayTag extends Tag { } return "TAG_Byte_Array" + append + ": " + hex; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java index 8e2ad5638..388ed82e2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java @@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt; * The {@code TAG_Byte} tag. */ public final class ByteTag extends Tag { - private final byte value; - + /** * Creates the tag with an empty name. * @@ -16,7 +15,7 @@ public final class ByteTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -27,12 +26,12 @@ public final class ByteTag extends Tag { super(name); this.value = value; } - + @Override public Byte getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); @@ -42,5 +41,4 @@ public final class ByteTag extends Tag { } return "TAG_Byte" + append + ": " + this.value; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java index a8d0b052b..10c11b32c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java @@ -9,9 +9,8 @@ import java.util.Map; * The {@code TAG_Compound} tag. */ public final class CompoundTag extends Tag { - private final Map value; - + /** * Creates the tag with an empty name. * @@ -21,7 +20,7 @@ public final class CompoundTag extends Tag { super(); this.value = Collections.unmodifiableMap(value); } - + /** * Creates the tag. * @@ -32,7 +31,7 @@ public final class CompoundTag extends Tag { super(name); this.value = Collections.unmodifiableMap(value); } - + /** * Returns whether this compound tag contains the given key. * @@ -43,12 +42,12 @@ public final class CompoundTag extends Tag { public boolean containsKey(final String key) { return this.value.containsKey(key); } - + @Override public Map getValue() { return this.value; } - + /** * Return a new compound tag with the given values. * @@ -59,7 +58,7 @@ public final class CompoundTag extends Tag { public CompoundTag setValue(final Map value) { return new CompoundTag(getName(), value); } - + /** * Create a compound tag builder. * @@ -68,7 +67,7 @@ public final class CompoundTag extends Tag { public CompoundTagBuilder createBuilder() { return new CompoundTagBuilder(new HashMap(this.value)); } - + /** * Get a byte array named with the given key.

If the key does not exist or its value is not a byte array * tag, then an empty byte array will be returned.

@@ -85,7 +84,7 @@ public final class CompoundTag extends Tag { return new byte[0]; } } - + /** * Get a byte named with the given key.

If the key does not exist or its value is not a byte tag, then * {@code 0} will be returned.

@@ -102,7 +101,7 @@ public final class CompoundTag extends Tag { return (byte) 0; } } - + /** * Get a double named with the given key.

If the key does not exist or its value is not a double tag, then * {@code 0} will be returned.

@@ -119,7 +118,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a double named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

@@ -132,27 +131,21 @@ public final class CompoundTag extends Tag { final Tag tag = this.value.get(key); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); - } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); - } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); - } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue(); - } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue(); - } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue(); - } else { return 0; } } - + /** * Get a float named with the given key.

If the key does not exist or its value is not a float tag, then * {@code 0} will be returned.

@@ -169,7 +162,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a {@code int[]} named with the given key.

If the key does not exist or its value is not an int array * tag, then an empty array will be returned.

@@ -186,7 +179,7 @@ public final class CompoundTag extends Tag { return new int[0]; } } - + /** * Get an int named with the given key.

If the key does not exist or its value is not an int tag, then * {@code 0} will be returned.

@@ -203,7 +196,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get an int named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

@@ -216,27 +209,21 @@ public final class CompoundTag extends Tag { final Tag tag = this.value.get(key); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); - } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); - } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); - } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue().intValue(); - } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue().intValue(); - } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue().intValue(); - } else { return 0; } } - + /** * Get a list of tags named with the given key.

If the key does not exist or its value is not a list tag, * then an empty list will be returned.

@@ -253,7 +240,7 @@ public final class CompoundTag extends Tag { return Collections.emptyList(); } } - + /** * Get a {@code TagList} named with the given key.

If the key does not exist or its value is not a list * tag, then an empty tag list will be returned.

@@ -267,10 +254,10 @@ public final class CompoundTag extends Tag { if (tag instanceof ListTag) { return (ListTag) tag; } else { - return new ListTag(key, StringTag.class, Collections.emptyList()); + return new ListTag(key, StringTag.class, Collections. emptyList()); } } - + /** * Get a list of tags named with the given key.

If the key does not exist or its value is not a list tag, * then an empty list will be returned. If the given key references a list but the list of of a different type, then @@ -296,7 +283,7 @@ public final class CompoundTag extends Tag { return Collections.emptyList(); } } - + /** * Get a long named with the given key.

If the key does not exist or its value is not a long tag, then * {@code 0} will be returned.

@@ -313,7 +300,7 @@ public final class CompoundTag extends Tag { return 0L; } } - + /** * Get a long named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

@@ -326,27 +313,21 @@ public final class CompoundTag extends Tag { final Tag tag = this.value.get(key); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); - } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); - } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); - } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue(); - } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue().longValue(); - } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue().longValue(); - } else { return 0L; } } - + /** * Get a short named with the given key.

If the key does not exist or its value is not a short tag, then * {@code 0} will be returned.

@@ -363,7 +344,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a string named with the given key.

If the key does not exist or its value is not a string tag, then * {@code ""} will be returned.

@@ -380,7 +361,7 @@ public final class CompoundTag extends Tag { return ""; } } - + @Override public String toString() { final String name = getName(); @@ -396,5 +377,4 @@ public final class CompoundTag extends Tag { bldr.append("}"); return bldr.toString(); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java index 365b7322a..86e04e2fd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java @@ -9,16 +9,15 @@ import java.util.Map; * Helps create compound tags. */ public class CompoundTagBuilder { - private final Map entries; - + /** * Create a new instance. */ CompoundTagBuilder() { this.entries = new HashMap(); } - + /** * Create a new instance and use the given map (which will be modified). * @@ -28,7 +27,7 @@ public class CompoundTagBuilder { checkNotNull(value); this.entries = value; } - + /** * Create a new builder instance. * @@ -37,7 +36,7 @@ public class CompoundTagBuilder { public static CompoundTagBuilder create() { return new CompoundTagBuilder(); } - + /** * Put the given key and tag into the compound tag. * @@ -52,7 +51,7 @@ public class CompoundTagBuilder { this.entries.put(key, value); return this; } - + /** * Put the given key and value into the compound tag as a {@code ByteArrayTag}. * @@ -64,7 +63,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putByteArray(final String key, final byte[] value) { return put(key, new ByteArrayTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code ByteTag}. * @@ -76,7 +75,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putByte(final String key, final byte value) { return put(key, new ByteTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code DoubleTag}. * @@ -88,7 +87,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putDouble(final String key, final double value) { return put(key, new DoubleTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code FloatTag}. * @@ -100,7 +99,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putFloat(final String key, final float value) { return put(key, new FloatTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code IntArrayTag}. * @@ -112,7 +111,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putIntArray(final String key, final int[] value) { return put(key, new IntArrayTag(key, value)); } - + /** * Put the given key and value into the compound tag as an {@code IntTag}. * @@ -124,7 +123,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putInt(final String key, final int value) { return put(key, new IntTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code LongTag}. * @@ -136,7 +135,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putLong(final String key, final long value) { return put(key, new LongTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code ShortTag}. * @@ -148,7 +147,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putShort(final String key, final short value) { return put(key, new ShortTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code StringTag}. * @@ -160,7 +159,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putString(final String key, final String value) { return put(key, new StringTag(key, value)); } - + /** * Put all the entries from the given map into this map. * @@ -175,7 +174,7 @@ public class CompoundTagBuilder { } return this; } - + /** * Build an unnamed compound tag with this builder's entries. * @@ -184,7 +183,7 @@ public class CompoundTagBuilder { public CompoundTag build() { return new CompoundTag(new HashMap(this.entries)); } - + /** * Build a new compound tag with this builder's entries. * @@ -195,5 +194,4 @@ public class CompoundTagBuilder { public CompoundTag build(final String name) { return new CompoundTag(name, new HashMap(this.entries)); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java index 2a4c52448..d85fd6135 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java @@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt; * The {@code TAG_Double} tag. */ public final class DoubleTag extends Tag { - private final double value; - + /** * Creates the tag with an empty name. * @@ -16,7 +15,7 @@ public final class DoubleTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -27,12 +26,12 @@ public final class DoubleTag extends Tag { super(name); this.value = value; } - + @Override public Double getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); @@ -42,5 +41,4 @@ public final class DoubleTag extends Tag { } return "TAG_Double" + append + ": " + this.value; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java index 408206b1b..981925184 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java @@ -4,22 +4,20 @@ package com.intellectualcrafters.jnbt; * The {@code TAG_End} tag. */ public final class EndTag extends Tag { - /** * Creates the tag. */ public EndTag() { super(); } - + @Override public Object getValue() { return null; } - + @Override public String toString() { return "TAG_End"; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java index a9701340a..2dea1766f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java @@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt; * The {@code TAG_Float} tag. */ public final class FloatTag extends Tag { - private final float value; - + /** * Creates the tag with an empty name. * @@ -16,7 +15,7 @@ public final class FloatTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -27,12 +26,12 @@ public final class FloatTag extends Tag { super(name); this.value = value; } - + @Override public Float getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); @@ -42,5 +41,4 @@ public final class FloatTag extends Tag { } return "TAG_Float" + append + ": " + this.value; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java index 9439f051b..c4349f89e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java @@ -6,9 +6,8 @@ import static com.google.common.base.Preconditions.checkNotNull; * The {@code TAG_Int_Array} tag. */ public final class IntArrayTag extends Tag { - private final int[] value; - + /** * Creates the tag with an empty name. * @@ -19,7 +18,7 @@ public final class IntArrayTag extends Tag { checkNotNull(value); this.value = value; } - + /** * Creates the tag. * @@ -31,12 +30,12 @@ public final class IntArrayTag extends Tag { checkNotNull(value); this.value = value; } - + @Override public int[] getValue() { return this.value; } - + @Override public String toString() { final StringBuilder hex = new StringBuilder(); @@ -54,5 +53,4 @@ public final class IntArrayTag extends Tag { } return "TAG_Int_Array" + append + ": " + hex; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java index 7e5328f37..bee6eb7d7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java @@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt; * The {@code TAG_Int} tag. */ public final class IntTag extends Tag { - private final int value; - + /** * Creates the tag with an empty name. * @@ -16,7 +15,7 @@ public final class IntTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -27,12 +26,12 @@ public final class IntTag extends Tag { super(name); this.value = value; } - + @Override public Integer getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); @@ -42,5 +41,4 @@ public final class IntTag extends Tag { } return "TAG_Int" + append + ": " + this.value; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java index 434f1a95a..415721c30 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java @@ -12,10 +12,9 @@ import javax.annotation.Nullable; * The {@code TAG_List} tag. */ public final class ListTag extends Tag { - private final Class type; private final List value; - + /** * Creates the tag with an empty name. * @@ -28,7 +27,7 @@ public final class ListTag extends Tag { this.type = type; this.value = Collections.unmodifiableList(value); } - + /** * Creates the tag. * @@ -42,7 +41,7 @@ public final class ListTag extends Tag { this.type = type; this.value = Collections.unmodifiableList(value); } - + /** * Gets the type of item in this list. * @@ -51,12 +50,12 @@ public final class ListTag extends Tag { public Class getType() { return this.type; } - + @Override public List getValue() { return this.value; } - + /** * Create a new list tag with this tag's name and type. * @@ -67,7 +66,7 @@ public final class ListTag extends Tag { public ListTag setValue(final List list) { return new ListTag(getName(), getType(), list); } - + /** * Get the tag if it exists at the given index. * @@ -83,7 +82,7 @@ public final class ListTag extends Tag { return null; } } - + /** * Get a byte array named with the given index.

If the index does not exist or its value is not a byte * array tag, then an empty byte array will be returned.

@@ -100,7 +99,7 @@ public final class ListTag extends Tag { return new byte[0]; } } - + /** * Get a byte named with the given index.

If the index does not exist or its value is not a byte tag, then * {@code 0} will be returned.

@@ -117,7 +116,7 @@ public final class ListTag extends Tag { return (byte) 0; } } - + /** * Get a double named with the given index.

If the index does not exist or its value is not a double tag, * then {@code 0} will be returned.

@@ -134,7 +133,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a double named with the given index, even if it's another type of number.

If the index does not * exist or its value is not a number, then {@code 0} will be returned.

@@ -147,27 +146,21 @@ public final class ListTag extends Tag { final Tag tag = getIfExists(index); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); - } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); - } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); - } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue(); - } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue(); - } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue(); - } else { return 0; } } - + /** * Get a float named with the given index.

If the index does not exist or its value is not a float tag, * then {@code 0} will be returned.

@@ -184,7 +177,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a {@code int[]} named with the given index.

If the index does not exist or its value is not an int * array tag, then an empty array will be returned.

@@ -201,7 +194,7 @@ public final class ListTag extends Tag { return new int[0]; } } - + /** * Get an int named with the given index.

If the index does not exist or its value is not an int tag, then * {@code 0} will be returned.

@@ -218,7 +211,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get an int named with the given index, even if it's another type of number.

If the index does not exist * or its value is not a number, then {@code 0} will be returned.

@@ -231,27 +224,21 @@ public final class ListTag extends Tag { final Tag tag = getIfExists(index); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); - } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); - } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); - } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue().intValue(); - } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue().intValue(); - } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue().intValue(); - } else { return 0; } } - + /** * Get a list of tags named with the given index.

If the index does not exist or its value is not a list * tag, then an empty list will be returned.

@@ -268,7 +255,7 @@ public final class ListTag extends Tag { return Collections.emptyList(); } } - + /** * Get a {@code TagList} named with the given index.

If the index does not exist or its value is not a list * tag, then an empty tag list will be returned.

@@ -282,10 +269,10 @@ public final class ListTag extends Tag { if (tag instanceof ListTag) { return (ListTag) tag; } else { - return new ListTag(StringTag.class, Collections.emptyList()); + return new ListTag(StringTag.class, Collections. emptyList()); } } - + /** * Get a list of tags named with the given index.

If the index does not exist or its value is not a list * tag, then an empty list will be returned. If the given index references a list but the list of of a different @@ -311,7 +298,7 @@ public final class ListTag extends Tag { return Collections.emptyList(); } } - + /** * Get a long named with the given index.

If the index does not exist or its value is not a long tag, then * {@code 0} will be returned.

@@ -328,7 +315,7 @@ public final class ListTag extends Tag { return 0L; } } - + /** * Get a long named with the given index, even if it's another type of number.

If the index does not exist * or its value is not a number, then {@code 0} will be returned.

@@ -341,27 +328,21 @@ public final class ListTag extends Tag { final Tag tag = getIfExists(index); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); - } else if (tag instanceof ShortTag) { return ((ShortTag) tag).getValue(); - } else if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); - } else if (tag instanceof LongTag) { return ((LongTag) tag).getValue(); - } else if (tag instanceof FloatTag) { return ((FloatTag) tag).getValue().longValue(); - } else if (tag instanceof DoubleTag) { return ((DoubleTag) tag).getValue().longValue(); - } else { return 0; } } - + /** * Get a short named with the given index.

If the index does not exist or its value is not a short tag, * then {@code 0} will be returned.

@@ -378,7 +359,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a string named with the given index.

If the index does not exist or its value is not a string tag, * then {@code ""} will be returned.

@@ -395,7 +376,7 @@ public final class ListTag extends Tag { return ""; } } - + @Override public String toString() { final String name = getName(); @@ -411,5 +392,4 @@ public final class ListTag extends Tag { bldr.append("}"); return bldr.toString(); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java index 42992d2e6..a050599c5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java @@ -11,10 +11,9 @@ import java.util.List; * Helps create list tags. */ public class ListTagBuilder { - private final Class type; private final List entries; - + /** * Create a new instance. * @@ -25,7 +24,7 @@ public class ListTagBuilder { this.type = type; this.entries = new ArrayList(); } - + /** * Create a new builder instance. * @@ -34,7 +33,7 @@ public class ListTagBuilder { public static ListTagBuilder create(final Class type) { return new ListTagBuilder(type); } - + /** * Create a new builder instance. * @@ -43,23 +42,20 @@ public class ListTagBuilder { @SafeVarargs public static ListTagBuilder createWith(final T... entries) { checkNotNull(entries); - if (entries.length == 0) { throw new IllegalArgumentException("This method needs an array of at least one entry"); } - final Class type = entries[0].getClass(); for (int i = 1; i < entries.length; i++) { if (!type.isInstance(entries[i])) { throw new IllegalArgumentException("An array of different tag types was provided"); } } - final ListTagBuilder builder = new ListTagBuilder(type); builder.addAll(Arrays.asList(entries)); return builder; } - + /** * Add the given tag. * @@ -75,7 +71,7 @@ public class ListTagBuilder { this.entries.add(value); return this; } - + /** * Add all the tags in the given list. * @@ -90,7 +86,7 @@ public class ListTagBuilder { } return this; } - + /** * Build an unnamed list tag with this builder's entries. * @@ -99,7 +95,7 @@ public class ListTagBuilder { public ListTag build() { return new ListTag(this.type, new ArrayList(this.entries)); } - + /** * Build a new list tag with this builder's entries. * @@ -110,5 +106,4 @@ public class ListTagBuilder { public ListTag build(final String name) { return new ListTag(name, this.type, new ArrayList(this.entries)); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java index a8d22218c..974a4d199 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java @@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt; * The {@code TAG_Long} tag. */ public final class LongTag extends Tag { - private final long value; - + /** * Creates the tag with an empty name. * @@ -16,7 +15,7 @@ public final class LongTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -27,12 +26,12 @@ public final class LongTag extends Tag { super(name); this.value = value; } - + @Override public Long getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); @@ -42,5 +41,4 @@ public final class LongTag extends Tag { } return "TAG_Long" + append + ": " + this.value; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java index 65a13f4ec..604859fff 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.jnbt; import java.nio.charset.Charset; @@ -27,18 +26,15 @@ import java.nio.charset.Charset; * A class which holds constant values. */ public final class NBTConstants { - public static final Charset CHARSET = Charset.forName("UTF-8"); - public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11; - + /** * Default private constructor. */ private NBTConstants() { - } - + /** * Convert a type ID to its corresponding {@link Tag} class. * @@ -78,5 +74,4 @@ public final class NBTConstants { throw new IllegalArgumentException("Unknown tag type ID of " + id); } } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java index 7aa319759..2c9a6610d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java @@ -15,9 +15,8 @@ import java.util.Map; * may be found at http://www.minecraft.net/docs/NBT.txt.

*/ public final class NBTInputStream implements Closeable { - private final DataInputStream is; - + /** * Creates a new {@code NBTInputStream}, which will source its data from the specified input stream. * @@ -28,7 +27,7 @@ public final class NBTInputStream implements Closeable { public NBTInputStream(final InputStream is) throws IOException { this.is = new DataInputStream(is); } - + /** * Reads an NBT tag from the stream. * @@ -39,7 +38,7 @@ public final class NBTInputStream implements Closeable { public Tag readTag() throws IOException { return readTag(0); } - + /** * Reads an NBT from the stream. * @@ -51,7 +50,6 @@ public final class NBTInputStream implements Closeable { */ private Tag readTag(final int depth) throws IOException { final int type = this.is.readByte() & 0xFF; - String name; if (type != NBTConstants.TYPE_END) { final int nameLength = this.is.readShort() & 0xFFFF; @@ -61,10 +59,9 @@ public final class NBTInputStream implements Closeable { } else { name = ""; } - return readTagPayload(type, name, depth); } - + /** * Reads the payload of a tag, given the name and type. * @@ -109,7 +106,6 @@ public final class NBTInputStream implements Closeable { case NBTConstants.TYPE_LIST: final int childType = this.is.readByte(); length = this.is.readInt(); - final List tagList = new ArrayList(); for (int i = 0; i < length; ++i) { final Tag tag = readTagPayload(childType, "", depth + 1); @@ -118,7 +114,6 @@ public final class NBTInputStream implements Closeable { } tagList.add(tag); } - return new ListTag(name, NBTUtils.getTypeClass(childType), tagList); case NBTConstants.TYPE_COMPOUND: final Map tagMap = new HashMap(); @@ -130,7 +125,6 @@ public final class NBTInputStream implements Closeable { tagMap.put(tag.getName(), tag); } } - return new CompoundTag(name, tagMap); case NBTConstants.TYPE_INT_ARRAY: length = this.is.readInt(); @@ -143,10 +137,9 @@ public final class NBTInputStream implements Closeable { throw new IOException("Invalid tag type: " + type + "."); } } - + @Override public void close() throws IOException { this.is.close(); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java index 65e3426e5..a4deec5a3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.jnbt; import java.io.Closeable; @@ -36,12 +35,11 @@ import java.util.List; * @author Graham Edgecombe */ public final class NBTOutputStream implements Closeable { - /** * The output stream. */ private final DataOutputStream os; - + /** * Creates a new NBTOutputStream, which will write data to the specified underlying output stream. * @@ -52,7 +50,7 @@ public final class NBTOutputStream implements Closeable { public NBTOutputStream(final OutputStream os) throws IOException { this.os = new DataOutputStream(os); } - + /** * Writes a tag. * @@ -64,18 +62,15 @@ public final class NBTOutputStream implements Closeable { final int type = NBTUtils.getTypeCode(tag.getClass()); final String name = tag.getName(); final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET); - this.os.writeByte(type); this.os.writeShort(nameBytes.length); this.os.write(nameBytes); - if (type == NBTConstants.TYPE_END) { throw new IOException("Named TAG_End not permitted."); } - writeTagPayload(tag); } - + /** * Writes tag payload. * @@ -126,7 +121,7 @@ public final class NBTOutputStream implements Closeable { throw new IOException("Invalid tag type: " + type + "."); } } - + /** * Writes a TAG_Byte tag. * @@ -137,7 +132,7 @@ public final class NBTOutputStream implements Closeable { private void writeByteTagPayload(final ByteTag tag) throws IOException { this.os.writeByte(tag.getValue()); } - + /** * Writes a TAG_Byte_Array tag. * @@ -150,7 +145,7 @@ public final class NBTOutputStream implements Closeable { this.os.writeInt(bytes.length); this.os.write(bytes); } - + /** * Writes a TAG_Compound tag. * @@ -164,7 +159,7 @@ public final class NBTOutputStream implements Closeable { } this.os.writeByte((byte) 0); // end tag - better way? } - + /** * Writes a TAG_List tag. * @@ -176,14 +171,13 @@ public final class NBTOutputStream implements Closeable { final Class clazz = tag.getType(); final List tags = tag.getValue(); final int size = tags.size(); - this.os.writeByte(NBTUtils.getTypeCode(clazz)); this.os.writeInt(size); for (final Tag tag1 : tags) { writeTagPayload(tag1); } } - + /** * Writes a TAG_String tag. * @@ -196,7 +190,7 @@ public final class NBTOutputStream implements Closeable { this.os.writeShort(bytes.length); this.os.write(bytes); } - + /** * Writes a TAG_Double tag. * @@ -207,7 +201,7 @@ public final class NBTOutputStream implements Closeable { private void writeDoubleTagPayload(final DoubleTag tag) throws IOException { this.os.writeDouble(tag.getValue()); } - + /** * Writes a TAG_Float tag. * @@ -218,7 +212,7 @@ public final class NBTOutputStream implements Closeable { private void writeFloatTagPayload(final FloatTag tag) throws IOException { this.os.writeFloat(tag.getValue()); } - + /** * Writes a TAG_Long tag. * @@ -229,7 +223,7 @@ public final class NBTOutputStream implements Closeable { private void writeLongTagPayload(final LongTag tag) throws IOException { this.os.writeLong(tag.getValue()); } - + /** * Writes a TAG_Int tag. * @@ -240,7 +234,7 @@ public final class NBTOutputStream implements Closeable { private void writeIntTagPayload(final IntTag tag) throws IOException { this.os.writeInt(tag.getValue()); } - + /** * Writes a TAG_Short tag. * @@ -251,7 +245,7 @@ public final class NBTOutputStream implements Closeable { private void writeShortTagPayload(final ShortTag tag) throws IOException { this.os.writeShort(tag.getValue()); } - + /** * Writes a TAG_Empty tag. * @@ -262,7 +256,7 @@ public final class NBTOutputStream implements Closeable { private void writeEndTagPayload(final EndTag tag) { /* empty */ } - + private void writeIntArrayTagPayload(final IntArrayTag tag) throws IOException { final int[] data = tag.getValue(); this.os.writeInt(data.length); @@ -270,10 +264,9 @@ public final class NBTOutputStream implements Closeable { this.os.writeInt(element); } } - + @Override public void close() throws IOException { this.os.close(); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java index fb7b85698..741fdf2ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java @@ -6,13 +6,12 @@ import java.util.Map; * A class which contains NBT-related utility methods. */ public final class NBTUtils { - /** * Default private constructor. */ private NBTUtils() { } - + /** * Gets the type name of a tag. * @@ -49,7 +48,7 @@ public final class NBTUtils { throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ")."); } } - + /** * Gets the type code of a tag class. * @@ -88,7 +87,7 @@ public final class NBTUtils { throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ")."); } } - + /** * Gets the class of a type of tag. * @@ -128,7 +127,7 @@ public final class NBTUtils { throw new IllegalArgumentException("Invalid tag type : " + type + "."); } } - + /** * Get child tag of a NBT structure. * @@ -148,5 +147,4 @@ public final class NBTUtils { } return expected.cast(tag); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java index b4fb7e2a8..df4ceb57e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java @@ -18,16 +18,14 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.jnbt; /** * The {@code TAG_Short} tag. */ public final class ShortTag extends Tag { - private final short value; - + /** * Creates the tag with an empty name. * @@ -37,7 +35,7 @@ public final class ShortTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -48,12 +46,12 @@ public final class ShortTag extends Tag { super(name); this.value = value; } - + @Override public Short getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); @@ -63,5 +61,4 @@ public final class ShortTag extends Tag { } return "TAG_Short" + append + ": " + this.value; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java index 708331cec..8c0756e63 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java @@ -6,9 +6,8 @@ import static com.google.common.base.Preconditions.checkNotNull; * The {@code TAG_String} tag. */ public final class StringTag extends Tag { - private final String value; - + /** * Creates the tag with an empty name. * @@ -19,7 +18,7 @@ public final class StringTag extends Tag { checkNotNull(value); this.value = value; } - + /** * Creates the tag. * @@ -31,12 +30,12 @@ public final class StringTag extends Tag { checkNotNull(value); this.value = value; } - + @Override public String getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); @@ -46,5 +45,4 @@ public final class StringTag extends Tag { } return "TAG_String" + append + ": " + this.value; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java index aa060c18e..395333e13 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java @@ -18,23 +18,21 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.jnbt; /** * Represents a NBT tag. */ public abstract class Tag { - private final String name; - + /** * Create a new tag with an empty name. */ Tag() { this(""); } - + /** * Creates the tag with the specified name. * @@ -46,7 +44,7 @@ public abstract class Tag { } this.name = name; } - + /** * Gets the name of this tag. * @@ -55,12 +53,11 @@ public abstract class Tag { public final String getName() { return this.name; } - + /** * Gets the value of this tag. * * @return the value */ public abstract Object getValue(); - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java index 30123a5ac..3f86f897a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java @@ -4,11 +4,8 @@ import org.bukkit.World; public class WorldEditUtils { public static void setNBT(final World world, final short id, final byte data, final int x, final int y, final int z, final com.intellectualcrafters.jnbt.CompoundTag tag) { - // final LocalWorld bukkitWorld = BukkitUtil.getLocalWorld(world); - // I need to somehow convert our CompoundTag to WorldEdit's - // final BaseBlock block = new BaseBlock(5, 5, (CompoundTag) tag); // final Vector vector = new Vector(x, y, z); // try { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java index 7e2f3f847..9514eea56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java @@ -18,7 +18,6 @@ package com.intellectualcrafters.json; * @version 2014-05-03 */ public class CDL { - /** * Get the next value. The value can be wrapped in quotes. The value can be empty. * @@ -42,7 +41,7 @@ public class CDL { case '\'': q = c; sb = new StringBuffer(); - for (; ; ) { + for (;;) { c = x.next(); if (c == q) { break; @@ -61,7 +60,7 @@ public class CDL { return x.nextTo(','); } } - + /** * Produce a JSONArray of strings from a row of comma delimited values. * @@ -73,14 +72,14 @@ public class CDL { */ public static JSONArray rowToJSONArray(final JSONTokener x) throws JSONException { final JSONArray ja = new JSONArray(); - for (; ; ) { + for (;;) { final String value = getValue(x); char c = x.next(); if ((value == null) || ((ja.length() == 0) && (value.length() == 0) && (c != ','))) { return null; } ja.put(value); - for (; ; ) { + for (;;) { if (c == ',') { break; } @@ -94,7 +93,7 @@ public class CDL { } } } - + /** * Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings to provides the * names of the elements. @@ -111,7 +110,7 @@ public class CDL { final JSONArray ja = rowToJSONArray(x); return ja != null ? ja.toJSONObject(names) : null; } - + /** * Produce a comma delimited text row from a JSONArray. Values containing the comma character will be quoted. * Troublesome characters may be removed. @@ -147,7 +146,7 @@ public class CDL { sb.append('\n'); return sb.toString(); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names. * @@ -160,7 +159,7 @@ public class CDL { public static JSONArray toJSONArray(final String string) throws JSONException { return toJSONArray(new JSONTokener(string)); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names. * @@ -173,7 +172,7 @@ public class CDL { public static JSONArray toJSONArray(final JSONTokener x) throws JSONException { return toJSONArray(rowToJSONArray(x), x); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of * element names. @@ -188,7 +187,7 @@ public class CDL { public static JSONArray toJSONArray(final JSONArray names, final String string) throws JSONException { return toJSONArray(names, new JSONTokener(string)); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of * element names. @@ -205,7 +204,7 @@ public class CDL { return null; } final JSONArray ja = new JSONArray(); - for (; ; ) { + for (;;) { final JSONObject jo = rowToJSONObject(names, x); if (jo == null) { break; @@ -217,7 +216,7 @@ public class CDL { } return ja; } - + /** * Produce a comma delimited text from a JSONArray of JSONObjects. The first row will be a list of names obtained by * inspecting the first JSONObject. @@ -238,7 +237,7 @@ public class CDL { } return null; } - + /** * Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names. The list of names * is not included in the output. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java index b5efcbd2d..ee4def328 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.json; /** @@ -29,7 +28,6 @@ package com.intellectualcrafters.json; * @version 2014-05-03 */ public class Cookie { - /** * Produce a copy of a string in which the characters '+', '%', '=', ';' and control characters are replaced with * "%hh". This is a gentle form of URL encoding, attempting to cause as little distortion to the string as possible. @@ -58,7 +56,7 @@ public class Cookie { } return sb.toString(); } - + /** * Convert a cookie specification string into a JSONObject. The string will contain a name value pair separated by * '='. The name and the value will be unescaped, possibly converting '+' and '%' sequences. The cookie properties @@ -98,7 +96,7 @@ public class Cookie { } return jo; } - + /** * Convert a JSONObject into a cookie specification string. The JSONObject must contain "name" and "value" members. * If the JSONObject contains "expires", "domain", "path", or "secure" members, they will be appended to the cookie @@ -112,7 +110,6 @@ public class Cookie { */ public static String toString(final JSONObject jo) throws JSONException { final StringBuilder sb = new StringBuilder(); - sb.append(escape(jo.getString("name"))); sb.append("="); sb.append(escape(jo.getString("value"))); @@ -133,7 +130,7 @@ public class Cookie { } return sb.toString(); } - + /** * Convert %hh sequences to single characters, and convert plus to space. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java index 99437329f..01eba0b85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java @@ -9,7 +9,6 @@ import java.util.Iterator; * @version 2014-05-03 */ public class CookieList { - /** * Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The names are separated * from the values by '='. The pairs are separated by ';'. The names and the values will be unescaped, possibly @@ -35,7 +34,7 @@ public class CookieList { } return jo; } - + /** * Convert a JSONObject into a cookie list. A cookie list is a sequence of name/value pairs. The names are separated * from the values by '='. The pairs are separated by ';'. The characters '%', '+', '=', and ';' in the names and diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java index 786fbf38e..8bc44d340 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.json; import java.util.Iterator; @@ -30,12 +29,11 @@ import java.util.Iterator; * @version 2014-05-03 */ public class HTTP { - /** * Carriage return/line feed. */ public static final String CRLF = "\r\n"; - + /** * Convert an HTTP header string into a JSONObject. It can be a request header or a response header. A request * header will contain @@ -93,28 +91,20 @@ public class HTTP { final JSONObject jo = new JSONObject(); final HTTPTokener x = new HTTPTokener(string); String token; - token = x.nextToken(); if (token.toUpperCase().startsWith("HTTP")) { - // Response - jo.put("HTTP-Version", token); jo.put("Status-Code", x.nextToken()); jo.put("Reason-Phrase", x.nextTo('\0')); x.next(); - } else { - // Request - jo.put("Method", token); jo.put("Request-URI", x.nextToken()); jo.put("HTTP-Version", x.nextToken()); } - // Fields - while (x.more()) { final String name = x.nextTo(':'); x.next(':'); @@ -123,7 +113,7 @@ public class HTTP { } return jo; } - + /** * Convert a JSONObject into an HTTP header. A request header must contain *

diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java index 09cc1af60..5a3fb1e56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java @@ -7,7 +7,6 @@ package com.intellectualcrafters.json; * @version 2014-05-03 */ public class HTTPTokener extends JSONTokener { - /** * Construct an HTTPTokener from a string. * @@ -16,7 +15,7 @@ public class HTTPTokener extends JSONTokener { public HTTPTokener(final String string) { super(string); } - + /** * Get the next token or string. This is used in parsing HTTP headers. * @@ -33,7 +32,7 @@ public class HTTPTokener extends JSONTokener { } while (Character.isWhitespace(c)); if ((c == '"') || (c == '\'')) { q = c; - for (; ; ) { + for (;;) { c = next(); if (c < ' ') { throw syntaxError("Unterminated string."); @@ -44,7 +43,7 @@ public class HTTPTokener extends JSONTokener { sb.append(c); } } - for (; ; ) { + for (;;) { if ((c == 0) || Character.isWhitespace(c)) { return sb.toString(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java index d82e9c6a8..4725eec68 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.json; import java.io.IOException; @@ -58,19 +57,18 @@ import java.util.Map; * @version 2014-05-03 */ public class JSONArray { - /** * The arrayList where the JSONArray's properties are kept. */ private final ArrayList myArrayList; - + /** * Construct an empty JSONArray. */ public JSONArray() { this.myArrayList = new ArrayList(); } - + /** * Construct a JSONArray from a JSONTokener. * @@ -85,7 +83,7 @@ public class JSONArray { } if (x.nextClean() != ']') { x.back(); - for (; ; ) { + for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); @@ -108,7 +106,7 @@ public class JSONArray { } } } - + /** * Construct a JSONArray from a source JSON text. * @@ -120,7 +118,7 @@ public class JSONArray { public JSONArray(final String source) throws JSONException { this(new JSONTokener(source)); } - + /** * Construct a JSONArray from a Collection. * @@ -134,7 +132,7 @@ public class JSONArray { } } } - + /** * Construct a JSONArray from an array * @@ -151,7 +149,7 @@ public class JSONArray { throw new JSONException("JSONArray initial value should be a string or collection or array."); } } - + /** * Get the object value associated with an index. * @@ -168,7 +166,7 @@ public class JSONArray { } return object; } - + /** * Get the boolean value associated with an index. The string values "true" and "false" are converted to boolean. * @@ -187,7 +185,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] is not a boolean."); } - + /** * Get the double value associated with an index. * @@ -205,7 +203,7 @@ public class JSONArray { throw new JSONException("JSONArray[" + index + "] is not a number."); } } - + /** * Get the int value associated with an index. * @@ -223,7 +221,7 @@ public class JSONArray { throw new JSONException("JSONArray[" + index + "] is not a number."); } } - + /** * Get the JSONArray associated with an index. * @@ -240,7 +238,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] is not a JSONArray."); } - + /** * Get the JSONObject associated with an index. * @@ -257,7 +255,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] is not a JSONObject."); } - + /** * Get the long value associated with an index. * @@ -275,7 +273,7 @@ public class JSONArray { throw new JSONException("JSONArray[" + index + "] is not a number."); } } - + /** * Get the string associated with an index. * @@ -292,7 +290,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] not a string."); } - + /** * Determine if the value is null. * @@ -303,7 +301,7 @@ public class JSONArray { public boolean isNull(final int index) { return JSONObject.NULL.equals(this.opt(index)); } - + /** * Make a string from the contents of this JSONArray. The separator string is inserted between each * element. Warning: This method assumes that the data structure is acyclical. @@ -317,7 +315,6 @@ public class JSONArray { public String join(final String separator) throws JSONException { final int len = this.length(); final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < len; i += 1) { if (i > 0) { sb.append(separator); @@ -326,7 +323,7 @@ public class JSONArray { } return sb.toString(); } - + /** * Get the number of elements in the JSONArray, included nulls. * @@ -335,7 +332,7 @@ public class JSONArray { public int length() { return this.myArrayList.size(); } - + /** * Get the optional object value associated with an index. * @@ -346,7 +343,7 @@ public class JSONArray { public Object opt(final int index) { return ((index < 0) || (index >= this.length())) ? null : this.myArrayList.get(index); } - + /** * Get the optional boolean value associated with an index. It returns false if there is no value at that index, or * if the value is not Boolean.TRUE or the String "true". @@ -358,7 +355,7 @@ public class JSONArray { public boolean optBoolean(final int index) { return this.optBoolean(index, false); } - + /** * Get the optional boolean value associated with an index. It returns the defaultValue if there is no value at that * index or if it is not a Boolean or the String "true" or "false" (case insensitive). @@ -375,7 +372,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional double value associated with an index. NaN is returned if there is no value for the index, or if * the value is not a number and cannot be converted to a number. @@ -387,7 +384,7 @@ public class JSONArray { public double optDouble(final int index) { return this.optDouble(index, Double.NaN); } - + /** * Get the optional double value associated with an index. The defaultValue is returned if there is no value for the * index, or if the value is not a number and cannot be converted to a number. @@ -404,7 +401,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional int value associated with an index. Zero is returned if there is no value for the index, or if * the value is not a number and cannot be converted to a number. @@ -416,7 +413,7 @@ public class JSONArray { public int optInt(final int index) { return this.optInt(index, 0); } - + /** * Get the optional int value associated with an index. The defaultValue is returned if there is no value for the * index, or if the value is not a number and cannot be converted to a number. @@ -433,7 +430,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional JSONArray associated with an index. * @@ -445,7 +442,7 @@ public class JSONArray { final Object o = this.opt(index); return o instanceof JSONArray ? (JSONArray) o : null; } - + /** * Get the optional JSONObject associated with an index. Null is returned if the key is not found, or null if the * index has no value, or if the value is not a JSONObject. @@ -458,7 +455,7 @@ public class JSONArray { final Object o = this.opt(index); return o instanceof JSONObject ? (JSONObject) o : null; } - + /** * Get the optional long value associated with an index. Zero is returned if there is no value for the index, or if * the value is not a number and cannot be converted to a number. @@ -470,7 +467,7 @@ public class JSONArray { public long optLong(final int index) { return this.optLong(index, 0); } - + /** * Get the optional long value associated with an index. The defaultValue is returned if there is no value for the * index, or if the value is not a number and cannot be converted to a number. @@ -487,7 +484,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional string value associated with an index. It returns an empty string if there is no value at that * index. If the value is not a string and is not null, then it is coverted to a string. @@ -499,7 +496,7 @@ public class JSONArray { public String optString(final int index) { return this.optString(index, ""); } - + /** * Get the optional string associated with an index. The defaultValue is returned if the key is not found. * @@ -512,7 +509,7 @@ public class JSONArray { final Object object = this.opt(index); return JSONObject.NULL.equals(object) ? defaultValue : object.toString(); } - + /** * Append a boolean value. This increases the array's length by one. * @@ -524,7 +521,7 @@ public class JSONArray { this.put(value ? Boolean.TRUE : Boolean.FALSE); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection. * @@ -536,7 +533,7 @@ public class JSONArray { this.put(new JSONArray(value)); return this; } - + /** * Append a double value. This increases the array's length by one. * @@ -552,7 +549,7 @@ public class JSONArray { this.put(d); return this; } - + /** * Append an int value. This increases the array's length by one. * @@ -564,7 +561,7 @@ public class JSONArray { this.put(new Integer(value)); return this; } - + /** * Append an long value. This increases the array's length by one. * @@ -576,7 +573,7 @@ public class JSONArray { this.put(new Long(value)); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONObject which is produced from a Map. * @@ -588,7 +585,7 @@ public class JSONArray { this.put(new JSONObject(value)); return this; } - + /** * Append an object value. This increases the array's length by one. * @@ -601,7 +598,7 @@ public class JSONArray { this.myArrayList.add(value); return this; } - + /** * Put or replace a boolean value in the JSONArray. If the index is greater than the length of the JSONArray, then * null elements will be added as necessary to pad it out. @@ -617,7 +614,7 @@ public class JSONArray { this.put(index, value ? Boolean.TRUE : Boolean.FALSE); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection. * @@ -632,7 +629,7 @@ public class JSONArray { this.put(index, new JSONArray(value)); return this; } - + /** * Put or replace a double value. If the index is greater than the length of the JSONArray, then null elements will * be added as necessary to pad it out. @@ -648,7 +645,7 @@ public class JSONArray { this.put(index, new Double(value)); return this; } - + /** * Put or replace an int value. If the index is greater than the length of the JSONArray, then null elements will be * added as necessary to pad it out. @@ -664,7 +661,7 @@ public class JSONArray { this.put(index, new Integer(value)); return this; } - + /** * Put or replace a long value. If the index is greater than the length of the JSONArray, then null elements will be * added as necessary to pad it out. @@ -680,7 +677,7 @@ public class JSONArray { this.put(index, new Long(value)); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONObject that is produced from a Map. * @@ -695,7 +692,7 @@ public class JSONArray { this.put(index, new JSONObject(value)); return this; } - + /** * Put or replace an object value in the JSONArray. If the index is greater than the length of the JSONArray, then * null elements will be added as necessary to pad it out. @@ -723,7 +720,7 @@ public class JSONArray { } return this; } - + /** * Remove an index and close the hole. * @@ -734,7 +731,7 @@ public class JSONArray { public Object remove(final int index) { return (index >= 0) && (index < this.length()) ? this.myArrayList.remove(index) : null; } - + /** * Determine if two JSONArrays are similar. They must contain similar sequences. * @@ -767,7 +764,7 @@ public class JSONArray { } return true; } - + /** * Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray. * @@ -787,7 +784,7 @@ public class JSONArray { } return jo; } - + /** * Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to * produce a syntactically correct JSON text then null will be returned instead. This could occur if the array @@ -805,7 +802,7 @@ public class JSONArray { return null; } } - + /** * Make a prettyprinted JSON text of this JSONArray. Warning: This method assumes that the data structure is * acyclical. @@ -824,7 +821,7 @@ public class JSONArray { return this.write(sw, indentFactor, 0).toString(); } } - + /** * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added. *

@@ -837,7 +834,7 @@ public class JSONArray { public Writer write(final Writer writer) throws JSONException { return this.write(writer, 0, 0); } - + /** * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added. *

@@ -855,12 +852,10 @@ public class JSONArray { boolean commanate = false; final int length = this.length(); writer.write('['); - if (length == 1) { JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent); } else if (length != 0) { final int newindent = indent + indentFactor; - for (int i = 0; i < length; i += 1) { if (commanate) { writer.write(','); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java index 090d4e4f7..d15aae6d9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java @@ -9,7 +9,7 @@ package com.intellectualcrafters.json; public class JSONException extends RuntimeException { private static final long serialVersionUID = 0; private Throwable cause; - + /** * Constructs a JSONException with an explanatory message. * @@ -18,7 +18,7 @@ public class JSONException extends RuntimeException { public JSONException(final String message) { super(message); } - + /** * Constructs a new JSONException with the specified cause. * @@ -28,7 +28,7 @@ public class JSONException extends RuntimeException { super(cause.getMessage()); this.cause = cause; } - + /** * Returns the cause of this exception or null if the cause is nonexistent or unknown. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java index 307ac1bef..8d92ddf10 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java @@ -10,7 +10,6 @@ import java.util.Iterator; * @version 2014-05-03 */ public class JSONML { - /** * Parse XML values and store them in a JSONArray. * @@ -31,13 +30,11 @@ public class JSONML { JSONObject newjo = null; Object token; String tagName = null; - // Test for and skip past these forms: // // // // - while (true) { if (!x.more()) { throw x.syntaxError("Bad XML"); @@ -47,9 +44,7 @@ public class JSONML { token = x.nextToken(); if (token instanceof Character) { if (token == XML.SLASH) { - // Close tag 0); } } else if (token == XML.QUEST) { - // "); } else { throw x.syntaxError("Misshaped tag"); } - // Open tag < - } else { if (!(token instanceof String)) { throw x.syntaxError("Bad tagName '" + token + "'."); @@ -121,7 +110,7 @@ public class JSONML { } } token = null; - for (; ; ) { + for (;;) { if (token == null) { token = x.nextToken(); } @@ -131,9 +120,7 @@ public class JSONML { if (!(token instanceof String)) { break; } - // attribute = value - attribute = (String) token; if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) { throw x.syntaxError("Reserved attribute."); @@ -153,9 +140,7 @@ public class JSONML { if (arrayForm && (newjo.length() > 0)) { newja.put(newjo); } - // Empty tag <.../> - if (token == XML.SLASH) { if (x.nextToken() != XML.GT) { throw x.syntaxError("Misshaped tag"); @@ -167,9 +152,7 @@ public class JSONML { return newjo; } } - // Content, between <...> and - } else { if (token != XML.GT) { throw x.syntaxError("Misshaped tag"); @@ -200,7 +183,7 @@ public class JSONML { } } } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each * XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then @@ -216,7 +199,7 @@ public class JSONML { public static JSONArray toJSONArray(final String string) throws JSONException { return toJSONArray(new XMLTokener(string)); } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each * XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then @@ -233,7 +216,7 @@ public class JSONML { public static JSONArray toJSONArray(final XMLTokener x) throws JSONException { return (JSONArray) parse(x, true, null); } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes @@ -251,7 +234,7 @@ public class JSONML { public static JSONObject toJSONObject(final XMLTokener x) throws JSONException { return (JSONObject) parse(x, false, null); } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes @@ -269,7 +252,7 @@ public class JSONML { public static JSONObject toJSONObject(final String string) throws JSONException { return toJSONObject(new XMLTokener(string)); } - + /** * Reverse the JSONML transformation, making an XML text from a JSONArray. * @@ -289,22 +272,17 @@ public class JSONML { final StringBuilder sb = new StringBuilder(); String tagName; String value; - // Emit = length) { sb.append('/'); @@ -351,7 +327,7 @@ public class JSONML { } return sb.toString(); } - + /** * Reverse the JSONML transformation, making an XML text from a JSONObject. The JSONObject must contain a "tagName" * property. If it has children, then it must have a "childNodes" property containing an array of objects. The other @@ -373,9 +349,7 @@ public class JSONML { Object object; String tagName; String value; - // Emit map; - + /** * Construct an empty JSONObject. */ public JSONObject() { this.map = new HashMap(); } - + /** * Construct a JSONObject from a subset of another JSONObject. An array of strings is used to identify the keys that * should be copied. Missing keys are ignored. @@ -91,7 +91,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from a JSONTokener. * @@ -103,11 +103,10 @@ public class JSONObject { this(); char c; String key; - if (x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); } - for (; ; ) { + for (;;) { c = x.nextClean(); switch (c) { case 0: @@ -118,17 +117,13 @@ public class JSONObject { x.back(); key = x.nextValue().toString(); } - // The key is followed by ':'. - c = x.nextClean(); if (c != ':') { throw x.syntaxError("Expected a ':' after a key"); } this.putOnce(key, x.nextValue()); - // Pairs are separated by ','. - switch (x.nextClean()) { case ';': case ',': @@ -144,7 +139,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from a Map. * @@ -163,7 +158,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from an Object using bean getters. It reflects on all of the public methods of the object. * For each of the methods with no parameters and a name starting with "get" or "is" @@ -183,7 +178,7 @@ public class JSONObject { this(); this.populateMap(bean); } - + /** * Construct a JSONObject from an Object, using reflection to find the public members. The resulting JSONObject's * keys will be the strings from the names array, and the values will be the field values associated with those keys @@ -202,7 +197,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from a source JSON text string. This is the most commonly used JSONObject constructor. * @@ -214,7 +209,7 @@ public class JSONObject { public JSONObject(final String source) throws JSONException { this(new JSONTokener(source)); } - + /** * Construct a JSONObject from a ResourceBundle. * @@ -226,20 +221,16 @@ public class JSONObject { public JSONObject(final String baseName, final Locale locale) throws JSONException { this(); final ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader()); - // Iterate through the keys in the bundle. - final Enumeration keys = bundle.getKeys(); while (keys.hasMoreElements()) { final Object key = keys.nextElement(); if (key != null) { - // Go through the path, ensuring that there is a nested // JSONObject for each // segment except the last. Add the value using the last // segment's name into // the deepest nested JSONObject. - final String[] path = ((String) key).split("\\."); final int last = path.length - 1; JSONObject target = this; @@ -256,7 +247,7 @@ public class JSONObject { } } } - + /** * Produce a string from a double. The string "null" will be returned if the number is not finite. * @@ -268,9 +259,7 @@ public class JSONObject { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } - // Shave off trailing zeros and decimal point, if possible. - String string = Double.toString(d); if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) { while (string.endsWith("0")) { @@ -282,7 +271,7 @@ public class JSONObject { } return string; } - + /** * Get an array of field names from a JSONObject. * @@ -302,7 +291,7 @@ public class JSONObject { } return names; } - + /** * Get an array of field names from an Object. * @@ -324,7 +313,7 @@ public class JSONObject { } return names; } - + /** * Produce a string from a Number. * @@ -339,9 +328,7 @@ public class JSONObject { throw new JSONException("Null pointer"); } testValidity(number); - // Shave off trailing zeros and decimal point, if possible. - String string = number.toString(); if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) { while (string.endsWith("0")) { @@ -353,7 +340,7 @@ public class JSONObject { } return string; } - + /** * Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted * within = '0') && (b <= '9')) || (b == '-')) { try { @@ -483,7 +466,7 @@ public class JSONObject { } return string; } - + /** * Throw an exception if the object is a NaN or infinite number. * @@ -504,7 +487,7 @@ public class JSONObject { } } } - + /** * Make a JSON text of an Object value. If the object has an value.toJSONString() method, then that method will be * used to produce the JSON text. The method is required to produce a strictly conforming text. If the object does @@ -557,7 +540,7 @@ public class JSONObject { } return quote(value.toString()); } - + /** * Wrap an object, if necessary. If the object is null, return the NULL object. If it is an array or collection, * wrap it in a JSONArray. If it is a map, wrap it in a JSONObject. If it is a standard property (Double, String, et @@ -576,7 +559,6 @@ public class JSONObject { if ((object instanceof JSONObject) || (object instanceof JSONArray) || NULL.equals(object) || (object instanceof JSONString) || (object instanceof Byte) || (object instanceof Character) || (object instanceof Short) || (object instanceof Integer) || (object instanceof Long) || (object instanceof Boolean) || (object instanceof Float) || (object instanceof Double) || (object instanceof String)) { return object; } - if (object instanceof Collection) { return new JSONArray((Collection) object); } @@ -596,7 +578,7 @@ public class JSONObject { return null; } } - + static final Writer writeValue(final Writer writer, final Object value, final int indentFactor, final int indent) throws JSONException, IOException { if ((value == null) || value.equals(null)) { writer.write("null"); @@ -627,13 +609,13 @@ public class JSONObject { } return writer; } - + static final void indent(final Writer writer, final int indent) throws IOException { for (int i = 0; i < indent; i += 1) { writer.write(' '); } } - + /** * Accumulate values under a key. It is similar to the put method except that if there is already an object stored * under the key then a JSONArray is stored under the key to hold all of the accumulated values. If there is already @@ -661,7 +643,7 @@ public class JSONObject { } return this; } - + /** * Append values to the array under a key. If the key does not exist in the JSONObject, then the key is put in the * JSONObject with its value being a JSONArray containing the value parameter. If the key was already associated @@ -686,7 +668,7 @@ public class JSONObject { } return this; } - + /** * Get the value object associated with a key. * @@ -706,7 +688,7 @@ public class JSONObject { } return object; } - + /** * Get the boolean value associated with a key. * @@ -725,7 +707,7 @@ public class JSONObject { } throw new JSONException("JSONObject[" + quote(key) + "] is not a Boolean."); } - + /** * Get the double value associated with a key. * @@ -744,7 +726,7 @@ public class JSONObject { throw new JSONException("JSONObject[" + quote(key) + "] is not a number."); } } - + /** * Get the int value associated with a key. * @@ -762,7 +744,7 @@ public class JSONObject { throw new JSONException("JSONObject[" + quote(key) + "] is not an int."); } } - + /** * Get the JSONArray value associated with a key. * @@ -779,7 +761,7 @@ public class JSONObject { } throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONArray."); } - + /** * Get the JSONObject value associated with a key. * @@ -796,7 +778,7 @@ public class JSONObject { } throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONObject."); } - + /** * Get the long value associated with a key. * @@ -814,7 +796,7 @@ public class JSONObject { throw new JSONException("JSONObject[" + quote(key) + "] is not a long."); } } - + /** * Get the string associated with a key. * @@ -831,7 +813,7 @@ public class JSONObject { } throw new JSONException("JSONObject[" + quote(key) + "] not a string."); } - + /** * Determine if the JSONObject contains a specific key. * @@ -842,7 +824,7 @@ public class JSONObject { public boolean has(final String key) { return this.map.containsKey(key); } - + /** * Increment a property of a JSONObject. If there is no such property, create one with a value of 1. If there is * such a property, and if it is an Integer, Long, Double, or Float, then add one to it. @@ -871,7 +853,7 @@ public class JSONObject { } return this; } - + /** * Determine if the value associated with the key is null or if there is no value. * @@ -882,7 +864,7 @@ public class JSONObject { public boolean isNull(final String key) { return JSONObject.NULL.equals(this.opt(key)); } - + /** * Get an enumeration of the keys of the JSONObject. * @@ -891,7 +873,7 @@ public class JSONObject { public Iterator keys() { return this.keySet().iterator(); } - + /** * Get a set of keys of the JSONObject. * @@ -900,7 +882,7 @@ public class JSONObject { public Set keySet() { return this.map.keySet(); } - + /** * Get the number of keys stored in the JSONObject. * @@ -909,7 +891,7 @@ public class JSONObject { public int length() { return this.map.size(); } - + /** * Produce a JSONArray containing the names of the elements of this JSONObject. * @@ -923,7 +905,7 @@ public class JSONObject { } return ja.length() == 0 ? null : ja; } - + /** * Get an optional value associated with a key. * @@ -934,7 +916,7 @@ public class JSONObject { public Object opt(final String key) { return key == null ? null : this.map.get(key); } - + /** * Get an optional boolean associated with a key. It returns false if there is no such key, or if the value is not * Boolean.TRUE or the String "true". @@ -946,7 +928,7 @@ public class JSONObject { public boolean optBoolean(final String key) { return this.optBoolean(key, false); } - + /** * Get an optional boolean associated with a key. It returns the defaultValue if there is no such key, or if it is * not a Boolean or the String "true" or "false" (case insensitive). @@ -963,7 +945,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional double associated with a key, or NaN if there is no such key or if its value is not a number. If * the value is a string, an attempt will be made to evaluate it as a number. @@ -975,7 +957,7 @@ public class JSONObject { public double optDouble(final String key) { return this.optDouble(key, Double.NaN); } - + /** * Get an optional double associated with a key, or the defaultValue if there is no such key or if its value is not * a number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -992,7 +974,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional int value associated with a key, or zero if there is no such key or if the value is not a number. * If the value is a string, an attempt will be made to evaluate it as a number. @@ -1004,7 +986,7 @@ public class JSONObject { public int optInt(final String key) { return this.optInt(key, 0); } - + /** * Get an optional int value associated with a key, or the default if there is no such key or if the value is not a * number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -1021,7 +1003,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional JSONArray associated with a key. It returns null if there is no such key, or if its value is not * a JSONArray. @@ -1034,7 +1016,7 @@ public class JSONObject { final Object o = this.opt(key); return o instanceof JSONArray ? (JSONArray) o : null; } - + /** * Get an optional JSONObject associated with a key. It returns null if there is no such key, or if its value is not * a JSONObject. @@ -1047,7 +1029,7 @@ public class JSONObject { final Object object = this.opt(key); return object instanceof JSONObject ? (JSONObject) object : null; } - + /** * Get an optional long value associated with a key, or zero if there is no such key or if the value is not a * number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -1059,7 +1041,7 @@ public class JSONObject { public long optLong(final String key) { return this.optLong(key, 0); } - + /** * Get an optional long value associated with a key, or the default if there is no such key or if the value is not a * number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -1076,7 +1058,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional string associated with a key. It returns an empty string if there is no such key. If the value is * not a string and is not null, then it is converted to a string. @@ -1088,7 +1070,7 @@ public class JSONObject { public String optString(final String key) { return this.optString(key, ""); } - + /** * Get an optional string associated with a key. It returns the defaultValue if there is no such key. * @@ -1101,14 +1083,11 @@ public class JSONObject { final Object object = this.opt(key); return NULL.equals(object) ? defaultValue : object.toString(); } - + private void populateMap(final Object bean) { final Class klass = bean.getClass(); - // If klass is a System class then set includeSuperClass to false. - final boolean includeSuperClass = klass.getClassLoader() != null; - final Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods(); for (final Method method : methods) { try { @@ -1130,7 +1109,6 @@ public class JSONObject { } else if (!Character.isUpperCase(key.charAt(1))) { key = key.substring(0, 1).toLowerCase() + key.substring(1); } - final Object result = method.invoke(bean, (Object[]) null); if (result != null) { this.map.put(key, wrap(result)); @@ -1141,7 +1119,7 @@ public class JSONObject { } } } - + /** * Put a key/boolean pair in the JSONObject. * @@ -1156,7 +1134,7 @@ public class JSONObject { this.put(key, value ? Boolean.TRUE : Boolean.FALSE); return this; } - + /** * Put a key/value pair in the JSONObject, where the value will be a JSONArray which is produced from a Collection. * @@ -1171,7 +1149,7 @@ public class JSONObject { this.put(key, new JSONArray(value)); return this; } - + /** * Put a key/double pair in the JSONObject. * @@ -1186,7 +1164,7 @@ public class JSONObject { this.put(key, new Double(value)); return this; } - + /** * Put a key/int pair in the JSONObject. * @@ -1201,7 +1179,7 @@ public class JSONObject { this.put(key, new Integer(value)); return this; } - + /** * Put a key/long pair in the JSONObject. * @@ -1216,7 +1194,7 @@ public class JSONObject { this.put(key, new Long(value)); return this; } - + /** * Put a key/value pair in the JSONObject, where the value will be a JSONObject which is produced from a Map. * @@ -1231,7 +1209,7 @@ public class JSONObject { this.put(key, new JSONObject(value)); return this; } - + /** * Put a key/value pair in the JSONObject. If the value is null, then the key will be removed from the JSONObject if * it is present. @@ -1256,7 +1234,7 @@ public class JSONObject { } return this; } - + /** * Put a key/value pair in the JSONObject, but only if the key and the value are both non-null, and only if there is * not already a member with that name. @@ -1277,7 +1255,7 @@ public class JSONObject { } return this; } - + /** * Put a key/value pair in the JSONObject, but only if the key and the value are both non-null. * @@ -1295,7 +1273,7 @@ public class JSONObject { } return this; } - + /** * Remove a name and its value, if present. * @@ -1306,7 +1284,7 @@ public class JSONObject { public Object remove(final String key) { return this.map.remove(key); } - + /** * Determine if two JSONObjects are similar. They must contain the same set of names which must be associated with * similar values. @@ -1344,7 +1322,7 @@ public class JSONObject { return false; } } - + /** * Produce a JSONArray containing the values of the members of this JSONObject. * @@ -1365,7 +1343,7 @@ public class JSONObject { } return ja; } - + /** * Make a JSON text of this JSONObject. For compactness, no whitespace is added. If this would not result in a * syntactically correct JSON text, then null will be returned instead. @@ -1384,7 +1362,7 @@ public class JSONObject { return null; } } - + /** * Make a prettyprinted JSON text of this JSONObject. *

@@ -1404,7 +1382,7 @@ public class JSONObject { return this.write(w, indentFactor, 0).toString(); } } - + /** * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added. *

@@ -1417,7 +1395,7 @@ public class JSONObject { public Writer write(final Writer writer) throws JSONException { return this.write(writer, 0, 0); } - + /** * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added. *

@@ -1433,7 +1411,6 @@ public class JSONObject { final int length = this.length(); final Iterator keys = this.keys(); writer.write('{'); - if (length == 1) { final Object key = keys.next(); writer.write(quote(key.toString())); @@ -1472,13 +1449,12 @@ public class JSONObject { throw new JSONException(exception); } } - + /** * JSONObject.NULL is equivalent to the value that JavaScript calls null, whilst Java's null is equivalent to the * value that JavaScript calls undefined. */ private static final class Null { - /** * There is only intended to be a single instance of the NULL object, so the clone method returns itself. * @@ -1492,7 +1468,7 @@ public class JSONObject { return this; } } - + /** * A Null object is equal to the null value and to itself. * @@ -1504,7 +1480,7 @@ public class JSONObject { public boolean equals(final Object object) { return (object == null) || (object == this); } - + /** * Get the "null" string value. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java index 053001408..d29ae0e46 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java @@ -40,7 +40,7 @@ public class JSONStringer extends JSONWriter { public JSONStringer() { super(new StringWriter()); } - + /** * Return the JSON text. This method is used to obtain the product of the JSONStringer instance. It will return * null if there was a problem in the construction of the JSON text (such as the calls to diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java index 7c465319a..62f0fa135 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java @@ -15,7 +15,6 @@ import java.io.StringReader; * @version 2014-05-03 */ public class JSONTokener { - private final Reader reader; private long character; private boolean eof; @@ -23,7 +22,7 @@ public class JSONTokener { private long line; private char previous; private boolean usePrevious; - + /** * Construct a JSONTokener from a Reader. * @@ -38,7 +37,7 @@ public class JSONTokener { this.character = 1; this.line = 1; } - + /** * Construct a JSONTokener from an InputStream. * @@ -47,7 +46,7 @@ public class JSONTokener { public JSONTokener(final InputStream inputStream) throws JSONException { this(new InputStreamReader(inputStream)); } - + /** * Construct a JSONTokener from a string. * @@ -56,7 +55,7 @@ public class JSONTokener { public JSONTokener(final String s) { this(new StringReader(s)); } - + /** * Get the hex value of a character (base16). * @@ -76,7 +75,7 @@ public class JSONTokener { } return -1; } - + /** * Back up one character. This provides a sort of lookahead capability, so that you can test for a digit or letter * before attempting to parse the next number or identifier. @@ -90,11 +89,11 @@ public class JSONTokener { this.usePrevious = true; this.eof = false; } - + public boolean end() { return this.eof && !this.usePrevious; } - + /** * Determine if the source string still contains characters that next() can consume. * @@ -108,7 +107,7 @@ public class JSONTokener { this.back(); return true; } - + /** * Get the next character in the source string. * @@ -125,7 +124,6 @@ public class JSONTokener { } catch (final IOException exception) { throw new JSONException(exception); } - if (c <= 0) { // End of stream this.eof = true; c = 0; @@ -144,7 +142,7 @@ public class JSONTokener { this.previous = (char) c; return this.previous; } - + /** * Consume the next character, and check that it matches a specified character. * @@ -161,7 +159,7 @@ public class JSONTokener { } return n; } - + /** * Get the next n characters. * @@ -175,10 +173,8 @@ public class JSONTokener { if (n == 0) { return ""; } - final char[] chars = new char[n]; int pos = 0; - while (pos < n) { chars[pos] = this.next(); if (this.end()) { @@ -188,7 +184,7 @@ public class JSONTokener { } return new String(chars); } - + /** * Get the next char in the string, skipping whitespace. * @@ -197,14 +193,14 @@ public class JSONTokener { * @throws JSONException */ public char nextClean() throws JSONException { - for (; ; ) { + for (;;) { final char c = this.next(); if ((c == 0) || (c > ' ')) { return c; } } } - + /** * Return the characters up to the next close quote character. Backslash processing is done. The formal JSON format * does not allow strings in single quotes, but an implementation is allowed to accept them. @@ -219,7 +215,7 @@ public class JSONTokener { public String nextString(final char quote) throws JSONException { char c; final StringBuilder sb = new StringBuilder(); - for (; ; ) { + for (;;) { c = this.next(); switch (c) { case 0: @@ -265,7 +261,7 @@ public class JSONTokener { } } } - + /** * Get the text up but not including the specified character or the end of line, whichever comes first. * @@ -275,7 +271,7 @@ public class JSONTokener { */ public String nextTo(final char delimiter) throws JSONException { final StringBuilder sb = new StringBuilder(); - for (; ; ) { + for (;;) { final char c = this.next(); if ((c == delimiter) || (c == 0) || (c == '\n') || (c == '\r')) { if (c != 0) { @@ -286,7 +282,7 @@ public class JSONTokener { sb.append(c); } } - + /** * Get the text up but not including one of the specified delimiter characters or the end of line, whichever comes * first. @@ -298,7 +294,7 @@ public class JSONTokener { public String nextTo(final String delimiters) throws JSONException { char c; final StringBuilder sb = new StringBuilder(); - for (; ; ) { + for (;;) { c = this.next(); if ((delimiters.indexOf(c) >= 0) || (c == 0) || (c == '\n') || (c == '\r')) { if (c != 0) { @@ -309,7 +305,7 @@ public class JSONTokener { sb.append(c); } } - + /** * Get the next value. The value can be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the * JSONObject.NULL object. @@ -321,7 +317,6 @@ public class JSONTokener { public Object nextValue() throws JSONException { char c = this.nextClean(); String string; - switch (c) { case '"': case '\'': @@ -333,7 +328,6 @@ public class JSONTokener { this.back(); return new JSONArray(this); } - /* * Handle unquoted text. This could be the values true, false, or * null, or it can be a number. An implementation (such as this one) @@ -341,21 +335,19 @@ public class JSONTokener { * Accumulate characters until we reach the end of the text or a * formatting character. */ - final StringBuilder sb = new StringBuilder(); while ((c >= ' ') && (",:]}/\\\"[{;=#".indexOf(c) < 0)) { sb.append(c); c = this.next(); } this.back(); - string = sb.toString().trim(); if ("".equals(string)) { throw this.syntaxError("Missing value"); } return JSONObject.stringToValue(string); } - + /** * Skip characters until the next character is the requested character. If the requested character is not found, no * characters are skipped. @@ -387,7 +379,7 @@ public class JSONTokener { this.back(); return c; } - + /** * Make a JSONException to signal a syntax error. * @@ -398,7 +390,7 @@ public class JSONTokener { public JSONException syntaxError(final String message) { return new JSONException(message + this.toString()); } - + /** * Make a printable string of this JSONTokener. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java index 7017db3d5..a332af1f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java @@ -55,7 +55,7 @@ public class JSONWriter { * The stack top index. A value of 0 indicates that the stack is empty. */ private int top; - + /** * Make a fresh JSONWriter. It can be used to build one JSON text. */ @@ -66,7 +66,7 @@ public class JSONWriter { this.top = 0; this.writer = w; } - + /** * Append a value. * @@ -97,7 +97,7 @@ public class JSONWriter { } throw new JSONException("Value out of sequence."); } - + /** * Begin appending a new array. All values until the balancing endArray will be appended to this array. * The endArray method must be called to mark the array's end. @@ -116,7 +116,7 @@ public class JSONWriter { } throw new JSONException("Misplaced array."); } - + /** * End something. * @@ -140,7 +140,7 @@ public class JSONWriter { this.comma = true; return this; } - + /** * End an array. This method most be called to balance calls to array. * @@ -151,7 +151,7 @@ public class JSONWriter { public JSONWriter endArray() throws JSONException { return this.end('a', ']'); } - + /** * End an object. This method most be called to balance calls to object. * @@ -162,7 +162,7 @@ public class JSONWriter { public JSONWriter endObject() throws JSONException { return this.end('k', '}'); } - + /** * Append a key. The key will be associated with the next value. In an object, every value must be preceded by a * key. @@ -195,7 +195,7 @@ public class JSONWriter { } throw new JSONException("Misplaced key."); } - + /** * Begin appending a new object. All keys and values until the balancing endObject will be appended to * this object. The endObject method must be called to mark the object's end. @@ -216,9 +216,8 @@ public class JSONWriter { return this; } throw new JSONException("Misplaced object."); - } - + /** * Pop an array or object scope. * @@ -237,7 +236,7 @@ public class JSONWriter { this.top -= 1; this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ? 'a' : 'k'; } - + /** * Push an array or object scope. * @@ -253,7 +252,7 @@ public class JSONWriter { this.mode = jo == null ? 'a' : 'k'; this.top += 1; } - + /** * Append either the value true or the value false . * @@ -266,7 +265,7 @@ public class JSONWriter { public JSONWriter value(final boolean b) throws JSONException { return this.append(b ? "true" : "false"); } - + /** * Append a double value. * @@ -279,7 +278,7 @@ public class JSONWriter { public JSONWriter value(final double d) throws JSONException { return this.value(new Double(d)); } - + /** * Append a long value. * @@ -292,7 +291,7 @@ public class JSONWriter { public JSONWriter value(final long l) throws JSONException { return this.append(Long.toString(l)); } - + /** * Append an object value. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java index 332b0083e..03520de0d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java @@ -27,7 +27,6 @@ package com.intellectualcrafters.json; * @version 2013-04-18 */ public class Kim { - /** * The number of bytes in the kim. The number of bytes can be as much as three times the number of characters. */ @@ -44,7 +43,7 @@ public class Kim { * The memoization of toString(). */ private String string = null; - + /** * Make a kim from a portion of a byte array. * @@ -53,11 +52,9 @@ public class Kim { * @param thru The index of the last byte plus one. */ public Kim(final byte[] bytes, final int from, final int thru) { - // As the bytes are copied into the new kim, a hashcode is computed // using a // modified Fletcher code. - int sum = 1; int value; this.hashcode = 0; @@ -73,7 +70,7 @@ public class Kim { this.hashcode += sum << 16; } } - + /** * Make a kim from a byte array. * @@ -83,7 +80,7 @@ public class Kim { public Kim(final byte[] bytes, final int length) { this(bytes, 0, length); } - + /** * Make a new kim from a substring of an existing kim. The coordinates are in byte units, not character units. * @@ -94,7 +91,7 @@ public class Kim { public Kim(final Kim kim, final int from, final int thru) { this(kim.bytes, from, thru); } - + /** * Make a kim from a string. * @@ -106,10 +103,8 @@ public class Kim { final int stringLength = string.length(); this.hashcode = 0; this.length = 0; - // First pass: Determine the length of the kim, allowing for the UTF-16 // to UTF-32 conversion, and then the UTF-32 to Kim conversion. - if (stringLength > 0) { for (int i = 0; i < stringLength; i += 1) { final int c = string.charAt(i); @@ -128,11 +123,9 @@ public class Kim { this.length += 3; } } - // Second pass: Allocate a byte array and fill that array with the // conversion // while computing the hashcode. - this.bytes = new byte[this.length]; int at = 0; int b; @@ -180,7 +173,7 @@ public class Kim { this.hashcode += sum << 16; } } - + /** * Returns the number of bytes needed to contain the character in Kim format. * @@ -196,7 +189,7 @@ public class Kim { } return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3; } - + /** * Returns the character at the specified index. The index refers to byte values and ranges from 0 to length - 1. * The index of the next character is at index + Kim.characterSize(kim.characterAt(index)). @@ -227,7 +220,7 @@ public class Kim { } throw new JSONException("Bad character at " + at); } - + /** * Copy the contents of this kim to a byte array. * @@ -240,7 +233,7 @@ public class Kim { System.arraycopy(this.bytes, 0, bytes, at, this.length); return at + this.length; } - + /** * Two kim objects containing exactly the same bytes in the same order are equal to each other. * @@ -262,7 +255,7 @@ public class Kim { } return java.util.Arrays.equals(this.bytes, that.bytes); } - + /** * Get a byte from a kim. * @@ -278,7 +271,7 @@ public class Kim { } return (this.bytes[at]) & 0xFF; } - + /** * Returns a hash code value for the kim. */ @@ -286,7 +279,7 @@ public class Kim { public int hashCode() { return this.hashcode; } - + /** * Produce a UTF-16 String from this kim. The number of codepoints in the string will not be greater than the number * of bytes in the kim, although it could be less. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java index d846ff117..a177df954 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.json; import java.util.Enumeration; @@ -52,7 +51,7 @@ public class Property { } return jo; } - + /** * Converts the JSONObject into a property file object. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java index cd6ce153f..c14748a1c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java @@ -9,52 +9,43 @@ import java.util.Iterator; * @version 2014-05-03 */ public class XML { - /** * The Character '&'. */ public static final Character AMP = '&'; - /** * The Character '''. */ public static final Character APOS = '\''; - /** * The Character '!'. */ public static final Character BANG = '!'; - /** * The Character '='. */ public static final Character EQ = '='; - /** * The Character '>'. */ public static final Character GT = '>'; - /** * The Character '<'. */ public static final Character LT = '<'; - /** * The Character '?'. */ public static final Character QUEST = '?'; - /** * The Character '"'. */ public static final Character QUOT = '"'; - /** * The Character '/'. */ public static final Character SLASH = '/'; - + /** * Replace special characters with XML escapes: *

@@ -96,7 +87,7 @@ public class XML { } return sb.toString(); } - + /** * Throw an exception if the string contains whitespace. Whitespace is not allowed in tagNames and attributes. * @@ -116,7 +107,7 @@ public class XML { } } } - + /** * Scan the content following the named tag, attaching it to the context. * @@ -135,7 +126,6 @@ public class XML { String string; String tagName; Object token; - // Test for and skip past these forms: // // @@ -145,11 +135,8 @@ public class XML { // <> // <= // << - token = x.nextToken(); - // 0); return false; } else if (token == QUEST) { - // "); return false; } else if (token == SLASH) { - // Close tag - } else if (token == SLASH) { if (x.nextToken() != GT) { throw x.syntaxError("Misshaped tag"); @@ -247,11 +223,9 @@ public class XML { context.accumulate(tagName, ""); } return false; - // Content, between <...> and - } else if (token == GT) { - for (; ; ) { + for (;;) { token = x.nextContent(); if (token == null) { if (tagName != null) { @@ -263,9 +237,7 @@ public class XML { if (string.length() > 0) { jsonobject.accumulate("content", XML.stringToValue(string)); } - // Nested element - } else if (token == LT) { if (parse(x, jsonobject, tagName)) { if (jsonobject.length() == 0) { @@ -285,7 +257,7 @@ public class XML { } } } - + /** * Try to convert a string into a number, boolean, or null. If the string can't be converted, return the string. * This is much less ambitious than JSONObject.stringToValue, especially because it does not attempt to convert plus @@ -305,11 +277,9 @@ public class XML { if ("null".equalsIgnoreCase(string)) { return JSONObject.NULL; } - // If it might be a number, try converting it, first as a Long, and then // as a // Double. If that doesn't work, return the string. - try { final char initial = string.charAt(0); if ((initial == '-') || ((initial >= '0') && (initial <= '9'))) { @@ -329,7 +299,7 @@ public class XML { } return string; } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONObject. Some information may be lost in * this transformation because JSON is a data format and XML is a document format. XML uses elements, attributes, @@ -352,7 +322,7 @@ public class XML { } return jo; } - + /** * Convert a JSONObject into a well-formed, element-normal XML string. * @@ -365,7 +335,7 @@ public class XML { public static String toString(final Object object) throws JSONException { return toString(object, null); } - + /** * Convert a JSONObject into a well-formed, element-normal XML string. * @@ -387,17 +357,13 @@ public class XML { String string; Object value; if (object instanceof JSONObject) { - // Emit - if (tagName != null) { sb.append('<'); sb.append(tagName); sb.append('>'); } - // Loop thru the keys. - jo = (JSONObject) object; keys = jo.keys(); while (keys.hasNext()) { @@ -407,9 +373,7 @@ public class XML { value = ""; } string = value instanceof String ? (String) value : null; - // Emit content in body - if ("content".equals(key)) { if (value instanceof JSONArray) { ja = (JSONArray) value; @@ -423,9 +387,7 @@ public class XML { } else { sb.append(escape(value.toString())); } - // Emit an array of similar keys - } else if (value instanceof JSONArray) { ja = (JSONArray) value; length = ja.length(); @@ -447,27 +409,21 @@ public class XML { sb.append('<'); sb.append(key); sb.append("/>"); - // Emit a new tag - } else { sb.append(toString(value, key)); } } if (tagName != null) { - // Emit the close tag - sb.append("'); } return sb.toString(); - // XML does not have good support for arrays. If an array appears in // a place // where XML is lacking, synthesize an element. - } else { if (object.getClass().isArray()) { object = new JSONArray(object); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java index ab1513a72..1431939c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java @@ -7,12 +7,10 @@ package com.intellectualcrafters.json; * @version 2014-05-03 */ public class XMLTokener extends JSONTokener { - /** * The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot. */ public static final java.util.HashMap entity; - static { entity = new java.util.HashMap(8); entity.put("amp", XML.AMP); @@ -21,7 +19,7 @@ public class XMLTokener extends JSONTokener { entity.put("lt", XML.LT); entity.put("quot", XML.QUOT); } - + /** * Construct an XMLTokener from a string. * @@ -30,7 +28,7 @@ public class XMLTokener extends JSONTokener { public XMLTokener(final String s) { super(s); } - + /** * Get the text in the CDATA block. * @@ -42,7 +40,7 @@ public class XMLTokener extends JSONTokener { char c; int i; final StringBuilder sb = new StringBuilder(); - for (; ; ) { + for (;;) { c = next(); if (end()) { throw syntaxError("Unclosed CDATA"); @@ -55,7 +53,7 @@ public class XMLTokener extends JSONTokener { } } } - + /** * Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins * a markup tag, and the content text between markup tags. @@ -77,7 +75,7 @@ public class XMLTokener extends JSONTokener { return XML.LT; } sb = new StringBuilder(); - for (; ; ) { + for (;;) { if ((c == '<') || (c == 0)) { back(); return sb.toString().trim(); @@ -90,7 +88,7 @@ public class XMLTokener extends JSONTokener { c = next(); } } - + /** * Return the next entity. These entities are translated to Characters: & ' > < * ". @@ -103,7 +101,7 @@ public class XMLTokener extends JSONTokener { */ public Object nextEntity(final char ampersand) throws JSONException { final StringBuilder sb = new StringBuilder(); - for (; ; ) { + for (;;) { final char c = next(); if (Character.isLetterOrDigit(c) || (c == '#')) { sb.append(Character.toLowerCase(c)); @@ -117,7 +115,7 @@ public class XMLTokener extends JSONTokener { final Object object = entity.get(string); return object != null ? object : ampersand + string + ";"; } - + /** * Returns the next XML meta token. This is used for skipping over and structures. * @@ -150,7 +148,7 @@ public class XMLTokener extends JSONTokener { case '"': case '\'': q = c; - for (; ; ) { + for (;;) { c = next(); if (c == 0) { throw syntaxError("Unterminated string"); @@ -160,7 +158,7 @@ public class XMLTokener extends JSONTokener { } } default: - for (; ; ) { + for (;;) { c = next(); if (Character.isWhitespace(c)) { return Boolean.TRUE; @@ -181,7 +179,7 @@ public class XMLTokener extends JSONTokener { } } } - + /** * Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these characters: * / > = ! ? or it may be a string wrapped in single quotes or double quotes, or it may be a name. @@ -212,14 +210,12 @@ public class XMLTokener extends JSONTokener { return XML.BANG; case '?': return XML.QUEST; - - // Quoted string - + // Quoted string case '"': case '\'': q = c; sb = new StringBuilder(); - for (; ; ) { + for (;;) { c = next(); if (c == 0) { throw syntaxError("Unterminated string"); @@ -234,11 +230,9 @@ public class XMLTokener extends JSONTokener { } } default: - // Name - sb = new StringBuilder(); - for (; ; ) { + for (;;) { sb.append(c); c = next(); if (Character.isWhitespace(c)) { @@ -264,7 +258,7 @@ public class XMLTokener extends JSONTokener { } } } - + /** * Skip characters until past the requested string. If it is not found, we are left at the end of the source with a * result of false. @@ -281,12 +275,10 @@ public class XMLTokener extends JSONTokener { int offset = 0; final int length = to.length(); final char[] circle = new char[length]; - /* * First fill the circle buffer with as many characters as are in the * to string. If we reach an early end, bail. */ - for (i = 0; i < length; i += 1) { c = next(); if (c == 0) { @@ -294,15 +286,11 @@ public class XMLTokener extends JSONTokener { } circle[i] = c; } - /* We will loop, possibly for all of the remaining characters. */ - - for (; ; ) { + for (;;) { j = offset; b = true; - /* Compare the circle buffer with the to string. */ - for (i = 0; i < length; i += 1) { if (circle[j] != to.charAt(i)) { b = false; @@ -313,15 +301,11 @@ public class XMLTokener extends JSONTokener { j -= length; } } - /* If we exit the loop with b intact, then victory is ours. */ - if (b) { return true; } - /* Get the next character. If there isn't one, then defeat is ours. */ - c = next(); if (c == 0) { return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index deca2ddb5..4c690bbf6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -2,9 +2,7 @@ package com.intellectualcrafters.plot; import java.io.File; import java.util.Arrays; - import net.milkbowl.vault.economy.Economy; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -20,7 +18,6 @@ import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; - import com.intellectualcrafters.plot.commands.Buy; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.WE_Anywhere; @@ -55,11 +52,10 @@ import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.bukkit.WorldEditPlugin; -public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { - +public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS = null; public static PlotSquared MAIN = null; - + // TODO restructure this public static boolean hasPermission(final Player player, final String perm) { if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { @@ -97,21 +93,18 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { // TODO restructure this public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) { - Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot); + final 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(bot.world, bot); - - int x = location.getX(); - int z = location.getZ(); - - + final int x = location.getX(); + final 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")) { + if ((Settings.TELEPORT_DELAY == 0) || hasPermission(player, "plots.teleport.delay.bypass")) { PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT); BukkitUtil.teleportPlayer(player, location); return true; @@ -140,17 +133,17 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { } @EventHandler - public static void worldLoad(WorldLoadEvent event) { + public static void worldLoad(final WorldLoadEvent event) { UUIDHandler.cacheAll(); } - + @EventHandler - public void PlayerCommand(PlayerCommandPreprocessEvent event) { - String message = event.getMessage(); + public void PlayerCommand(final PlayerCommandPreprocessEvent event) { + final String message = event.getMessage(); if (message.toLowerCase().startsWith("/plotme")) { - Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe"); + final Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe"); if (plotme == null) { - Player player = event.getPlayer(); + final Player player = event.getPlayer(); if (Settings.USE_PLOTME_ALIAS) { player.performCommand(message.replace("/plotme", "plots")); } else { @@ -165,7 +158,6 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { public void onEnable() { MAIN = new PlotSquared(this); THIS = this; - if (Settings.METRICS) { try { final Metrics metrics = new Metrics(this); @@ -177,7 +169,6 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { } else { log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); } - getServer().getPluginManager().registerEvents(this, this); } @@ -187,10 +178,10 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { MAIN = null; THIS = null; } - + @Override public void log(String message) { - if (THIS == null || Bukkit.getServer().getConsoleSender() == null) { + if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) { System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message))); } else { message = ChatColor.translateAlternateColorCodes('&', message); @@ -200,12 +191,12 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { Bukkit.getServer().getConsoleSender().sendMessage(message); } } - + @Override public void disable() { onDisable(); } - + @Override public String getVersion() { return this.getDescription().getVersion(); @@ -219,17 +210,17 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot")); plotCommand.setTabCompleter(command); } - + @Override public File getDirectory() { return getDataFolder(); } - + @Override public TaskManager getTaskManager() { return new BukkitTaskManager(); } - + @Override public void runEntityTask() { log(C.PREFIX.s() + "KillAllEntities started."); @@ -279,24 +270,24 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { return new HybridGen(world); } - public static boolean checkVersion(int major, int minor, int minor2) { + public static boolean checkVersion(final int major, final int minor, final int minor2) { try { - String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\."); - int a = Integer.parseInt(version[0]); - int b = Integer.parseInt(version[1]); + final String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\."); + final int a = Integer.parseInt(version[0]); + final 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)) { + if ((a > major) || ((a == major) && (b > minor)) || ((a == major) && (b == minor) && (c >= minor2))) { return true; } return false; - } catch (Exception e) { + } catch (final Exception e) { return false; } } - + @Override public void registerPlayerEvents() { getServer().getPluginManager().registerEvents(new PlayerEvents(), this); @@ -304,23 +295,23 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); } } - + @Override public void registerInventoryEvents() { getServer().getPluginManager().registerEvents(new InventoryListener(), this); } - + @Override public void registerPlotPlusEvents() { PlotPlusListener.startRunnable(this); getServer().getPluginManager().registerEvents(new PlotPlusListener(), this); } - + @Override public void registerForceFieldEvents() { getServer().getPluginManager().registerEvents(new ForceFieldListener(), this); } - + @Override public void registerWorldEditEvents() { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { @@ -336,7 +327,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { } } } - + @Override public Economy getEconomy() { if ((getServer().getPluginManager().getPlugin("Vault") != null) && getServer().getPluginManager().getPlugin("Vault").isEnabled()) { @@ -348,22 +339,20 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { } return null; } - + @Override public void initSetBlockManager() { if (checkVersion(1, 8, 0)) { try { SetBlockManager.setBlockManager = new SetBlockFast_1_8(); - } - catch (Throwable e) { + } catch (final Throwable e) { e.printStackTrace(); SetBlockManager.setBlockManager = new SetBlockSlow(); } - } - else { + } else { try { SetBlockManager.setBlockManager = new SetBlockFast(); - } catch (Throwable e) { + } catch (final Throwable e) { SetBlockManager.setBlockManager = new SetBlockSlow(); } } @@ -374,7 +363,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { PlotHelper.canSendChunk = false; } } - + @Override public boolean initPlotMeConverter() { try { @@ -387,19 +376,19 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { } return false; } - + @Override - public void getGenerator(String world, String name) { - Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name); - if (gen_plugin != null && gen_plugin.isEnabled()) { + public void getGenerator(final String world, final String name) { + final 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) { + public boolean callRemovePlot(final String world, final PlotId id) { final PlotDeleteEvent event = new PlotDeleteEvent(world, id); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 3129a48ec..dba352914 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -41,4 +41,4 @@ public interface IPlotMain { 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 18c9daee5..17998101c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -36,9 +36,11 @@ import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.generator.AugmentedPopulator; +import com.intellectualcrafters.plot.generator.ClassicPlotWorld; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.SquarePlotManager; +import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotCluster; @@ -56,19 +58,14 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class PlotSquared { - public static final String MAIN_PERMISSION = "plots.use"; public static final String ADMIN_PERMISSION = "plots.admin"; - public static File styleFile; public static YamlConfiguration style; - public static File configFile; public static YamlConfiguration config; - public static File storageFile; public static YamlConfiguration storage; - public static PlotSquared THIS = null; // This class public static IPlotMain IMP = null; // Specific implementation of PlotSquared public static String VERSION = null; @@ -76,11 +73,9 @@ public class PlotSquared { private static boolean LOADING_WORLD = false; public static Economy economy = null; public static WorldEditPlugin worldEdit = null; - private final static HashMap plotworlds = new HashMap<>(); private final static HashMap plotmanagers = new HashMap<>(); private static LinkedHashMap> plots; - private static MySQL mySQL; public static Connection connection; @@ -190,10 +185,9 @@ public class PlotSquared { } 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); - + final PlotId last = PlotHelper.lastPlot.get(world); + final int last_max = Math.max(last.x, last.y); + final int this_max = Math.max(id.x, id.y); if (this_max < last_max) { PlotHelper.lastPlot.put(world, id); } @@ -205,16 +199,13 @@ public class PlotSquared { 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; + plotGenerator = generator; plotWorld = plotGenerator.getNewPlotWorld(world); plotManager = plotGenerator.getPlotManager(); if (!world.equals("CheckingPlotSquaredGenerator")) { @@ -243,14 +234,13 @@ public class PlotSquared { if (!LOADING_WORLD) { LOADING_WORLD = true; try { - String gen_string = config.getString("worlds." + world + "." + "generator.plugin"); + final String gen_string = config.getString("worlds." + world + "." + "generator.plugin"); if (gen_string == null) { new HybridGen(world); - } - else { + } else { IMP.getGenerator(world, gen_string); } - } catch (Exception e) { + } catch (final Exception e) { log("&d=== Oh no! Please set the generator for the " + world + " ==="); e.printStackTrace(); LOADING_WORLD = false; @@ -259,7 +249,7 @@ public class PlotSquared { LOADING_WORLD = false; } } else { - PlotGenerator gen_class = (PlotGenerator) generator; + final PlotGenerator gen_class = generator; plotWorld = gen_class.getNewPlotWorld(world); plotManager = gen_class.getPlotManager(); if (!config.contains(path)) { @@ -274,14 +264,14 @@ public class PlotSquared { } catch (final IOException e) { e.printStackTrace(); } - if ((plotWorld.TYPE == 2 && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) { + 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)) { + for (final PlotCluster cluster : ClusterManager.getClusters(world)) { new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2); } } @@ -292,65 +282,63 @@ public class PlotSquared { } } - public static boolean setupPlotWorld(String world, String id) { - if (id != null && id.length() > 0) { + public static boolean setupPlotWorld(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("="); + final String[] split = id.split(","); + final HybridPlotWorld plotworld = new HybridPlotWorld(world); + final int width = SquarePlotWorld.PLOT_WIDTH_DEFAULT; + final int gap = SquarePlotWorld.ROAD_WIDTH_DEFAULT; + final int height = ClassicPlotWorld.PLOT_HEIGHT_DEFAULT; + final PlotBlock[] floor = ClassicPlotWorld.TOP_BLOCK_DEFAULT; + final PlotBlock[] main = ClassicPlotWorld.MAIN_BLOCK_DEFAULT; + final PlotBlock wall = ClassicPlotWorld.WALL_FILLING_DEFAULT; + final PlotBlock border = ClassicPlotWorld.WALL_BLOCK_DEFAULT; + for (final String element : split) { + final String[] pair = element.split("="); if (pair.length != 2) { log("&cNo value provided for: &7" + element); return false; } - String key = pair[0].toLowerCase(); - String value = pair[1]; + final String key = pair[0].toLowerCase(); + final String value = pair[1]; try { switch (key) { case "s": case "size": { - HybridPlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + SquarePlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); break; } case "g": case "gap": { - HybridPlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue(); + SquarePlotWorld.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); + ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); + ClassicPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value); break; } case "f": case "floor": { - HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + ClassicPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); break; } case "m": case "main": { - HybridPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); + ClassicPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value); break; } case "w": case "wall": { - HybridPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + ClassicPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); break; } case "b": case "border": { - HybridPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); + ClassicPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value); break; } default: { @@ -358,30 +346,28 @@ public class PlotSquared { return false; } } - } - catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); log("&cInvalid value: &7" + value + " in arg " + element); return false; } } try { - String root = "worlds." + world; + final 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) { + ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = height; + ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = height; + ClassicPlotWorld.WALL_HEIGHT_DEFAULT = height; + ClassicPlotWorld.TOP_BLOCK_DEFAULT = floor; + ClassicPlotWorld.MAIN_BLOCK_DEFAULT = main; + ClassicPlotWorld.WALL_BLOCK_DEFAULT = border; + ClassicPlotWorld.WALL_FILLING_DEFAULT = wall; + SquarePlotWorld.PLOT_WIDTH_DEFAULT = width; + SquarePlotWorld.ROAD_WIDTH_DEFAULT = gap; + } catch (final Exception e) { e.printStackTrace(); } } @@ -392,14 +378,12 @@ public class PlotSquared { return connection; } - public PlotSquared(IPlotMain imp_class) { + public PlotSquared(final IPlotMain imp_class) { THIS = this; IMP = imp_class; VERSION = IMP.getVersion(); - C.setupTranslations(); C.saveTranslations(); - if (getJavaVersion() < 1.7) { log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); // Didn't know of any other link :D @@ -410,7 +394,6 @@ public class PlotSquared { if (getJavaVersion() < 1.8) { log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); } - TASK = IMP.getTaskManager(); if (Settings.KILL_ROAD_MOBS) { IMP.runEntityTask(); @@ -418,11 +401,9 @@ public class PlotSquared { if (C.ENABLED.s().length() > 0) { log(C.ENABLED.s()); } - setupConfigs(); setupDefaultFlags(); setupDatabase(); - // Events IMP.registerCommands(); IMP.registerPlayerEvents(); @@ -430,10 +411,8 @@ public class PlotSquared { IMP.registerPlotPlusEvents(); IMP.registerForceFieldEvents(); IMP.registerWorldEditEvents(); - // Set block IMP.initSetBlockManager(); - // PlotMe TaskManager.runTaskLater(new Runnable() { @Override @@ -447,11 +426,9 @@ public class PlotSquared { } } }, 200); - if (Settings.AUTO_CLEAR) { ExpireManager.runTask(); } - economy = IMP.getEconomy(); } @@ -466,7 +443,7 @@ public class PlotSquared { } } - public static void log(String message) { + public static void log(final String message) { IMP.log(message); } @@ -474,10 +451,9 @@ public class PlotSquared { 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"}; + tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments", "cluster" }; + } else { + tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" }; } if (Settings.DB.USE_MYSQL) { try { @@ -515,12 +491,10 @@ public class PlotSquared { if (Settings.ENABLE_CLUSTERS) { ClusterManager.clusters = DBFunc.getClusters(); } - } - else if (Settings.DB.USE_MONGO) { + } else if (Settings.DB.USE_MONGO) { // DBFunc.dbManager = new MongoManager(); log(C.PREFIX.s() + "MongoDB is not yet implemented"); - } - else if (Settings.DB.USE_SQLITE) { + } else if (Settings.DB.USE_SQLITE) { try { connection = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection(); { @@ -554,8 +528,7 @@ public class PlotSquared { IMP.disable(); return; } - - } + } public static void setupDefaultFlags() { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); @@ -571,31 +544,22 @@ public class PlotSquared { FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue())); } 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) { @@ -616,17 +580,14 @@ public class PlotSquared { 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) { @@ -643,7 +604,7 @@ public class PlotSquared { return null; } } - + @Override public String getValueDesc() { return "Flag value must be weather type: 'clear' or 'rain'"; @@ -676,7 +637,6 @@ public class PlotSquared { 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()); @@ -693,8 +653,7 @@ public class PlotSquared { 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.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"); @@ -707,13 +666,11 @@ public class PlotSquared { 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"); } - + public static void setupConfigs() { final File folder = new File(IMP.getDirectory() + File.separator + "config"); if (!folder.exists() && !folder.mkdirs()) { @@ -788,44 +745,43 @@ public class PlotSquared { } public static void showDebug() { - 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(style.getString("color.1")); - C.COLOR_2 = ChatColor.getByChar(style.getString("color.2")); - C.COLOR_3 = ChatColor.getByChar(style.getString("color.3")); - C.COLOR_4 = ChatColor.getByChar(style.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()) { - log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue())); + 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(style.getString("color.1")); + C.COLOR_2 = ChatColor.getByChar(style.getString("color.2")); + C.COLOR_3 = ChatColor.getByChar(style.getString("color.3")); + C.COLOR_4 = ChatColor.getByChar(style.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()) { + log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue())); + } } } - } private static void setupStyle() { style.set("version", VERSION); @@ -840,11 +796,11 @@ public class PlotSquared { } } } - + public static double getJavaVersion() { return Double.parseDouble(System.getProperty("java.specification.version")); } - + public static Set getPlotWorlds() { return plotworlds.keySet(); } 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 a49188996..8fdceb51d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; @@ -45,7 +44,7 @@ public class Auto extends SubCommand { public Auto() { super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true); } - + public static PlotId getNextPlot(final PlotId id, final int step) { final int absX = Math.abs(id.x); final int absY = Math.abs(id.y); @@ -74,7 +73,7 @@ public class Auto extends SubCommand { return new PlotId(id.x + 1, id.y); } } - + // TODO auto claim a mega plot with schematic @Override public boolean execute(final Player plr, final String... args) { @@ -121,7 +120,6 @@ public class Auto extends SubCommand { // return false; } } - if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) { PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); return false; @@ -161,42 +159,40 @@ public class Auto extends SubCommand { } // } } - String worldname = world.getName(); - PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); + final String worldname = world.getName(); + final PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); if (plotworld.TYPE == 2) { - Location loc = BukkitUtil.getLocation(plr); - Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); - if (plot == null) { - return sendMessage(plr, C.NOT_IN_PLOT); - } - PlotCluster cluster = ClusterManager.getCluster(loc); - // Must be standing in a cluster - if (cluster == null) { + final Location loc = BukkitUtil.getLocation(plr); + final Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + if (plot == null) { + return sendMessage(plr, C.NOT_IN_PLOT); + } + final PlotCluster cluster = ClusterManager.getCluster(loc); + // Must be standing in a cluster + if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } - PlotId bot = cluster.getP1(); - PlotId top = cluster.getP2(); - PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); - PlotId id = new PlotId(0, 0); - int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1); - int max = width * width; - // - for (int i = 0; i <= max; i++) { - PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); - Plot current = PlotHelper.getPlot(worldname, currentId); - if (current != null && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) { - Claim.claimPlot(plr, current, true, true); - return true; - } - id = getNextPlot(id, 1); - } - - // no free plots - PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS); - return false; + final PlotId bot = cluster.getP1(); + final PlotId top = cluster.getP2(); + final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); + PlotId id = new PlotId(0, 0); + final int width = Math.max((top.x - bot.x) + 1, (top.y - bot.y) + 1); + final int max = width * width; + // + for (int i = 0; i <= max; i++) { + final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); + final Plot current = PlotHelper.getPlot(worldname, currentId); + if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) { + Claim.claimPlot(plr, current, true, true); + return true; + } + id = getNextPlot(id, 1); + } + // no free plots + PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS); + return false; } - boolean br = false; if ((size_x == 1) && (size_z == 1)) { while (!br) { @@ -239,12 +235,11 @@ public class Auto extends SubCommand { PlotHelper.lastPlot.put(worldname, new PlotId(0, 0)); return true; } - - public PlotId getLastPlot(String world) { - if (PlotHelper.lastPlot == null || !PlotHelper.lastPlot.containsKey(world)) { - PlotHelper.lastPlot.put(world, new PlotId(0,0)); - } - return PlotHelper.lastPlot.get(world); - } + public PlotId getLastPlot(final String world) { + if ((PlotHelper.lastPlot == null) || !PlotHelper.lastPlot.containsKey(world)) { + PlotHelper.lastPlot.put(world, new PlotId(0, 0)); + } + return PlotHelper.lastPlot.get(world); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java index b55153375..31c43dcef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java @@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class Ban extends SubCommand { - public Ban() { super(Command.BAN, "Alias for /plot denied add", "/plot ban [player]", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { 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 67a0d5798..c4d31f562 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; @@ -42,32 +41,29 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class Buy extends SubCommand { - public Buy() { super(Command.BUY, "Buy the plot you are standing on", "b", CommandCategory.CLAIMING, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlotSquared.useEconomy) { return sendMessage(plr, C.ECON_DISABLED); } - World world = plr.getWorld(); + final World world = plr.getWorld(); if (!PlotSquared.isPlotWorld(world)) { return sendMessage(plr, C.NOT_IN_PLOT_WORLD); } Plot plot; if (args.length > 0) { try { - String[] split = args[0].split(";"); - PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + final String[] split = args[0].split(";"); + final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); plot = PlotHelper.getPlot(world, id); - } - catch (Exception e) { + } catch (final Exception e) { return sendMessage(plr, C.NOT_VALID_PLOT_ID); } - } - else { + } else { plot = PlayerFunctions.getCurrentPlot(plr); } if (plot == null) { @@ -82,16 +78,16 @@ public class Buy extends SubCommand { if (plot.owner.equals(UUIDHandler.getUUID(plr))) { return sendMessage(plr, C.CANNOT_BUY_OWN); } - Flag flag = FlagManager.getPlotFlag(plot, "price"); + final Flag flag = FlagManager.getPlotFlag(plot, "price"); if (flag == null) { return sendMessage(plr, C.NOT_FOR_SALE); } double initPrice = (double) flag.getValue(); double price = initPrice; - PlotId id = plot.id; - PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; - int size = PlayerFunctions.getPlotSelectionIds(id, id2).size(); - PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotId id = plot.id; + final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; + final int size = PlayerFunctions.getPlotSelectionIds(id, id2).size(); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (plotworld.USE_ECONOMY) { price += plotworld.PLOT_PRICE * size; initPrice += plotworld.SELL_PRICE * size; @@ -104,7 +100,7 @@ public class Buy extends SubCommand { economy.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); - Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner); + final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner); if (owner != null) { sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); } 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 a33e0bf26..82ac5733c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; @@ -41,19 +40,18 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class Claim extends SubCommand { - public Claim() { super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true); } - + public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final boolean auto) { return claimPlot(player, plot, teleport, "", auto); } - + public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) { - if (plot.hasOwner() || plot.settings.isMerged()) { - return false; - } + if (plot.hasOwner() || plot.settings.isMerged()) { + return false; + } final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -63,11 +61,9 @@ public class Claim extends SubCommand { if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } - World world = plot.world; + final World world = plot.world; final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id); - if (plotworld.SCHEMATIC_ON_CLAIM) { SchematicHandler.Schematic sch; if (schematic.equals("")) { @@ -85,7 +81,7 @@ public class Claim extends SubCommand { } return event.isCancelled(); } - + @Override public boolean execute(final Player plr, final String... args) { String schematic = ""; @@ -124,7 +120,6 @@ public class Claim extends SubCommand { } } } - return !claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED); } } 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 a1a4a127f..82e63b284 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; @@ -34,11 +33,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Clear extends SubCommand { - public Clear() { super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr == null) { @@ -66,7 +64,6 @@ public class Clear extends SubCommand { } return true; } - if (!PlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } @@ -79,11 +76,8 @@ public class Clear extends SubCommand { } assert plot != null; plot.clear(plr, false); - // sign - // wall - return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java index 1ba785605..5b25afe0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -28,28 +27,22 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Clipboard extends SubCommand { - public Clipboard() { super(Command.CLIPBOARD, "View information about your current copy", "clipboard", CommandCategory.INFO, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!currentSelection.containsKey(plr.getName())) { return sendMessage(plr, C.NO_CLIPBOARD); } final PlotSelection selection = currentSelection.get(plr.getName()); - final PlotId plotId = selection.getPlot().getId(); final int width = selection.getWidth(); final int total = selection.getBlocks().length; - String message = C.CLIPBOARD_INFO.s(); - message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + ""); - PlayerFunctions.sendMessage(plr, message); - return true; } } 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 b4753d0dd..7a5ee1227 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -47,21 +46,19 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Cluster extends SubCommand { - public Cluster() { super(Command.CLUSTER, "Manage a plot cluster", "cluster", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome - if (args.length == 0) { // return arguments PlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); return false; } - String sub = args[0].toLowerCase(); + final String sub = args[0].toLowerCase(); switch (sub) { case "l": case "list": { @@ -73,21 +70,18 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list"); return false; } - HashSet clusters = ClusterManager.getClusters(plr.getWorld()); + final HashSet clusters = ClusterManager.getClusters(plr.getWorld()); PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); - for (PlotCluster cluster : clusters) { + for (final PlotCluster cluster : clusters) { // Ignore unmanaged clusters - String name = "'" + cluster.getName() + "' : " + cluster.toString(); + final String name = "'" + cluster.getName() + "' : " + cluster.toString(); if (UUIDHandler.getUUID(plr).equals(cluster.owner)) { PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name); - } - else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) { + } else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) { PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name); - } - else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) { + } else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) { PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name); - } - else { + } else { PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString()); } } @@ -100,36 +94,36 @@ public class Cluster extends SubCommand { return false; } if (args.length != 4) { - PlotId id = ClusterManager.estimatePlotId(plr.getLocation()); + final PlotId id = ClusterManager.estimatePlotId(plr.getLocation()); PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create "); PlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id); return false; } // check pos1 / pos2 - PlotId pos1 = PlotHelper.parseId(args[2]); - PlotId pos2 = PlotHelper.parseId(args[3]); - if (pos1 == null || pos2 == null) { + final PlotId pos1 = PlotHelper.parseId(args[2]); + final PlotId pos2 = PlotHelper.parseId(args[3]); + if ((pos1 == null) || (pos2 == null)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } // check if name is taken - String name = args[1]; - for (PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) { + final String name = args[1]; + for (final PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) { if (name.equals(cluster.getName())) { PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); - return false; + return false; } } //check if overlap - PlotClusterId id = new PlotClusterId(pos1, pos2); - HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); - if (intersects.size() > 0 || pos2.x < pos1.x || pos2.y < pos1.y) { + final PlotClusterId id = new PlotClusterId(pos1, pos2); + final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); + if ((intersects.size() > 0) || (pos2.x < pos1.x) || (pos2.y < pos1.y)) { PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + ""); - return false; + return false; } // create cluster - String world = plr.getWorld().getName(); - PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr)); + final String world = plr.getWorld().getName(); + final PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr)); cluster.settings.setAlias(name); DBFunc.createCluster(world, cluster); if (!ClusterManager.clusters.containsKey(world)) { @@ -137,8 +131,8 @@ public class Cluster extends SubCommand { } ClusterManager.clusters.get(world).add(cluster); // Add any existing plots to the current cluster - for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { - PlotCluster current = ClusterManager.getCluster(plot); + for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { + final PlotCluster current = ClusterManager.getCluster(plot); if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { cluster.invited.add(plot.owner); DBFunc.setInvited(world, cluster, plot.owner); @@ -158,7 +152,7 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); return false; } - if (args.length != 1 && args.length != 2) { + if ((args.length != 1) && (args.length != 2)) { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); return false; } @@ -169,8 +163,7 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } - } - else { + } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); @@ -183,23 +176,23 @@ public class Cluster extends SubCommand { return false; } } - PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld()); + final PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld()); if (plotworld.TYPE == 2) { - ArrayList toRemove = new ArrayList<>(); - for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { - PlotCluster other = ClusterManager.getCluster(plot); + final ArrayList toRemove = new ArrayList<>(); + for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { + final PlotCluster other = ClusterManager.getCluster(plot); if (cluster.equals(other)) { toRemove.add(plot); } } - for (Plot plot : toRemove) { + for (final Plot plot : toRemove) { DBFunc.delete(plot.world, plot); } } DBFunc.delete(cluster); if (plotworld.TYPE == 2) { - for (Iterator iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) { - BlockPopulator populator = iterator.next(); + for (final Iterator iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) { + final BlockPopulator populator = iterator.next(); if (populator instanceof AugmentedPopulator) { if (((AugmentedPopulator) populator).cluster.equals(cluster)) { iterator.remove(); @@ -207,7 +200,7 @@ public class Cluster extends SubCommand { } } } - for (String set : ClusterManager.clusters.keySet()) { + for (final String set : ClusterManager.clusters.keySet()) { } ClusterManager.last = null; ClusterManager.clusters.get(cluster.world).remove(cluster); @@ -226,14 +219,14 @@ public class Cluster extends SubCommand { return false; } // check pos1 / pos2 - PlotId pos1 = PlotHelper.parseId(args[1]); - PlotId pos2 = PlotHelper.parseId(args[2]); - if (pos1 == null || pos2 == null) { + final PlotId pos1 = PlotHelper.parseId(args[1]); + final PlotId pos2 = PlotHelper.parseId(args[2]); + if ((pos1 == null) || (pos2 == null)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } // check if in cluster - PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; @@ -245,11 +238,11 @@ public class Cluster extends SubCommand { } } //check if overlap - PlotClusterId id = new PlotClusterId(pos1, pos2); - HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); + final PlotClusterId id = new PlotClusterId(pos1, pos2); + final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); if (intersects.size() > 1) { PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + ""); - return false; + return false; } // resize cluster DBFunc.resizeCluster(cluster, id); @@ -263,7 +256,7 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen"); return false; } - if (args.length != 1 && args.length != 2) { + if ((args.length != 1) && (args.length != 2)) { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]"); return false; } @@ -274,8 +267,7 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } - } - else { + } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); @@ -292,8 +284,8 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.CLUSTER_REGENERATED); return true; } - case "add": - case "inv": + case "add": + case "inv": case "invite": { if (!BukkitMain.hasPermission(plr, "plots.cluster.invite")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite"); @@ -304,7 +296,7 @@ public class Cluster extends SubCommand { return false; } // check if in cluster - PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; @@ -316,7 +308,7 @@ public class Cluster extends SubCommand { } } // check uuid - UUID uuid = UUIDHandler.getUUID(args[1]); + final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; @@ -324,9 +316,9 @@ public class Cluster extends SubCommand { if (!cluster.hasRights(uuid)) { // add the user if not added cluster.invited.add(uuid); - String world = plr.getWorld().getName(); + final String world = plr.getWorld().getName(); DBFunc.setInvited(world, cluster, uuid); - Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { PlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); } @@ -345,7 +337,7 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick "); return false; } - PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; @@ -357,7 +349,7 @@ public class Cluster extends SubCommand { } } // check uuid - UUID uuid = UUIDHandler.getUUID(args[1]); + final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; @@ -373,14 +365,14 @@ public class Cluster extends SubCommand { } cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); - Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { PlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } - for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { - PlotCluster current = ClusterManager.getCluster(plot); - if (current != null && current.equals(cluster)) { - String world = plr.getWorld().getName(); + for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { + final PlotCluster current = ClusterManager.getCluster(plot); + if ((current != null) && current.equals(cluster)) { + final String world = plr.getWorld().getName(); DBFunc.delete(world, plot); } } @@ -393,7 +385,7 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); return false; } - if (args.length != 1 && args.length != 2) { + if ((args.length != 1) && (args.length != 2)) { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); return false; } @@ -404,15 +396,14 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } - } - else { + } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } - UUID uuid = UUIDHandler.getUUID(plr); + final UUID uuid = UUIDHandler.getUUID(plr); if (!cluster.hasRights(uuid)) { PlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED); return false; @@ -428,10 +419,10 @@ public class Cluster extends SubCommand { cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); - for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { - PlotCluster current = ClusterManager.getCluster(plot); - if (current != null && current.equals(cluster)) { - String world = plr.getWorld().getName(); + for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { + final PlotCluster current = ClusterManager.getCluster(plot); + if ((current != null) && current.equals(cluster)) { + final String world = plr.getWorld().getName(); DBFunc.delete(world, plot); } } @@ -448,12 +439,12 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); return false; } - PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } - UUID uuid = UUIDHandler.getUUID(args[2]); + final UUID uuid = UUIDHandler.getUUID(args[2]); if (uuid == null) { PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; @@ -480,12 +471,12 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp "); return false; } - PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + final PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } - UUID uuid = UUIDHandler.getUUID(plr); + final UUID uuid = UUIDHandler.getUUID(plr); if (!cluster.hasRights(uuid)) { if (!BukkitMain.hasPermission(plr, "plots.cluster.tp.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); @@ -503,7 +494,7 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); return false; } - if (args.length != 1 && args.length != 2) { + if ((args.length != 1) && (args.length != 2)) { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); return false; } @@ -514,30 +505,27 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } - } - else { + } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } - String id = cluster.toString(); + final String id = cluster.toString(); String owner = UUIDHandler.getName(cluster.owner); if (owner == null) { owner = "unknown"; } - String name = cluster.getName(); - String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1); - String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + ""; - + final String name = cluster.getName(); + final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1); + final String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + ""; String message = C.CLUSTER_INFO.s(); message = message.replaceAll("%id%", id); message = message.replaceAll("%owner%", owner); message = message.replaceAll("%name%", name); message = message.replaceAll("%size%", size); message = message.replaceAll("%rights%", rights); - PlayerFunctions.sendMessage(plr, message); return true; } @@ -548,11 +536,11 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); return false; } - if (args.length != 1 && args.length != 2) { + if ((args.length != 1) && (args.length != 2)) { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); return false; } - PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; @@ -563,10 +551,10 @@ public class Cluster extends SubCommand { return false; } } - Location base = ClusterManager.getClusterBottom(cluster); + final Location base = ClusterManager.getClusterBottom(cluster); base.setY(0); - Location relative = plr.getLocation().subtract(base); - BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); + final Location relative = plr.getLocation().subtract(base); + final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); cluster.settings.setPosition(blockloc); DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); return PlayerFunctions.sendMessage(plr, C.POSITION_SET); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 48c3b8a8c..5ed37a89b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; /** @@ -28,7 +27,6 @@ package com.intellectualcrafters.plot.commands; * @author Empire92 */ public enum Command { - // TODO new commands // (economy) // - /plot buy @@ -39,7 +37,7 @@ public enum Command { FLAG("flag", "f"), TARGET("target"), CLUSTER("cluster", "clusters"), - BUY("buy","b"), + BUY("buy", "b"), CREATEROADSCHEMATIC("createroadschematic"), DEBUGROADREGEN("debugroadregen"), DEBUGFIXFLAGS("debugfixflags"), @@ -77,22 +75,19 @@ public enum Command { UNBAN("unban", "unblock"), DATABASE("database", "convert"), TP("tp", "tp"); - /** * Command */ private final String command; - /** * Alias */ private final String alias; - /** * Permission Node */ private final CommandPermission permission; - + /** * @param command Command "name" (/plot [cmd]) */ @@ -101,7 +96,7 @@ public enum Command { this.alias = command; this.permission = new CommandPermission("plots." + command); } - + /** * @param command Command "name" (/plot [cmd]) * @param permission Command Permission Node @@ -111,7 +106,7 @@ public enum Command { this.permission = permission; this.alias = command; } - + /** * @param command Command "name" (/plot [cmd]) * @param alias Command Alias @@ -121,7 +116,7 @@ public enum Command { this.alias = alias; this.permission = new CommandPermission("plots." + command); } - + /** * @param command Command "name" (/plot [cmd]) * @param alias Command Alias @@ -132,21 +127,21 @@ public enum Command { this.alias = alias; this.permission = permission; } - + /** * @return command */ public String getCommand() { return this.command; } - + /** * @return alias */ public String getAlias() { return this.alias; } - + /** * @return permission object * 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 f104798a3..b93041ab4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -31,19 +30,18 @@ import com.intellectualcrafters.plot.BukkitMain; * @author Citymonstret */ public class CommandPermission { - /** * Permission Node */ public final String permission; - + /** * @param permission Command Permission */ public CommandPermission(final String permission) { this.permission = permission.toLowerCase(); } - + /** * @param player Does the player have the 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 f05d92945..927a5f2db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.Arrays; @@ -35,11 +34,10 @@ import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Comment extends SubCommand { - public Comment() { super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { @@ -49,11 +47,8 @@ public class Comment extends SubCommand { if (!plot.hasOwner()) { return sendMessage(plr, C.NOT_IN_PLOT); } - final List recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone"); - if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) { - if (BukkitMain.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())); 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 db047b480..8927ac563 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -40,27 +39,25 @@ import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Condense extends SubCommand { - public static boolean TASK = false; - private static int TASK_ID = 0; public Condense() { super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr != null) { PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; } - if (args.length != 2 && args.length != 3) { + if ((args.length != 2) && (args.length != 3)) { PlayerFunctions.sendMessage(plr, "/plot condense [radius]"); return false; } - String worldname = args[0]; + final String worldname = args[0]; final World world = Bukkit.getWorld(worldname); - if (world == null || !PlotSquared.isPlotWorld(worldname)) { + if ((world == null) || !PlotSquared.isPlotWorld(worldname)) { PlayerFunctions.sendMessage(plr, "INVALID WORLD"); return false; } @@ -82,19 +79,19 @@ public class Condense extends SubCommand { PlayerFunctions.sendMessage(plr, "INVALID RADIUS"); return false; } - int radius = Integer.parseInt(args[2]); - Collection plots = PlotSquared.getPlots(worldname).values(); - int size = plots.size(); - int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1); + final int radius = Integer.parseInt(args[2]); + final Collection plots = PlotSquared.getPlots(worldname).values(); + final int size = plots.size(); + final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); return false; } final List to_move = new ArrayList<>(getPlots(plots, radius)); final List free = new ArrayList<>(); - PlotId start = new PlotId(0,0); - while (start.x <= minimum_radius && start.y <= minimum_radius) { - Plot plot = PlotHelper.getPlot(world, start); + PlotId start = new PlotId(0, 0); + while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) { + final Plot plot = PlotHelper.getPlot(world, start); if (!plot.hasOwner()) { free.add(plot.id); } @@ -110,25 +107,25 @@ public class Condense extends SubCommand { to_move.remove(0); free.remove(0); int index = 0; - for (PlotId id : to_move) { - Plot plot = PlotHelper.getPlot(world, id); + for (final PlotId id : to_move) { + final Plot plot = PlotHelper.getPlot(world, id); if (plot.hasOwner()) { break; } index++; } - for (int i = 0; i plots = PlotSquared.getPlots(worldname).values(); - int size = plots.size(); - int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1); + final int radius = Integer.parseInt(args[2]); + final Collection plots = PlotSquared.getPlots(worldname).values(); + final int size = plots.size(); + final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); return false; } - int max_move = getPlots(plots, minimum_radius).size(); - int user_move = getPlots(plots, radius).size(); + final int max_move = getPlots(plots, minimum_radius).size(); + final int user_move = getPlots(plots, radius).size(); PlayerFunctions.sendMessage(plr, "=== DEFAULT EVAL ==="); PlayerFunctions.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius); PlayerFunctions.sendMessage(plr, "MAXIMUM MOVES: " + max_move); @@ -192,10 +189,10 @@ public class Condense extends SubCommand { return false; } - public Set getPlots(Collection plots, int radius) { - HashSet outside = new HashSet<>(); - for (Plot plot : plots) { - if (plot.id.x > radius || plot.id.x < -radius || plot.id.y > radius || plot.id.y < -radius) { + public Set getPlots(final Collection plots, final int radius) { + final HashSet outside = new HashSet<>(); + for (final Plot plot : plots) { + if ((plot.id.x > radius) || (plot.id.x < -radius) || (plot.id.y > radius) || (plot.id.y < -radius)) { outside.add(plot.id); } } @@ -205,5 +202,4 @@ public class Condense extends SubCommand { public static void sendMessage(final String message) { PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index f04c6138c..595b6ec72 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -31,11 +30,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Copy extends SubCommand { - public Copy() { super(Command.COPY, "Copy a plot", "copy", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { 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 514c87d0f..24b37bf43 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -32,31 +31,24 @@ import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class CreateRoadSchematic extends SubCommand { - public CreateRoadSchematic() { super(Command.CREATEROADSCHEMATIC, "Add a road schematic to your world using the road around your current plot", "crs", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final Player player, final String... args) { - if (!PlayerFunctions.isInPlot(player)) { PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return false; } - if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - final Plot plot = PlayerFunctions.getCurrentPlot(player); - - HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); - + final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); PlotHelper.update(BukkitUtil.getLocation(entity)); PlayerFunctions.sendMessage(player, "&6Saved new road schematic"); - return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java index 42e502f1f..884208be4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java @@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class DEOP extends SubCommand { - public DEOP() { super(Command.DEOP, "Alias for /plot trusted remove", "/plot deop [player]", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { 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 8f33c9a73..a610d6481 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -24,13 +24,12 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class Database extends SubCommand { - - final String[] tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"}; - + final String[] tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" }; + public Database() { super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false); } - + private static boolean sendMessageU(final UUID uuid, final String msg) { if (uuid == null) { PlotSquared.log(msg); @@ -44,7 +43,7 @@ public class Database extends SubCommand { } return true; } - + public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) { final java.util.Set plots = PlotSquared.getPlots(); TaskManager.runTaskAsync(new Runnable() { @@ -70,13 +69,13 @@ public class Database extends SubCommand { } }); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { return sendMessage(plr, "/plot database [sqlite/mysql]"); } - final String type = new StringComparison(args[0], new String[]{"mysql", "sqlite"}).getBestMatch().toLowerCase(); + final String type = new StringComparison(args[0], new String[] { "mysql", "sqlite" }).getBestMatch().toLowerCase(); switch (type) { case "mysql": if (args.length < 6) { @@ -137,7 +136,7 @@ public class Database extends SubCommand { } return false; } - + private boolean sendMessage(final Player player, final String msg) { if (player == null) { PlotSquared.log(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 4e6b0bac1..12f78918c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; @@ -33,11 +32,10 @@ import com.intellectualcrafters.plot.util.RUtils; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Debug extends SubCommand { - public Debug() { super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player plr, final String... args) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { @@ -90,11 +88,11 @@ public class Debug extends SubCommand { } return true; } - + private String getSection(final String line, final String val) { return line.replaceAll("%val%", val) + "\n"; } - + private String getLine(final String line, final String var, final Object val) { return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n"; } 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 0b71855b4..1e061579f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -50,16 +49,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class DebugClaimTest extends SubCommand { - public DebugClaimTest() { super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false); } - + @SuppressWarnings("unused") public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) { return claimPlot(player, plot, teleport, ""); } - + public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) { final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true); Bukkit.getPluginManager().callEvent(event); @@ -73,7 +71,7 @@ public class DebugClaimTest extends SubCommand { } return event.isCancelled(); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr == null) { @@ -84,13 +82,10 @@ public class DebugClaimTest extends SubCommand { if ((world == null) || !PlotSquared.isPlotWorld(world)) { return !PlayerFunctions.sendMessage(null, "&cInvalid plot world!"); } - PlotId min, max; - try { final String[] split1 = args[1].split(";"); final String[] split2 = args[2].split(";"); - min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1])); max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1])); } catch (final Exception e) { @@ -98,12 +93,9 @@ 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 = 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 = PlotSquared.getPlots(world).containsKey(plot.id); @@ -111,18 +103,14 @@ public class DebugClaimTest extends SubCommand { PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id); continue; } - final Location loc = manager.getSignLoc(world, plotworld, plot); - final Chunk chunk = world.getChunkAt(loc); - if (!chunk.isLoaded()) { final boolean result = chunk.load(false); if (!result) { continue; } } - final Block block = world.getBlockAt(loc); if (block != null) { if (block.getState() instanceof Sign) { @@ -130,11 +118,8 @@ public class DebugClaimTest extends SubCommand { String line = sign.getLine(2); if ((line != null) && (line.length() > 2)) { line = line.substring(2); - final BiMap map = UUIDHandler.getUuidMap(); - UUID uuid = (map.get(new StringWrapper(line))); - if (uuid == null) { for (final StringWrapper string : map.keySet()) { if (string.value.toLowerCase().startsWith(line.toLowerCase())) { @@ -158,22 +143,17 @@ public class DebugClaimTest extends SubCommand { } } } - if (plots.size() > 0) { PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!"); DBFunc.createPlots(plots); DBFunc.createAllSettingsAndHelpers(plots); - for (final Plot plot : plots) { PlotSquared.updatePlot(plot); } - PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); - } else { PlayerFunctions.sendMessage(null, "No plots were found for the given search."); } - } 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/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index e4dc89bdf..214026a95 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; @@ -38,11 +37,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugClear extends SubCommand { - public DebugClear() { super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr == null) { @@ -62,9 +60,9 @@ public class DebugClear extends SubCommand { if (plot == null) { PlotSquared.log("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); - Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id); + final World bukkitWorld = Bukkit.getWorld(world); + final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); + final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id); if (PlotHelper.runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return false; @@ -84,7 +82,6 @@ public class DebugClear extends SubCommand { } return true; } - if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getWorldSettings(plr.getWorld()) instanceof SquarePlotWorld)) { return sendMessage(plr, C.NOT_IN_PLOT); } @@ -96,9 +93,9 @@ public class DebugClear extends SubCommand { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - World bukkitWorld = plr.getWorld(); - Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); - Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id); + final World bukkitWorld = plr.getWorld(); + final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); + final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id); if (PlotHelper.runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return false; @@ -111,11 +108,8 @@ public class DebugClear extends SubCommand { PlayerFunctions.sendMessage(plr, "&aDone!"); } }); - // sign - // wall - return true; } } 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 e79c8edf4..dbccadcec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.io.File; @@ -46,100 +45,94 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugExec extends SubCommand { - - private ArrayList chunks = null; - private World world; - public DebugExec() { - super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false); + super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player player, final String... args) { - List allowed_params = Arrays.asList(new String[]{"stop-expire","start-expire", "show-expired", "update-expired", "seen", "trim-check"}); + final List allowed_params = Arrays.asList(new String[] { "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check" }); if (args.length > 0) { - String arg = args[0].toLowerCase(); - switch (arg) { - case "stop-expire": { - if (ExpireManager.task != -1) { - Bukkit.getScheduler().cancelTask(ExpireManager.task); - } - else { - return PlayerFunctions.sendMessage(null, "Task already halted"); - } - ExpireManager.task = -1; - return PlayerFunctions.sendMessage(null, "Cancelled task."); - } - case "start-expire": { - if (ExpireManager.task == -1) { - ExpireManager.runTask(); - } - else { - return PlayerFunctions.sendMessage(null, "Plot expiry task already started"); - } - return PlayerFunctions.sendMessage(null, "Started plot expiry task"); - } - case "update-expired": { - if (args.length > 1) { - World world = Bukkit.getWorld(args[1]); - if (world == null) { - return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]); - } - PlayerFunctions.sendMessage(null, "Updating expired plot list"); - ExpireManager.updateExpired(args[1]); - return true; - } - return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired "); - } - case "show-expired": { - if (args.length > 1) { - World world = Bukkit.getWorld(args[1]); - if (world == null || !ExpireManager.expiredPlots.containsKey(args[1])) { - return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]); - } - PlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):"); - for (Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { - Plot plot = entry.getKey(); - Long stamp = entry.getValue(); - PlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) +" : " + stamp); - } - return true; - } - return PlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired "); - } - case "seen": { - if (args.length != 2) { - return PlayerFunctions.sendMessage(null, "Use /plot debugexec seen "); - } - UUID uuid = UUIDHandler.getUUID(args[1]); - if (uuid == null) { - return PlayerFunctions.sendMessage(null, "player not found: " + args[1]); - } - OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if (op == null || !op.hasPlayedBefore()) { - return PlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]); - } - Timestamp stamp = new Timestamp(op.getLastPlayed()); - Date date = new Date(stamp.getTime()); - PlayerFunctions.sendMessage(null, "PLAYER: " + args[1]); - PlayerFunctions.sendMessage(null, "UUID: " + uuid); - PlayerFunctions.sendMessage(null, "Object: " + date.toGMTString()); - PlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString()); - PlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString()); - return true; - } - case "trim-check": { - if (args.length != 2) { - PlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check "); - PlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim"); - return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run"); - } - final World world = Bukkit.getWorld(args[1]); - if (world == null || !PlotSquared.isPlotWorld(args[1])) { - return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]); + final String arg = args[0].toLowerCase(); + switch (arg) { + case "stop-expire": { + if (ExpireManager.task != -1) { + Bukkit.getScheduler().cancelTask(ExpireManager.task); + } else { + return PlayerFunctions.sendMessage(null, "Task already halted"); } - final ArrayList empty = new ArrayList<>(); - boolean result = Trim.getTrimRegions(empty, world, new Runnable() { + ExpireManager.task = -1; + return PlayerFunctions.sendMessage(null, "Cancelled task."); + } + case "start-expire": { + if (ExpireManager.task == -1) { + ExpireManager.runTask(); + } else { + return PlayerFunctions.sendMessage(null, "Plot expiry task already started"); + } + return PlayerFunctions.sendMessage(null, "Started plot expiry task"); + } + case "update-expired": { + if (args.length > 1) { + final World world = Bukkit.getWorld(args[1]); + if (world == null) { + return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + } + PlayerFunctions.sendMessage(null, "Updating expired plot list"); + ExpireManager.updateExpired(args[1]); + return true; + } + return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired "); + } + case "show-expired": { + if (args.length > 1) { + final World world = Bukkit.getWorld(args[1]); + if ((world == null) || !ExpireManager.expiredPlots.containsKey(args[1])) { + return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + } + PlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):"); + for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { + final Plot plot = entry.getKey(); + final Long stamp = entry.getValue(); + PlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); + } + return true; + } + return PlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired "); + } + case "seen": { + if (args.length != 2) { + return PlayerFunctions.sendMessage(null, "Use /plot debugexec seen "); + } + final UUID uuid = UUIDHandler.getUUID(args[1]); + if (uuid == null) { + return PlayerFunctions.sendMessage(null, "player not found: " + args[1]); + } + final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); + if ((op == null) || !op.hasPlayedBefore()) { + return PlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]); + } + final Timestamp stamp = new Timestamp(op.getLastPlayed()); + final Date date = new Date(stamp.getTime()); + PlayerFunctions.sendMessage(null, "PLAYER: " + args[1]); + PlayerFunctions.sendMessage(null, "UUID: " + uuid); + PlayerFunctions.sendMessage(null, "Object: " + date.toGMTString()); + PlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString()); + PlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString()); + return true; + } + case "trim-check": { + if (args.length != 2) { + PlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check "); + PlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim"); + return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run"); + } + final World world = Bukkit.getWorld(args[1]); + if ((world == null) || !PlotSquared.isPlotWorld(args[1])) { + return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + } + final ArrayList empty = new ArrayList<>(); + final boolean result = Trim.getTrimRegions(empty, world, new Runnable() { @Override public void run() { Trim.sendMessage("Processing is complete! Here's how many chunks would be deleted:"); @@ -150,13 +143,13 @@ public class DebugExec extends SubCommand { PrintWriter writer; try { writer = new PrintWriter(file); - String worldname = world.getName(); - for (ChunkLoc loc : empty) { - writer.println(worldname +"/region/r." + loc.x + "." + loc.z +".mca" ); + final String worldname = world.getName(); + for (final ChunkLoc loc : empty) { + writer.println(worldname + "/region/r." + loc.x + "." + loc.z + ".mca"); } writer.close(); Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'"); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { e.printStackTrace(); Trim.sendMessage("File failed to save! :("); } @@ -166,14 +159,14 @@ public class DebugExec extends SubCommand { Trim.sendMessage(" - Add 31 to each number to get the end position"); } }); - if (!result) { - PlayerFunctions.sendMessage(null, "Trim task already started!"); - } - return result; - } - } + if (!result) { + PlayerFunctions.sendMessage(null, "Trim task already started!"); + } + return result; + } + } } - PlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); + PlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); return true; } } 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 86db84da9..8f740f6c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -38,11 +37,10 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class DebugFixFlags extends SubCommand { - public DebugFixFlags() { super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr != null) { @@ -53,22 +51,22 @@ public class DebugFixFlags extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags "); return false; } - World world = Bukkit.getWorld(args[0]); - if (world == null || !PlotSquared.isPlotWorld(world)) { + final World world = Bukkit.getWorld(args[0]); + 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 : PlotSquared.getPlots(world).values()) { - Set flags = plot.settings.flags; - ArrayList toRemove = new ArrayList(); - for (Flag flag : flags) { - AbstractFlag af = FlagManager.getFlag(flag.getKey()); + for (final Plot plot : PlotSquared.getPlots(world).values()) { + final Set flags = plot.settings.flags; + final ArrayList toRemove = new ArrayList(); + for (final Flag flag : flags) { + final AbstractFlag af = FlagManager.getFlag(flag.getKey()); if (af == null) { toRemove.add(flag); } } - for (Flag flag : toRemove) { + for (final Flag flag : toRemove) { plot.settings.flags.remove(flag); } if (toRemove.size() > 0) { @@ -76,7 +74,6 @@ public class DebugFixFlags extends SubCommand { } } PlayerFunctions.sendMessage(plr, "&aDone!"); - return true; } } 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 bcdcdbe9f..6c2ebfec8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.lang.reflect.Field; @@ -33,11 +32,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class DebugLoadTest extends SubCommand { - public DebugLoadTest() { super(Command.DEBUGLOADTEST, "This debug command will force the reload of all plots in the DB", "debugloadtest", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr == null) { 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 512213e08..7d0af13c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.Arrays; @@ -34,24 +33,22 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class DebugRoadRegen extends SubCommand { - public DebugRoadRegen() { super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final Player player, final String... args) { if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); - - Chunk chunk = BukkitUtil.getLocation(entity).getChunk(); - boolean result = manager.regenerateRoad(chunk); + final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); + final Chunk chunk = BukkitUtil.getLocation(entity).getChunk(); + final boolean result = manager.regenerateRoad(chunk); if (result) { - SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] {chunk})); + SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } - PlayerFunctions.sendMessage(player, "&6Regenerating chunk: "+chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); + PlayerFunctions.sendMessage(player, "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return true; } } 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 d9157f693..cfb5816ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -34,11 +33,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class DebugSaveTest extends SubCommand { - public DebugSaveTest() { super(Command.DEBUGSAVETEST, "This debug command will force the recreation of all plots in the DB", "debugsavetest", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr == null) { 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 4165c9b7e..2fb966fa8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; @@ -35,11 +34,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Delete extends SubCommand { - public Delete() { super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { 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 7f8de1f69..26a7980cc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.UUID; @@ -34,12 +33,12 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings("deprecation") public class Denied extends SubCommand { - +@SuppressWarnings("deprecation") +public class Denied extends SubCommand { public Denied() { super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 2) { @@ -63,7 +62,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; UUID uuid; if (args[1].equalsIgnoreCase("*")) { uuid = DBFunc.everyone; - } else { uuid = UUIDHandler.getUUID(args[1]); } 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 33094ce99..24165dfe2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -40,11 +39,10 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class FlagCmd extends SubCommand { - public FlagCmd() { super(Command.FLAG, "Manage plot flags", "f", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player player, final String... args) { /* @@ -58,7 +56,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); return false; } - Plot plot = PlayerFunctions.getCurrentPlot(player); + final Plot plot = PlayerFunctions.getCurrentPlot(player); if (plot == null) { PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return false; @@ -81,7 +79,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); return false; } - AbstractFlag af = FlagManager.getFlag(args[1]); + final AbstractFlag af = FlagManager.getFlag(args[1]); if (af == null) { PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); @@ -104,7 +102,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set "); return false; } - AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); + final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; @@ -113,14 +111,14 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } - String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); - Object parsed = af.parseValueRaw(value); + final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); + final Object parsed = af.parseValueRaw(value); if (parsed == null) { PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); return false; } final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed); - boolean result = FlagManager.addPlotFlag(plot, flag); + final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); return false; @@ -134,11 +132,11 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove"); return false; } - if (args.length != 2 && args.length != 3) { + if ((args.length != 2) && (args.length != 3)) { PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove [values]"); return false; } - AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); + final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; @@ -147,18 +145,17 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } - Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()); + final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()); if (flag == null) { PlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT); return false; } - if (args.length == 3 && flag.getAbstractFlag().isList()) { - String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); + if ((args.length == 3) && flag.getAbstractFlag().isList()) { + final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); ((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value); DBFunc.setFlags(plot.world, plot, plot.settings.flags); - } - else { - boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); + } else { + final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); if (!result) { PlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED); return false; @@ -177,7 +174,7 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add "); return false; } - AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); + final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; @@ -186,20 +183,19 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } - String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); - Object parsed = af.parseValueRaw(value); + final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); + final Object parsed = af.parseValueRaw(value); if (parsed == null) { PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); return false; } Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase()); - if (flag == null || !flag.getAbstractFlag().isList()) { + if ((flag == null) || !flag.getAbstractFlag().isList()) { flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed); - } - else { + } else { ((FlagValue.ListValue) flag.getAbstractFlag().value).add(flag.getValue(), value); } - boolean result = FlagManager.addPlotFlag(plot, flag); + final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); return false; @@ -218,9 +214,9 @@ public class FlagCmd extends SubCommand { PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list"); return false; } - HashMap> flags = new HashMap<>(); - for (AbstractFlag af : FlagManager.getFlags()) { - String type = af.value.getClass().getSimpleName().replaceAll("Value", ""); + final HashMap> flags = new HashMap<>(); + for (final AbstractFlag af : FlagManager.getFlags()) { + final String type = af.value.getClass().getSimpleName().replaceAll("Value", ""); if (!flags.containsKey(type)) { flags.put(type, new ArrayList()); } @@ -228,8 +224,8 @@ public class FlagCmd extends SubCommand { } String message = ""; String prefix = ""; - for (String flag : flags.keySet()) { - message += prefix + "&6" + flag +": &7" + StringUtils.join(flags.get(flag), ", "); + for (final String flag : flags.keySet()) { + message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", "); prefix = "\n"; } PlayerFunctions.sendMessage(player, message); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java index 439d630a5..e8dac809a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java @@ -5,7 +5,6 @@ * * >> File = Help.java >> Generated by: Citymonstret at 2014-08-11 17:32 */ - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -14,7 +13,7 @@ public class Help extends SubCommand { public Help() { super("help", "", "Get this help menu", "help", "he", SubCommand.CommandCategory.INFO, false); } - + @Override public boolean execute(final Player plr, final String... args) { 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 134c233d0..997d847a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.UUID; @@ -35,11 +34,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Helpers extends SubCommand { - public Helpers() { super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 2) { 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 5e44c4d3a..54a9e19fa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -33,11 +32,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class Home extends SubCommand { - public Home() { super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT, true); } - + private Plot isAlias(final String a) { for (final Plot p : PlotSquared.getPlots()) { if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { @@ -46,7 +44,7 @@ public class Home extends SubCommand { } return null; } - + @Override public boolean execute(final Player plr, String... args) { final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]); @@ -55,7 +53,7 @@ public class Home extends SubCommand { return true; } else if (plots.length > 1) { if (args.length < 1) { - args = new String[]{"1"}; + args = new String[] { "1" }; } int id = 0; try { @@ -87,8 +85,7 @@ public class Home extends SubCommand { } } - public void teleportPlayer(Player player, Plot plot) { - PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); + public void teleportPlayer(final Player player, final Plot plot) { + PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), 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 e89a9d953..3e204817b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -39,51 +38,49 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Inbox extends SubCommand { - public Inbox() { super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { - boolean report = false; - if (args.length == 1){ - if (args[0].equalsIgnoreCase("reports")) { - report = true; - } - } + boolean report = false; + if (args.length == 1) { + if (args[0].equalsIgnoreCase("reports")) { + report = true; + } + } if (!PlayerFunctions.isInPlot(plr) && !report) { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (plot != null && !plot.hasOwner()) { + if ((plot != null) && !plot.hasOwner()) { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } - Integer tier; final UUID uuid = UUIDHandler.getUUID(plr); if (BukkitMain.hasPermission(plr, "plots.comment.admin")) { tier = 0; - } else if (plot != null && plot.owner.equals(uuid)) { + } else if ((plot != null) && plot.owner.equals(uuid)) { tier = 1; - } else if (plot != null && plot.helpers.contains(uuid)) { + } else if ((plot != null) && plot.helpers.contains(uuid)) { tier = 2; - } else if (plot != null && plot.trusted.contains(uuid)) { + } else if ((plot != null) && plot.trusted.contains(uuid)) { tier = 3; } else { tier = 4; } final boolean below; if (args.length > 0) { - below = false; + below = false; switch (args[0].toLowerCase()) { case "admin": if (tier <= 0) { tier = 0; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); return false; } break; @@ -91,7 +88,7 @@ public class Inbox extends SubCommand { if (tier <= 1) { tier = 1; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner"); + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner"); return false; } break; @@ -99,7 +96,7 @@ public class Inbox extends SubCommand { if (tier <= 2) { tier = 2; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper"); + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper"); return false; } break; @@ -107,7 +104,7 @@ public class Inbox extends SubCommand { if (tier <= 3) { tier = 3; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted"); + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted"); return false; } break; @@ -115,45 +112,40 @@ public class Inbox extends SubCommand { if (tier <= 4) { tier = 4; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone"); + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone"); return false; } break; case "reports": - if (tier <= 0) { + if (tier <= 0) { tier = -1; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); return false; } - break; + break; default: - PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[]{"admin", "owner", "helper", "trusted", "everyone"}, Math.max(0, tier), 4)); + PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4)); return false; } + } else { + below = true; } - else { - below = true; - } - final String world = plr.getWorld().getName(); final int tier2 = tier; - Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { @Override public void run() { - ArrayList comments = null; - if (tier2 == -1) { - comments = DBFunc.getComments(world, null, 0, false); - } - else { - comments = plot.settings.getComments(tier2); - } + ArrayList comments = null; + if (tier2 == -1) { + comments = DBFunc.getComments(world, null, 0, false); + } else { + comments = plot.settings.getComments(tier2); + } if (comments == null) { comments = DBFunc.getComments(world, plot, tier2, below); plot.settings.setComments(comments); } - if (args.length == 2) { final String[] split = args[1].toLowerCase().split(":"); if (!split[0].equals("clear")) { 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 32dc175c4..225f17c5a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -46,12 +45,12 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret */ -@SuppressWarnings({"javadoc"}) public class Info extends SubCommand { - +@SuppressWarnings({ "javadoc" }) +public class Info extends SubCommand { public Info() { super(Command.INFO, "Display plot info", "info", CommandCategory.INFO, false); } - + @Override public boolean execute(final Player player, String... args) { World world; @@ -87,7 +86,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } world = Bukkit.getWorld(args[0]); if (args.length == 3) { - args = new String[]{args[2]}; + args = new String[] { args[2] }; } else { args = new String[0]; } @@ -96,28 +95,23 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return false; } } - if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) { new InfoInventory(plot, player).build().display(); return true; } - final boolean hasOwner = plot.hasOwner(); boolean containsEveryone; boolean trustedEveryone; - // Wildcard player {added} { containsEveryone = (plot.helpers != null) && plot.helpers.contains(DBFunc.everyone); trustedEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone); } - // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); return true; } - String owner = "none"; if (plot.owner != null) { owner = UUIDHandler.getName(plot.owner); @@ -126,7 +120,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; owner = plot.owner.toString(); } String info = C.PLOT_INFO.s(); - if (args.length == 1) { info = getCaption(args[0].toLowerCase()); if (info == null) { @@ -134,13 +127,12 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return false; } } - info = format(info, world, plot, player); PlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER); PlayerFunctions.sendMessage(player, info, false); return true; } - + private String getCaption(final String string) { switch (string) { case "helpers": @@ -167,9 +159,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return null; } } - + private String format(String info, final World world, final Plot plot, final Player player) { - final PlotId id = plot.id; final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; final int num = PlayerFunctions.getPlotSelectionIds(id, id2).size(); @@ -181,7 +172,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; final String rating = String.format("%.1f", DBFunc.getRatings(plot)); final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none"); final boolean build = (player == null) || plot.hasRights(player); - String owner = "none"; if (plot.owner != null) { owner = UUIDHandler.getName(plot.owner); @@ -189,7 +179,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; if (owner == null) { owner = plot.owner.toString(); } - info = info.replaceAll("%alias%", alias); info = info.replaceAll("%id%", id.toString()); info = info.replaceAll("%id2%", id2.toString()); @@ -203,10 +192,9 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; info = info.replaceAll("%flags%", flags); info = info.replaceAll("%build%", build + ""); info = info.replaceAll("%desc%", "No description set."); - return info; } - + private String getPlayerList(final ArrayList l) { if ((l == null) || (l.size() < 1)) { return " none"; @@ -222,7 +210,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } return list.toString(); } - + private String getPlayerName(final UUID uuid) { if (uuid == null) { return "unknown"; @@ -230,13 +218,13 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) { return "everyone"; } - String name = UUIDHandler.getName(uuid); + final String name = UUIDHandler.getName(uuid); if (name == null) { return "unknown"; } return name; } - + private Biome getBiomeAt(final Plot plot) { final World w = Bukkit.getWorld(plot.world); final Location bl = PlotHelper.getPlotTopLoc(w, plot.id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java index 4921d16ac..119c75766 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -31,11 +30,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; public class Inventory extends SubCommand { - public Inventory() { super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO, true); } - + @Override public boolean execute(final Player plr, final String... args) { final ArrayList cmds = new ArrayList<>(); @@ -52,7 +50,7 @@ public class Inventory extends SubCommand { plr.openInventory(inventory); return true; } - + private ItemStack getItem(final SubCommand cmd) { final ItemStack stack = new ItemStack(Material.COMMAND); final ItemMeta meta = stack.getItemMeta(); 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 e7411639b..410c1c105 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; @@ -30,12 +29,12 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings({"unused", "deprecation", "javadoc"}) public class Kick extends SubCommand { - +@SuppressWarnings({ "unused", "deprecation", "javadoc" }) +public class Kick extends SubCommand { public Kick() { super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { 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 b40fdb5b4..6b27b0e37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -44,35 +43,33 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class MainCommand implements CommandExecutor, TabCompleter { - /** * Main Permission Node */ - 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() }; - + 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() { { addAll(Arrays.asList(_subCommands)); } }; - + public static boolean no_permission(final Player player, final String permission) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission); return false; } - + public static List getCommands(final SubCommand.CommandCategory category, final Player player) { final List cmds = new ArrayList<>(); for (final SubCommand c : subCommands) { - if (!c.isPlayer || player != null) { - if ((c.category.equals(category)) && c.permission.hasPermission(player)) { - cmds.add(c); - } - } + if (!c.isPlayer || (player != null)) { + if ((c.category.equals(category)) && c.permission.hasPermission(player)) { + cmds.add(c); + } + } } return cmds; } - + public static List helpMenu(final Player player, final SubCommand.CommandCategory category, int page) { List commands; if (category != null) { @@ -91,15 +88,11 @@ public class MainCommand implements CommandExecutor, TabCompleter { if (max > commands.size()) { max = commands.size(); } - final List help = new ArrayList<>(); - help.add(C.HELP_HEADER.s()); // HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"), help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size())); - SubCommand cmd; - final int start = page * perPage; for (int x = start; x < max; x++) { cmd = commands.get(x); @@ -112,19 +105,17 @@ public class MainCommand implements CommandExecutor, TabCompleter { } return help; } - + private static String t(final String s) { return ChatColor.translateAlternateColorCodes('&', s); } - + @Override 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 (!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")))) { if (args.length < 2) { final StringBuilder builder = new StringBuilder(); @@ -143,7 +134,7 @@ public class MainCommand implements CommandExecutor, TabCompleter { break; } } - if (cato == null && !cat.equalsIgnoreCase("all")) { + if ((cato == null) && !cat.equalsIgnoreCase("all")) { final StringBuilder builder = new StringBuilder(); builder.append(C.HELP_INFO.s()); for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { @@ -153,16 +144,13 @@ public class MainCommand implements CommandExecutor, TabCompleter { } final StringBuilder help = new StringBuilder(); int page = 0; - boolean digit = true; - String arg2; if (args.length > 2) { arg2 = args[2]; } else { arg2 = "1"; } - for (final char c : arg2.toCharArray()) { if (!Character.isDigit(c)) { digit = false; @@ -175,7 +163,6 @@ public class MainCommand implements CommandExecutor, TabCompleter { page = 0; } } - for (final String string : helpMenu(player, cato, page)) { help.append(string).append("\n"); } @@ -198,12 +185,10 @@ public class MainCommand implements CommandExecutor, TabCompleter { } } PlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND); - final String[] commands = new String[subCommands.size()]; for (int x = 0; x < subCommands.size(); x++) { commands[x] = subCommands.get(x).cmd; } - /* Let's try to get a proper usage string */ final String command = new StringComparison(args[0], commands).getBestMatch(); return PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); @@ -212,14 +197,13 @@ public class MainCommand implements CommandExecutor, TabCompleter { } return true; } - + @Override public List onTabComplete(final CommandSender commandSender, final Command command, final String s, final String[] strings) { if (!(commandSender instanceof Player)) { return null; } final Player player = (Player) commandSender; - if (strings.length < 1) { if ((strings.length == 0) || "plots".startsWith(s)) { return Arrays.asList("plots"); 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 80aecf2c9..bc2432b4d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -45,14 +44,13 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class Merge extends SubCommand { - - public final static String[] values = new String[]{"north", "east", "south", "west"}; - public final static String[] aliases = new String[]{"n", "e", "s", "w"}; - + public final static String[] values = new String[] { "north", "east", "south", "west" }; + public final static String[] aliases = new String[] { "n", "e", "s", "w" }; + public Merge() { super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true); } - + public static String direction(float yaw) { yaw = yaw / 90; final int i = Math.round(yaw); @@ -74,7 +72,7 @@ public class Merge extends SubCommand { return ""; } } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { @@ -86,7 +84,7 @@ public class Merge extends SubCommand { PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge"); + final boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge"); if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; @@ -128,21 +126,15 @@ public class Merge extends SubCommand { default: return false; } - - PlotId botId = plots.get(0); - PlotId topId = plots.get(plots.size() - 1); - - PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id; - PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id; - - PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id; - PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id; - + final PlotId botId = plots.get(0); + final PlotId topId = plots.get(plots.size() - 1); + final PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id; + final PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id; + final PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id; + final PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id; bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y)); top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y)); - plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top); - for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) { @@ -150,7 +142,6 @@ public class Merge extends SubCommand { return false; } } - final PlotWorld plotWorld = PlotSquared.getWorldSettings(world); if (PlotSquared.useEconomy && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; @@ -165,9 +156,7 @@ public class Merge extends SubCommand { sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } - final PlotMergeEvent event = new PlotMergeEvent(world, plot, plots); - Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { event.setCancelled(true); @@ -176,7 +165,6 @@ public class Merge extends SubCommand { } PlayerFunctions.sendMessage(plr, "&cPlots have been merged"); PlotHelper.mergePlots(world, plots, true); - PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot); PlotHelper.update(plr.getLocation()); return true; 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 0689f9234..39d78be0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.World; @@ -34,11 +33,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Empire92 */ public class Move extends SubCommand { - public Move() { super("debugmove", "plots.admin", "plot moving debug test", "debugmove", "move", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (plr == null) { @@ -48,10 +46,10 @@ public class Move extends SubCommand { PlayerFunctions.sendMessage(plr, "/plot move "); return false; } - World world = plr.getWorld(); - PlotId plot1 = PlotHelper.parseId(args[0]); - PlotId plot2 = PlotHelper.parseId(args[1]); - if (plot1 == null || plot2 == null) { + final World world = plr.getWorld(); + final PlotId plot1 = PlotHelper.parseId(args[0]); + final PlotId plot2 = PlotHelper.parseId(args[1]); + if ((plot1 == null) || (plot2 == null)) { PlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move "); return false; } @@ -66,8 +64,7 @@ public class Move extends SubCommand { } })) { return true; - } - else { + } else { PlayerFunctions.sendMessage(plr, "MOVE FAILED"); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index a9462438c..bb8720c03 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.Arrays; @@ -38,7 +37,7 @@ public class MusicSubcommand extends SubCommand { public MusicSubcommand() { super("music", "plots.music", "Play music in plot", "music", "mus", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player player, final String... args) { if (!PlayerFunctions.isInPlot(player)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java index e383b0e1f..7a7f0f4ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java @@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class OP extends SubCommand { - public OP() { super(Command.OP, "Alias for /plot trusted add", "/plot op [player]", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { 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 1ec3d2395..16c27699f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -31,11 +30,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Paste extends SubCommand { - public Paste() { super(Command.PASTE, "Paste a plot", "paste", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { @@ -53,7 +51,6 @@ public class Paste extends SubCommand { } assert plot != null; final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); - if (PlotSelection.currentSelection.containsKey(plr.getName())) { final PlotSelection selection = PlotSelection.currentSelection.get(plr.getName()); if (size != selection.getWidth()) { 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 22eed2844..94f078bf5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.Collection; @@ -38,18 +37,17 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings({"javadoc"}) public class Purge extends SubCommand { - +@SuppressWarnings({ "javadoc" }) +public class Purge extends SubCommand { public Purge() { super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false); } - - public PlotId getId(String id) { + + public PlotId getId(final String id) { try { - String[] split = id.split(";"); + final String[] split = id.split(";"); return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - } - catch (Exception e) { + } catch (final Exception e) { return null; } } @@ -61,15 +59,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return false; } if (args.length == 1) { - String arg = args[0].toLowerCase(); - PlotId id = getId(arg); + final String arg = args[0].toLowerCase(); + final PlotId id = getId(arg); if (id != null) { PlayerFunctions.sendMessage(plr, "/plot purge x;z &l"); return false; } - UUID uuid = UUIDHandler.getUUID(args[0]); + final UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - PlayerFunctions.sendMessage(plr, "/plot purge "+args[0]+" &l"); + PlayerFunctions.sendMessage(plr, "/plot purge " + args[0] + " &l"); return false; } if (arg.equals("player")) { @@ -95,68 +93,68 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); return false; } - World world = Bukkit.getWorld(args[1]); - if (world == null || !PlotSquared.isPlotWorld(world)) { + final World world = Bukkit.getWorld(args[1]); + if ((world == null) || !PlotSquared.isPlotWorld(world)) { PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD); return false; } - String worldname = world.getName(); - String arg = args[0].toLowerCase(); - PlotId id = getId(arg); + final String worldname = world.getName(); + final String arg = args[0].toLowerCase(); + final PlotId id = getId(arg); if (id != null) { - HashSet ids = new HashSet(); - int DBid = DBFunc.getId(worldname, id); + final HashSet ids = new HashSet(); + final int DBid = DBFunc.getId(worldname, id); if (DBid != Integer.MAX_VALUE) { ids.add(DBid); } DBFunc.purgeIds(worldname, ids); return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0); } - UUID uuid = UUIDHandler.getUUID(args[0]); + final UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - Set plots = PlotSquared.getPlots(world,uuid); - Set ids = new HashSet<>(); - for (Plot plot : plots) { + final Set plots = PlotSquared.getPlots(world, uuid); + final Set ids = new HashSet<>(); + for (final Plot plot : plots) { ids.add(plot.id); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } if (arg.equals("all")) { - Set ids = PlotSquared.getPlots(world).keySet(); + final Set ids = PlotSquared.getPlots(world).keySet(); if (ids.size() == 0) { - return PlayerFunctions.sendMessage(null, "&cNo plots found"); + return PlayerFunctions.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } if (arg.equals("unknown")) { - Collection plots = PlotSquared.getPlots(world).values(); - Set ids = new HashSet<>(); - for (Plot plot : plots) { + final Collection plots = PlotSquared.getPlots(world).values(); + final Set ids = new HashSet<>(); + for (final Plot plot : plots) { if (plot.owner != null) { - String name = UUIDHandler.getName(plot.owner); + final String name = UUIDHandler.getName(plot.owner); if (name == null) { ids.add(plot.id); } } } if (ids.size() == 0) { - return PlayerFunctions.sendMessage(null, "&cNo plots found"); + return PlayerFunctions.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } if (arg.equals("unowned")) { - Collection plots = PlotSquared.getPlots(world).values(); - Set ids = new HashSet<>(); - for (Plot plot : plots) { + final Collection plots = PlotSquared.getPlots(world).values(); + final Set ids = new HashSet<>(); + for (final Plot plot : plots) { if (plot.owner == null) { ids.add(plot.id); } } if (ids.size() == 0) { - return PlayerFunctions.sendMessage(null, "&cNo plots found"); + return PlayerFunctions.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); @@ -164,10 +162,9 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); return false; } - - private boolean finishPurge(int amount) { + + private boolean finishPurge(final int amount) { PlayerFunctions.sendMessage(null, C.PURGE_SUCCESS, amount + ""); return false; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 3bb333161..a66ed1a45 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -29,17 +28,16 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Rate extends SubCommand { - +@SuppressWarnings({ "unused", "deprecated", "javadoc" }) +public class Rate extends SubCommand { /* * String cmd, String permission, String description, String usage, String * alias, CommandCategory category */ - public Rate() { super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { @@ -82,7 +80,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } catch (final Exception e) { rated = false; } - if (rated) { sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString()); } 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 f6ab45617..b93c3cfeb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -35,49 +34,38 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; public class RegenAllRoads extends SubCommand { - public RegenAllRoads() { super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "rgar", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final Player player, final String... args) { - if (player != null) { sendMessage(player, C.NOT_CONSOLE); return false; } - if (args.length != 1) { sendMessage(player, C.NEED_PLOT_WORLD); return false; } - - String name = args[0]; - PlotManager manager = PlotSquared.getPlotManager(name); - - if (manager == null || !(manager instanceof HybridPlotManager)) { + final String name = args[0]; + final PlotManager manager = PlotSquared.getPlotManager(name); + if ((manager == null) || !(manager instanceof HybridPlotManager)) { sendMessage(player, C.NOT_VALID_PLOT_WORLD); return false; } - - HybridPlotManager hpm = (HybridPlotManager) manager; - - World world = Bukkit.getWorld(name); - ArrayList chunks = ChunkManager.getChunkChunks(world); - + final HybridPlotManager hpm = (HybridPlotManager) manager; + final World world = Bukkit.getWorld(name); + final ArrayList chunks = ChunkManager.getChunkChunks(world); PlotSquared.log("&cIf no schematic is set, the following will not do anything"); PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); - PlotSquared.log("&6Potential chunks to update: &7"+ (chunks.size() * 1024)); - PlotSquared.log("&6Estimated time: &7"+ (chunks.size()) + " seconds"); - - boolean result = hpm.scheduleRoadUpdate(world); - + PlotSquared.log("&6Potential chunks to update: &7" + (chunks.size() * 1024)); + PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds"); + final boolean result = hpm.scheduleRoadUpdate(world); if (!result) { PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); return false; } - return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index aa11a9d74..200e021d7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -29,11 +28,10 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Reload extends SubCommand { - public Reload() { super("reload", "plots.admin.command.reload", "Reload configurations", "", "reload", CommandCategory.INFO, false); } - + @Override public boolean execute(final Player plr, final String... args) { try { @@ -52,5 +50,4 @@ public class Reload extends SubCommand { } return true; } - } 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 04d1fbc5c..4a134b7c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.Collection; @@ -45,17 +44,16 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Schematic extends SubCommand { - private int counter = 0; private boolean running = false; private Plot[] plots; private int task; - + public Schematic() { super("schematic", "plots.schematic", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false); // TODO command to fetch schematic from worldedit directory } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { @@ -99,22 +97,17 @@ public class Schematic extends SubCommand { Schematic.this.running = false; return; } - final int x; final int z; - final Plot plot2 = PlayerFunctions.getCurrentPlot(plr); - final Dimension dem = schematic.getSchematicDimension(); final Location bot = PlotHelper.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1); final int length2 = PlotHelper.getPlotWidth(plr.getWorld(), plot2.id); - if ((dem.getX() > length2) || (dem.getZ() > length2)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2)); Schematic.this.running = false; return; } - if ((dem.getX() != length2) || (dem.getZ() != length2)) { final Location loc = plr.getLocation(); x = Math.min(length2 - dem.getX(), loc.getBlockX() - bot.getBlockX()); @@ -123,7 +116,6 @@ public class Schematic extends SubCommand { x = 0; z = 0; } - final World w = plot2.getWorld(); final DataCollection[] b = schematic.getBlockCollection(); final int sy = w.getHighestBlockYAt(bot.getBlockX(), bot.getBlockZ()); @@ -131,7 +123,6 @@ public class Schematic extends SubCommand { final int WIDTH = schematic.getSchematicDimension().getX(); final int LENGTH = schematic.getSchematicDimension().getZ(); final int blen = b.length - 1; - Schematic.this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { @Override public void run() { @@ -173,13 +164,10 @@ public class Schematic extends SubCommand { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent"); break; } - final int l1 = schematic.getSchematicDimension().getX(); final int l2 = schematic.getSchematicDimension().getZ(); - final Plot plot = PlayerFunctions.getCurrentPlot(plr); final int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id); - if ((l1 < length) || (l2 < length)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); break; @@ -205,19 +193,15 @@ public class Schematic extends SubCommand { PlayerFunctions.sendMessage(null, "&cTask is already running."); return false; } - PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); final World worldObj = Bukkit.getWorld(args[1]); final String worldname = Bukkit.getWorld(args[1]).getName(); - final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); - final Collection values = plotmap.values(); this.plots = values.toArray(new Plot[values.size()]); this.running = true; this.counter = 0; - this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { @@ -295,13 +279,10 @@ public class Schematic extends SubCommand { return false; } } - final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); - - this.plots = new Plot[]{p2}; + this.plots = new Plot[] { p2 }; this.running = true; this.counter = 0; - this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin2, new Runnable() { @Override public void run() { 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 f2b1d314b..38625d8c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.Arrays; @@ -56,14 +55,13 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class Set extends SubCommand { - - public final static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"}; - public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"}; - + public final static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "flag" }; + public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" }; + public Set() { super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true); } - + @SuppressWarnings("deprecation") @Override public boolean execute(final Player plr, final String... args) { @@ -96,7 +94,6 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); return false; } - if (args[0].equalsIgnoreCase("flag")) { if (args.length < 2) { String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6"); @@ -110,15 +107,12 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } - AbstractFlag af; - try { af = FlagManager.getFlag(args[1].toLowerCase()); } catch (final Exception e) { af = new AbstractFlag(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; @@ -138,9 +132,7 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT); return false; } - - boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase()); - + final boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase()); if (!result) { PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED); return false; @@ -150,20 +142,18 @@ public class Set extends SubCommand { return true; } try { - String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); - Object parsed_value = af.parseValueRaw(value); + final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); + final Object parsed_value = af.parseValueRaw(value); if (parsed_value == null) { PlayerFunctions.sendMessage(plr, af.getValueDesc()); return false; } - 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; } - final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed_value); - boolean result = FlagManager.addPlotFlag(plot, flag); + final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED); return false; @@ -176,7 +166,6 @@ public class Set extends SubCommand { return false; } } - if (args[0].equalsIgnoreCase("home")) { if (args.length > 1) { if (args[1].equalsIgnoreCase("none")) { @@ -187,16 +176,15 @@ public class Set extends SubCommand { return PlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT); } //set to current location - World world = plr.getWorld(); - Location base = PlotHelper.getPlotBottomLoc(world, plot.id); + final World world = plr.getWorld(); + final Location base = PlotHelper.getPlotBottomLoc(world, plot.id); base.setY(0); - Location relative = plr.getLocation().subtract(base); - BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); + final Location relative = plr.getLocation().subtract(base); + final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); plot.settings.setPosition(blockloc); DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); return PlayerFunctions.sendMessage(plr, C.POSITION_SET); } - if (args[0].equalsIgnoreCase("alias")) { if (args.length < 2) { PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS); @@ -230,7 +218,6 @@ public class Set extends SubCommand { sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2"); return true; } - final Biome biome = Biome.valueOf(new StringComparison(args[1], Biome.values()).getBestMatch()); /* * for (Biome b : Biome.values()) { @@ -240,7 +227,6 @@ public class Set extends SubCommand { * } * } */ - if (biome == null) { PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); return true; @@ -249,13 +235,12 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); return true; } - // Get components - World world = plr.getWorld(); + final World world = plr.getWorld(); final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - PlotManager manager = PlotSquared.getPlotManager(world); - String[] components = manager.getPlotComponents(world, plotworld, plot.id); - for (String component : components) { + final PlotManager manager = PlotSquared.getPlotManager(world); + final String[] components = manager.getPlotComponents(world, plotworld, plot.id); + for (final String component : components) { if (component.equalsIgnoreCase(args[0])) { if (args.length < 2) { PlayerFunctions.sendMessage(plr, C.NEED_BLOCK); @@ -264,14 +249,13 @@ public class Set extends SubCommand { PlotBlock[] blocks; try { blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseObject(args[2]); - } - catch (Exception e) { + } catch (final Exception e) { try { - blocks = new PlotBlock[] {new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0)}; - } catch (Exception e2) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK); - return false; - } + blocks = new PlotBlock[] { new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0) }; + } catch (final Exception e2) { + PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK); + return false; + } } manager.setComponent(world, plotworld, plot.id, component, blocks); PlayerFunctions.sendMessage(plr, C.GENERATING_COMPONENT); @@ -299,19 +283,19 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); return false; } - + private String getMaterial(final Material m) { return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase())); } - + private String getBiome(final Biome b) { return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase())); } - + private String getString(final String s) { return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); } - + private String getArgumentList(final String[] strings) { final StringBuilder builder = new StringBuilder(); for (final String s : strings) { @@ -319,7 +303,7 @@ public class Set extends SubCommand { } return builder.toString().substring(1, builder.toString().length() - 1); } - + private String getBiomeList(final List biomes) { final StringBuilder builder = new StringBuilder(); builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); @@ -328,18 +312,8 @@ public class Set extends SubCommand { } return builder.toString().substring(1, builder.toString().length() - 1); } - + private Material getMaterial(final String input, final List blocks) { return Material.valueOf(new StringComparison(input, blocks.toArray()).getBestMatch()); } - - private String getBlockList(final List blocks) { - final StringBuilder builder = new StringBuilder(); - builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); - for (final Material b : blocks) { - builder.append(getMaterial(b)); - } - return builder.toString().substring(1, builder.toString().length() - 1); - } - } 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 c4a829396..6f2266b24 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -38,25 +37,23 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class SetOwner extends SubCommand { - public SetOwner() { super("setowner", "plots.set.owner", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true); } - + /* * private UUID getUUID(String string) { OfflinePlayer player = * Bukkit.getOfflinePlayer(string); return ((player != null) && * player.hasPlayedBefore()) ? UUIDHandler.getUUID(player) : null; } */ - private UUID getUUID(final String string) { return UUIDHandler.getUUID(string); } - + @Override public boolean execute(final Player plr, final String... args) { - Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (plot == null || plot.owner == null) { + final Plot plot = PlayerFunctions.getCurrentPlot(plr); + if ((plot == null) || (plot.owner == null)) { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } @@ -64,7 +61,6 @@ public class SetOwner extends SubCommand { PlayerFunctions.sendMessage(plr, C.NEED_USER); return false; } - if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.setowner")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; @@ -75,18 +71,14 @@ public class SetOwner extends SubCommand { final ArrayList plots = PlayerFunctions.getPlotSelectionIds(bot, top); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); - - UUID uuid = getUUID(args[0]); - + final UUID uuid = getUUID(args[0]); if (uuid == null) { PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - current.owner = uuid; PlotSquared.updatePlot(current); DBFunc.setOwner(current, current.owner); - if (PlotSquared.worldGuardListener != null) { PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); } 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 ea4e5fcaf..da4ff9416 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.io.IOException; @@ -45,7 +44,6 @@ import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Setup extends SubCommand { - public final static Map setupMap = new HashMap<>(); public HashMap generators = new HashMap<>(); @@ -62,22 +60,22 @@ public class Setup extends SubCommand { int terrain = 0; ConfigurationNode[] step = null; } - + public void updateGenerators() { - if (generators.size() > 0) { + if (this.generators.size() > 0) { return; } - String testWorld = "CheckingPlotSquaredGenerator"; + final String testWorld = "CheckingPlotSquaredGenerator"; for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { if (plugin.isEnabled()) { - ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); + final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); if (generator != null) { PlotSquared.removePlotWorld(testWorld); final String name = plugin.getDescription().getName(); if (generator instanceof PlotGenerator) { - PlotGenerator pgen = (PlotGenerator) generator; + final PlotGenerator pgen = (PlotGenerator) generator; if (pgen.getPlotManager() instanceof SquarePlotManager) { - generators.put(name, pgen); + this.generators.put(name, pgen); } } } @@ -88,15 +86,14 @@ public class Setup extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { // going through setup - - String name = plr.getName(); + final String name = plr.getName(); if (!setupMap.containsKey(name)) { - SetupObject object = new SetupObject(); + final SetupObject object = new SetupObject(); setupMap.put(name, object); updateGenerators(); - String prefix = "\n&8 - &7"; + final String prefix = "\n&8 - &7"; sendMessage(plr, C.SETUP_INIT); - PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); return false; } if (args.length == 1) { @@ -106,86 +103,70 @@ public class Setup extends SubCommand { return false; } if (args[0].equalsIgnoreCase("back")) { - SetupObject object = setupMap.get(plr.getName()); + final SetupObject object = setupMap.get(plr.getName()); if (object.setup_index > 0) { object.setup_index--; - ConfigurationNode node = object.step[object.current]; + final ConfigurationNode node = object.step[object.current]; sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + ""); return false; - } - else if (object.current > 0 ){ + } else if (object.current > 0) { object.current--; } } } - SetupObject object = setupMap.get(name); - int index = object.current; - switch(index) { + final SetupObject object = setupMap.get(name); + final int index = object.current; + switch (index) { case 0: { // choose generator - if (args.length != 1 || !generators.containsKey(args[0])) { - String prefix = "\n&8 - &7"; - PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + if ((args.length != 1) || !this.generators.containsKey(args[0])) { + final String prefix = "\n&8 - &7"; + PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); sendMessage(plr, C.SETUP_INIT); return false; } object.generator = args[0]; object.current++; - - String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : ""; - PlayerFunctions.sendMessage(plr, "&6What world type do you want?" - + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" - + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" - + partial); + final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : ""; + PlayerFunctions.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); break; } case 1: { // choose world type List types; if (Settings.ENABLE_CLUSTERS) { - types = Arrays.asList(new String[] {"default", "augmented", "partial"}); + types = Arrays.asList(new String[] { "default", "augmented", "partial" }); + } else { + types = Arrays.asList(new String[] { "default", "augmented" }); } - else { - types = Arrays.asList(new String[] {"default", "augmented"}); - } - if (args.length != 1 || !types.contains(args[0].toLowerCase())) { - PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!" - + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" - + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" - + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); + if ((args.length != 1) || !types.contains(args[0].toLowerCase())) { + PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); return false; } object.type = types.indexOf(args[0].toLowerCase()); if (object.type == 0) { object.current++; if (object.step == null) { - object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); + object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); } - ConfigurationNode step = object.step[object.setup_index]; + final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); - } - else { - PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?" - + "\n&8 - &2NONE&8 - &7No terrain at all" - + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" - + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + } else { + PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); } object.current++; break; } case 2: { // Choose terrain - List terrain = Arrays.asList(new String[] {"none", "ore", "all"}); - if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) { - PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!" - + "\n&8 - &2NONE&8 - &7No terrain at all" - + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" - + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + final List terrain = Arrays.asList(new String[] { "none", "ore", "all" }); + if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) { + PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); return false; } object.terrain = terrain.indexOf(args[0].toLowerCase()); object.current++; if (object.step == null) { - object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); + object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); } - ConfigurationNode step = object.step[object.setup_index]; + final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); break; } @@ -229,11 +210,10 @@ public class Setup extends SubCommand { } object.world = args[0]; setupMap.remove(plr.getName()); - World world = setupWorld(object); + final World world = setupWorld(object); try { plr.teleport(world.getSpawnLocation()); - } - catch (Exception e) { + } catch (final Exception e) { plr.sendMessage("&cAn error occured. See console for more information"); e.printStackTrace(); } @@ -252,20 +232,20 @@ public class Setup extends SubCommand { * 2.2 augmented partial world with ore * 2.3 augmented partial world with terrain * 3.0 no generation + normal manager - * + * * generator.TYPE: PlotSquared, augmented, partial * generator.TERRAIN - * + * * WORLD.TYPE: hybrid, augmented, partial * if (augmented/partial) - * WORLD.TERRAIN: - * - * + * WORLD.TERRAIN: + * + * * types (0, 1, 2, 3) * 0: no options - * 1: - * - * + * 1: + * + * * - return null * - schedule task to create world later * - externalize multiverse/world hooks to separate class @@ -286,15 +266,15 @@ public class Setup extends SubCommand { * = square generator * = square plot generator (must have plot section and road section) (plot height, road height) * = hybrid generator - * + * * - All will support whole world augmentation * - Only grid will support partial plot worlds - * + * */ return false; } - public World setupWorld(SetupObject object) { + public World setupWorld(final SetupObject object) { // Configuration final ConfigurationNode[] steps = object.step; final String world = object.world; @@ -318,14 +298,13 @@ public class Setup extends SubCommand { if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator); } else { - WorldCreator wc = new WorldCreator(object.world); + final WorldCreator wc = new WorldCreator(object.world); wc.generator(object.generator); wc.environment(Environment.NORMAL); - World newWorld = Bukkit.createWorld(wc); + Bukkit.createWorld(wc); } } - } - else { + } else { if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal"); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 3f1485f27..742073d7c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -34,8 +33,8 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * * @author Citymonstret */ -@SuppressWarnings({"deprecation", "unused"}) public abstract class SubCommand { - +@SuppressWarnings({ "deprecation", "unused" }) +public abstract class SubCommand { /** * Command */ @@ -64,7 +63,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * Is this a player-online command? */ public final boolean isPlayer; - + /** * @param cmd Command /plot {cmd} <-- That! * @param permission Permission Node @@ -83,7 +82,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; this.category = category; this.isPlayer = isPlayer; } - + /** * @param cmd Command /plot {cmd} <-- That! * @param permission Permission Node @@ -102,7 +101,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; this.category = category; this.isPlayer = isPlayer; } - + /** * @param command Command /plot {cmd} <-- That! * @param description Simple description @@ -119,7 +118,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; this.category = category; this.isPlayer = isPlayer; } - + /** * Execute. * @@ -129,7 +128,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @return true on success, false on failure */ public abstract boolean execute(final Player plr, final String... args); - + /** * Execute the command as console * @@ -138,7 +137,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public void executeConsole(final String... args) { this.execute(null, args); } - + /** * Send a message * @@ -153,7 +152,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; PlayerFunctions.sendMessage(plr, c, args); return true; } - + /** * CommandCategory * @@ -191,12 +190,11 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * Such as: /plot debug */ DEBUG("Debug"); - /** * The category name (Readable) */ private final String name; - + /** * Constructor * @@ -205,7 +203,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; CommandCategory(final String name) { this.name = name; } - + @Override public String toString() { return this.name; 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 8a05962db..291cc0e5d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.World; @@ -40,11 +39,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Empire92 */ public class Swap extends SubCommand { - public Swap() { super(Command.SWAP, "Swap two plots", "switch", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { @@ -87,11 +85,9 @@ public class Swap extends SubCommand { return false; } PlotSelection.swap(world, plot.id, plotid); - // TODO Requires testing!! DBFunc.dbManager.swapPlots(plot, PlotHelper.getPlot(world, plotid)); // TODO Requires testing!! - PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS); PlotHelper.update(plr.getLocation()); return true; 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 2a7c67c70..de091975e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.apache.commons.lang.StringUtils; @@ -37,11 +36,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class TP extends SubCommand { - public TP() { super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { @@ -65,7 +63,6 @@ public class TP extends SubCommand { PlotSquared.teleportPlayer(plr, plr.getLocation(), temp); return true; } - try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); PlotSquared.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid)); @@ -75,7 +72,7 @@ public class TP extends SubCommand { } return false; } - + private Plot isAlias(final World world, String a) { int index = 0; if (a.contains(";")) { @@ -85,7 +82,8 @@ public class TP extends SubCommand { } a = split[0]; } - @SuppressWarnings("deprecation") final Player player = Bukkit.getPlayer(a); + @SuppressWarnings("deprecation") + final Player player = Bukkit.getPlayer(a); if (player != null) { final java.util.Set plotMainPlots = PlotSquared.getPlots(world, player); final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]); 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 f84d90866..5a1de4393 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.Location; @@ -31,11 +30,10 @@ import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Target extends SubCommand { - public Target() { super(Command.TARGET, "Target a plot with your compass", "target ", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlotSquared.isPlotWorld(plr.getWorld())) { @@ -43,12 +41,12 @@ public class Target extends SubCommand { return false; } if (args.length == 1) { - PlotId id = PlotHelper.parseId(args[1]); + final PlotId id = PlotHelper.parseId(args[1]); if (id == null) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } - Location loc = PlotHelper.getPlotHome(plr.getWorld(), id); + final Location loc = PlotHelper.getPlotHome(plr.getWorld(), id); plr.setCompassTarget(loc); PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET); return true; 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 826c27ca4..607e395c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.io.FileInputStream; @@ -36,7 +35,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Template extends SubCommand { - public Template() { super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true); } @@ -47,9 +45,9 @@ public class Template extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); return false; } - World world = Bukkit.getWorld(args[1]); - PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]); - if (world == null || plotworld == null) { + final World world = Bukkit.getWorld(args[1]); + final PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]); + if ((world == null) || (plotworld == null)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); return false; } @@ -63,19 +61,16 @@ public class Template extends SubCommand { PlayerFunctions.sendMessage(plr, "TODO"); } } - // TODO allow world settings (including schematics to be packed into a single file) - // TODO allow world created based on these packaged files - return true; } - public void gzipIt(String output, String input) { - byte[] buffer = new byte[1024]; + public void gzipIt(final String output, final String input) { + final byte[] buffer = new byte[1024]; try { - GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(output)); - FileInputStream in = new FileInputStream(input); + final GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(output)); + final FileInputStream in = new FileInputStream(input); int len; while ((len = in.read(buffer)) > 0) { gzos.write(buffer, 0, len); @@ -83,7 +78,7 @@ public class Template extends SubCommand { in.close(); gzos.finish(); gzos.close(); - } catch (IOException ex) { + } catch (final IOException ex) { ex.printStackTrace(); } } 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 5a1056a51..0d27ccf08 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.io.File; @@ -40,25 +39,23 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Trim extends SubCommand { - public static boolean TASK = false; private static int TASK_ID = 0; public Trim() { super("trim", "plots.admin", "Delete unmodified portions of your plotworld", "trim", "", CommandCategory.DEBUG, false); } - - public PlotId getId(String id) { + + public PlotId getId(final String id) { try { - String[] split = id.split(";"); + final String[] split = id.split(";"); return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - } - catch (Exception e) { + } catch (final Exception e) { return null; } } @@ -70,8 +67,8 @@ public class Trim extends SubCommand { return false; } if (args.length == 1) { - String arg = args[0].toLowerCase(); - PlotId id = getId(arg); + final String arg = args[0].toLowerCase(); + final PlotId id = getId(arg); if (id != null) { PlayerFunctions.sendMessage(plr, "/plot trim x;z &l"); return false; @@ -87,22 +84,20 @@ public class Trim extends SubCommand { PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); return false; } - String arg = args[0].toLowerCase(); + final String arg = args[0].toLowerCase(); if (!arg.equals("all")) { PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); return false; } final World world = Bukkit.getWorld(args[1]); - if (world == null || PlotSquared.getWorldSettings(world) == null) { + if ((world == null) || (PlotSquared.getWorldSettings(world) == null)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD); return false; } - if (Trim.TASK) { sendMessage(C.TRIM_IN_PROGRESS.s()); return false; } - sendMessage(C.TRIM_START.s()); final ArrayList empty = new ArrayList<>(); getTrimRegions(empty, world, new Runnable() { @@ -118,54 +113,50 @@ public class Trim extends SubCommand { if (Trim.TASK) { return false; } - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - String directory = world.getName() + File.separator + "region"; - File folder = new File(directory); - File[] regionFiles = folder.listFiles(); - for (File file : regionFiles) { - String name = file.getName(); + final String directory = world.getName() + File.separator + "region"; + final File folder = new File(directory); + final File[] regionFiles = folder.listFiles(); + for (final File file : regionFiles) { + final String name = file.getName(); if (name.endsWith("mca")) { if (file.getTotalSpace() <= 8192) { try { - String[] split = name.split("\\."); - int x = Integer.parseInt(split[1]); - int z = Integer.parseInt(split[2]); - ChunkLoc loc = new ChunkLoc(x, z); + final String[] split = name.split("\\."); + final int x = Integer.parseInt(split[1]); + final int z = Integer.parseInt(split[2]); + final ChunkLoc loc = new ChunkLoc(x, z); empty.add(loc); - } - catch (Exception e) { + } catch (final Exception e) { System.out.print("INVALID MCA: " + name); } - } - else { - Path path = Paths.get(file.getPath()); + } else { + final Path path = Paths.get(file.getPath()); try { - BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class); - long creation = attr.creationTime().toMillis(); - long modification = file.lastModified(); - long diff = Math.abs(creation - modification); + final BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class); + final long creation = attr.creationTime().toMillis(); + final long modification = file.lastModified(); + final long diff = Math.abs(creation - modification); if (diff < 10000) { try { - String[] split = name.split("\\."); - int x = Integer.parseInt(split[1]); - int z = Integer.parseInt(split[2]); - ChunkLoc loc = new ChunkLoc(x, z); + final String[] split = name.split("\\."); + final int x = Integer.parseInt(split[1]); + final int z = Integer.parseInt(split[2]); + final ChunkLoc loc = new ChunkLoc(x, z); empty.add(loc); - } - catch (Exception e) { + } catch (final Exception e) { System.out.print("INVALID MCA: " + name); } } - } catch (Exception e) { - + } catch (final Exception e) { } } } } Trim.TASK = false; - BukkitTaskManager.runTaskAsync(whenDone); + TaskManager.runTaskAsync(whenDone); } }); Trim.TASK = true; @@ -182,29 +173,27 @@ public class Trim extends SubCommand { 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"); + sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)"); + sendMessage(" - TIME ESTIMATE: " + (chunks.size() / 1200) + " minutes"); Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { @Override public void run() { - long start = System.currentTimeMillis(); - while (System.currentTimeMillis() - start < 50) { + final long start = System.currentTimeMillis(); + while ((System.currentTimeMillis() - start) < 50) { if (plots.size() == 0) { empty.addAll(chunks); System.out.print("DONE!"); Trim.TASK = false; - BukkitTaskManager.runTaskAsync(whenDone); + TaskManager.runTaskAsync(whenDone); Bukkit.getScheduler().cancelTask(Trim.TASK_ID); return; } - Plot plot = plots.get(0); + final Plot plot = plots.get(0); plots.remove(0); - Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id); - Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); - - Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ()); - Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ()); - + final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id); + final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); + final Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ()); + final Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ()); chunks.remove(ChunkManager.getChunkChunk(pos1)); chunks.remove(ChunkManager.getChunkChunk(pos2)); chunks.remove(ChunkManager.getChunkChunk(pos3)); @@ -218,39 +207,39 @@ public class Trim extends SubCommand { public static ArrayList expired = null; -// public static void updateUnmodifiedPlots(final World 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(PlotSquared.getMain(), new Runnable() { -// @Override -// public void run() { -// if (manager != null && plots.size() > 0) { -// Plot plot = plots.iterator().next(); -// if (plot.hasOwner()) { -// SquarePlotManager.checkModified(plot, 0); -// } -// if (plot.owner == null || !SquarePlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) { -// expired.add(plot); -// sendMessage("found expired: " + plot); -// } -// } -// else { -// Trim.expired = expired; -// Trim.TASK = false; -// sendMessage("Done!"); -// Bukkit.getScheduler().cancelTask(Trim.TASK_ID); -// return; -// } -// } -// }, 1, 1); -// } -// - public static void deleteChunks(World world, ArrayList chunks) { - String worldname = world.getName(); - for (ChunkLoc loc : chunks) { + // public static void updateUnmodifiedPlots(final World 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(PlotSquared.getMain(), new Runnable() { + // @Override + // public void run() { + // if (manager != null && plots.size() > 0) { + // Plot plot = plots.iterator().next(); + // if (plot.hasOwner()) { + // SquarePlotManager.checkModified(plot, 0); + // } + // if (plot.owner == null || !SquarePlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) { + // expired.add(plot); + // sendMessage("found expired: " + plot); + // } + // } + // else { + // Trim.expired = expired; + // Trim.TASK = false; + // sendMessage("Done!"); + // Bukkit.getScheduler().cancelTask(Trim.TASK_ID); + // return; + // } + // } + // }, 1, 1); + // } + // + public static void deleteChunks(final World world, final ArrayList chunks) { + final String worldname = world.getName(); + for (final ChunkLoc loc : chunks) { ChunkManager.deleteRegionFile(worldname, loc); } } @@ -258,5 +247,4 @@ public class Trim extends SubCommand { public static void sendMessage(final String message) { PlotSquared.log("&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 8fededa8d..2258308dc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.UUID; @@ -34,12 +33,12 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings("deprecation") public class Trusted extends SubCommand { - +@SuppressWarnings("deprecation") +public class Trusted extends SubCommand { public Trusted() { super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 2) { @@ -63,7 +62,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; UUID uuid; if (args[1].equalsIgnoreCase("*")) { uuid = DBFunc.everyone; - } else { uuid = UUIDHandler.getUUID(args[1]); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java index 8e869667c..0412ee321 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java @@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class Unban extends SubCommand { - public Unban() { super(Command.UNBAN, "Alias for /plot denied remove", "/plot unban [player]", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { 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 c98fefb5e..3ff765574 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; @@ -36,11 +35,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Unclaim extends SubCommand { - public Unclaim() { super(Command.UNCLAIM, "Unclaim a plot", "unclaim", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { @@ -65,8 +63,8 @@ public class Unclaim extends SubCommand { } final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true); if (result) { - World world = plr.getWorld(); - String worldname = world.getName(); + final World world = plr.getWorld(); + final String worldname = world.getName(); PlotSquared.getPlotManager(world).unclaimPlot(world, pWorld, plot); DBFunc.delete(worldname, plot); // TODO set wall block 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 e9e356d9e..2e9573215 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -46,11 +45,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class Unlink extends SubCommand { - public Unlink() { super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (!PlayerFunctions.isInPlot(plr)) { @@ -63,7 +61,6 @@ public class Unlink extends SubCommand { if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_IMPOSSIBLE); } - final World world = plr.getWorld(); if (!unlinkPlot(world, plot)) { PlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled"); @@ -83,31 +80,24 @@ public class Unlink extends SubCommand { return true; } - public static boolean unlinkPlot(World world, Plot plot) { + public static boolean unlinkPlot(final World world, final Plot plot) { final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id; final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id; final ArrayList ids = PlayerFunctions.getPlotSelectionIds(pos1, pos2); - final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids); - Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { event.setCancelled(true); return false; } - 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 = PlotSquared.getPlots(world).get(id); - if (plot == null) { continue; } - if (plot.helpers != null) { myplot.helpers = plot.helpers; } @@ -115,25 +105,20 @@ public class Unlink extends SubCommand { myplot.denied = plot.denied; } myplot.deny_entry = plot.deny_entry; - myplot.settings.setMerged(new boolean[]{false, false, false, false}); + myplot.settings.setMerged(new boolean[] { false, false, false, false }); DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged()); } - for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { final boolean lx = x < pos2.x; final boolean ly = y < pos2.y; - final Plot p = PlotHelper.getPlot(world, new PlotId(x, y)); - if (lx) { manager.createRoadEast(plotworld, p); if (ly) { manager.createRoadSouthEast(plotworld, p); } - } - if (ly) { manager.createRoadSouth(plotworld, p); } @@ -141,10 +126,10 @@ public class Unlink extends SubCommand { } } manager.finishPlotUnlink(world, plotworld, ids); - for (PlotId id : ids) { - Plot myPlot = PlotHelper.getPlot(world, id); + for (final PlotId id : ids) { + final Plot myPlot = PlotHelper.getPlot(world, id); if (plot.hasOwner()) { - String name = UUIDHandler.getName(myPlot.owner); + final String name = UUIDHandler.getName(myPlot.owner); if (name != null) { PlotHelper.setSign(world, name, myPlot); } 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 0901ed1fc..46bf43db5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.ArrayList; @@ -36,7 +35,7 @@ public class Visit extends SubCommand { public Visit() { super("visit", "plots.visit", "Visit someones plot", "visit {player} [#]", "v", CommandCategory.TELEPORT, true); } - + public List getPlots(final UUID uuid) { final List plots = new ArrayList<>(); for (final Plot p : PlotSquared.getPlots()) { @@ -46,7 +45,7 @@ public class Visit extends SubCommand { } return plots; } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { 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 6630ead8f..371d53149 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 @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import org.bukkit.entity.Player; @@ -29,23 +28,20 @@ import com.intellectualcrafters.plot.util.bukkit.PWE; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class WE_Anywhere extends SubCommand { - public WE_Anywhere() { super("weanywhere", "plots.weanywhere", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final Player plr, final String... args) { if (PlotSquared.worldEdit == null) { PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); return false; } - if (BukkitMain.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { PWE.removeMask(plr); PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask"); - } - else { + } else { PWE.setMask(plr, plr.getLocation(), true); PlayerFunctions.sendMessage(plr, "&6Updated 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 8697d8b41..6e0c93330 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.util.HashMap; @@ -41,31 +40,30 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class list extends SubCommand { - public list() { super(Command.LIST, "List all plots", "list {mine|shared|all|world|forsale}", CommandCategory.INFO, false); } - + private static String getName(final UUID id) { if (id == null) { return "none"; } - String name = UUIDHandler.getName(id); + final String name = UUIDHandler.getName(id); if (name == null) { return "unknown"; } return name; } - + @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { final StringBuilder builder = new StringBuilder(); builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); if (plr != null) { - builder.append(getArgumentList(new String[]{"mine", "shared", "world", "all", "forsale"})); + builder.append(getArgumentList(new String[] { "mine", "shared", "world", "all", "forsale" })); } else { - builder.append(getArgumentList(new String[]{"all"})); + builder.append(getArgumentList(new String[] { "all" })); } PlayerFunctions.sendMessage(plr, builder.toString()); return true; @@ -78,7 +76,7 @@ public class list extends SubCommand { string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "buyable")).append("\n"); int idx = 0; for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) { - Flag price = FlagManager.getPlotFlag(p, "price"); + final 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"); idx++; @@ -121,7 +119,6 @@ public class list extends SubCommand { } else if (args[0].equalsIgnoreCase("all")) { // Current page int page = 0; - // is a page specified? else use 0 if (args.length > 1) { try { @@ -134,34 +131,26 @@ public class list extends SubCommand { page = 0; } } - // Get the total pages // int totalPages = ((int) Math.ceil(12 * // (PlotSquared.getPlotsSorted().size()) / 100)); final int totalPages = (int) Math.ceil(PlotSquared.getPlotsSorted().size() / 12); - if (page > totalPages) { page = totalPages; } - // Only display 12! int max = (page * 12) + 12; - if (max > PlotSquared.getPlotsSorted().size()) { max = PlotSquared.getPlotsSorted().size(); } - final StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n"); Plot p; - // This might work xD for (int x = (page * 12); x < max; 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%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots")); PlayerFunctions.sendMessage(plr, string.toString()); return true; @@ -177,11 +166,11 @@ public class list extends SubCommand { return true; } else { // execute(plr); - sendMessage(plr, C.DID_YOU_MEAN, new StringComparison(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch()); + sendMessage(plr, C.DID_YOU_MEAN, new StringComparison(args[0], new String[] { "mine", "shared", "world", "all" }).getBestMatch()); return false; } } - + private String getArgumentList(final String[] strings) { final StringBuilder builder = new StringBuilder(); for (final String s : strings) { @@ -189,9 +178,8 @@ public class list extends SubCommand { } return builder.toString().substring(1, builder.toString().length() - 1); } - + private String getString(final String s) { return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); } - } 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 831fe4520..5a76e480c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.commands; import java.io.BufferedReader; @@ -35,13 +34,12 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class plugin extends SubCommand { - public static String downloads, version; - + public plugin() { super("plugin", "plots.use", "Show plugin information", "plugin", "version", CommandCategory.INFO, false); } - + public static void setup(final JavaPlugin plugin) { plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { @Override @@ -65,7 +63,7 @@ public class plugin extends SubCommand { } }, 200l); } - + private static String convertToNumericString(final String str, final boolean dividers) { final StringBuilder builder = new StringBuilder(); for (final char c : str.toCharArray()) { @@ -77,7 +75,7 @@ public class plugin extends SubCommand { } return builder.toString(); } - + private static String getInfo(final String link) throws Exception { final URLConnection connection = new URL(link).openConnection(); connection.addRequestProperty("User-Agent", "Mozilla/4.0"); @@ -89,7 +87,7 @@ public class plugin extends SubCommand { reader.close(); return document; } - + @Override public boolean execute(final Player plr, final String... args) { Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { @@ -111,5 +109,4 @@ public class plugin extends SubCommand { }); return true; } - } 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 92d96cb37..ac5be71dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.config; import org.bukkit.ChatColor; @@ -201,7 +200,6 @@ public enum C { CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."), CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"), YOU_BE_DENIED("$2You are not allowed to enter this plot"), - NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"), UNLINK_REQUIRED("$2An unlink is required to do this."), UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot"), @@ -329,7 +327,6 @@ public enum C { PLOT_INFO_ID("$1ID:$2 %id%"), PLOT_INFO_ALIAS("$1Alias:$2 %alias%"), PLOT_INFO_SIZE("$1Size:$2 %size%"), - PLOT_USER_LIST(" $1%user%$2,"), INFO_SYNTAX_CONSOLE("$2/plot info X;Y"), /* @@ -389,7 +386,6 @@ public enum C { FLAG_KEY("$2Key: %s"), FLAG_TYPE("$2Type: %s"), FLAG_DESC("$2Desc: %s"), - NEED_KEY("$2Possible values: $1%values%"), NOT_VALID_FLAG("$2That is not a valid flag"), NOT_VALID_VALUE("$2Flag values must be alphanumerical"), @@ -442,7 +438,6 @@ public enum C { * Custom */ CUSTOM_STRING("-"); - /** * Special Language * @@ -474,8 +469,7 @@ public enum C { * Should the string be prefixed? */ private boolean prefix; - private ChatColor[] sColors = null; - + /** * Constructor for custom strings. */ @@ -484,7 +478,7 @@ public enum C { * use setCustomString(); */ } - + /** * Constructor * @@ -498,7 +492,7 @@ public enum C { } this.prefix = prefix; } - + /** * Constructor * @@ -507,7 +501,7 @@ public enum C { C(final String d) { this(d, true); } - + public static void setupTranslations() { manager = new TranslationManager(); defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(), lang, "PlotSquared", manager).read(); @@ -516,15 +510,15 @@ public enum C { manager.addTranslationObject(new TranslationObject(c.toString(), c.d, "", "")); } } - + public static void saveTranslations() { try { manager.saveAll(defaultFile).saveFile(defaultFile); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } - + /** * Get the default string * @@ -533,14 +527,14 @@ public enum C { public String d() { return this.d; } - + /** * Get translated if exists * * @return translated if exists else default */ public String s() { - String s = manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n"); + final 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 (PlotSquared.translations != null) { @@ -555,11 +549,11 @@ public enum C { * return this.s.replace("\\n", "\n"); */ } - + public boolean usePrefix() { return this.prefix; } - + /** * @return translated and color decoded * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java index f0b7b5b50..7d312e2e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.config; import java.util.ArrayList; @@ -32,32 +31,30 @@ import com.intellectualcrafters.plot.object.PlotBlock; * * @author Empire92 */ -@SuppressWarnings("unused") public class Configuration { - +@SuppressWarnings("unused") +public class Configuration { public static final SettingValue STRING = new SettingValue("STRING") { @Override public boolean validateValue(final String string) { return true; } - + @Override public Object parseString(final String string) { return string; } }; - public static final SettingValue STRINGLIST = new SettingValue("STRINGLIST") { @Override public boolean validateValue(final String string) { return true; } - + @Override public Object parseString(final String string) { return string.split(","); } }; - public static final SettingValue INTEGER = new SettingValue("INTEGER") { @Override public boolean validateValue(final String string) { @@ -68,13 +65,12 @@ import com.intellectualcrafters.plot.object.PlotBlock; return false; } } - + @Override public Object parseString(final String string) { return Integer.parseInt(string); } }; - public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") { @Override public boolean validateValue(final String string) { @@ -85,13 +81,12 @@ import com.intellectualcrafters.plot.object.PlotBlock; return false; } } - + @Override public Object parseString(final String string) { return Boolean.parseBoolean(string); } }; - public static final SettingValue DOUBLE = new SettingValue("DOUBLE") { @Override public boolean validateValue(final String string) { @@ -102,13 +97,12 @@ import com.intellectualcrafters.plot.object.PlotBlock; return false; } } - + @Override public Object parseString(final String string) { return Double.parseDouble(string); } }; - public static final SettingValue BIOME = new SettingValue("BIOME") { @Override public boolean validateValue(final String string) { @@ -119,7 +113,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; return false; } } - + @Override public Object parseString(final String string) { for (final Biome biome : Biome.values()) { @@ -129,13 +123,12 @@ import com.intellectualcrafters.plot.object.PlotBlock; } return Biome.FOREST; } - + @Override public Object parseObject(final Object object) { return (((Biome) object)).toString(); } }; - public static final SettingValue BLOCK = new SettingValue("BLOCK") { @Override public boolean validateValue(final String string) { @@ -152,7 +145,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; return false; } } - + @Override public Object parseString(final String string) { if (string.contains(":")) { @@ -162,7 +155,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; return new PlotBlock(Short.parseShort(string), (byte) 0); } } - + @Override public Object parseObject(final Object object) { return object; @@ -191,12 +184,11 @@ import com.intellectualcrafters.plot.object.PlotBlock; return false; } } - + @Override public Object parseString(final String string) { final String[] blocks = string.split(","); final ArrayList parsedvalues = new ArrayList<>(); - final PlotBlock[] values = new PlotBlock[blocks.length]; final int[] counts = new int[blocks.length]; int min = 100; @@ -229,23 +221,22 @@ import com.intellectualcrafters.plot.object.PlotBlock; parsedvalues.add(values[i]); } } - return parsedvalues.toArray(new PlotBlock[parsedvalues.size()]); } - + @Override public Object parseObject(final Object object) { return object; } }; - + public static int gcd(final int a, final int b) { if (b == 0) { return a; } return gcd(b, a % b); } - + private static int gcd(final int[] a) { int result = a[0]; for (int i = 1; i < a.length; i++) { @@ -253,27 +244,27 @@ import com.intellectualcrafters.plot.object.PlotBlock; } return result; } - + /** * Create your own SettingValue object to make the management of plotworld configuration easier */ public static abstract class SettingValue { private final String type; - + public SettingValue(final String type) { this.type = type; } - + public String getType() { return this.type; } - + public Object parseObject(final Object object) { return object; } - + public abstract Object parseString(final String string); - + public abstract boolean validateValue(final String string); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java index 0c0fceca9..da13195e6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.config; import java.util.ArrayList; @@ -41,7 +40,7 @@ public class ConfigurationNode { private final String description; private final SettingValue type; private Object value; - + public ConfigurationNode(final String constant, final Object default_value, final String description, final SettingValue type, final boolean required) { this.constant = constant; this.default_value = default_value; @@ -49,11 +48,11 @@ public class ConfigurationNode { this.value = default_value; this.type = type; } - + public SettingValue getType() { return this.type; } - + public boolean isValid(final String string) { try { final Object result = this.type.parseString(string); @@ -62,7 +61,7 @@ public class ConfigurationNode { return false; } } - + public boolean setValue(final String string) { if (!this.type.validateValue(string)) { return false; @@ -70,35 +69,33 @@ public class ConfigurationNode { this.value = this.type.parseString(string); return true; } - + public Object getValue() { if (this.value instanceof String[]) { return Arrays.asList((String[]) this.value); - } - else if (this.value instanceof Object[]) { - List values = new ArrayList(); - for (Object value : (Object[]) this.value) { + } else if (this.value instanceof Object[]) { + final List values = new ArrayList(); + for (final Object value : (Object[]) this.value) { values.add(value.toString()); } return values; - } - else if (this.value instanceof PlotBlock) { + } else if (this.value instanceof PlotBlock) { return this.value.toString(); } return this.value; } - + public String getConstant() { return this.constant; } - + public Object getDefaultValue() { if (this.default_value instanceof Object[]) { return StringUtils.join((Object[]) this.default_value, ","); } return this.default_value; } - + public String getDescription() { return this.description; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index e9cd1f485..bc9d8e51f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -18,10 +18,8 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.config; - /** * Updater and DB settings * @@ -29,15 +27,15 @@ package com.intellectualcrafters.plot.config; * @author Empire92 */ public class Settings { - public static boolean ENABLE_CLUSTERS = false; + public static boolean ENABLE_CLUSTERS = false; /** * Default UUID_FECTHING: false */ public static boolean UUID_FECTHING = false; public static boolean UUID_FROM_DISK = false; /** - * - */ + * + */ public static boolean CONVERT_PLOTME = true; public static boolean USE_PLOTME_ALIAS = false; /** @@ -63,11 +61,11 @@ public class Settings { /** * Mob Cap Enabled */ -// public static boolean MOB_CAP_ENABLED = false; + // public static boolean MOB_CAP_ENABLED = false; /** * The Mob Cap */ -// public static int MOB_CAP = 20; + // public static int MOB_CAP = 20; /** * Display titles */ @@ -104,7 +102,6 @@ public class Settings { * Delete plots on ban? */ public static boolean DELETE_PLOTS_ON_BAN = false; - /** * Verbose? */ @@ -113,7 +110,6 @@ public class Settings { * Have colored console messages? */ public static boolean CONSOLE_COLOR = true; - /** * The delay (in seconds) before teleportation commences */ @@ -122,30 +118,25 @@ public class Settings { * Auto clear enabled */ public static boolean AUTO_CLEAR = false; - /** * Days until a plot gets cleared */ public static int AUTO_CLEAR_DAYS = 360; public static boolean AUTO_CLEAR_CHECK_DISK = false; - public static int MIN_BLOCKS_CHANGED = -1; - /** * API Location */ public static String API_URL = "http://www.intellectualsites.com/minecraft.php"; - /** * Use the custom API */ public static boolean CUSTOM_API = true; - /** * Use offline mode storage */ public static boolean OFFLINE_MODE = false; - + /** * Database settings * @@ -155,10 +146,10 @@ public class Settings { /** * MongoDB enabled? */ - public static boolean USE_MONGO = false; /* - * TODO: Implement Mongo - * @Brandon - */ + public static boolean USE_MONGO = false; /* + * TODO: Implement Mongo + * @Brandon + */ /** * SQLite enabled? */ @@ -166,7 +157,7 @@ public class Settings { /** * MySQL Enabled? */ - public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */ + public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */ /** * SQLite Database name */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 37594fdfa..f898bd9af 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.database; import java.sql.SQLException; @@ -41,14 +40,12 @@ import com.intellectualcrafters.plot.object.PlotId; * @author Empire92 */ public interface AbstractDB { - // TODO MongoDB @Brandon - /** * The UUID that will count as everyone */ public UUID everyone = UUID.fromString("1-1-3-3-7"); - + /** * Set Plot owner * @@ -56,28 +53,28 @@ public interface AbstractDB { * @param uuid The uuid of the new owner */ public void setOwner(final Plot plot, final UUID uuid); - + /** * Create all settings, and create default helpers, trusted + denied lists * * @param plots Plots for which the default table entries should be created */ public void createAllSettingsAndHelpers(final ArrayList plots); - + /** * Create a plot * * @param plots Plots that should be created */ public void createPlots(final ArrayList plots); - + /** * Create a plot * * @param plot That should be created */ public void createPlot(final Plot plot); - + /** * Create tables * @@ -86,7 +83,7 @@ public interface AbstractDB { * @throws SQLException If the database manager is unable to create the tables */ public void createTables(final String database, final boolean add_constraint) throws Exception; - + /** * Delete a plot * @@ -95,7 +92,7 @@ public interface AbstractDB { public void delete(final String world, final Plot plot); public void delete(final PlotCluster cluster); - + /** * Create plot settings * @@ -103,7 +100,7 @@ public interface AbstractDB { * @param plot Plot Object */ public void createPlotSettings(final int id, final Plot plot); - + /** * Get the table entry ID * @@ -118,7 +115,7 @@ public interface AbstractDB { * Get the id of a given plot cluster * * @param world Which the plot is located in - * @param pos1 bottom Plot ID + * @param pos1 bottom Plot ID * @param pos2 top Plot ID * * @return Integer = Cluster Entry Id @@ -129,7 +126,7 @@ public interface AbstractDB { * @return A linked hashmap containing all plots */ public LinkedHashMap> getPlots(); - + /** * @return A hashmap containing all plot clusters */ @@ -143,14 +140,14 @@ public interface AbstractDB { * @param merged boolean[] */ public void setMerged(final String world, final Plot plot, final boolean[] merged); - + /** * Swap the settings, helpers etc. of two plots * @param p1 Plot1 * @param p2 Plot2 */ public void swapPlots(final Plot p1, final Plot p2); - + /** * Set plot flags * @@ -174,7 +171,6 @@ public interface AbstractDB { */ public void setClusterName(final PlotCluster cluster, final String name); - /** * Set the plot alias * @@ -182,7 +178,7 @@ public interface AbstractDB { * @param alias Plot Alias */ public void setAlias(final String world, final Plot plot, final String alias); - + /** * Purgle a plot * @@ -190,14 +186,14 @@ public interface AbstractDB { * @param id Plot ID */ public void purgeIds(final String world, final Set uniqueIds); - + /** * Purge a whole world * * @param world World in which the plots should be purged */ public void purge(final String world, final Set plotIds); - + /** * Set Plot Home Position * @@ -207,12 +203,12 @@ public interface AbstractDB { public void setPosition(final String world, final Plot plot, final String position); /** - * + * * @param cluster * @param position */ public void setPosition(final PlotCluster cluster, final String position); - + /** * @param id Plot Entry ID * @@ -221,12 +217,12 @@ public interface AbstractDB { public HashMap getSettings(final int id); /** - * + * * @param id * @return */ public HashMap getClusterSettings(final int id); - + /** * @param plot Plot Object * @param uuid Player that should be removed @@ -238,18 +234,20 @@ public interface AbstractDB { * @param uuid Player that should be removed */ public void removeHelper(final PlotCluster cluster, final UUID uuid); - + /** * @param plot Plot Object * @param uuid Player that should be removed */ public void removeTrusted(final String world, final Plot plot, final UUID uuid); + /** - * + * * @param cluster * @param uuid */ public void removeInvited(final PlotCluster cluster, final UUID uuid); + /** * @param plot Plot Object * @param uuid Player that should be removed @@ -261,32 +259,33 @@ public interface AbstractDB { * @param uuid Player that should be removed */ public void setHelper(final PlotCluster cluster, final UUID uuid); - + /** * @param plot Plot Object * @param uuid Player that should be added */ public void setTrusted(final String world, final Plot plot, final UUID uuid); + /** - * + * * @param world * @param cluster * @param uuid */ public void setInvited(final String world, final PlotCluster cluster, final UUID uuid); - + /** * @param plot Plot Object * @param player Player that should be added */ public void removeDenied(final String world, final Plot plot, final UUID uuid); - + /** * @param plot Plot Object * @param player Player that should be added */ public void setDenied(final String world, final Plot plot, final UUID uuid); - + /** * Get Plots ratings * @@ -295,7 +294,7 @@ public interface AbstractDB { * @return Plot Ratings (pre-calculated) */ public double getRatings(final Plot plot); - + /** * Remove a plot comment * @@ -304,7 +303,7 @@ public interface AbstractDB { * @param comment Comment to remove */ public void removeComment(final String world, final Plot plot, final PlotComment comment); - + /** * Set a plot comment * @@ -313,7 +312,7 @@ public interface AbstractDB { * @param comment Comment to add */ public void setComment(final String world, final Plot plot, final PlotComment comment); - + /** * Get Plot Comments * @@ -324,12 +323,12 @@ public interface AbstractDB { * @return Plot Comments within the specified tier */ public ArrayList getComments(final String world, final Plot plot, final int tier, boolean below); - + public void createPlotAndSettings(Plot plot); public void createCluster(PlotCluster cluster); public void resizeCluster(PlotCluster current, PlotClusterId resize); - + public void movePlot(String world, PlotId originalPlot, PlotId newPlot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 02cfb20c9..9f5ae964f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.database; import java.util.ArrayList; @@ -42,7 +41,6 @@ import com.intellectualcrafters.plot.object.PlotId; * @author Citymonstret */ public class DBFunc { - /** * The "global" uuid */ @@ -51,8 +49,8 @@ public class DBFunc { * Abstract Database Manager */ public static AbstractDB dbManager; - - public static void movePlot(String world, PlotId originalPlot, PlotId newPlot) { + + public static void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { dbManager.movePlot(world, originalPlot, newPlot); } @@ -65,7 +63,7 @@ public class DBFunc { public static void setOwner(final Plot plot, final UUID uuid) { dbManager.setOwner(plot, uuid); } - + /** * Create all settings + (helpers, denied, trusted) * @@ -74,7 +72,7 @@ public class DBFunc { public static void createAllSettingsAndHelpers(final ArrayList plots) { dbManager.createAllSettingsAndHelpers(plots); } - + /** * Create all plots * @@ -83,7 +81,7 @@ public class DBFunc { public static void createPlots(final ArrayList plots) { dbManager.createPlots(plots); } - + /** * Create a plot * @@ -101,7 +99,7 @@ public class DBFunc { public static void createPlotAndSettings(final Plot plot) { dbManager.createPlotAndSettings(plot); } - + /** * Create tables * @@ -110,7 +108,7 @@ public class DBFunc { public static void createTables(final String database, final boolean add_constraint) throws Exception { dbManager.createTables(database, add_constraint); } - + /** * Delete a plot * @@ -123,7 +121,7 @@ public class DBFunc { public static void delete(final PlotCluster toDelete) { dbManager.delete(toDelete); } - + /** * Create plot settings * @@ -133,7 +131,7 @@ public class DBFunc { public static void createPlotSettings(final int id, final Plot plot) { dbManager.createPlotSettings(id, plot); } - + /** * Get a plot id * @@ -155,18 +153,18 @@ public class DBFunc { public static int getId(final String world, final PlotId id2) { return dbManager.getId(world, id2); } - + /** * @return Plots */ public static LinkedHashMap> getPlots() { return dbManager.getPlots(); } - + public static void setMerged(final String world, final Plot plot, final boolean[] merged) { dbManager.setMerged(world, plot, merged); } - + public static void setFlags(final String world, final Plot plot, final Set flags) { dbManager.setFlags(world, plot, flags); } @@ -174,7 +172,7 @@ public class DBFunc { public static void setFlags(final PlotCluster cluster, final Set flags) { dbManager.setFlags(cluster, flags); } - + /** * @param plot * @param alias @@ -182,15 +180,15 @@ public class DBFunc { public static void setAlias(final String world, final Plot plot, final String alias) { dbManager.setAlias(world, plot, alias); } - + public static void purgeIds(final String world, final Set uniqueIds) { dbManager.purgeIds(world, uniqueIds); } - + public static void purge(final String world, final Set plotIds) { dbManager.purge(world, plotIds); } - + /** * @param plot * @param position @@ -198,7 +196,7 @@ public class DBFunc { public static void setPosition(final String world, final Plot plot, final String position) { dbManager.setPosition(world, plot, position); } - + /** * @param id * @@ -207,7 +205,7 @@ public class DBFunc { public static HashMap getSettings(final int id) { return dbManager.getSettings(id); } - + /** * @param plot * @param comment @@ -215,7 +213,7 @@ public class DBFunc { public static void removeComment(final String world, final Plot plot, final PlotComment comment) { dbManager.removeComment(world, plot, comment); } - + /** * @param plot * @param comment @@ -223,14 +221,14 @@ public class DBFunc { public static void setComment(final String world, final Plot plot, final PlotComment comment) { dbManager.setComment(world, plot, comment); } - + /** * @param plot */ public static ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) { return dbManager.getComments(world, plot, tier, below); } - + /** * @param plot * @param player @@ -246,25 +244,25 @@ public class DBFunc { public static void removeHelper(final PlotCluster cluster, final UUID uuid) { dbManager.removeHelper(cluster, uuid); } - + /** * @param world * @param cluster * @param name */ - public static void createCluster(String world, PlotCluster cluster) { - dbManager.createCluster(cluster); + public static void createCluster(final String world, final PlotCluster cluster) { + dbManager.createCluster(cluster); } - + /** * @param world * @param current * @param resize */ - public static void resizeCluster(PlotCluster current, PlotClusterId resize) { - dbManager.resizeCluster(current, resize); + public static void resizeCluster(final PlotCluster current, final PlotClusterId resize) { + dbManager.resizeCluster(current, resize); } - + /** * @param plot * @param player @@ -274,7 +272,7 @@ public class DBFunc { } /** - * + * * @param world * @param plot * @param uuid @@ -282,7 +280,7 @@ public class DBFunc { public static void removeInvited(final PlotCluster cluster, final UUID uuid) { dbManager.removeInvited(cluster, uuid); } - + /** * @param plot * @param player @@ -294,7 +292,7 @@ public class DBFunc { public static void setHelper(final PlotCluster cluster, final UUID uuid) { dbManager.setHelper(cluster, uuid); } - + /** * @param plot * @param player @@ -306,7 +304,7 @@ public class DBFunc { public static void setInvited(final String world, final PlotCluster cluster, final UUID uuid) { dbManager.setInvited(world, cluster, uuid); } - + /** * @param plot * @param player @@ -314,7 +312,7 @@ public class DBFunc { public static void removeDenied(final String world, final Plot plot, final UUID uuid) { dbManager.removeDenied(world, plot, uuid); } - + /** * @param plot * @param player @@ -328,14 +326,14 @@ public class DBFunc { } public static HashMap> getClusters() { - return dbManager.getClusters(); + return dbManager.getClusters(); } - public static void setPosition(PlotCluster cluster, String position) { - dbManager.setPosition(cluster, position); + public static void setPosition(final PlotCluster cluster, final String position) { + dbManager.setPosition(cluster, position); } - public static HashMap getClusterSettings(int id) { + public static HashMap getClusterSettings(final int id) { return dbManager.getClusterSettings(id); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java index 0e3b503e9..fba75f6b3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.database; import java.sql.Connection; @@ -34,12 +33,11 @@ import com.intellectualcrafters.plot.PlotSquared; * @author tips48 */ public abstract class Database { - /** * Plugin instance, use for plugin.getDataFolder() */ protected final PlotSquared plotsquared; - + /** * Creates a new Database * @@ -48,7 +46,7 @@ public abstract class Database { protected Database(final PlotSquared plotsquared) { this.plotsquared = plotsquared; } - + /** * Opens a connection with the database * @@ -58,7 +56,7 @@ public abstract class Database { * @throws ClassNotFoundException if the driver cannot be found */ public abstract Connection openConnection() throws SQLException, ClassNotFoundException; - + /** * Checks if a connection is open with the database * @@ -67,14 +65,14 @@ public abstract class Database { * @throws SQLException if the connection cannot be checked */ public abstract boolean checkConnection() throws SQLException; - + /** * Gets the connection with the database * * @return Connection with the database, null if none */ public abstract Connection getConnection(); - + /** * Closes the connection with the database * @@ -83,7 +81,7 @@ public abstract class Database { * @throws SQLException if the connection cannot be closed */ public abstract boolean closeConnection() throws SQLException; - + /** * Executes a SQL Query
If the connection is closed, it will be opened * @@ -95,7 +93,7 @@ public abstract class Database { * @throws ClassNotFoundException If the driver cannot be found; see {@link #openConnection()} */ public abstract ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException; - + /** * Executes an Update SQL Query
See {@link java.sql.Statement#executeUpdate(String)}
If the connection is * closed, it will be opened diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index 6622a85c5..4f7856d70 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.database; import java.sql.Connection; @@ -41,9 +40,8 @@ public class MySQL extends Database { private final String password; private final String port; private final String hostname; - private Connection connection; - + /** * Creates a new MySQL instance * @@ -63,14 +61,13 @@ public class MySQL extends Database { this.password = password; this.connection = null; } - - + public Connection forceConnection() throws SQLException, ClassNotFoundException { Class.forName("com.mysql.jdbc.Driver"); this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); return this.connection; } - + @Override public Connection openConnection() throws SQLException, ClassNotFoundException { if (checkConnection()) { @@ -80,17 +77,17 @@ public class MySQL extends Database { this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); return this.connection; } - + @Override public boolean checkConnection() throws SQLException { return (this.connection != null) && !this.connection.isClosed(); } - + @Override public Connection getConnection() { return this.connection; } - + @Override public boolean closeConnection() throws SQLException { if (this.connection == null) { @@ -99,27 +96,22 @@ public class MySQL extends Database { this.connection.close(); return true; } - + @Override public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } - final Statement statement = this.connection.createStatement(); - return statement.executeQuery(query); } - + @Override public int updateSQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } - final Statement statement = this.connection.createStatement(); - return statement.executeUpdate(query); } - } 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 6bfc55e3e..35ebaabf1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -18,12 +18,10 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.database; import java.io.File; import java.io.IOException; -import java.nio.ByteBuffer; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -54,7 +52,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Empire92 */ public class PlotMeConverter { - /** * Constructor * @@ -80,7 +77,6 @@ public class PlotMeConverter { sendMessage("Connecting to PlotMe DB"); final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile); int count = 0; - Connection connection; if (plotConfig.getBoolean("usemySQL")) { final String user = plotConfig.getString("mySQLuname"); @@ -97,7 +93,6 @@ public class PlotMeConverter { final HashMap plotSize = new HashMap<>(); final HashMap> plots = new HashMap<>(); final Set worlds = plotConfig.getConfigurationSection("worlds").getKeys(false); - stmt = connection.createStatement(); r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); while (r.next()) { @@ -105,8 +100,6 @@ public class PlotMeConverter { final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final String name = r.getString("owner"); final String world = getWorld(r.getString("world")); - - if (!plotSize.containsKey(world)) { final int size = r.getInt("topZ") - r.getInt("bottomZ"); plotSize.put(world, size); @@ -116,9 +109,8 @@ public class PlotMeConverter { if (owner == null) { if (name.equals("*")) { owner = DBFunc.everyone; - } - else { - sendMessage("&cCould not identify owner for plot: " + id +" -> " + name); + } else { + sendMessage("&cCould not identify owner for plot: " + id + " -> " + name); continue; } } @@ -163,31 +155,23 @@ public class PlotMeConverter { plots.get(world).get(id).denied.add(denied); } } - sendMessage("Collected " + count + " plots from PlotMe"); - for (final String world : plots.keySet()) { sendMessage("Copying config for: " + world); try { - String plotMeWorldName = world.toLowerCase(); + final String plotMeWorldName = world.toLowerCase(); final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); // PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); - final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); // PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); - final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); // PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); - final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); // PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); - final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); // PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); - final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId"); PlotSquared.config.set("worlds." + world + ".road.block", road); - Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // if (height == null) { height = 64; @@ -197,53 +181,46 @@ public class PlotMeConverter { sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); } } - final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml"); if (PLOTME_DG_FILE.exists()) { final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE); try { for (final String world : plots.keySet()) { - String plotMeWorldName = world.toLowerCase(); + final String plotMeWorldName = world.toLowerCase(); Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); // if (pathwidth == null) { pathwidth = 7; } PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); - Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // if (plotsize == null) { plotsize = 32; } PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); - String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // if (wallblock == null) { wallblock = "44"; } PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); - String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // if (floor == null) { floor = "2"; } PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); - String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // if (filling == null) { filling = "3"; } PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); - String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); if (road == null) { road = "5"; } PlotSquared.config.set("worlds." + world + ".road.block", road); - Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // - if (height == null || height == 0) { + if ((height == null) || (height == 0)) { height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); // - if (height == null || height == 0) { + if ((height == null) || (height == 0)) { height = 64; } } @@ -252,7 +229,6 @@ public class PlotMeConverter { PlotSquared.config.set("worlds." + world + ".wall.height", height); } } catch (final Exception e) { - } } for (final String world : plots.keySet()) { @@ -268,7 +244,6 @@ public class PlotMeConverter { PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?"); } } - sendMessage("Creating plot DB"); Thread.sleep(1000); DBFunc.createPlots(createdPlots); @@ -286,20 +261,16 @@ public class PlotMeConverter { try { boolean MV = false; boolean MW = false; - if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { MV = true; } else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { MW = true; } - for (final String worldname : worlds) { final World world = Bukkit.getWorld(getWorld(worldname)); final String actualWorldName = world.getName(); sendMessage("Reloading generator for world: '" + actualWorldName + "'..."); - PlotSquared.removePlotWorld(actualWorldName); - if (MV) { // unload Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName); @@ -326,7 +297,6 @@ public class PlotMeConverter { myworld.save(); } } - PlotSquared.setAllPlotsRaw(DBFunc.getPlots()); sendMessage("Conversion has finished"); PlotSquared.log("&cPlease disable 'plotme-convert.enabled' in the settings.yml to indicate that you conversion is no longer required."); @@ -336,25 +306,17 @@ public class PlotMeConverter { } }); } catch (final Exception e) { - } } }, 20); } - public String getWorld(String world) { - for (World newworld : Bukkit.getWorlds()) { + public String getWorld(final String world) { + for (final World newworld : Bukkit.getWorlds()) { if (newworld.getName().equalsIgnoreCase(world)) { return newworld.getName(); } } return world; } - - private UUID uuidFromBytes(byte[] byteArray) { - ByteBuffer wrapped = ByteBuffer.wrap(byteArray); - long minor = wrapped.getLong(); - long major = wrapped.getLong(); - return new UUID(major, minor); - } } 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 38201d4ce..c28886d01 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.database; import java.sql.Connection; @@ -49,13 +48,11 @@ import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; /** * @author Citymonstret */ public class SQLManager implements AbstractDB { - // Public final public final String SET_OWNER; public final String GET_ALL_PLOTS; @@ -67,7 +64,7 @@ public class SQLManager implements AbstractDB { private final String prefix; // Private Final private Connection connection; - + /** * Constructor * @@ -80,7 +77,6 @@ public class SQLManager implements AbstractDB { this.prefix = p; // Set timout // setTimout(); - // Public final this.SET_OWNER = "UPDATE `" + this.prefix + "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ?"; this.GET_ALL_PLOTS = "SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `" + this.prefix + "plot`"; @@ -89,7 +85,6 @@ public class SQLManager implements AbstractDB { this.CREATE_HELPERS = "INSERT INTO `" + this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) values "; this.CREATE_PLOT = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)"; this.CREATE_CLUSTER = "INSERT INTO `" + this.prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)"; - // schedule reconnect if (PlotSquared.getMySQL() != null) { TaskManager.runTaskRepeat(new Runnable() { @@ -103,9 +98,8 @@ public class SQLManager implements AbstractDB { } }, 11000); } - } - + /** * Set Plot owner * @@ -114,7 +108,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setOwner(final Plot plot, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -126,25 +120,24 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"Could not set owner for plot " + plot.id); + PlotSquared.log("&c[ERROR] " + "Could not set owner for plot " + plot.id); } } }); } - + @Override public void createAllSettingsAndHelpers(final ArrayList mylist) { - int size = mylist.size(); + final int size = mylist.size(); int packet; if (PlotSquared.getMySQL() != null) { packet = Math.min(size, 50000); - } - else { + } else { packet = Math.min(size, 5000); } - int amount = size/packet; - for (int j = 0; j <= amount;j++) { - List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); + final int amount = size / packet; + for (int j = 0; j <= amount; j++) { + final List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); final HashMap> stored = new HashMap<>(); final HashMap> helpers = new HashMap<>(); try { @@ -155,7 +148,6 @@ public class SQLManager implements AbstractDB { final int idx = result.getInt("plot_id_x"); final int idz = result.getInt("plot_id_z"); final String world = result.getString("world"); - if (!stored.containsKey(world)) { stored.put(world, new HashMap()); } @@ -194,8 +186,8 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - for (int i = 0; i < ids.length; i++) { - createPlotSettings(ids[i], null); + for (final Integer id : ids) { + createPlotSettings(id, null); } } // add plot helpers @@ -215,7 +207,6 @@ public class SQLManager implements AbstractDB { int counter = 0; for (final Integer id : helpers.keySet()) { for (final UUID helper : helpers.get(id)) { - stmt.setInt((counter * 2) + 1, id); stmt.setString((counter * 2) + 2, helper.toString()); counter++; @@ -230,13 +221,13 @@ public class SQLManager implements AbstractDB { setHelper(id, helper); } } + } catch (final Exception e2) { } - catch (Exception e2) {} - PlotSquared.log("&7[WARN] "+"Failed to set all helpers for plots"); + PlotSquared.log("&7[WARN] " + "Failed to set all helpers for plots"); } } } - + /** * Create a plot * @@ -244,27 +235,24 @@ public class SQLManager implements AbstractDB { */ @Override public void createPlots(final ArrayList mylist) { - int size = mylist.size(); + final int size = mylist.size(); int packet; if (PlotSquared.getMySQL() != null) { packet = Math.min(size, 50000); - } - else { + } else { packet = Math.min(size, 5000); } - int amount = size/packet; - for (int j = 0; j <= amount;j++) { - List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); + final int amount = size / packet; + for (int j = 0; j <= amount; j++) { + final List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); if (plots.size() == 0) { return; } final StringBuilder statement = new StringBuilder(this.CREATE_PLOTS); - for (int i = 0; i < (plots.size() - 1); i++) { statement.append("(?,?,?,?),"); } statement.append("(?,?,?,?)"); - PreparedStatement stmt = null; try { stmt = this.connection.prepareStatement(statement.toString()); @@ -274,8 +262,7 @@ public class SQLManager implements AbstractDB { stmt.setInt((i * 4) + 2, plot.id.y); try { stmt.setString((i * 4) + 3, plot.owner.toString()); - } - catch (Exception e) { + } catch (final Exception e) { stmt.setString((i * 4) + 3, DBFunc.everyone.toString()); } stmt.setString((i * 4) + 4, plot.world); @@ -284,25 +271,23 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotSquared.log("&6[WARN] "+"Could not bulk save. Conversion may be slower..."); + PlotSquared.log("&6[WARN] " + "Could not bulk save. Conversion may be slower..."); try { - for (Plot plot : plots) { + for (final Plot plot : plots) { try { createPlot(plot); - } - catch (Exception e3) { - PlotSquared.log("&c[ERROR] "+"Failed to save plot: "+plot.id); + } catch (final Exception e3) { + PlotSquared.log("&c[ERROR] " + "Failed to save plot: " + plot.id); } } - } - catch (Exception e2) { + } catch (final Exception e2) { e2.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"Failed to save plots!"); + PlotSquared.log("&c[ERROR] " + "Failed to save plots!"); } } } } - + /** * Create a plot * @@ -310,7 +295,7 @@ public class SQLManager implements AbstractDB { */ @Override public void createPlot(final Plot plot) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -324,15 +309,15 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"Failed to save plot " + plot.id); + PlotSquared.log("&c[ERROR] " + "Failed to save plot " + plot.id); } } }); } - + @Override public void createPlotAndSettings(final Plot plot) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -344,20 +329,18 @@ public class SQLManager implements AbstractDB { stmt.setString(4, plot.world); stmt.executeUpdate(); stmt.close(); - - int id = getId(plot.world, plot.id); + final int id = getId(plot.world, plot.id); stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)"); stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"Failed to save plot " + plot.id); + PlotSquared.log("&c[ERROR] " + "Failed to save plot " + plot.id); } } }); } - /** * Create tables @@ -366,7 +349,6 @@ public class SQLManager implements AbstractDB { */ @Override public void createTables(final String database, final boolean add_constraint) throws SQLException { - final boolean mysql = database.equals("mysql"); final Statement stmt = this.connection.createStatement(); if (mysql) { @@ -382,18 +364,16 @@ public class SQLManager implements AbstractDB { } stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - } else { - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`tier` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); @@ -403,7 +383,7 @@ public class SQLManager implements AbstractDB { stmt.clearBatch(); stmt.close(); } - + /** * Delete a plot * @@ -412,7 +392,7 @@ public class SQLManager implements AbstractDB { @Override public void delete(final String world, final Plot plot) { PlotSquared.removePlot(world, plot.id, false); - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -444,7 +424,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * Create plot settings * @@ -453,7 +433,7 @@ public class SQLManager implements AbstractDB { */ @Override public void createPlotSettings(final int id, final Plot plot) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -465,11 +445,10 @@ public class SQLManager implements AbstractDB { } catch (final SQLException e) { e.printStackTrace(); } - } }); } - + @Override public int getId(final String world, final PlotId id2) { PreparedStatement stmt = null; @@ -491,7 +470,7 @@ public class SQLManager implements AbstractDB { } return Integer.MAX_VALUE; } - + /** * Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap */ @@ -524,17 +503,14 @@ public class SQLManager implements AbstractDB { e.printStackTrace(); } final HashMap plots = new HashMap<>(); - Statement stmt = null; try { - Set worlds = new HashSet<>(); if (PlotSquared.config.contains("worlds")) { worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false); } final HashMap uuids = new HashMap(); final HashMap noExist = new HashMap(); - /* * Getting plots */ @@ -562,10 +538,9 @@ public class SQLManager implements AbstractDB { user = UUID.fromString(o); uuids.put(o, user); } - p = new Plot(plot_id, user, new ArrayList(), new ArrayList(), new ArrayList(), "", null, null, worldname, new boolean[]{false, false, false, false}); + p = new Plot(plot_id, user, new ArrayList(), new ArrayList(), new ArrayList(), "", null, null, worldname, new boolean[] { false, false, false, false }); plots.put(id, p); } - /* * Getting helpers */ @@ -628,7 +603,6 @@ public class SQLManager implements AbstractDB { id = r.getInt("plot_plot_id"); final Plot plot = plots.get(id); if (plot != null) { - final String b = r.getString("biome"); if (b != null) { for (final Biome mybiome : Biome.values()) { @@ -637,14 +611,11 @@ public class SQLManager implements AbstractDB { } } } - final String alias = r.getString("alias"); if (alias != null) { plot.settings.setAlias(alias); } - final String pos = r.getString("position"); - switch (pos.toLowerCase()) { case "": case "default": @@ -653,11 +624,11 @@ public class SQLManager implements AbstractDB { break; default: try { - String[] split = pos.split(","); - BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Integer.parseInt(split[2])); + final String[] split = pos.split(","); + final BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); plot.settings.setPosition(loc); + } catch (final Exception e) { } - catch (Exception e) {} } final Integer m = r.getInt("merged"); if (m != null) { @@ -667,19 +638,17 @@ public class SQLManager implements AbstractDB { } plot.settings.setMerged(merged); } else { - plot.settings.setMerged(new boolean[]{false, false, false, false}); + plot.settings.setMerged(new boolean[] { false, false, false, false }); } - String[] flags_string; final String myflags = r.getString("flags"); if (myflags == null) { - flags_string = new String[]{}; + flags_string = new String[] {}; } else { if (myflags.length() > 0) { flags_string = myflags.split(","); - } - else { - flags_string = new String[]{}; + } else { + flags_string = new String[] {}; } } final Set flags = new HashSet(); @@ -688,8 +657,8 @@ public class SQLManager implements AbstractDB { if (element.contains(":")) { final String[] split = element.split(":"); try { - String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("\u00B4", ","); - Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str); + final String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("\u00B4", ","); + final Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str); flags.add(flag); } catch (final Exception e) { e.printStackTrace(); @@ -726,16 +695,16 @@ public class SQLManager implements AbstractDB { PlotSquared.log("&c[WARNING] - Please create the world/s or remove the plots using the purge command"); } } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to load plots."); + PlotSquared.log("&7[WARN] " + "Failed to load plots."); e.printStackTrace(); } return newplots; } - + @Override public void setMerged(final String world, final Plot plot, final boolean[] merged) { plot.settings.setMerged(merged); - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -750,71 +719,67 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Could not set merged for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Could not set merged for plot " + plot.id); } } }); } - + @Override public void swapPlots(final Plot p1, final Plot p2) { - BukkitTaskManager.runTaskAsync( - new Runnable() { - @Override - public void run() { - /* - * We don't need to actually swap all the rows - * - Just switch the plot_id_x and plot_id_z - * - The other tables reference the `id` so it will cascade - */ - try { - String world = p1.world; - int id1 = getId(world, p1.id); - int id2 = getId(world, p2.id); - PlotId pos1 = p1.getId(); - PlotId pos2 = p2.getId(); - PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); - stmt.setInt(1, pos2.x); - stmt.setInt(2, pos2.y); - stmt.setInt(3, id1); - stmt.executeUpdate(); - stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); - stmt.setInt(1, pos1.x); - stmt.setInt(2, pos1.y); - stmt.setInt(3, id2); - stmt.executeUpdate(); - stmt.close(); - } catch (final Exception e) { - e.printStackTrace(); - } - } + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + /* + * We don't need to actually swap all the rows + * - Just switch the plot_id_x and plot_id_z + * - The other tables reference the `id` so it will cascade + */ + try { + final String world = p1.world; + final int id1 = getId(world, p1.id); + final int id2 = getId(world, p2.id); + final PlotId pos1 = p1.getId(); + final PlotId pos2 = p2.getId(); + PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); + stmt.setInt(1, pos2.x); + stmt.setInt(2, pos2.y); + stmt.setInt(3, id1); + stmt.executeUpdate(); + stmt.close(); + stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); + stmt.setInt(1, pos1.x); + stmt.setInt(2, pos1.y); + stmt.setInt(3, id2); + stmt.executeUpdate(); + stmt.close(); + } catch (final Exception e) { + e.printStackTrace(); } - ); + } + }); } @Override public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { - BukkitTaskManager.runTaskAsync( - new Runnable() { - @Override - public void run() { - try { - int id = getId(world, originalPlot); - PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); - stmt.setInt(1, newPlot.x); - stmt.setInt(2, newPlot.y); - stmt.setInt(3, id); - stmt.executeUpdate(); - stmt.close(); - } catch (final Exception e) { - e.printStackTrace(); - } - } + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + try { + final int id = getId(world, originalPlot); + final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); + stmt.setInt(1, newPlot.x); + stmt.setInt(2, newPlot.y); + stmt.setInt(3, id); + stmt.executeUpdate(); + stmt.close(); + } catch (final Exception e) { + e.printStackTrace(); } - ); + } + }); } - + @Override public void setFlags(final String world, final Plot plot, final Set flags) { final StringBuilder flag_string = new StringBuilder(); @@ -826,7 +791,7 @@ public class SQLManager implements AbstractDB { flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4")); i++; } - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -837,12 +802,12 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Could not set flag for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Could not set flag for plot " + plot.id); } } }); } - + public void setFlags(final int id, final Flag[] flags) { final ArrayList newflags = new ArrayList(); for (final Flag flag : flags) { @@ -851,7 +816,7 @@ public class SQLManager implements AbstractDB { } } final String flag_string = StringUtils.join(newflags, ","); - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -862,12 +827,12 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Could not set flag for plot " + id); + PlotSquared.log("&7[WARN] " + "Could not set flag for plot " + id); } } }); } - + /** * @param plot * @param alias @@ -875,7 +840,7 @@ public class SQLManager implements AbstractDB { @Override public void setAlias(final String world, final Plot plot, final String alias) { plot.settings.setAlias(alias); - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -886,24 +851,22 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set alias for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to set alias for plot " + plot.id); e.printStackTrace(); } - } }); } - + /** * Purge all plots with the following database IDs */ + @Override public void purgeIds(final String world, final Set uniqueIds) { if (uniqueIds.size() > 0) { try { - String stmt_prefix = ""; final StringBuilder idstr = new StringBuilder(""); - for (final Integer id : uniqueIds) { idstr.append(stmt_prefix + id); stmt_prefix = " OR `plot_plot_id` = "; @@ -911,43 +874,40 @@ public class SQLManager implements AbstractDB { PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr + ""); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot` WHERE `world` = ?"); stmt.setString(1, world); stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); + PlotSquared.log("&c[ERROR] " + "FAILED TO PURGE WORLD '" + world + "'!"); return; } } - PlotSquared.log("&6[INFO] "+"SUCCESSFULLY PURGED WORLD '" + world + "'!"); + PlotSquared.log("&6[INFO] " + "SUCCESSFULLY PURGED WORLD '" + world + "'!"); } + @Override - public void purge(final String world, Set plots) { - for (PlotId id : plots) { - PlotSquared.removePlot(world, id, true); - } + public void purge(final String world, final Set plots) { + for (final PlotId id : plots) { + PlotSquared.removePlot(world, id, true); + } PreparedStatement stmt; try { stmt = SQLManager.this.connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + this.prefix + "plot` WHERE `world` = ?"); stmt.setString(1, world); - ResultSet r = stmt.executeQuery(); + final ResultSet r = stmt.executeQuery(); PlotId plot_id; - Set ids = new HashSet<>(); + final Set ids = new HashSet<>(); while (r.next()) { plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z")); if (plots.contains(plot_id)) { @@ -957,9 +917,9 @@ public class SQLManager implements AbstractDB { purgeIds(world, ids); stmt.close(); r.close(); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!"); + PlotSquared.log("&c[ERROR] " + "FAILED TO PURGE WORLD '" + world + "'!"); } } @@ -969,7 +929,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setPosition(final String world, final Plot plot, final String position) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -980,13 +940,13 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set position for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to set position for plot " + plot.id); e.printStackTrace(); } } }); } - + /** * @param id * @@ -1034,55 +994,53 @@ public class SQLManager implements AbstractDB { stmt.close(); r.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to load settings for plot: " + id); + PlotSquared.log("&7[WARN] " + "Failed to load settings for plot: " + id); e.printStackTrace(); } return h; } - + @Override public void removeComment(final String world, final Plot plot, final PlotComment comment) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { - PreparedStatement statement; - if (plot != null) { - statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `tier` = ? AND `sender` = ?"); - statement.setInt(1, getId(world, plot.id)); - statement.setString(2, comment.comment); - statement.setInt(3, comment.tier); - statement.setString(4, comment.senderName); - } - else { - statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `comment` = ? AND `tier` = ? AND `sender` = ?"); - statement.setString(1, comment.comment); - statement.setInt(2, comment.tier); - statement.setString(3, comment.senderName); - } + PreparedStatement statement; + if (plot != null) { + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `tier` = ? AND `sender` = ?"); + statement.setInt(1, getId(world, plot.id)); + statement.setString(2, comment.comment); + statement.setInt(3, comment.tier); + statement.setString(4, comment.senderName); + } else { + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `comment` = ? AND `tier` = ? AND `sender` = ?"); + statement.setString(1, comment.comment); + statement.setInt(2, comment.tier); + statement.setString(3, comment.senderName); + } statement.executeUpdate(); statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Failed to remove helper for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to remove helper for plot " + plot.id); } } }); } - + @Override - public ArrayList getComments(final String world, final Plot plot, final int tier, boolean below) { + public ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) { final ArrayList comments = new ArrayList(); try { final PreparedStatement statement; - String comparison = below ? ">=" : "="; + final String comparison = below ? ">=" : "="; if (plot != null) { - statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?"); - statement.setInt(1, getId(plot.world, plot.id)); + statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?"); + statement.setInt(1, getId(plot.world, plot.id)); statement.setInt(2, tier); - } - else { - statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `tier` " + comparison + " ?"); + } else { + statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `tier` " + comparison + " ?"); statement.setInt(1, tier); } final ResultSet set = statement.executeQuery(); @@ -1096,15 +1054,15 @@ public class SQLManager implements AbstractDB { statement.close(); set.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to fetch comment"); + PlotSquared.log("&7[WARN] " + "Failed to fetch comment"); e.printStackTrace(); } return comments; } - + @Override public void setComment(final String world, final Plot plot, final PlotComment comment) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1117,20 +1075,19 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Failed to set comment for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to set comment for plot " + plot.id); } } }); - } - + /** * @param plot * @param player */ @Override public void removeHelper(final String world, final Plot plot, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1141,19 +1098,19 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Failed to remove helper for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to remove helper for plot " + plot.id); } } }); } - + /** * @param plot * @param player */ @Override public void removeTrusted(final String world, final Plot plot, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1164,19 +1121,19 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Failed to remove trusted user for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to remove trusted user for plot " + plot.id); } } }); } - + /** * @param plot * @param player */ @Override public void setHelper(final String world, final Plot plot, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1186,7 +1143,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set helper for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to set helper for plot " + plot.id); e.printStackTrace(); } } @@ -1194,7 +1151,7 @@ public class SQLManager implements AbstractDB { } public void setHelper(final int id, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1204,7 +1161,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set helper for id " + id); + PlotSquared.log("&7[WARN] " + "Failed to set helper for id " + id); e.printStackTrace(); } } @@ -1217,7 +1174,7 @@ public class SQLManager implements AbstractDB { */ @Override public void setTrusted(final String world, final Plot plot, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1227,20 +1184,20 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set plot trusted for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to set plot trusted for plot " + plot.id); e.printStackTrace(); } } }); } - + /** * @param plot * @param player */ @Override public void removeDenied(final String world, final Plot plot, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1251,19 +1208,19 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Failed to remove denied for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to remove denied for plot " + plot.id); } } }); } - + /** * @param plot * @param player */ @Override public void setDenied(final String world, final Plot plot, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1273,13 +1230,13 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set denied for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to set denied for plot " + plot.id); e.printStackTrace(); } } }); } - + @Override public double getRatings(final Plot plot) { try { @@ -1294,16 +1251,16 @@ public class SQLManager implements AbstractDB { set.close(); return rating; } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString()); + PlotSquared.log("&7[WARN] " + "Failed to fetch rating for plot " + plot.getId().toString()); e.printStackTrace(); } return 0.0d; } - - @Override - public void delete(final PlotCluster cluster) { - ClusterManager.removeCluster(cluster); - BukkitTaskManager.runTaskAsync(new Runnable() { + + @Override + public void delete(final PlotCluster cluster) { + ClusterManager.removeCluster(cluster); + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1325,15 +1282,15 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2()); + PlotSquared.log("&c[ERROR] " + "Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2()); } } }); - } - - @Override - public int getClusterId(String world, PlotClusterId id) { - PreparedStatement stmt = null; + } + + @Override + public int getClusterId(final String world, final PlotClusterId id) { + PreparedStatement stmt = null; try { stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC"); stmt.setInt(1, id.pos1.x); @@ -1344,7 +1301,7 @@ public class SQLManager implements AbstractDB { final ResultSet r = stmt.executeQuery(); int c_id = Integer.MAX_VALUE; while (r.next()) { - c_id = r.getInt("id"); + c_id = r.getInt("id"); } stmt.close(); r.close(); @@ -1353,22 +1310,20 @@ public class SQLManager implements AbstractDB { e.printStackTrace(); } return Integer.MAX_VALUE; - } - - @Override - public HashMap> getClusters() { - final LinkedHashMap> newClusters = new LinkedHashMap<>(); + } + + @Override + public HashMap> getClusters() { + final LinkedHashMap> newClusters = new LinkedHashMap<>(); final HashMap clusters = new HashMap<>(); Statement stmt = null; try { - Set worlds = new HashSet<>(); if (PlotSquared.config.contains("worlds")) { worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false); } final HashMap uuids = new HashMap(); final HashMap noExist = new HashMap(); - /* * Getting clusters */ @@ -1376,14 +1331,14 @@ public class SQLManager implements AbstractDB { ResultSet r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster`"); PlotId pos1; PlotId pos2; - PlotCluster cluster; + PlotCluster cluster; String owner; String worldname; UUID user; int id; while (r.next()) { - pos1 = new PlotId(r.getInt("pos1_x"), r.getInt("pos1_z")); - pos2 = new PlotId(r.getInt("pos2_x"), r.getInt("pos2_z")); + pos1 = new PlotId(r.getInt("pos1_x"), r.getInt("pos1_z")); + pos2 = new PlotId(r.getInt("pos2_x"), r.getInt("pos2_z")); id = r.getInt("id"); worldname = r.getString("world"); if (!worlds.contains(worldname)) { @@ -1402,7 +1357,6 @@ public class SQLManager implements AbstractDB { cluster = new PlotCluster(worldname, pos1, pos2, user); clusters.put(id, cluster); } - /* * Getting helpers */ @@ -1454,14 +1408,11 @@ public class SQLManager implements AbstractDB { } } } - final String alias = r.getString("alias"); if (alias != null) { cluster.settings.setAlias(alias); } - final String pos = r.getString("position"); - switch (pos.toLowerCase()) { case "": case "default": @@ -1470,11 +1421,11 @@ public class SQLManager implements AbstractDB { break; default: try { - String[] split = pos.split(","); - BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Integer.parseInt(split[2])); + final String[] split = pos.split(","); + final BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); cluster.settings.setPosition(loc); + } catch (final Exception e) { } - catch (Exception e) {} } final Integer m = r.getInt("merged"); if (m != null) { @@ -1484,19 +1435,17 @@ public class SQLManager implements AbstractDB { } cluster.settings.setMerged(merged); } else { - cluster.settings.setMerged(new boolean[]{false, false, false, false}); + cluster.settings.setMerged(new boolean[] { false, false, false, false }); } - String[] flags_string; final String myflags = r.getString("flags"); if (myflags == null) { - flags_string = new String[]{}; + flags_string = new String[] {}; } else { if (myflags.length() > 0) { flags_string = myflags.split(","); - } - else { - flags_string = new String[]{}; + } else { + flags_string = new String[] {}; } } final Set flags = new HashSet(); @@ -1505,8 +1454,8 @@ public class SQLManager implements AbstractDB { if (element.contains(":")) { final String[] split = element.split(":"); try { - String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("�", ","); - Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str); + final String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("�", ","); + final Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str); flags.add(flag); } catch (final Exception e) { e.printStackTrace(); @@ -1530,7 +1479,7 @@ public class SQLManager implements AbstractDB { for (final PlotCluster c : clusters.values()) { final String world = c.world; if (!newClusters.containsKey(world)) { - newClusters.put(world, new HashSet()); + newClusters.put(world, new HashSet()); } newClusters.get(world).add(c); } @@ -1543,15 +1492,15 @@ public class SQLManager implements AbstractDB { PlotSquared.log("&c[WARNING] - Please create the world/s or remove the clusters using the purge command"); } } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to load clusters."); + PlotSquared.log("&7[WARN] " + "Failed to load clusters."); e.printStackTrace(); } return newClusters; - } - - @Override - public void setFlags(final PlotCluster cluster, Set flags) { - final StringBuilder flag_string = new StringBuilder(); + } + + @Override + public void setFlags(final PlotCluster cluster, final Set flags) { + final StringBuilder flag_string = new StringBuilder(); int i = 0; for (final Flag flag : flags) { if (i != 0) { @@ -1560,7 +1509,7 @@ public class SQLManager implements AbstractDB { flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4")); i++; } - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1571,17 +1520,16 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Could not set flag for plot " + cluster); + PlotSquared.log("&7[WARN] " + "Could not set flag for plot " + cluster); } } }); - - } - - @Override - public void setClusterName(final PlotCluster cluster, final String name) { - cluster.settings.setAlias(name); - BukkitTaskManager.runTaskAsync(new Runnable() { + } + + @Override + public void setClusterName(final PlotCluster cluster, final String name) { + cluster.settings.setAlias(name); + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1592,17 +1540,16 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set alias for cluster " + cluster); + PlotSquared.log("&7[WARN] " + "Failed to set alias for cluster " + cluster); e.printStackTrace(); } - } }); - } - - @Override - public void removeHelper(final PlotCluster cluster, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + } + + @Override + public void removeHelper(final PlotCluster cluster, final UUID uuid) { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1613,15 +1560,15 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Failed to remove helper for cluster " + cluster); + PlotSquared.log("&7[WARN] " + "Failed to remove helper for cluster " + cluster); } } }); - } - - @Override - public void setHelper(final PlotCluster cluster, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + } + + @Override + public void setHelper(final PlotCluster cluster, final UUID uuid) { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1631,16 +1578,16 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set helper for cluster " + cluster); + PlotSquared.log("&7[WARN] " + "Failed to set helper for cluster " + cluster); e.printStackTrace(); } } }); - } - - @Override - public void createCluster(final PlotCluster cluster) { - BukkitTaskManager.runTaskAsync(new Runnable() { + } + + @Override + public void createCluster(final PlotCluster cluster) { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1654,8 +1601,7 @@ public class SQLManager implements AbstractDB { stmt.setString(6, cluster.world); stmt.executeUpdate(); stmt.close(); - - int id = getClusterId(cluster.world, ClusterManager.getClusterId(cluster)); + final int id = getClusterId(cluster.world, ClusterManager.getClusterId(cluster)); stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "cluster_settings`(`cluster_id`, `alias`) VALUES(?, ?" + ")"); stmt.setInt(1, id); stmt.setString(2, cluster.settings.getAlias()); @@ -1663,19 +1609,19 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { e.printStackTrace(); - PlotSquared.log("&c[ERROR] "+"Failed to save cluster " + cluster); + PlotSquared.log("&c[ERROR] " + "Failed to save cluster " + cluster); } } }); - } - - @Override - public void resizeCluster(final PlotCluster current, final PlotClusterId resize) { - final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y); - final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y); - current.setP1(resize.pos1); - current.setP2(resize.pos2); - BukkitTaskManager.runTaskAsync(new Runnable() { + } + + @Override + public void resizeCluster(final PlotCluster current, final PlotClusterId resize) { + final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y); + final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y); + current.setP1(resize.pos1); + current.setP2(resize.pos2); + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1689,16 +1635,16 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to rezize cluster " + current); + PlotSquared.log("&7[WARN] " + "Failed to rezize cluster " + current); e.printStackTrace(); } } - }); - } - - @Override - public void setPosition(final PlotCluster cluster, final String position) { - BukkitTaskManager.runTaskAsync(new Runnable() { + }); + } + + @Override + public void setPosition(final PlotCluster cluster, final String position) { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; @@ -1709,16 +1655,16 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set position for cluster " + cluster); + PlotSquared.log("&7[WARN] " + "Failed to set position for cluster " + cluster); e.printStackTrace(); } } }); - } - - @Override - public HashMap getClusterSettings(int id) { - final HashMap h = new HashMap(); + } + + @Override + public HashMap getClusterSettings(final int id) { + final HashMap h = new HashMap(); PreparedStatement stmt = null; try { stmt = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "cluster_settings` WHERE `cluster_id` = ?"); @@ -1758,15 +1704,15 @@ public class SQLManager implements AbstractDB { stmt.close(); r.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to load settings for cluster: " + id); + PlotSquared.log("&7[WARN] " + "Failed to load settings for cluster: " + id); e.printStackTrace(); } return h; - } - + } + @Override public void removeInvited(final PlotCluster cluster, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1777,16 +1723,15 @@ public class SQLManager implements AbstractDB { statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] "+"Failed to remove invited for cluster " + cluster); + PlotSquared.log("&7[WARN] " + "Failed to remove invited for cluster " + cluster); } } }); - } - + @Override - public void setInvited(String world, final PlotCluster cluster, final UUID uuid) { - BukkitTaskManager.runTaskAsync(new Runnable() { + public void setInvited(final String world, final PlotCluster cluster, final UUID uuid) { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -1796,7 +1741,7 @@ public class SQLManager implements AbstractDB { statement.executeUpdate(); statement.close(); } catch (final SQLException e) { - PlotSquared.log("&7[WARN] "+"Failed to set helper for cluster " + cluster); + PlotSquared.log("&7[WARN] " + "Failed to set helper for cluster " + cluster); e.printStackTrace(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index 9f75cf13f..4c7ddde40 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.database; import java.io.File; @@ -38,10 +37,9 @@ import com.intellectualcrafters.plot.PlotSquared; * @author tips48 */ public class SQLite extends Database { - private final String dbLocation; private Connection connection; - + /** * Creates a new SQLite instance * @@ -52,7 +50,7 @@ public class SQLite extends Database { super(plotsquared); this.dbLocation = dbLocation; } - + @Override public Connection openConnection() throws SQLException, ClassNotFoundException { if (checkConnection()) { @@ -73,17 +71,17 @@ public class SQLite extends Database { this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation); return this.connection; } - + @Override public boolean checkConnection() throws SQLException { return (this.connection != null) && !this.connection.isClosed(); } - + @Override public Connection getConnection() { return this.connection; } - + @Override public boolean closeConnection() throws SQLException { if (this.connection == null) { @@ -92,26 +90,22 @@ public class SQLite extends Database { this.connection.close(); return true; } - + @Override public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } - final Statement statement = this.connection.createStatement(); - return statement.executeQuery(query); } - + @Override public int updateSQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } - final Statement statement = this.connection.createStatement(); - return statement.executeUpdate(query); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java index 5939a8dab..548d28d1a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.entity.Player; @@ -32,12 +31,13 @@ import com.intellectualcrafters.plot.object.Plot; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings("unused") public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { +@SuppressWarnings("unused") +public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { private static HandlerList handlers = new HandlerList(); private final Plot plot; private final boolean auto; private boolean cancelled; - + /** * PlayerClaimPlotEvent: Called when a plot is claimed * @@ -49,11 +49,11 @@ import com.intellectualcrafters.plot.object.Plot; this.plot = plot; this.auto = auto; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -62,24 +62,24 @@ import com.intellectualcrafters.plot.object.Plot; public Plot getPlot() { return this.plot; } - + /** * @return true if it was an automated claim, else false */ public boolean wasAuto() { return this.auto; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java index 6174a8812..cfb8ad5ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.entity.Player; @@ -32,11 +31,9 @@ import com.intellectualcrafters.plot.object.Plot; * @author Empire92 */ public class PlayerEnterPlotEvent extends PlayerEvent { - private static HandlerList handlers = new HandlerList(); - private final Plot plot; - + /** * PlayerEnterPlotEvent: Called when a player leaves a plot * @@ -47,11 +44,11 @@ public class PlayerEnterPlotEvent extends PlayerEvent { super(player); this.plot = plot; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -60,10 +57,9 @@ public class PlayerEnterPlotEvent extends PlayerEvent { public Plot getPlot() { return this.plot; } - + @Override public HandlerList getHandlers() { return handlers; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java index 6ae951dbf..21d217f46 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.entity.Player; @@ -33,9 +32,8 @@ import com.intellectualcrafters.plot.object.Plot; */ public class PlayerLeavePlotEvent extends PlayerEvent { private static HandlerList handlers = new HandlerList(); - private final Plot plot; - + /** * PlayerLeavePlotEvent: Called when a player leaves a plot * @@ -46,11 +44,11 @@ public class PlayerLeavePlotEvent extends PlayerEvent { super(player); this.plot = plot; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -59,7 +57,7 @@ public class PlayerLeavePlotEvent extends PlayerEvent { public Plot getPlot() { return this.plot; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java index 5c751aeb0..35703c2cd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import java.util.UUID; @@ -35,12 +34,11 @@ import com.intellectualcrafters.plot.object.Plot; */ public class PlayerPlotDeniedEvent extends Event { private static HandlerList handlers = new HandlerList(); - private final Plot plot; private final Player initiator; private final boolean added; private final UUID player; - + /** * PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot * @@ -55,11 +53,11 @@ public class PlayerPlotDeniedEvent extends Event { this.added = added; this.player = player; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * If a user was added * @@ -68,7 +66,7 @@ public class PlayerPlotDeniedEvent extends Event { public boolean wasAdded() { return this.added; } - + /** * The player added/removed * @@ -77,7 +75,7 @@ public class PlayerPlotDeniedEvent extends Event { public UUID getPlayer() { return this.player; } - + /** * The plot involved * @@ -86,7 +84,7 @@ public class PlayerPlotDeniedEvent extends Event { public Plot getPlot() { return this.plot; } - + /** * The player initiating the action * @@ -95,7 +93,7 @@ public class PlayerPlotDeniedEvent extends Event { public Player getInitiator() { return this.initiator; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java index d9378c3c9..e802e8123 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import java.util.UUID; @@ -35,12 +34,11 @@ import com.intellectualcrafters.plot.object.Plot; */ public class PlayerPlotHelperEvent extends Event { private static HandlerList handlers = new HandlerList(); - private final Plot plot; private final Player initiator; private final boolean added; private final UUID player; - + /** * PlayerPlotHelperEvent: Called when a plot helper is added/removed * @@ -55,11 +53,11 @@ public class PlayerPlotHelperEvent extends Event { this.added = added; this.player = player; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * If a player was added * @@ -68,7 +66,7 @@ public class PlayerPlotHelperEvent extends Event { public boolean wasAdded() { return this.added; } - + /** * The UUID added/removed * @@ -77,7 +75,7 @@ public class PlayerPlotHelperEvent extends Event { public UUID getPlayer() { return this.player; } - + /** * The plot involved * @@ -86,7 +84,7 @@ public class PlayerPlotHelperEvent extends Event { public Plot getPlot() { return this.plot; } - + /** * The player initiating the action * @@ -95,7 +93,7 @@ public class PlayerPlotHelperEvent extends Event { public Player getInitiator() { return this.initiator; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java index 6989b8e45..95333f704 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import java.util.UUID; @@ -35,12 +34,11 @@ import com.intellectualcrafters.plot.object.Plot; */ public class PlayerPlotTrustedEvent extends Event { private static HandlerList handlers = new HandlerList(); - private final Plot plot; private final Player initiator; private final boolean added; private final UUID player; - + /** * PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed * @@ -55,11 +53,11 @@ public class PlayerPlotTrustedEvent extends Event { this.added = added; this.player = player; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * If a player was added * @@ -68,7 +66,7 @@ public class PlayerPlotTrustedEvent extends Event { public boolean wasAdded() { return this.added; } - + /** * The UUID added/removed * @@ -77,7 +75,7 @@ public class PlayerPlotTrustedEvent extends Event { public UUID getPlayer() { return this.player; } - + /** * The plot involved * @@ -86,7 +84,7 @@ public class PlayerPlotTrustedEvent extends Event { public Plot getPlot() { return this.plot; } - + /** * The player initiating the action * @@ -95,7 +93,7 @@ public class PlayerPlotTrustedEvent extends Event { public Player getInitiator() { return this.initiator; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java index 032c5c384..45af3054e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.entity.Player; @@ -37,12 +36,10 @@ import com.intellectualcrafters.plot.object.Plot; */ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); - private final Location from; private final Plot plot; - private boolean cancelled; - + /** * PlayerTeleportToPlotEvent: Called when a player teleports to a plot * @@ -55,16 +52,16 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl this.from = from; this.plot = plot; } - + public static HandlerList getHandlerList() { return handlers; } - + @Override public HandlerList getHandlers() { return handlers; } - + /** * Get the from location * @@ -73,7 +70,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl public Location getFrom() { return this.from; } - + /** * Get the plot involved * @@ -82,12 +79,12 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl public Plot getPlot() { return this.plot; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean cancelled) { this.cancelled = cancelled; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java index 7b238c46a..76d55fb20 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.event.Cancellable; @@ -38,7 +37,7 @@ public class PlotClearEvent extends Event implements Cancellable { private final PlotId id; private final String world; private boolean cancelled; - + /** * PlotDeleteEvent: Called when a plot is cleared * @@ -49,11 +48,11 @@ public class PlotClearEvent extends Event implements Cancellable { this.id = id; this.world = world; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the PlotId * @@ -62,7 +61,7 @@ public class PlotClearEvent extends Event implements Cancellable { public PlotId getPlotId() { return this.id; } - + /** * Get the world name * @@ -71,17 +70,17 @@ public class PlotClearEvent extends Event implements Cancellable { public String getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java index 5e17845be..9d6c1c067 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.event.Cancellable; @@ -38,7 +37,7 @@ public class PlotDeleteEvent extends Event implements Cancellable { private final PlotId id; private final String world; private boolean cancelled; - + /** * PlotDeleteEvent: Called when a plot is deleted * @@ -49,11 +48,11 @@ public class PlotDeleteEvent extends Event implements Cancellable { this.id = id; this.world = world; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the PlotId * @@ -62,7 +61,7 @@ public class PlotDeleteEvent extends Event implements Cancellable { public PlotId getPlotId() { return this.id; } - + /** * Get the world name * @@ -71,17 +70,17 @@ public class PlotDeleteEvent extends Event implements Cancellable { public String getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java index 3e5234cf0..35035e3f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.event.Cancellable; @@ -39,7 +38,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable { private final Plot plot; private final Flag flag; private boolean cancelled; - + /** * PlotFlagAddEvent: Called when a Flag is added to a plot * @@ -50,11 +49,11 @@ public class PlotFlagAddEvent extends Event implements Cancellable { this.plot = plot; this.flag = flag; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -63,7 +62,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable { public Plot getPlot() { return this.plot; } - + /** * Get the flag involved * @@ -72,17 +71,17 @@ public class PlotFlagAddEvent extends Event implements Cancellable { public Flag getFlag() { return this.flag; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java index 3272fad58..5a0e5b22e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import org.bukkit.event.Cancellable; @@ -39,7 +38,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { private final Plot plot; private final Flag flag; private boolean cancelled; - + /** * PlotFlagRemoveEvent: Called when a flag is removed from a plot * @@ -50,11 +49,11 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { this.plot = plot; this.flag = flag; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -63,7 +62,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { public Plot getPlot() { return this.plot; } - + /** * Get the flag involved * @@ -72,17 +71,17 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { public Flag getFlag() { return this.flag; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java index d810c5c73..61654ffbc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import java.util.ArrayList; @@ -40,7 +39,7 @@ public class PlotMergeEvent extends Event implements Cancellable { private boolean cancelled; private Plot plot; private World world; - + /** * PlotMergeEvent: Called when plots are merged * @@ -51,11 +50,11 @@ public class PlotMergeEvent extends Event implements Cancellable { public PlotMergeEvent(final World world, final Plot plot, final ArrayList plots) { this.plots = plots; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plots being added; * @@ -64,7 +63,7 @@ public class PlotMergeEvent extends Event implements Cancellable { public ArrayList getPlots() { return this.plots; } - + /** * Get the main plot * @@ -73,21 +72,21 @@ public class PlotMergeEvent extends Event implements Cancellable { public Plot getPlot() { return this.plot; } - + public World getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java index 6d03c61d5..8de7ab3a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.events; import java.util.ArrayList; @@ -38,7 +37,7 @@ public class PlotUnlinkEvent extends Event implements Cancellable { private final ArrayList plots; private final World world; private boolean cancelled; - + /** * Called when a mega-plot is unlinked. * @@ -49,11 +48,11 @@ public class PlotUnlinkEvent extends Event implements Cancellable { this.plots = plots; this.world = world; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plots involved * @@ -62,21 +61,21 @@ public class PlotUnlinkEvent extends Event implements Cancellable { public ArrayList getPlots() { return this.plots; } - + public World getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java index 3bf3dd4e3..e35d2ec98 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.flag; import org.apache.commons.lang.StringUtils; @@ -30,13 +29,13 @@ import org.apache.commons.lang.StringUtils; * @author Empire92 */ public class AbstractFlag { - public final String key; public final FlagValue value; - + public AbstractFlag(final String key) { this(key, new FlagValue.StringValue()); } + /** * AbstractFlag is a parameter used in creating a new Flag
* The key must be alphabetical characters and <= 16 characters in length @@ -60,12 +59,11 @@ public class AbstractFlag { public boolean isList() { return this.value instanceof FlagValue.ListValue; } - + public Object parseValueRaw(final String value) { try { return this.value.parse(value); - } - catch (Exception e) { + } catch (final Exception e) { return null; } } @@ -77,7 +75,7 @@ public class AbstractFlag { public String getValueDesc() { return this.value.getDescription(); } - + /** * AbstractFlag key * @@ -86,12 +84,12 @@ public class AbstractFlag { public String getKey() { return this.key; } - + @Override public String toString() { return this.key; } - + @Override public boolean equals(final Object other) { if (other == null) { @@ -106,5 +104,4 @@ public class AbstractFlag { final AbstractFlag otherObj = (AbstractFlag) other; return (otherObj.key.equals(this.key)); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index 034a76373..9db2081bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.flag; import org.apache.commons.lang.StringUtils; @@ -26,7 +25,7 @@ import org.apache.commons.lang.StringUtils; public class Flag { private AbstractFlag key; private Object value; - + /** * Flag object used to store basic information for a Plot. Flags are a key/value pair. For a flag to be usable by a * player, you need to register it with PlotSquared. @@ -37,7 +36,7 @@ public class Flag { * @throws IllegalArgumentException if you provide inadequate inputs */ public Flag(final AbstractFlag key, final String value) { - final char[] allowedCharacters = new char[]{'[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', ':', '\u00A7'}; + final char[] allowedCharacters = new char[] { '[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', ':', '\u00A7' }; String tempValue = value; for (final char c : allowedCharacters) { tempValue = tempValue.replace(c, 'c'); @@ -55,21 +54,21 @@ public class Flag { } } - public void setKey(AbstractFlag key) { + public void setKey(final AbstractFlag key) { this.key = key; if (this.value instanceof String) { this.value = key.parseValueRaw((String) this.value); } } - + /** * Warning: Unchecked */ public Flag(final AbstractFlag key, final Object value) { - this.key = key; - this.value = value; + this.key = key; + this.value = value; } - + /** * Get the AbstractFlag used in creating the flag * @@ -78,7 +77,7 @@ public class Flag { public AbstractFlag getAbstractFlag() { return this.key; } - + /** * Get the key for the AbstractFlag * @@ -87,7 +86,7 @@ public class Flag { public String getKey() { return this.key.getKey(); } - + /** * Get the value * @@ -98,9 +97,9 @@ public class Flag { } public String getValueString() { - return this.key.toString(this.value); + return this.key.toString(this.value); } - + @Override public String toString() { if (this.value.equals("")) { @@ -108,7 +107,7 @@ public class Flag { } return this.key + ":" + getValueString(); } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -123,7 +122,7 @@ public class Flag { final Flag other = (Flag) obj; return (this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value)); } - + @Override public int hashCode() { return this.key.getKey().hashCode(); 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 38b0533c1..060a84f55 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.flag; import java.util.ArrayList; @@ -46,15 +45,14 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings("unused") public class FlagManager { - +@SuppressWarnings("unused") +public class FlagManager { // TODO add some flags // - Plot clear interval // - Mob cap // - customized plot composition - private final static ArrayList flags = new ArrayList<>(); - + /** * Register an AbstractFlag with PlotSquared * @@ -64,10 +62,10 @@ import com.intellectualcrafters.plot.object.PlotWorld; */ public static boolean addFlag(final AbstractFlag af) { PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af); - String key = af.getKey(); + af.getKey(); if (PlotSquared.getAllPlotsRaw() != null) { - for (Plot plot : PlotSquared.getPlots()) { - for (Flag flag : plot.settings.flags) { + for (final Plot plot : PlotSquared.getPlots()) { + for (final Flag flag : plot.settings.flags) { if (flag.getAbstractFlag().getKey().equals(af.getKey())) { flag.setKey(af); } @@ -76,14 +74,14 @@ import com.intellectualcrafters.plot.object.PlotWorld; } return (getFlag(af.getKey()) == null) && flags.add(af); } - - public static Flag getSettingFlag(String world, PlotSettings settings, String flag) { - ArrayList flags = new ArrayList<>(); - if (settings.flags != null && settings.flags.size() > 0) { - flags.addAll(settings.flags); + + public static Flag getSettingFlag(final String world, final PlotSettings settings, final String flag) { + final ArrayList flags = new ArrayList<>(); + if ((settings.flags != null) && (settings.flags.size() > 0)) { + flags.addAll(settings.flags); } - PlotWorld plotworld = PlotSquared.getWorldSettings(world); - if (plotworld != null && plotworld.DEFAULT_FLAGS != null && plotworld.DEFAULT_FLAGS.length > 0) { + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + if ((plotworld != null) && (plotworld.DEFAULT_FLAGS != null) && (plotworld.DEFAULT_FLAGS.length > 0)) { flags.addAll(Arrays.asList(plotworld.DEFAULT_FLAGS)); } for (final Flag myflag : flags) { @@ -100,19 +98,19 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param flag * @return */ - public static Flag getPlotFlag(Plot plot, String flag) { + public static Flag getPlotFlag(final Plot plot, final String flag) { return getSettingFlag(plot.world, plot.settings, flag); } - public static boolean isPlotFlagTrue(Plot plot, String strFlag) { - Flag flag = getPlotFlag(plot, strFlag); - if (flag == null) { - return false; - } - if (flag.getValue() instanceof Boolean) { - return (boolean) flag.getValue(); - } - return false; + public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) { + final Flag flag = getPlotFlag(plot, strFlag); + if (flag == null) { + return false; + } + if (flag.getValue() instanceof Boolean) { + return (boolean) flag.getValue(); + } + return false; } /** @@ -121,13 +119,13 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param flag * @return */ - public static Flag getPlotFlagAbs(Plot plot, String flag) { - return getSettingFlagAbs(plot.settings, flag); + public static Flag getPlotFlagAbs(final Plot plot, final String flag) { + return getSettingFlagAbs(plot.settings, flag); } - public static Flag getSettingFlagAbs(PlotSettings settings, String flag) { - if (settings.flags == null || settings.flags.size() == 0) { - return null; + public static Flag getSettingFlagAbs(final PlotSettings settings, final String flag) { + if ((settings.flags == null) || (settings.flags.size() == 0)) { + return null; } for (final Flag myflag : settings.flags) { if (myflag.getKey().equals(flag)) { @@ -142,7 +140,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; * @param plot * @param flag */ - public static boolean addPlotFlag(Plot plot, final Flag flag) { + public static boolean addPlotFlag(final Plot plot, final Flag flag) { final PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -157,8 +155,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; return true; } - public static boolean addClusterFlag(PlotCluster cluster, final Flag flag) { - //TODO plot cluster flag event + public static boolean addClusterFlag(final PlotCluster cluster, final Flag flag) { + //TODO plot cluster flag event final Flag hasFlag = getSettingFlag(cluster.world, cluster.settings, flag.getKey()); if (hasFlag != null) { cluster.settings.flags.remove(hasFlag); @@ -169,23 +167,23 @@ import com.intellectualcrafters.plot.object.PlotWorld; } /** - * + * * @param plot * @return */ - public static Set getPlotFlags(Plot plot) { + public static Set getPlotFlags(final Plot plot) { return getSettingFlags(plot.world, plot.settings); } - public static Set getSettingFlags(String world, PlotSettings settings) { - Set plotflags = settings.flags; - 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) { + public static Set getSettingFlags(final String world, final PlotSettings settings) { + final Set plotflags = settings.flags; + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + if ((plotworld != null) && (plotworld.DEFAULT_FLAGS != null) && (plotworld.DEFAULT_FLAGS.length > 0)) { + final HashSet flagStrings = new HashSet<>(); + for (final Flag flag : plotflags) { flagStrings.add(flag.getKey()); } - for (Flag newflag : plotworld.DEFAULT_FLAGS) { + for (final Flag newflag : plotworld.DEFAULT_FLAGS) { if (!flagStrings.contains(newflag.getKey())) { plotflags.add(newflag); } @@ -194,10 +192,10 @@ import com.intellectualcrafters.plot.object.PlotWorld; return plotflags; } - public static boolean removePlotFlag(Plot plot, String flag) { + public static boolean removePlotFlag(final Plot plot, final String flag) { final Flag hasFlag = getPlotFlag(plot, flag); if (hasFlag != null) { - Flag flagObj = FlagManager.getPlotFlagAbs(plot, flag); + final Flag flagObj = FlagManager.getPlotFlagAbs(plot, flag); if (flagObj != null) { final PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flagObj, plot); Bukkit.getServer().getPluginManager().callEvent(event); @@ -212,12 +210,12 @@ import com.intellectualcrafters.plot.object.PlotWorld; return false; } - public static boolean removeClusterFlag(PlotCluster cluster, String flag) { + public static boolean removeClusterFlag(final PlotCluster cluster, final String flag) { final Flag hasFlag = getSettingFlag(cluster.world, cluster.settings, flag); if (hasFlag != null) { - Flag flagObj = FlagManager.getSettingFlagAbs(cluster.settings, flag); + final Flag flagObj = FlagManager.getSettingFlagAbs(cluster.settings, flag); if (flagObj != null) { - //TODO cluster flag add event + //TODO cluster flag add event cluster.settings.flags.remove(hasFlag); DBFunc.setFlags(cluster, cluster.settings.flags); return true; @@ -225,8 +223,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; } return false; } - - public static void setPlotFlags(Plot plot, Set flags) { + + public static void setPlotFlags(final Plot plot, final Set flags) { if (flags == null) { plot.settings.flags = new HashSet<>(); DBFunc.setFlags(plot.world, plot, plot.settings.flags); @@ -236,7 +234,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; DBFunc.setFlags(plot.world, plot, plot.settings.flags); } - public static void setClusterFlags(PlotCluster cluster, Set flags) { + public static void setClusterFlags(final PlotCluster cluster, final Set flags) { if (flags == null) { cluster.settings.flags = new HashSet<>(); DBFunc.setFlags(cluster, cluster.settings.flags); @@ -245,7 +243,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; cluster.settings.flags = flags; DBFunc.setFlags(cluster, cluster.settings.flags); } - + public static Flag[] removeFlag(final Flag[] flags, final String r) { final Flag[] f = new Flag[flags.length - 1]; int index = 0; @@ -256,10 +254,9 @@ import com.intellectualcrafters.plot.object.PlotWorld; } return f; } - + public static Set removeFlag(final Set flags, final String r) { final HashSet newflags = new HashSet<>(); - int index = 0; for (final Flag flag : flags) { if (!flag.getKey().equalsIgnoreCase(r)) { newflags.add(flag); @@ -276,7 +273,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; public static List getFlags() { return flags; } - + /** * Get a list of registerd AbstragFlag objects based on player permissions * @@ -293,7 +290,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; } return returnFlags; } - + /** * Get an AbstractFlag by a string Returns null if flag does not exist * @@ -309,7 +306,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; } return null; } - + /** * Get an AbstractFlag by a string * @@ -326,7 +323,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; } return getFlag(string); } - + /** * Remove a registered AbstractFlag * @@ -337,7 +334,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; public static boolean removeFlag(final AbstractFlag flag) { return flags.remove(flag); } - + public static Flag[] parseFlags(final List flagstrings) { final Flag[] flags = new Flag[flagstrings.size()]; for (int i = 0; i < flagstrings.size(); i++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index 6218f24a5..5166a68ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -12,97 +12,91 @@ import com.intellectualcrafters.plot.object.PlotBlock; * @author Citymonstret */ public abstract class FlagValue { - private final Class clazz; - + @SuppressWarnings("unchecked") - public FlagValue() { + public FlagValue() { this.clazz = (Class) getClass(); } - + public FlagValue(final Class clazz) { if (clazz == null) { throw new NullPointerException(); } this.clazz = clazz; } - + public boolean validValue(final Object value) { return (value != null) && (value.getClass() == this.clazz); } - public String toString(Object t) { - return t.toString(); + public String toString(final Object t) { + return t.toString(); } - + public abstract T getValue(Object t); - + public abstract T parse(String t); - + public abstract String getDescription(); - + public static class BooleanValue extends FlagValue { - @Override public Boolean getValue(final Object t) { return (Boolean) t; } - + @Override public Boolean parse(final String t) { - try { - return Boolean.parseBoolean(t); - } - catch (IllegalArgumentException e) { - return null; - } + try { + return Boolean.parseBoolean(t); + } catch (final IllegalArgumentException e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a boolean (true|false)"; + return "Flag value must be a boolean (true|false)"; } } public static class IntegerValue extends FlagValue { - @Override public Integer getValue(final Object t) { return (Integer) t; } - + @Override public Integer parse(final String t) { - try { - return Integer.parseInt(t); - } - catch (IllegalArgumentException e) { - return null; - } + try { + return Integer.parseInt(t); + } catch (final IllegalArgumentException e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a whole number"; + return "Flag value must be a whole number"; } } public static class IntervalValue extends FlagValue { - - @Override - public String toString(Object t) { - Integer[] value = ((Integer[]) t); - return value[0] + " " + value[1]; - } - + @Override + public String toString(final Object t) { + final Integer[] value = ((Integer[]) t); + return value[0] + " " + value[1]; + } + @Override public Integer[] getValue(final Object t) { return (Integer[]) t; } - + @Override public Integer[] parse(final String t) { - int seconds; + int seconds; int amount; final String[] values = t.split(" "); if (values.length < 2) { @@ -120,262 +114,241 @@ public abstract class FlagValue { return null; } } - return new Integer[]{amount, seconds}; + return new Integer[] { amount, seconds }; } - + @Override public String getDescription() { - return "Value(s) must be numeric. /plot set flag {flag} {amount} [seconds]"; + return "Value(s) must be numeric. /plot set flag {flag} {amount} [seconds]"; } } public static class UnsignedIntegerValue extends FlagValue { - @Override public Integer getValue(final Object t) { return (Integer) t; } - + @Override public Integer parse(final String t) { - try { - int value = Integer.parseInt(t); - if (value >= 0) { - return null; - } - return value; - } - catch (IllegalArgumentException e) { - return null; - } + try { + final int value = Integer.parseInt(t); + if (value >= 0) { + return null; + } + return value; + } catch (final IllegalArgumentException e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a positive whole number (includes 0)"; + return "Flag value must be a positive whole number (includes 0)"; } } public static class DoubleValue extends FlagValue { - @Override public Double getValue(final Object t) { return (Double) t; } - + @Override public Double parse(final String t) { - try { - return Double.parseDouble(t); - } - catch (IllegalArgumentException e) { - return null; - } + try { + return Double.parseDouble(t); + } catch (final IllegalArgumentException e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a number (negative decimals are allowed)"; + return "Flag value must be a number (negative decimals are allowed)"; } } public static class LongValue extends FlagValue { - @Override public Long getValue(final Object t) { return (Long) t; } - + @Override public Long parse(final String t) { - try { - return Long.parseLong(t); - } - catch (IllegalArgumentException e) { - return null; - } + try { + return Long.parseLong(t); + } catch (final IllegalArgumentException e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a whole number (large numbers allowed)"; + return "Flag value must be a whole number (large numbers allowed)"; } } public static class UnsignedLongValue extends FlagValue { - @Override public Long getValue(final Object t) { return (Long) t; } - + @Override public Long parse(final String t) { - try { - long value = Long.parseLong(t); - if (value < 0) { - return null; - } - return value; - } - catch (IllegalArgumentException e) { - return null; - } + try { + final long value = Long.parseLong(t); + if (value < 0) { + return null; + } + return value; + } catch (final IllegalArgumentException e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a positive whole number (large numbers allowed)"; + return "Flag value must be a positive whole number (large numbers allowed)"; } } public static class UnsignedDoubleValue extends FlagValue { - @Override public Double getValue(final Object t) { return (Double) t; } - + @Override public Double parse(final String t) { - try { - double value = Double.parseDouble(t); - if (value < 0) { - return null; - } - return value; - } - catch (IllegalArgumentException e) { - return null; - } + try { + final double value = Double.parseDouble(t); + if (value < 0) { + return null; + } + return value; + } catch (final IllegalArgumentException e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a positive number (decimals allowed)"; + return "Flag value must be a positive number (decimals allowed)"; } } public static class PlotBlockValue extends FlagValue { - @Override public PlotBlock getValue(final Object t) { return (PlotBlock) t; } - + @Override public PlotBlock parse(final String t) { - try { - String[] split = t.split(":"); - byte data; - if (split.length == 2) { - if ("*".equals(split[1])) { + try { + final String[] split = t.split(":"); + byte data; + if (split.length == 2) { + if ("*".equals(split[1])) { data = -1; - } - else { + } else { data = Byte.parseByte(split[1]); } - } - else { - data = -1; - } - short id = Short.parseShort(split[0]); - return new PlotBlock(id, data); - } - catch (Exception e) { - return null; - } + } else { + data = -1; + } + final short id = Short.parseShort(split[0]); + return new PlotBlock(id, data); + } catch (final Exception e) { + return null; + } } - + @Override public String getDescription() { - return "Flag value must be a number (negative decimals are allowed)"; + return "Flag value must be a number (negative decimals are allowed)"; } } public interface ListValue { public void add(Object t, String value); + public void remove(Object t, String value); } public static class PlotBlockListValue extends FlagValue> implements ListValue { - - @SuppressWarnings("unchecked") - @Override - public String toString(Object t) { - return StringUtils.join((HashSet) t, ","); - } - @SuppressWarnings("unchecked") - @Override - public HashSet getValue(final Object t) { - return (HashSet)t; + @Override + public String toString(final Object t) { + return StringUtils.join((HashSet) t, ","); } - + + @SuppressWarnings("unchecked") + @Override + public HashSet getValue(final Object t) { + return (HashSet) t; + } + @Override public HashSet parse(final String t) { - HashSet list = new HashSet(); - for (String item : t.split(",")) { - String[] split = item.split(":"); - byte data; - if (split.length == 2) { - if ("*".equals(split[1])) { - data = -1; - } - else { - data = Byte.parseByte(split[1]); - } - } - else { - data = -1; - } - short id = Short.parseShort(split[0]); - PlotBlock block = new PlotBlock(id, data); - list.add(block); + final HashSet list = new HashSet(); + for (final String item : t.split(",")) { + final String[] split = item.split(":"); + byte data; + if (split.length == 2) { + if ("*".equals(split[1])) { + data = -1; + } else { + data = Byte.parseByte(split[1]); + } + } else { + data = -1; + } + final short id = Short.parseShort(split[0]); + final PlotBlock block = new PlotBlock(id, data); + list.add(block); } return list; } - + @Override public String getDescription() { - return "Flag value must be a block list"; + return "Flag value must be a block list"; } - + @Override - public void add(Object t, String value) { + public void add(final Object t, final String value) { try { - ((HashSet)t).addAll(parse(value)); - } - catch (Exception e) { - + ((HashSet) t).addAll(parse(value)); + } catch (final Exception e) { } } - + @Override - public void remove(Object t, String value) { + public void remove(final Object t, final String value) { try { - for (PlotBlock item : parse(value)) { - ((HashSet)t).remove(item); + for (final PlotBlock item : parse(value)) { + ((HashSet) t).remove(item); } - } - catch (Exception e) { - + } catch (final Exception e) { } } } - + public static class StringValue extends FlagValue { - @Override public String parse(final String s) { return s; } - + @Override public String getDescription() { return "Flag value must be alphanumeric. Some special characters are allowed."; } - + @Override public String getValue(final Object t) { return t.toString(); 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 3d0f43331..7d6fa0dee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -17,184 +17,167 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class AugmentedPopulator extends BlockPopulator { - - public final PlotWorld plotworld; - public final PlotManager manager; - public final PlotGenerator generator; - public final PlotCluster cluster; - public final Random r = new Random(); - public final boolean p; - public final boolean b; - public final boolean o; - - private final int bx; - private final int bz; - private final int tx; - private final int tz; - - public BlockWrapper get(int X, int Z, int i, int j, short[][] r, boolean c) { - int y = (i << 4) + (j >> 8); - int a = (j - ((y & 0xF) << 8)); - int z = (a >> 4); - int x = a - (z << 4); - if (r[i] == null) { - return (c && (Z + z < bz || Z + z > tz || X + x < bx || X + x > tx)) ? null : new BlockWrapper(x, y, z, (short) 0, (byte) 0); - } - else { - return (c && (Z + z < bz || Z + z > tz || X + x < bx || X + x > tx)) ? null : new BlockWrapper(x, y, z, r[i][j], (byte) 0); - } - } - - public AugmentedPopulator(String world, PlotGenerator generator, PlotCluster cluster, boolean p, boolean b) { - this.cluster = cluster; - this.generator = generator; - this.plotworld = PlotSquared.getWorldSettings(world); - this.manager = generator.getPlotManager(); - this.p = p; - this.b = b; - this.o = this.plotworld.TERRAIN == 1 || this.plotworld.TERRAIN == 2; - - World bukkitWorld = Bukkit.getWorld(world); - - if (cluster != null) { - Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); - Location tl = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1); - - this.bx = bl.getX(); - this.bz = bl.getZ(); - - this.tx = tl.getX(); - this.tz = tl.getZ(); - } - else { - this.bx = Integer.MIN_VALUE; + public final PlotWorld plotworld; + public final PlotManager manager; + public final PlotGenerator generator; + public final PlotCluster cluster; + public final Random r = new Random(); + public final boolean p; + public final boolean b; + public final boolean o; + private final int bx; + private final int bz; + private final int tx; + private final int tz; + + public BlockWrapper get(final int X, final int Z, final int i, final int j, final short[][] r, final boolean c) { + final int y = (i << 4) + (j >> 8); + final int a = (j - ((y & 0xF) << 8)); + final int z = (a >> 4); + final int x = a - (z << 4); + if (r[i] == null) { + return (c && (((Z + z) < this.bz) || ((Z + z) > this.tz) || ((X + x) < this.bx) || ((X + x) > this.tx))) ? null : new BlockWrapper(x, y, z, (short) 0, (byte) 0); + } else { + return (c && (((Z + z) < this.bz) || ((Z + z) > this.tz) || ((X + x) < this.bx) || ((X + x) > this.tx))) ? null : new BlockWrapper(x, y, z, r[i][j], (byte) 0); + } + } + + public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { + this.cluster = cluster; + this.generator = generator; + this.plotworld = PlotSquared.getWorldSettings(world); + this.manager = generator.getPlotManager(); + this.p = p; + this.b = b; + this.o = (this.plotworld.TERRAIN == 1) || (this.plotworld.TERRAIN == 2); + final World bukkitWorld = Bukkit.getWorld(world); + if (cluster != null) { + final Location bl = this.manager.getPlotBottomLocAbs(this.plotworld, cluster.getP1()); + final Location tl = this.manager.getPlotTopLocAbs(this.plotworld, cluster.getP2()).add(1, 0, 1); + this.bx = bl.getX(); + this.bz = bl.getZ(); + this.tx = tl.getX(); + this.tz = tl.getZ(); + } else { + this.bx = Integer.MIN_VALUE; this.bz = Integer.MIN_VALUE; - this.tx = Integer.MAX_VALUE; this.tz = Integer.MAX_VALUE; - } - - // Add the populator - if (this.o) { - bukkitWorld.getPopulators().add(0, this); - } - else { - bukkitWorld.getPopulators().add(this); - } - } - - @Override - public void populate(final World world, final Random rand, final Chunk chunk) { - final int X = chunk.getX(); - final int Z = chunk.getZ(); - final int x = X << 4; - final int z = Z << 4; - int x2 = x + 15; - int z2 = z + 15; - - boolean inX1 = (x >= bx && x <= tx); - boolean inX2 = (x2 >= bx && x2 <= tx); - boolean inZ1 = (z >= bz && z <= tz); - boolean inZ2 = (z2 >= bz && z2 <= tz); - - boolean inX = inX1 || inX2; - boolean inZ = inZ1 || inZ2; - - if (!inX || !inZ) { - return; - } - - final boolean check; - if (!inX1 || !inX2 || !inZ1 || !inZ2) { - check = true; - } - else { - check = false; - } - if (plotworld.TERRAIN == 2) { - PlotId plot1 = manager.getPlotIdAbs(plotworld, x, 0, z); - PlotId plot2 = manager.getPlotIdAbs(plotworld, x2, 0, z2); - if (plot1 != null && plot2 != null && plot1.equals(plot2)) { - return; - } - } - if (this.o) { - chunk.load(true); - populateBlocks(world, rand, X, Z, x, z, check); - BukkitTaskManager.runTaskLater(new Runnable() { + } + // Add the populator + if (this.o) { + bukkitWorld.getPopulators().add(0, this); + } else { + bukkitWorld.getPopulators().add(this); + } + } + + @Override + public void populate(final World world, final Random rand, final Chunk chunk) { + final int X = chunk.getX(); + final int Z = chunk.getZ(); + final int x = X << 4; + final int z = Z << 4; + final int x2 = x + 15; + final int z2 = z + 15; + final boolean inX1 = ((x >= this.bx) && (x <= this.tx)); + final boolean inX2 = ((x2 >= this.bx) && (x2 <= this.tx)); + final boolean inZ1 = ((z >= this.bz) && (z <= this.tz)); + final boolean inZ2 = ((z2 >= this.bz) && (z2 <= this.tz)); + final boolean inX = inX1 || inX2; + final boolean inZ = inZ1 || inZ2; + if (!inX || !inZ) { + return; + } + final boolean check; + if (!inX1 || !inX2 || !inZ1 || !inZ2) { + check = true; + } else { + check = false; + } + if (this.plotworld.TERRAIN == 2) { + final PlotId plot1 = this.manager.getPlotIdAbs(this.plotworld, x, 0, z); + final PlotId plot2 = this.manager.getPlotIdAbs(this.plotworld, x2, 0, z2); + if ((plot1 != null) && (plot2 != null) && plot1.equals(plot2)) { + return; + } + } + if (this.o) { + chunk.load(true); + populateBlocks(world, rand, X, Z, x, z, check); + TaskManager.runTaskLater(new Runnable() { @Override public void run() { populateBiome(world, x, z); chunk.unload(true, true); - SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); + SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } }, 20); - } - else { - BukkitTaskManager.runTaskLater(new Runnable() { + } else { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { populateBiome(world, x, z); } }, 20 + rand.nextInt(10)); - BukkitTaskManager.runTaskLater(new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); chunk.unload(true, true); - SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); + SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } }, 40 + rand.nextInt(40)); - } - } - - private void populateBiome(World world, int x, int z) { - if (this.b) { - for (int i = 0; i < 16; i++) { - for (int j = 0; j < 16; j++) { - world.setBiome(x + i, z + j, plotworld.PLOT_BIOME); - } - } - } - } - - private void populateBlocks(World world, Random rand, int X, int Z, int x, int z, boolean check) { - short[][] result = generator.generateExtBlockSections(world, rand, X, Z, null); - int length = result[0].length; - for(int i = 0; i < result.length; i++) { - for(int j = 0; j < length; j++) { - BlockWrapper blockInfo = get(x, z, i, j, result, check); + } + } + + private void populateBiome(final World world, final int x, final int z) { + if (this.b) { + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 16; j++) { + world.setBiome(x + i, z + j, this.plotworld.PLOT_BIOME); + } + } + } + } + + private void populateBlocks(final World world, final Random rand, final int X, final int Z, final int x, final int z, final boolean check) { + final short[][] result = this.generator.generateExtBlockSections(world, rand, X, Z, null); + final int length = result[0].length; + for (int i = 0; i < result.length; i++) { + for (int j = 0; j < length; j++) { + final BlockWrapper blockInfo = get(x, z, i, j, result, check); if (blockInfo == null) { continue; } - int xx = x + blockInfo.x; - int zz = z + blockInfo.z; - if (p) { - if (ChunkManager.CURRENT_PLOT_CLEAR != null) { - if (ChunkManager.isIn(ChunkManager.CURRENT_PLOT_CLEAR, xx, zz)) { + final int xx = x + blockInfo.x; + final int zz = z + blockInfo.z; + if (this.p) { + if (AChunkManager.CURRENT_PLOT_CLEAR != null) { + if (ChunkManager.isIn(AChunkManager.CURRENT_PLOT_CLEAR, xx, zz)) { continue; } - } - else if (manager.getPlotIdAbs(plotworld, xx, 0, zz) != null) { + } else if (this.manager.getPlotIdAbs(this.plotworld, xx, 0, zz) != null) { continue; } } PlotHelper.setBlock(world, xx, blockInfo.y, zz, blockInfo.id, (byte) 0); } } - for (BlockPopulator populator : generator.getDefaultPopulators(world)) { - populator.populate(world, r,world.getChunkAt(X, Z)); + for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) { + populator.populate(world, this.r, world.getChunkAt(X, Z)); } - } - - public boolean isIn(RegionWrapper plot, int x, int z) { - return (x >= plot.minX && x <= plot.maxX && z >= plot.minZ && z <= plot.maxZ); } -} \ No newline at end of file + + public boolean isIn(final RegionWrapper plot, final int x, final int z) { + return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); + } +} 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 878fb7589..a22103198 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -12,15 +12,13 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlotHelper; - /** - * A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot) + * A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot) */ public abstract class ClassicPlotManager extends SquarePlotManager { - @Override - public boolean setComponent(World world, PlotWorld plotworld, PlotId plotid, String component, PlotBlock[] blocks) { - switch(component) { + public boolean setComponent(final World world, final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) { + switch (component) { case "floor": { setFloor(world, plotworld, plotid, blocks); return true; @@ -36,7 +34,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return false; } - + public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location pos1 = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); @@ -44,7 +42,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { PlotHelper.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks); return true; } - + public boolean setWallFilling(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; if (dpw.ROAD_WIDTH == 0) { @@ -52,7 +50,6 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); final Location top = PlotHelper.getPlotTopLoc(w, plotid); - int x, z; z = bottom.getBlockZ(); for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) { @@ -60,14 +57,12 @@ public abstract class ClassicPlotManager extends SquarePlotManager { PlotHelper.setBlock(w, x, y, z, blocks); } } - x = top.getBlockX() + 1; for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { PlotHelper.setBlock(w, x, y, z, blocks); } } - z = top.getBlockZ() + 1; for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { @@ -82,7 +77,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return true; } - + public boolean setWall(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; if (dpw.ROAD_WIDTH == 0) { @@ -90,9 +85,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); final Location top = PlotHelper.getPlotTopLoc(w, plotid); - int x, z; - z = bottom.getBlockZ(); for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) { PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); @@ -111,147 +104,112 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return true; } - + /** * PLOT MERGING */ - @Override public boolean createRoadEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World w = Bukkit.getWorld(plot.world); - final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sx = pos2.getBlockX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos1.getBlockZ() - 1; final int ez = pos2.getBlockZ() + 2; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); PlotHelper.setCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); PlotHelper.setCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); - return true; } - + @Override public boolean createRoadSouth(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World w = Bukkit.getWorld(plot.world); - final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sz = pos2.getBlockZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int sx = pos1.getBlockX() - 1; final int ex = pos2.getBlockX() + 2; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); PlotHelper.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING); PlotHelper.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); - return true; } - + @Override public boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World w = Bukkit.getWorld(plot.world); - final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sx = pos2.getBlockX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos2.getBlockZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); PlotHelper.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0)); PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); - return true; } - + @Override public boolean removeRoadEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World w = Bukkit.getWorld(plot.world); - final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sx = pos2.getBlockX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos1.getBlockZ(); final int ez = pos2.getBlockZ() + 1; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); - return true; } - + @Override public boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World w = Bukkit.getWorld(plot.world); - final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sz = pos2.getBlockZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int sx = pos1.getBlockX(); final int ex = pos2.getBlockX() + 1; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); - return true; } - + @Override public boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World world = Bukkit.getWorld(plot.world); - final Location loc = getPlotTopLocAbs(dpw, plot.id); - final int sx = loc.getBlockX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = loc.getBlockZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - PlotHelper.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); PlotHelper.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); return true; } - + /** * Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED) */ @@ -259,62 +217,58 @@ public abstract class ClassicPlotManager extends SquarePlotManager { public boolean finishPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final PlotId pos1 = plotIds.get(0); - PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; + final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; if (block.id != 0) { - setWall(world, plotworld, pos1, new PlotBlock[] {(( ClassicPlotWorld) plotworld).WALL_BLOCK }); + setWall(world, plotworld, pos1, new PlotBlock[] { ((ClassicPlotWorld) plotworld).WALL_BLOCK }); } return true; } - + @Override public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds) { - PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; - PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; - for (PlotId id : plotIds) { + final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; + final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; + for (final PlotId id : plotIds) { if (block.equals(unclaim)) { - setWall(world, plotworld, id, new PlotBlock[] {block }); + setWall(world, plotworld, id, new PlotBlock[] { block }); } } return true; } - + @Override public boolean startPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds) { return true; } - + @Override public boolean startPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds) { return true; } - + @Override - public boolean claimPlot(World world, final PlotWorld plotworld, Plot plot) { - PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; - PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; + public boolean claimPlot(final World world, final PlotWorld plotworld, final Plot plot) { + final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; + final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; if (claim.equals(unclaim)) { - setWall(world, plotworld, plot.id, new PlotBlock[] {claim}); + setWall(world, plotworld, plot.id, new PlotBlock[] { claim }); } return true; } - + @Override - public boolean unclaimPlot(World world, final PlotWorld plotworld, Plot plot) { - PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; - PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; + public boolean unclaimPlot(final World world, final PlotWorld plotworld, final Plot plot) { + final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; + final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; if (claim != unclaim) { - setWall(world, plotworld, plot.id, new PlotBlock[] {unclaim}); + setWall(world, plotworld, plot.id, new PlotBlock[] { unclaim }); } return true; } - + @Override - public String[] getPlotComponents(PlotWorld plotworld, PlotId plotid) { - return new String[] { - "floor", - "wall", - "border" - }; + public String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid) { + return new String[] { "floor", "wall", "border" }; } /** @@ -323,7 +277,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { @Override public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - Location bot = PlotHelper.getPlotBottomLoc(plotworld.worldname, plot.id); + final Location bot = PlotHelper.getPlotBottomLoc(plotworld.worldname, plot.id); return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getBlockX(), dpw.ROAD_HEIGHT + 1, bot.getBlockZ() - 1); } } 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 9e621ef29..187505d61 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java @@ -18,7 +18,6 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { public final static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1); public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0); public final static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0); - public int ROAD_HEIGHT; public int PLOT_HEIGHT; public int WALL_HEIGHT; @@ -39,7 +38,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { */ @Override public ConfigurationNode[] getSettingNodes() { - return new ConfigurationNode[] { new ConfigurationNode("plot.height", ClassicPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true), new ConfigurationNode("plot.size", ClassicPlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true), new ConfigurationNode("plot.filling", ClassicPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.floor", ClassicPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("wall.block", ClassicPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), new ConfigurationNode("wall.block_claimed", ClassicPlotWorld.CLAIMED_WALL_BLOCK_DEFAULT, "Wall block (claimed)", Configuration.BLOCK, true), new ConfigurationNode("road.width", ClassicPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true), + return new ConfigurationNode[] { new ConfigurationNode("plot.height", ClassicPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true), new ConfigurationNode("plot.size", SquarePlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true), new ConfigurationNode("plot.filling", ClassicPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.floor", ClassicPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("wall.block", ClassicPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), new ConfigurationNode("wall.block_claimed", ClassicPlotWorld.CLAIMED_WALL_BLOCK_DEFAULT, "Wall block (claimed)", Configuration.BLOCK, true), new ConfigurationNode("road.width", SquarePlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true), new ConfigurationNode("road.height", ClassicPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true), new ConfigurationNode("road.block", ClassicPlotWorld.ROAD_BLOCK_DEFAULT, "Road block", Configuration.BLOCK, true), new ConfigurationNode("wall.filling", ClassicPlotWorld.WALL_FILLING_DEFAULT, "Wall filling block", Configuration.BLOCK, true), new ConfigurationNode("wall.height", ClassicPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", Configuration.INTEGER, true), new ConfigurationNode("plot.bedrock", true, "Plot bedrock generation", Configuration.BOOLEAN, true) }; } @@ -64,11 +63,10 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling")); this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height")); this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block_claimed")); - this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH); } - public ClassicPlotWorld(String worldname) { + public ClassicPlotWorld(final String worldname) { super(worldname); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotManager.java index a131a1499..5d737a910 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotManager.java @@ -6,5 +6,4 @@ import com.intellectualcrafters.plot.object.PlotManager; * A plot manager where plots tessellate in a grid formation symmetrical about x=z */ public abstract class GridPlotManager extends PlotManager { - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java index 64e925706..cc179feb9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java @@ -3,10 +3,9 @@ package com.intellectualcrafters.plot.generator; import com.intellectualcrafters.plot.object.PlotWorld; public abstract class GridPlotWorld extends PlotWorld { - public short SIZE; - public GridPlotWorld(String worldname) { + public GridPlotWorld(final String worldname) { super(worldname); } } 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 7cd5078ea..4675de0e6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.generator; import java.util.Arrays; @@ -38,7 +37,7 @@ import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.AChunkManager; /** * The default generator is very messy, as we have decided to try externalize all calculations from within the loop. - @@ -57,7 +56,6 @@ public class HybridGen extends PlotGenerator { * plotworld object */ public HybridPlotWorld plotworld = null; - /** * Some generator specific variables (implementation dependent) */ @@ -85,7 +83,7 @@ public class HybridGen extends PlotGenerator { * Faster sudo-random number generator than java.util.random */ private long state = 13; - + /** * Initialize variables, and create plotworld object used in calculations */ @@ -95,51 +93,39 @@ public class HybridGen extends PlotGenerator { this.plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); } this.plotsize = this.plotworld.PLOT_WIDTH; - this.pathsize = this.plotworld.ROAD_WIDTH; - this.roadblock = this.plotworld.ROAD_BLOCK.id; - this.wallfilling = this.plotworld.WALL_FILLING.id; this.size = this.pathsize + this.plotsize; this.wall = this.plotworld.WALL_BLOCK.id; - this.plotfloors = new short[this.plotworld.TOP_BLOCK.length]; for (int i = 0; i < this.plotworld.TOP_BLOCK.length; i++) { this.plotfloors[i] = this.plotworld.TOP_BLOCK[i].id; } - this.filling = new short[this.plotworld.MAIN_BLOCK.length]; for (int i = 0; i < this.plotworld.MAIN_BLOCK.length; i++) { this.filling[i] = this.plotworld.MAIN_BLOCK[i].id; } - - if (this.filling.length > 1 || this.plotfloors.length > 1) { + if ((this.filling.length > 1) || (this.plotfloors.length > 1)) { this.doState = true; } - this.wallheight = this.plotworld.WALL_HEIGHT; this.roadheight = this.plotworld.ROAD_HEIGHT; this.plotheight = this.plotworld.PLOT_HEIGHT; - if ((this.pathsize % 2) == 0) { this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1); } else { this.pathWidthLower = (short) (Math.floor(this.pathsize / 2)); } - this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); - this.biome = this.plotworld.PLOT_BIOME; - try { - maxY = Bukkit.getWorld(world).getMaxHeight(); - } - catch (NullPointerException e) { - maxY = 256; + this.maxY = Bukkit.getWorld(world).getMaxHeight(); + } catch (final NullPointerException e) { + this.maxY = 256; } } - + /** * Return the plot manager for this type of generator, or create one For square plots you may as well use the * default plot manager which comes with PlotSquared @@ -151,7 +137,7 @@ public class HybridGen extends PlotGenerator { } return HybridGen.manager; } - + /** * Allow spawning everywhere */ @@ -159,7 +145,7 @@ public class HybridGen extends PlotGenerator { public boolean canSpawn(final World world, final int x, final int z) { return true; } - + /** * Get a new plotworld class For square plots you can use the DefaultPlotWorld class which comes with PlotSquared */ @@ -170,43 +156,44 @@ public class HybridGen extends PlotGenerator { } return this.plotworld; } - + public final long nextLong() { final long a = this.state; this.state = xorShift64(a); return a; } - + public final long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - + public final int random(final int n) { final long r = ((nextLong() >>> 32) * n) >> 32; return (int) r; } - private void setBlock(short[][] result, int x, int y, int z, short[] blkids) { + + private void setBlock(final short[][] result, final int x, final int y, final int z, final short[] blkids) { if (blkids.length == 1) { setBlock(result, x, y, z, blkids[0]); - } - else { + } else { final int i = random(blkids.length); setBlock(result, x, y, z, blkids[i]); } } + /** * Standard setblock method for world generation */ - private void setBlock(short[][] result, int x, int y, int z, short blkid) { + private void setBlock(final short[][] result, final int x, final int y, final int z, final short blkid) { if (result[y >> 4] == null) { result[y >> 4] = new short[4096]; } result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; } - + /** * Return the block populator */ @@ -224,7 +211,7 @@ public class HybridGen extends PlotGenerator { // populator, ore populator return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld)); } - + /** * Return the default spawn location for this world */ @@ -232,47 +219,40 @@ public class HybridGen extends PlotGenerator { public Location getFixedSpawnLocation(final World world, final Random random) { return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0); } - + /** * This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world * generator */ @Override - public short[][] generateExtBlockSections(final World world, final Random random, int cx, int cz, final BiomeGrid biomes) { - if (doState) { + public short[][] generateExtBlockSections(final World world, final Random random, final int cx, final int cz, final BiomeGrid biomes) { + if (this.doState) { final int prime = 13; int h = 1; h = (prime * h) + cx; h = (prime * h) + cz; this.state = h; } - - this.result = new short[maxY / 16][]; - if (plotworld.PLOT_BEDROCK) { + this.result = new short[this.maxY / 16][]; + if (this.plotworld.PLOT_BEDROCK) { for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { setBlock(this.result, x, 0, z, (short) 7); } } } - - RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR; + final RegionWrapper plot = AChunkManager.CURRENT_PLOT_CLEAR; if (plot != null) { - - int X = cx << 4; - int Z = cz << 4; - + final int X = cx << 4; + final int Z = cz << 4; int sx = ((X) % this.size); int sz = ((Z) % this.size); - if (sx < 0) { sx += this.size; } - if (sz < 0) { sz += this.size; } - for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (biomes != null) { @@ -283,69 +263,56 @@ public class HybridGen extends PlotGenerator { setBlock(this.result, x, y, z, this.filling); } setBlock(this.result, x, this.plotheight, z, this.plotfloors); - } - else { - ChunkLoc loc = new ChunkLoc(X + x, Z + z); - HashMap blocks = ChunkManager.GENERATE_BLOCKS.get(loc); + } else { + final ChunkLoc loc = new ChunkLoc(X + x, Z + z); + final HashMap blocks = AChunkManager.GENERATE_BLOCKS.get(loc); if (blocks != null) { - for (short y : blocks.keySet()) { + for (final short y : blocks.keySet()) { setBlock(this.result, x, y, z, blocks.get(y).shortValue()); } } } } } - return this.result; } - int sx = ((cx << 4) % this.size); int sz = ((cz << 4) % this.size); - if (sx < 0) { sx += this.size; } - if (sz < 0) { sz += this.size; } - - for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - if (biomes != null) { biomes.setBiome(x, z, this.biome); } - - int absX = ((sx + x) % this.size); - int absZ = ((sz + z) % this.size); - - boolean gx = absX > pathWidthLower; - boolean gz = absZ > pathWidthLower; - - boolean lx = absX < pathWidthUpper; - boolean lz = absZ < pathWidthUpper; - + final int absX = ((sx + x) % this.size); + final int absZ = ((sz + z) % this.size); + final boolean gx = absX > this.pathWidthLower; + final boolean gz = absZ > this.pathWidthLower; + final boolean lx = absX < this.pathWidthUpper; + final boolean lz = absZ < this.pathWidthUpper; // inside plot if (gx && gz && lx && lz) { for (short y = 1; y < this.plotheight; y++) { setBlock(this.result, x, y, z, this.filling); } setBlock(this.result, x, this.plotheight, z, this.plotfloors); - if (plotworld.PLOT_SCHEMATIC) { - ChunkLoc loc = new ChunkLoc(absX, absZ); - HashMap blocks = this.plotworld.G_SCH.get(loc); + if (this.plotworld.PLOT_SCHEMATIC) { + final ChunkLoc loc = new ChunkLoc(absX, absZ); + final HashMap blocks = this.plotworld.G_SCH.get(loc); if (blocks != null) { - for (short y : blocks.keySet()) { - setBlock(this.result, x, this.plotheight + y, z, blocks.get(y)); + for (final short y : blocks.keySet()) { + setBlock(this.result, x, this.plotheight + y, z, blocks.get(y)); } } } } else { // wall - if ((absX >= pathWidthLower && absX <= pathWidthUpper && absZ >= pathWidthLower && absZ <= pathWidthUpper)) - { + if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { for (short y = 1; y <= this.wallheight; y++) { setBlock(this.result, x, y, z, this.wallfilling); } @@ -360,11 +327,11 @@ public class HybridGen extends PlotGenerator { } } if (this.plotworld.ROAD_SCHEMATIC_ENABLED) { - ChunkLoc loc = new ChunkLoc(absX, absZ); - HashMap blocks = this.plotworld.G_SCH.get(loc); + final ChunkLoc loc = new ChunkLoc(absX, absZ); + final HashMap blocks = this.plotworld.G_SCH.get(loc); if (blocks != null) { - for (short y : blocks.keySet()) { - setBlock(this.result, x, this.roadheight + y, z, blocks.get(y)); + for (final short y : blocks.keySet()) { + setBlock(this.result, x, this.roadheight + y, z, blocks.get(y)); } } } @@ -374,7 +341,7 @@ public class HybridGen extends PlotGenerator { return this.result; } - public boolean isIn(RegionWrapper plot, int x, int z) { - return (x >= plot.minX && x <= plot.maxX && z >= plot.minZ && z <= plot.maxZ); + public boolean isIn(final RegionWrapper plot, final int x, final int z) { + return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); } } 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 a56c0ffa3..6556605cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.generator; import java.io.File; @@ -29,6 +28,7 @@ import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.plugin.Plugin; @@ -42,31 +42,26 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager { - +@SuppressWarnings("deprecation") +public class HybridPlotManager extends ClassicPlotManager { private static boolean UPDATE = false; private int task; - public static boolean checkModified(Plot plot, int requiredChanges) { - World world = Bukkit.getWorld(plot.world); - Location bottom = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - Location top = PlotHelper.getPlotTopLoc(world, plot.id); - - int botx = bottom.getBlockX(); - int botz = bottom.getBlockZ(); - - int topx = top.getBlockX(); - int topz = top.getBlockZ(); - - HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getWorldSettings(world); - - PlotBlock[] air = new PlotBlock[] {new PlotBlock((short) 0, (byte) 0)}; - + public static boolean checkModified(final Plot plot, int requiredChanges) { + final World world = Bukkit.getWorld(plot.world); + final Location bottom = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + final Location top = PlotHelper.getPlotTopLoc(world, plot.id); + final int botx = bottom.getBlockX(); + final int botz = bottom.getBlockZ(); + final int topx = top.getBlockX(); + final int topz = top.getBlockZ(); + final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getWorldSettings(world); + final PlotBlock[] air = new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) }; int changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK); if (changes == -1) { return true; @@ -86,15 +81,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return changes == -1; } - public static int checkModified(int threshhold, World world, int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) { + public static int checkModified(final int threshhold, final World world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) { int count = 0; for (int y = y1; y <= y2; y++) { for (int x = x1; x <= x2; x++) { for (int z = z1; z <= z2; z++) { - Block block = world.getBlockAt(x, y, z); - int id = block.getTypeId(); + final Block block = world.getBlockAt(x, y, z); + final int id = block.getTypeId(); boolean same = false; - for (PlotBlock p : blocks) { + for (final PlotBlock p : blocks) { if (id == p.id) { same = true; break; @@ -112,59 +107,46 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return count; } - public boolean setupRoadSchematic(Plot plot) { - World world = Bukkit.getWorld(plot.world); - - Location bot = PlotHelper.getPlotBottomLoc(world, plot.id); - Location top = PlotHelper.getPlotTopLoc(world, plot.id); - - HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); - - int sx = bot.getBlockX() - plotworld.ROAD_WIDTH + 1; - int sz = bot.getBlockZ() + 1; - int sy = plotworld.ROAD_HEIGHT; - - int ex = bot.getBlockX(); - int ez = top.getBlockZ(); - int ey = get_ey(world, sx, ex, sz, ez, sy); - - Location pos1 = new Location(world, sx, sy, sz); - Location pos2 = new Location(world, ex, ey, ez); - - int bx = sx; - int bz = sz - plotworld.ROAD_WIDTH; - int by = sy; - - int tx = ex; - int tz = sz - 1; - int ty = get_ey(world, bx, tx, bz, tz, by); - - Location pos3 = new Location(world, bx, by, bz); - Location pos4 = new Location(world, tx, ty, tz); - - CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2); - CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4); - - String dir = PlotSquared.IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator; - + public boolean setupRoadSchematic(final Plot plot) { + final World world = Bukkit.getWorld(plot.world); + final Location bot = PlotHelper.getPlotBottomLoc(world, plot.id); + final Location top = PlotHelper.getPlotTopLoc(world, plot.id); + final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); + final int sx = (bot.getBlockX() - plotworld.ROAD_WIDTH) + 1; + final int sz = bot.getBlockZ() + 1; + final int sy = plotworld.ROAD_HEIGHT; + final int ex = bot.getBlockX(); + final int ez = top.getBlockZ(); + final int ey = get_ey(world, sx, ex, sz, ez, sy); + final Location pos1 = new Location(world, sx, sy, sz); + final Location pos2 = new Location(world, ex, ey, ez); + final int bx = sx; + final int bz = sz - plotworld.ROAD_WIDTH; + final int by = sy; + final int tx = ex; + final int tz = sz - 1; + final int ty = get_ey(world, bx, tx, bz, tz, by); + final Location pos3 = new Location(world, bx, by, bz); + final Location pos4 = new Location(world, tx, ty, tz); + final CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2); + final CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4); + final String dir = PlotSquared.IMP.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"); - plotworld.ROAD_SCHEMATIC_ENABLED = true; plotworld.setupSchematics(); - return true; } - public int get_ey(World world, int sx, int ex, int sz, int ez, int sy) { - int maxY = world.getMaxHeight(); + public int get_ey(final World world, final int sx, final int ex, final int sz, final int ez, final int sy) { + final int maxY = world.getMaxHeight(); int ey = sy; for (int x = sx; x <= ex; x++) { - for (int z = sz; z <= ez; z++) { + for (int z = sz; z <= ez; z++) { for (int y = sy; y < maxY; y++) { if (y > ey) { - Block block = world.getBlockAt(new Location(world, x, y, z)); - if (block.getTypeId() !=0) { + final Block block = world.getBlockAt(new Location(world, x, y, z)); + if (block.getTypeId() != 0) { ey = y; } } @@ -174,22 +156,19 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return ey; } - public void regenerateChunkChunk(World world, ChunkLoc loc) { - - int sx = loc.x << 5; - int sz = loc.z << 5; - - for (int x = sx; x < sx + 32; x++) { - for (int z = sz; z < sz + 32; z++) { - Chunk chunk = world.getChunkAt(x, z); + public void regenerateChunkChunk(final World world, final ChunkLoc loc) { + final int sx = loc.x << 5; + final int sz = loc.z << 5; + for (int x = sx; x < (sx + 32); x++) { + for (int z = sz; z < (sz + 32); z++) { + final Chunk chunk = world.getChunkAt(x, z); chunk.load(false); } } - - ArrayList chunks2 = new ArrayList<>(); - for (int x = sx; x < sx + 32; x++) { - for (int z = sz; z < sz + 32; z++) { - Chunk chunk = world.getChunkAt(x, z); + final ArrayList chunks2 = new ArrayList<>(); + for (int x = sx; x < (sx + 32); x++) { + for (int z = sz; z < (sz + 32); z++) { + final Chunk chunk = world.getChunkAt(x, z); chunks2.add(chunk); regenerateRoad(chunk); } @@ -202,7 +181,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return false; } final ArrayList chunks = ChunkManager.getChunkChunks(world); - final Plugin plugin = (Plugin) PlotSquared.getMain(); this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override @@ -210,20 +188,18 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; if (chunks.size() == 0) { HybridPlotManager.UPDATE = false; PlotSquared.log(C.PREFIX.s() + "Finished road conversion"); - Bukkit.getScheduler().cancelTask(task); + Bukkit.getScheduler().cancelTask(HybridPlotManager.this.task); return; - } - else { + } else { try { - ChunkLoc loc = chunks.get(0); - PlotSquared.log("Updating .mcr: " + loc.x + ", "+loc.z + " (aprrox 256 chunks)"); - PlotSquared.log("Remaining regions: "+chunks.size()); + final ChunkLoc loc = chunks.get(0); + PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)"); + PlotSquared.log("Remaining regions: " + chunks.size()); regenerateChunkChunk(world, loc); chunks.remove(0); - } - catch (Exception e) { - ChunkLoc loc = chunks.get(0); - PlotSquared.log("&c[ERROR]&7 Could not update '"+world.getName() + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); + } catch (final Exception e) { + final ChunkLoc loc = chunks.get(0); + PlotSquared.log("&c[ERROR]&7 Could not update '" + world.getName() + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); PlotSquared.log("&d - Potentially skipping 256 chunks"); PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); } @@ -233,90 +209,76 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return true; } - - public boolean regenerateRoad(Chunk chunk) { - World world = chunk.getWorld(); - int x = chunk.getX() << 4; - int z = chunk.getZ() << 4; - int ex = x + 15; - int ez = z + 15; - - Location bot = new Location(world, x, 0, z); - Location top = new Location(world, ex, 0, ez); - - HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); + public boolean regenerateRoad(final Chunk chunk) { + final World world = chunk.getWorld(); + final int x = chunk.getX() << 4; + final int z = chunk.getZ() << 4; + final int ex = x + 15; + final int ez = z + 15; + final Location bot = new Location(world, x, 0, z); + final Location top = new Location(world, ex, 0, ez); + final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); if (!plotworld.ROAD_SCHEMATIC_ENABLED) { return false; } - - PlotId id1 = getPlotId(plotworld, bot); - PlotId id2 = getPlotId(plotworld, top); - + final PlotId id1 = getPlotId(plotworld, bot); + final PlotId id2 = getPlotId(plotworld, top); boolean toCheck = false; - - - if (id1 == null || id2 == null || id1 != id2) { - boolean result = chunk.load(false); + if ((id1 == null) || (id2 == null) || (id1 != id2)) { + final boolean result = chunk.load(false); if (result) { - while (!chunk.isLoaded()) { chunk.load(false); } - if (id1 != null) { - Plot p1 = PlotHelper.getPlot(world, id1); - if (p1 != null && p1.hasOwner() && p1.settings.isMerged()) { + final Plot p1 = PlotHelper.getPlot(world, id1); + if ((p1 != null) && p1.hasOwner() && p1.settings.isMerged()) { toCheck = true; } } - if (id2 != null && !toCheck) { - Plot p2 = PlotHelper.getPlot(world, id2); - if (p2 != null && p2.hasOwner() && p2.settings.isMerged()) { + if ((id2 != null) && !toCheck) { + final Plot p2 = PlotHelper.getPlot(world, id2); + if ((p2 != null) && p2.hasOwner() && p2.settings.isMerged()) { toCheck = true; } } - int size = plotworld.SIZE; + final int size = plotworld.SIZE; for (int X = 0; X < 16; X++) { for (int Z = 0; Z < 16; Z++) { - short absX = (short) ((x + X) % size); short absZ = (short) ((z + Z) % size); - if (absX < 0) { absX += size; } if (absZ < 0) { absZ += size; } - - boolean gx = absX > plotworld.PATH_WIDTH_LOWER; - boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; - boolean lx = absX < plotworld.PATH_WIDTH_UPPER; - boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; + final boolean gx = absX > plotworld.PATH_WIDTH_LOWER; + final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; + final boolean lx = absX < plotworld.PATH_WIDTH_UPPER; + final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; boolean condition; - if (toCheck) { - Location l = new Location(world, x + X, 1, z + Z); + final Location l = new Location(world, x + X, 1, z + Z); condition = getPlotId(plotworld, l) == null; + } else { + condition = (!gx || !gz || !lx || !lz); } - else { condition = (!gx || !gz || !lx || !lz); } - if (condition) { - int sy = plotworld.ROAD_HEIGHT; - ChunkLoc loc = new ChunkLoc(absX, absZ); - HashMap blocks = plotworld.G_SCH.get(loc); - for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT; y++) { + final int sy = plotworld.ROAD_HEIGHT; + final ChunkLoc loc = new ChunkLoc(absX, absZ); + final HashMap blocks = plotworld.G_SCH.get(loc); + for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT); y++) { PlotHelper.setBlock(world, x + X, sy + y, z + Z, 0, (byte) 0); } if (blocks != null) { - HashMap datas = plotworld.G_SCH_DATA.get(loc); + final HashMap datas = plotworld.G_SCH_DATA.get(loc); if (datas == null) { - for (Short y : blocks.keySet()) { + for (final Short y : blocks.keySet()) { PlotHelper.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0); } - } - else { - for (Short y : blocks.keySet()) { + } else { + for (final Short y : blocks.keySet()) { Byte data = datas.get(y); if (data == null) { data = 0; @@ -336,23 +298,22 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @Override public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds) { - HybridPlotWorld hpw = (HybridPlotWorld) plotworld; + final HybridPlotWorld hpw = (HybridPlotWorld) plotworld; if (hpw.ROAD_SCHEMATIC_ENABLED) { - for (PlotId id : plotIds) { - Location bottom = getPlotBottomLocAbs(plotworld, id); - int sx = bottom.getBlockX() - hpw.PATH_WIDTH_LOWER; - int sz = bottom.getBlockZ() - hpw.PATH_WIDTH_LOWER; - int sy = hpw.ROAD_HEIGHT; - for (ChunkLoc loc : hpw.G_SCH.keySet()) { - HashMap blocks = hpw.G_SCH.get(loc); - HashMap datas = hpw.G_SCH_DATA.get(loc); + for (final PlotId id : plotIds) { + final Location bottom = getPlotBottomLocAbs(plotworld, id); + final int sx = bottom.getBlockX() - hpw.PATH_WIDTH_LOWER; + final int sz = bottom.getBlockZ() - hpw.PATH_WIDTH_LOWER; + final int sy = hpw.ROAD_HEIGHT; + for (final ChunkLoc loc : hpw.G_SCH.keySet()) { + final HashMap blocks = hpw.G_SCH.get(loc); + final HashMap datas = hpw.G_SCH_DATA.get(loc); if (datas == null) { - for (Short y : blocks.keySet()) { + for (final Short y : blocks.keySet()) { PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0); } - } - else { - for (Short y : blocks.keySet()) { + } else { + for (final Short y : blocks.keySet()) { Byte data = datas.get(y); if (data == null) { data = 0; @@ -361,16 +322,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } } } - } } - PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; + final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; if (block.id != 0) { - for (PlotId id : plotIds) { - setWall(world, plotworld, id, new PlotBlock[] {(( ClassicPlotWorld) plotworld).WALL_BLOCK }); - Plot plot = PlotHelper.getPlot(world, id); + for (final PlotId id : plotIds) { + setWall(world, plotworld, id, new PlotBlock[] { ((ClassicPlotWorld) plotworld).WALL_BLOCK }); + final Plot plot = PlotHelper.getPlot(world, id); if (plot.hasOwner()) { - String name = UUIDHandler.getName(plot.owner); + final String name = UUIDHandler.getName(plot.owner); if (name != null) { PlotHelper.setSign(world, name, plot); } @@ -380,7 +340,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return true; } - /** * Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid * function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster @@ -397,41 +356,30 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; PlotHelper.runners.remove(plot); } }, 90L); - final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld); - final Location pos1 = PlotHelper.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1); final Location pos2 = PlotHelper.getPlotTopLocAbs(world, plot.id); - final PlotBlock[] plotfloor = dpw.TOP_BLOCK; final PlotBlock[] filling = dpw.MAIN_BLOCK; - // PlotBlock wall = dpw.WALL_BLOCK; final PlotBlock wall; - if (isDelete) { wall = dpw.WALL_BLOCK; } else { wall = dpw.CLAIMED_WALL_BLOCK; } - final PlotBlock wall_filling = dpw.WALL_FILLING; - final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, 1, pos1.getBlockZ())); - if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) { - setWallFilling(world, dpw, plot.id, new PlotBlock[] {wall_filling}); + setWallFilling(world, dpw, plot.id, new PlotBlock[] { wall_filling }); } - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, dpw.WALL_HEIGHT + 1, pos1.getBlockZ())); if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) { - setWall(world, dpw, plot.id, new PlotBlock[] {wall}); + setWall(world, dpw, plot.id, new PlotBlock[] { wall }); } - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -457,7 +405,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 5L); return; } - final int startX = (pos1.getBlockX() / 16) * 16; final int startZ = (pos1.getBlockZ() / 16) * 16; final int chunkX = 16 + pos2.getBlockX(); @@ -501,10 +448,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; world.regenerateChunk(i / 16, j / 16); } } - final Location max = mx; final Location min = mn; - if (min == null) { PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @@ -527,7 +472,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 5L); return; } else { - if (min.getBlockX() < plotMinX) { min.setX(plotMinX); } @@ -540,7 +484,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; if (max.getBlockZ() > plotMaxZ) { max.setZ(plotMaxZ); } - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -565,7 +508,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 1L); } }, 21L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -590,7 +532,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 1L); } }, 25L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -615,7 +556,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 1L); } }, 29L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -640,7 +580,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 1L); } }, 33L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -665,7 +604,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 1L); } }, 37L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -690,7 +628,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 1L); } }, 41L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -715,7 +652,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 1L); } }, 45L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -732,7 +668,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @Override public void run() { PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); - BukkitTaskManager.runTask(whenDone); + TaskManager.runTask(whenDone); } }, 1L); } @@ -748,4 +684,70 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; }, 20L); return true; } + + @Override + public PlotId getPlotIdAbs(PlotWorld plotworld, int x, int y, int z) { + // TODO Auto-generated method stub + return null; + } + + @Override + public PlotId getPlotId(PlotWorld plotworld, int x, int y, int z) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean clearPlot(PlotWorld plotworld, Plot plot, boolean isDelete, Runnable whenDone) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean claimPlot(PlotWorld plotworld, Plot plot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean unclaimPlot(PlotWorld plotworld, Plot plot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean setComponent(PlotWorld plotworld, PlotId plotid, String component, PlotBlock[] blocks) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean setBiome(Plot plot, Biome biome) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean startPlotMerge(PlotWorld plotworld, ArrayList plotIds) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean startPlotUnlink(PlotWorld plotworld, ArrayList plotIds) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean finishPlotMerge(PlotWorld plotworld, ArrayList plotIds) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean finishPlotUnlink(PlotWorld plotworld, ArrayList plotIds) { + // TODO Auto-generated method stub + return false; + } } 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 a82aad7e4..ad22096c0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.generator; import java.util.HashMap; @@ -41,10 +40,9 @@ public class HybridPlotWorld extends ClassicPlotWorld { public short SCHEMATIC_HEIGHT; public boolean PLOT_SCHEMATIC = false; public short REQUIRED_CHANGES = 0; - public short PATH_WIDTH_LOWER; public short PATH_WIDTH_UPPER; - + /* * Here we are just calling the super method, nothing special */ @@ -76,19 +74,16 @@ public class HybridPlotWorld extends ClassicPlotWorld { this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling")); this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height")); this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block_claimed")); - this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH); - if ((this.ROAD_WIDTH % 2) == 0) { - PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2) - 1); + this.PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2) - 1); } else { - PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2)); + this.PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2)); } - this.PATH_WIDTH_UPPER = (short) (this.PATH_WIDTH_LOWER + this.PLOT_WIDTH + 1); try { setupSchematics(); - } catch (Exception e) { + } catch (final Exception e) { PlotSquared.log("&c - road schematics are disabled for this world."); this.ROAD_SCHEMATIC_ENABLED = false; } @@ -96,98 +91,85 @@ public class HybridPlotWorld extends ClassicPlotWorld { } public void setupSchematics() { - G_SCH_DATA = new HashMap<>(); - G_SCH = new HashMap<>(); - String schem1Str = "GEN_ROAD_SCHEMATIC/" + worldname + "/sideroad"; - String schem2Str = "GEN_ROAD_SCHEMATIC/" + worldname + "/intersection"; - String schem3Str = "GEN_ROAD_SCHEMATIC/" + worldname + "/plot"; - - Schematic schem1 = SchematicHandler.getSchematic(schem1Str); - Schematic schem2 = SchematicHandler.getSchematic(schem2Str); - Schematic schem3 = SchematicHandler.getSchematic(schem3Str); - - int shift = (int) Math.floor(this.ROAD_WIDTH / 2); + this.G_SCH_DATA = new HashMap<>(); + this.G_SCH = new HashMap<>(); + final String schem1Str = "GEN_ROAD_SCHEMATIC/" + this.worldname + "/sideroad"; + final String schem2Str = "GEN_ROAD_SCHEMATIC/" + this.worldname + "/intersection"; + final String schem3Str = "GEN_ROAD_SCHEMATIC/" + this.worldname + "/plot"; + final Schematic schem1 = SchematicHandler.getSchematic(schem1Str); + final Schematic schem2 = SchematicHandler.getSchematic(schem2Str); + final Schematic schem3 = SchematicHandler.getSchematic(schem3Str); + final int shift = (int) Math.floor(this.ROAD_WIDTH / 2); int oddshift = 0; - if (this.ROAD_WIDTH % 2 != 0) { + if ((this.ROAD_WIDTH % 2) != 0) { oddshift = 1; } - if (schem3 != null) { - PLOT_SCHEMATIC = true; - DataCollection[] blocks3 = schem3.getBlockCollection(); - Dimension d3 = schem3.getSchematicDimension(); - short w3 = (short) d3.getX(); - short l3 = (short) d3.getZ(); - short h3 = (short) d3.getY(); - + this.PLOT_SCHEMATIC = true; + final DataCollection[] blocks3 = schem3.getBlockCollection(); + final Dimension d3 = schem3.getSchematicDimension(); + final short w3 = (short) d3.getX(); + final short l3 = (short) d3.getZ(); + final short h3 = (short) d3.getY(); int center_shift_x = 0; int center_shift_z = 0; - if (l3 < PLOT_WIDTH) { - center_shift_z = (int) ((PLOT_WIDTH - l3)/2); + if (l3 < this.PLOT_WIDTH) { + center_shift_z = (this.PLOT_WIDTH - l3) / 2; } - if (w3 < PLOT_WIDTH) { - center_shift_x = (int) ((PLOT_WIDTH - w3)/2); + if (w3 < this.PLOT_WIDTH) { + center_shift_x = (this.PLOT_WIDTH - w3) / 2; } - for (short x = 0; x < w3; x++) { for (short z = 0; z < l3; z++) { for (short y = 0; y < h3; y++) { - int index = y * w3 * l3 + z * w3 + x; - short id = blocks3[index].getBlock(); - byte data = blocks3[index].getData(); + final int index = (y * w3 * l3) + (z * w3) + x; + final short id = blocks3[index].getBlock(); + final byte data = blocks3[index].getData(); if (id != 0) { - addOverlayBlock((short) (x + shift + oddshift + center_shift_x), (short) (y), (short) (z + shift + oddshift + center_shift_z), id, data, false); + addOverlayBlock((short) (x + shift + oddshift + center_shift_x), (y), (short) (z + shift + oddshift + center_shift_z), id, data, false); } } } } } - - if (schem1 == null || schem2 == null || this.ROAD_WIDTH == 0) { + if ((schem1 == null) || (schem2 == null) || (this.ROAD_WIDTH == 0)) { PlotSquared.log(C.PREFIX.s() + "&3 - schematic: &7false"); return; } // Do not populate road if using schematic population this.ROAD_BLOCK = new PlotBlock(this.ROAD_BLOCK.id, (byte) 0); - - DataCollection[] blocks1 = schem1.getBlockCollection(); - DataCollection[] blocks2 = schem2.getBlockCollection(); - - Dimension d1 = schem1.getSchematicDimension(); - short w1 = (short) d1.getX(); - short l1 = (short) d1.getZ(); - short h1 = (short) d1.getY(); - - Dimension d2 = schem2.getSchematicDimension(); - short w2 = (short) d2.getX(); - short l2 = (short) d2.getZ(); - short h2 = (short) d2.getY(); + final DataCollection[] blocks1 = schem1.getBlockCollection(); + final DataCollection[] blocks2 = schem2.getBlockCollection(); + final Dimension d1 = schem1.getSchematicDimension(); + final short w1 = (short) d1.getX(); + final short l1 = (short) d1.getZ(); + final short h1 = (short) d1.getY(); + final Dimension d2 = schem2.getSchematicDimension(); + final short w2 = (short) d2.getX(); + final short l2 = (short) d2.getZ(); + final short h2 = (short) d2.getY(); this.SCHEMATIC_HEIGHT = (short) Math.max(h2, h1); - for (short x = 0; x < w1; x++) { for (short z = 0; z < l1; z++) { for (short y = 0; y < h1; y++) { - int index = y * w1 * l1 + z * w1 + x; - - short id = blocks1[index].getBlock(); - byte data = blocks1[index].getData(); - + final int index = (y * w1 * l1) + (z * w1) + x; + final short id = blocks1[index].getBlock(); + final byte data = blocks1[index].getData(); if (id != 0) { - addOverlayBlock((short) (x - (shift)), (short) (y), (short) (z + shift + oddshift), id, data, false); - addOverlayBlock((short) (z + shift + oddshift), (short) (y), (short) (x - shift), id, data, true); + addOverlayBlock((short) (x - (shift)), (y), (short) (z + shift + oddshift), id, data, false); + addOverlayBlock((short) (z + shift + oddshift), (y), (short) (x - shift), id, data, true); } } } } - for (short x = 0; x < w2; x++) { for (short z = 0; z < l2; z++) { for (short y = 0; y < h2; y++) { - int index = y * w2 * l2 + z * w2 + x; - short id = blocks2[index].getBlock(); - byte data = blocks2[index].getData(); + final int index = (y * w2 * l2) + (z * w2) + x; + final short id = blocks2[index].getBlock(); + final byte data = blocks2[index].getData(); if (id != 0) { - addOverlayBlock((short) (x - shift), (short) (y), (short) (z - shift), id, data, false); + addOverlayBlock((short) (x - shift), (y), (short) (z - shift), id, data, false); } } } @@ -195,7 +177,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { this.ROAD_SCHEMATIC_ENABLED = true; } - public static boolean isRotate(short id) { + public static boolean isRotate(final short id) { switch (id) { case 23: return true; @@ -312,31 +294,28 @@ public class HybridPlotWorld extends ClassicPlotWorld { } } - public void addOverlayBlock(short x, short y, short z, short id, byte data, boolean rotate) { + public void addOverlayBlock(short x, final short y, short z, final short id, byte data, final boolean rotate) { if (z < 0) { z += this.SIZE; } if (x < 0) { x += this.SIZE; } - ChunkLoc loc = new ChunkLoc(x, z); + final ChunkLoc loc = new ChunkLoc(x, z); if (!this.G_SCH.containsKey(loc)) { this.G_SCH.put(loc, new HashMap()); } - this.G_SCH.get(loc).put(y, id); if (isRotate(id)) { if (rotate) { data = (byte) ((data + 2) % 4); } - } - else if (data == 0) { + } else if (data == 0) { return; } if (!this.G_SCH_DATA.containsKey(loc)) { this.G_SCH_DATA.put(loc, new HashMap()); } - this.G_SCH_DATA.get(loc).put(y, data); } } 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 a3638cb86..98cb4725b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -12,19 +12,17 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.AChunkManager; /** * @author Citymonstret */ public class HybridPop extends BlockPopulator { - /* * Sorry, this isn't well documented at the moment. * We advise you to take a look at a world generation tutorial for * information about how a BlockPopulator works. */ - final short plotsize; final short pathsize; final byte wall; @@ -46,24 +44,18 @@ public class HybridPop extends BlockPopulator { private boolean doFilling = false; private boolean doFloor = false; private boolean doState = false; - + public HybridPop(final PlotWorld pw) { this.plotworld = (HybridPlotWorld) pw; - // save configuration - this.plotsize = (short) this.plotworld.PLOT_WIDTH; this.pathsize = (short) this.plotworld.ROAD_WIDTH; - this.roadblock = this.plotworld.ROAD_BLOCK.data; - this.wallfilling = this.plotworld.WALL_FILLING.data; this.size = this.pathsize + this.plotsize; this.wall = this.plotworld.WALL_BLOCK.data; - int count1 = 0; int count2 = 0; - this.plotfloors = new byte[this.plotworld.TOP_BLOCK.length]; for (int i = 0; i < this.plotworld.TOP_BLOCK.length; i++) { count1++; @@ -72,7 +64,6 @@ public class HybridPop extends BlockPopulator { this.doFloor = true; } } - this.filling = new byte[this.plotworld.MAIN_BLOCK.length]; for (int i = 0; i < this.plotworld.MAIN_BLOCK.length; i++) { count2++; @@ -81,88 +72,77 @@ public class HybridPop extends BlockPopulator { this.doFilling = true; } } - - if ((count1 > 0 && doFloor) || (count2 > 0 && doFilling)) { - doState = true; + if (((count1 > 0) && this.doFloor) || ((count2 > 0) && this.doFilling)) { + this.doState = true; } - this.wallheight = this.plotworld.WALL_HEIGHT; this.roadheight = this.plotworld.ROAD_HEIGHT; this.plotheight = this.plotworld.PLOT_HEIGHT; - if ((this.pathsize % 2) == 0) { this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1); } else { this.pathWidthLower = (short) (Math.floor(this.pathsize / 2)); } - this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); } - + public final long nextLong() { final long a = this.state; this.state = xorShift64(a); return a; } - + public final long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - + public final int random(final int n) { final long result = ((nextLong() >>> 32) * n) >> 32; return (int) result; } - + @Override public void populate(final World w, final Random r, final Chunk c) { - int cx = c.getX(), cz = c.getZ(); - - if (doState) { + final int cx = c.getX(), cz = c.getZ(); + if (this.doState) { final int prime = 13; int h = 1; h = (prime * h) + cx; h = (prime * h) + cz; this.state = h; } - this.X = cx << 4; this.Z = cz << 4; - - HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(w); - RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR; + final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(w); + final RegionWrapper plot = AChunkManager.CURRENT_PLOT_CLEAR; if (plot != null) { - short sx = (short) ((X) % this.size); - short sz = (short) ((Z) % this.size); - + short sx = (short) ((this.X) % this.size); + short sz = (short) ((this.Z) % this.size); if (sx < 0) { sx += this.size; } - if (sz < 0) { sz += this.size; } - for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - if (isIn(plot, X + x, Z + z)) { - if (doFilling) { + if (isIn(plot, this.X + x, this.Z + z)) { + if (this.doFilling) { for (short y = 1; y < this.plotheight; y++) { setBlock(w, x, y, z, this.filling); } } - if (doFloor) { - setBlock(w, x,(short) this.plotheight, z, this.plotfloors); + if (this.doFloor) { + setBlock(w, x, (short) this.plotheight, z, this.plotfloors); } - } - else { - ChunkLoc loc = new ChunkLoc(X + x, Z + z); - HashMap data = ChunkManager.GENERATE_DATA.get(loc); + } else { + final ChunkLoc loc = new ChunkLoc(this.X + x, this.Z + z); + final HashMap data = AChunkManager.GENERATE_DATA.get(loc); if (data != null) { - for (short y : data.keySet()) { + for (final short y : data.keySet()) { setBlock(w, x, y, z, data.get(y).byteValue()); } } @@ -171,51 +151,42 @@ public class HybridPop extends BlockPopulator { } return; } - - short sx = (short) ((X) % this.size); - short sz = (short) ((Z) % this.size); - + short sx = (short) ((this.X) % this.size); + short sz = (short) ((this.Z) % this.size); if (sx < 0) { sx += this.size; } - if (sz < 0) { sz += this.size; } - // Setting biomes for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - - short absX = (short) ((sx + x) % this.size); - short absZ = (short) ((sz + z) % this.size); - - boolean gx = absX > pathWidthLower; - boolean gz = absZ > pathWidthLower; - - boolean lx = absX < pathWidthUpper; - boolean lz = absZ < pathWidthUpper; - + final short absX = (short) ((sx + x) % this.size); + final short absZ = (short) ((sz + z) % this.size); + final boolean gx = absX > this.pathWidthLower; + final boolean gz = absZ > this.pathWidthLower; + final boolean lx = absX < this.pathWidthUpper; + final boolean lz = absZ < this.pathWidthUpper; // inside plot if (gx && gz && lx && lz) { - if (doFilling) { + if (this.doFilling) { for (short y = 1; y < this.plotheight; y++) { setBlock(w, x, y, z, this.filling); } } - if (doFloor) { + if (this.doFloor) { setBlock(w, x, (short) this.plotheight, z, this.plotfloors); } } else { // wall - if ((absX >= pathWidthLower && absX <= pathWidthUpper && absZ >= pathWidthLower && absZ <= pathWidthUpper)) - { + if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { if (this.wallfilling != 0) { for (short y = 1; y <= this.wallheight; y++) { setBlock(w, x, y, z, this.wallfilling); } } - if (this.wall != 0 && !this.plotworld.ROAD_SCHEMATIC_ENABLED) { + if ((this.wall != 0) && !this.plotworld.ROAD_SCHEMATIC_ENABLED) { setBlock(w, x, (short) (this.wallheight + 1), z, this.wall); } } @@ -228,11 +199,11 @@ public class HybridPop extends BlockPopulator { } } if (this.plotworld.ROAD_SCHEMATIC_ENABLED) { - ChunkLoc loc = new ChunkLoc(absX, absZ); - HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); + final ChunkLoc loc = new ChunkLoc(absX, absZ); + final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { - for (short y : blocks.keySet()) { - setBlock(w, x, (short) (this.roadheight + y), z, blocks.get(y)); + for (final short y : blocks.keySet()) { + setBlock(w, x, (short) (this.roadheight + y), z, blocks.get(y)); } } } @@ -240,12 +211,11 @@ public class HybridPop extends BlockPopulator { } } } - - private void setBlock(final World w, short x, short y, short z, byte[] blkids) { + + private void setBlock(final World w, final short x, final short y, final short z, final byte[] blkids) { if (blkids.length == 1) { setBlock(w, x, y, z, blkids[0]); - } - else { + } else { final int i = random(blkids.length); setBlock(w, x, y, z, blkids[i]); } @@ -256,8 +226,7 @@ public class HybridPop extends BlockPopulator { w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false); } - public boolean isIn(RegionWrapper plot, int x, int z) { - return (x >= plot.minX && x <= plot.maxX && z >= plot.minZ && z <= plot.maxZ); + public boolean isIn(final RegionWrapper plot, final int x, final int z) { + return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); } - } 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 b59fede0e..58740422e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -18,9 +18,8 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * A plot manager with a square grid layout, with square shaped plots */ public abstract class SquarePlotManager extends GridPlotManager { - @Override - public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, Runnable whendone) { + public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whendone) { final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); ChunkManager.regenerateRegion(pos1, pos2, whendone); @@ -30,27 +29,21 @@ public abstract class SquarePlotManager extends GridPlotManager { @Override public Location getPlotTopLocAbs(final PlotWorld plotworld, final PlotId plotid) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); - final int px = plotid.x; final int pz = plotid.y; - final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; - return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z); } @Override public PlotId getPlotIdAbs(final PlotWorld plotworld, final Location loc) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); - // get x,z loc int x = loc.getBlockX(); int z = loc.getBlockZ(); - // get plot size final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; - // get size of path on bottom part, and top part of plot // (As 0,0 is in the middle of a road, not the very start) int pathWidthLower; @@ -59,7 +52,6 @@ public abstract class SquarePlotManager extends GridPlotManager { } else { pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2); } - // calulating how many shifts need to be done int dx = x / size; int dz = z / size; @@ -71,11 +63,9 @@ public abstract class SquarePlotManager extends GridPlotManager { dz--; z += ((-dz) * size); } - // reducing to first plot final int rx = (x) % size; final int rz = (z) % size; - // checking if road (return null if so) final int end = pathWidthLower + dpw.PLOT_WIDTH; final boolean northSouth = (rz <= pathWidthLower) || (rz > end); @@ -90,10 +80,8 @@ public abstract class SquarePlotManager extends GridPlotManager { @Override public PlotId getPlotId(final PlotWorld plotworld, final Location loc) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); - int x = loc.getBlockX(); int z = loc.getBlockZ(); - if (plotworld == null) { return null; } @@ -104,10 +92,8 @@ public abstract class SquarePlotManager extends GridPlotManager { } else { pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2); } - int dx = x / size; int dz = z / size; - if (x < 0) { dx--; x += ((-dx) * size); @@ -116,12 +102,9 @@ public abstract class SquarePlotManager extends GridPlotManager { dz--; z += ((-dz) * size); } - final int rx = (x) % size; final int rz = (z) % size; - final int end = pathWidthLower + dpw.PLOT_WIDTH; - final boolean northSouth = (rz <= pathWidthLower) || (rz > end); final boolean eastWest = (rx <= pathWidthLower) || (rx > end); if (northSouth && eastWest) { @@ -175,13 +158,10 @@ public abstract class SquarePlotManager extends GridPlotManager { @Override public Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); - final int px = plotid.x; final int pz = plotid.y; - final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; - return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z); } @@ -190,18 +170,15 @@ public abstract class SquarePlotManager extends GridPlotManager { */ @Override public boolean setBiome(final World world, final Plot plot, final Biome biome) { - final int bottomX = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX() - 1; final int topX = PlotHelper.getPlotTopLoc(world, plot.id).getBlockX() + 1; final int bottomZ = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1; final int topZ = PlotHelper.getPlotTopLoc(world, plot.id).getBlockZ() + 1; - final Block block = world.getBlockAt(PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 1, 1)); final Biome current = block.getBiome(); if (biome.equals(current)) { return false; } - for (int x = bottomX; x <= topX; x++) { for (int z = bottomZ; z <= topZ; z++) { final Block blk = world.getBlockAt(x, 0, z); 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 64026a72c..01586954f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java @@ -5,10 +5,8 @@ import org.bukkit.configuration.ConfigurationSection; import com.intellectualcrafters.plot.PlotSquared; public abstract class SquarePlotWorld extends GridPlotWorld { - public static int PLOT_WIDTH_DEFAULT = 42; public static int ROAD_WIDTH_DEFAULT = 7; - public int PLOT_WIDTH; public int ROAD_WIDTH; @@ -22,7 +20,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld { this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH); } - public SquarePlotWorld(String worldname) { + public SquarePlotWorld(final String worldname) { super(worldname); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index de1b6a62d..24b4fa881 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.listeners; import java.util.HashSet; @@ -40,7 +39,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * @author Citymonstret */ public class ForceFieldListener implements Listener { - private Set getNearbyPlayers(final Player player, final Plot plot) { final Set players = new HashSet<>(); Player oPlayer; @@ -54,7 +52,7 @@ public class ForceFieldListener implements Listener { } return players; } - + private Player hasNearbyPermitted(final Player player, final Plot plot) { Player oPlayer; for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { @@ -67,7 +65,7 @@ public class ForceFieldListener implements Listener { } return null; } - + public Vector calculateVelocity(final Player p, final Player e) { final Location playerLocation = p.getLocation(); final Location oPlayerLocation = e.getLocation(); @@ -90,7 +88,7 @@ public class ForceFieldListener implements Listener { } return new Vector(x, y, z); } - + @EventHandler public void onPlotEntry(final PlayerMoveEvent event) { final Player player = event.getPlayer(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index a56e27a3b..33a6a1487 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -16,15 +16,15 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; * * @author Citymonstret */ -@SuppressWarnings("unused") public class InventoryListener implements Listener { - +@SuppressWarnings("unused") +public class InventoryListener implements Listener { @EventHandler public void onInventoryAction(final InventoryInteractEvent event) { if (event.getInventory().getHolder() instanceof InfoInventory) { event.setResult(Event.Result.DENY); } } - + @EventHandler public void onInventoryClick(final InventoryClickEvent event) { final Inventory inventory = event.getInventory(); @@ -43,5 +43,4 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; } } } - } 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 775add2b2..0d5ac8bae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.listeners; import java.util.Collection; @@ -101,7 +100,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -113,46 +112,42 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Empire92 */ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onWorldInit(final WorldInitEvent event) { - World world = event.getWorld(); - ChunkGenerator gen = world.getGenerator(); + final World world = event.getWorld(); + final ChunkGenerator gen = world.getGenerator(); if (gen instanceof PlotGenerator) { PlotSquared.loadWorld(world.getName(), (PlotGenerator) gen); - } - else { + } else { PlotSquared.loadWorld(world.getName(), null); } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onChunkLoad(final ChunkLoadEvent event) { - String worldname = event.getWorld().getName(); - Chunk chunk = event.getChunk(); + final String worldname = event.getWorld().getName(); + final Chunk chunk = event.getChunk(); if (PlotHelper.worldBorder.containsKey(worldname)) { - int border = PlotHelper.getBorder(worldname); - int x = Math.abs(chunk.getX() << 4); - int z = Math.abs(chunk.getZ() << 4); - if (x > border || z > border) { - chunk.unload(false, true); - } + final int border = PlotHelper.getBorder(worldname); + final int x = Math.abs(chunk.getX() << 4); + final int z = Math.abs(chunk.getZ() << 4); + if ((x > border) || (z > border)) { + chunk.unload(false, true); + } } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onJoin(final PlayerJoinEvent event) { - Player player = event.getPlayer(); + final Player player = event.getPlayer(); if (!player.hasPlayedBefore()) { player.saveData(); } - // UUID stuff - String username = player.getName(); - StringWrapper name = new StringWrapper(username); - UUID uuid = UUIDHandler.getUUID(player); + final String username = player.getName(); + final StringWrapper name = new StringWrapper(username); + final UUID uuid = UUIDHandler.getUUID(player); UUIDHandler.add(name, uuid); - // textures(event.getPlayer()); if (isInPlot(event.getPlayer().getLocation())) { if (Settings.TELEPORT_ON_LOGIN) { @@ -163,7 +158,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void PlayerMove(final PlayerMoveEvent event) { try { @@ -172,41 +167,39 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location t = event.getTo(); final Location q = new Location(t.getWorld(), t.getBlockX(), 0, t.getZ()); if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { - if (Settings.TELEPORT_DELAY != 0 && BukkitTaskManager.TELEPORT_QUEUE.size() > 0) { - String name = player.getName(); - if (BukkitTaskManager.TELEPORT_QUEUE.contains(name)) { - BukkitTaskManager.TELEPORT_QUEUE.remove(name); + if ((Settings.TELEPORT_DELAY != 0) && (TaskManager.TELEPORT_QUEUE.size() > 0)) { + final String name = player.getName(); + if (TaskManager.TELEPORT_QUEUE.contains(name)) { + TaskManager.TELEPORT_QUEUE.remove(name); } } if (!isPlotWorld(player.getWorld())) { return; } - String worldname = q.getWorld().getName(); + final String worldname = q.getWorld().getName(); if (PlotHelper.worldBorder.containsKey(worldname)) { - int border = PlotHelper.getBorder(worldname); - boolean passed = false; - if (t.getBlockX() > border) { - q.setX(border); - passed = true; - } - else if (t.getBlockX() < -border) { - q.setX(-border); - passed = true; - } - if (t.getBlockZ() > border) { - q.setZ(border); - passed = true; - } - else if (t.getBlockZ() < -border) { - q.setZ(-border); - passed = true; - } - if (passed) { - q.setY(t.getBlockY()); - event.setTo(q); - PlayerFunctions.sendMessage(player, C.BORDER); - return; - } + final int border = PlotHelper.getBorder(worldname); + boolean passed = false; + if (t.getBlockX() > border) { + q.setX(border); + passed = true; + } else if (t.getBlockX() < -border) { + q.setX(-border); + passed = true; + } + if (t.getBlockZ() > border) { + q.setZ(border); + passed = true; + } else if (t.getBlockZ() < -border) { + q.setZ(-border); + passed = true; + } + if (passed) { + q.setY(t.getBlockY()); + event.setTo(q); + PlayerFunctions.sendMessage(player, C.BORDER); + return; + } } Plot plot = getCurrentPlot(q); if (plot != null) { @@ -217,9 +210,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - if (!plot.equals(getCurrentPlot(f))) { - plotEntry(player, plot); - } + if (!plot.equals(getCurrentPlot(f))) { + plotEntry(player, plot); + } } else if (leftPlot(f, event.getTo())) { plot = getCurrentPlot(f); plotExit(player, plot); @@ -229,7 +222,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi // Gotta catch 'em all. } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onChat(final AsyncPlayerChatEvent event) { final World world = event.getPlayer().getWorld(); @@ -259,15 +252,15 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi format = ChatColor.translateAlternateColorCodes('&', format); event.setFormat(format); } - + @EventHandler(priority = EventPriority.HIGH) public static void BlockDestroy(final BlockBreakEvent event) { final World world = event.getPlayer().getWorld(); if (!isPlotWorld(world)) { return; } - Player player = event.getPlayer(); - Location loc = event.getBlock().getLocation(); + final Player player = event.getPlayer(); + final Location loc = event.getBlock().getLocation(); final Plot plot = getCurrentPlot(loc); if (plot != null) { if (event.getBlock().getY() == 0) { @@ -283,9 +276,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasRights(event.getPlayer())) { - Flag destroy = FlagManager.getPlotFlag(plot, "break"); - Block block = event.getBlock(); - if (destroy != null && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), (byte) block.getData()))) { + final Flag destroy = FlagManager.getPlotFlag(plot, "break"); + final Block block = event.getBlock(); + if ((destroy != null) && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { @@ -306,20 +299,20 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onBigBoom(final EntityExplodeEvent event) { final World world = event.getLocation().getWorld(); if (!isPlotWorld(world)) { return; } - Location loc = event.getLocation(); + final Location loc = event.getLocation(); final Plot plot = getCurrentPlot(loc); - if (plot != null && plot.hasOwner()) { + if ((plot != null) && plot.hasOwner()) { if (FlagManager.isPlotFlagTrue(plot, "explosion")) { - Iterator iter = event.blockList().iterator(); + final Iterator iter = event.blockList().iterator(); while (iter.hasNext()) { - Block b = iter.next(); + final Block b = iter.next(); if (!plot.equals(getCurrentPlot(b.getLocation()))) { iter.remove(); } @@ -327,18 +320,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - if (isPlotArea(loc)) { event.setCancelled(true); } - else { - Iterator iter = event.blockList().iterator(); + if (isPlotArea(loc)) { + event.setCancelled(true); + } else { + final Iterator iter = event.blockList().iterator(); while (iter.hasNext()) { - Block b = iter.next(); + final Block b = iter.next(); if (isPlotArea(loc)) { iter.remove(); } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { final World world = event.getBlock().getWorld(); @@ -354,7 +348,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Block b = event.getBlock(); final Player p = (Player) e; - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (!isInPlot(loc)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); @@ -363,7 +357,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(loc); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); @@ -371,7 +365,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else if (!plot.hasRights(p)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { - if (isPlotArea(loc)) { + if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; @@ -381,7 +375,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityBlockForm(final EntityBlockFormEvent e) { final World world = e.getBlock().getWorld(); @@ -389,98 +383,116 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if ((!(e.getEntity() instanceof Player))) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBS(final BlockSpreadEvent e) { final Block b = e.getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBF(final BlockFormEvent e) { final Block b = e.getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBD(final BlockDamageEvent e) { final Block b = e.getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onFade(final BlockFadeEvent e) { final Block b = e.getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onChange(final BlockFromToEvent e) { final Block b = e.getToBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onGrow(final BlockGrowEvent e) { final Block b = e.getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonExtend(final BlockPistonExtendEvent e) { if (isInPlot(e.getBlock().getLocation())) { for (final Block block : e.getBlocks()) { if (!isInPlot(block.getLocation())) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonRetract(final BlockPistonRetractEvent e) { final Block b = e.getRetractLocation().getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { e.setCancelled(true); } + if (isPlotArea(e.getBlock().getLocation())) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onStructureGrow(final StructureGrowEvent e) { final List blocks = e.getBlocks(); @@ -488,21 +500,22 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi for (int i = blocks.size() - 1; i >= 0; i--) { if (remove || isPlotWorld(blocks.get(i).getLocation())) { remove = true; - Location loc = blocks.get(i).getLocation(); + final Location loc = blocks.get(i).getLocation(); if (!isInPlot(loc)) { - if (isPlotArea(loc)) { e.getBlocks().remove(i); } + if (isPlotArea(loc)) { + e.getBlocks().remove(i); + } } } } } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractEvent event) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) { return; } - Block block = event.getClickedBlock(); + final Block block = event.getClickedBlock(); if (block == null) { return; } @@ -510,8 +523,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - Player player = event.getPlayer(); - Location loc = event.getClickedBlock().getLocation(); + final Player player = event.getPlayer(); + final Location loc = event.getClickedBlock().getLocation(); if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { @@ -522,8 +535,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } - Flag use = FlagManager.getPlotFlag(plot, "use"); - if (use != null && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { + final Flag use = FlagManager.getPlotFlag(plot, "use"); + if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } if (!plot.hasRights(player)) { @@ -539,13 +552,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.interact.road")) { return; } - if (isPlotArea(loc)) { + if (isPlotArea(loc)) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road"); event.setCancelled(true); return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void MobSpawn(final CreatureSpawnEvent event) { final World world = event.getLocation().getWorld(); @@ -555,7 +568,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - Location loc = event.getLocation(); + final Location loc = event.getLocation(); if (!isPlotArea(loc)) { return; } @@ -572,11 +585,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBlockIgnite(final BlockIgniteEvent e) { final World world; - if (e.getBlock() != null) { world = e.getBlock().getWorld(); } else if (e.getIgnitingEntity() != null) { @@ -586,7 +598,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { return; } - if (!isPlotWorld(world)) { return; } @@ -595,7 +606,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } final Block b = e.getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (b != null) { if (e.getPlayer() != null) { final Player p = e.getPlayer(); @@ -607,7 +618,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(loc); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); @@ -615,7 +626,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else if (!plot.hasRights(p)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { - if (isPlotArea(loc)) { + if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -624,17 +635,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } else { - if (isPlotArea(loc)) { e.setCancelled(true); } + if (isPlotArea(loc)) { + e.setCancelled(true); + } } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onTeleport(final PlayerTeleportEvent event) { final Location f = event.getFrom(); final Location t = event.getTo(); final Location q = new Location(t.getWorld(), t.getBlockX(), 64, t.getZ()); - if (isPlotWorld(q)) { if (isInPlot(q)) { final Plot plot = getCurrentPlot(q); @@ -659,14 +671,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { final BlockFace bf = e.getBlockFace(); final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { - Player p = e.getPlayer(); + final Player p = e.getPlayer(); if (!isInPlot(loc)) { if (BukkitMain.hasPermission(p, "plots.admin.build.road")) { return; @@ -676,7 +688,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } else { final Plot plot = getCurrentPlot(loc); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { return; } @@ -684,14 +696,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } else if (!plot.hasRights(e.getPlayer())) { - Flag use = FlagManager.getPlotFlag(plot, "use"); - if (use != null && ((HashSet) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { + final Flag use = FlagManager.getPlotFlag(plot, "use"); + if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { return; } if (BukkitMain.hasPermission(p, "plots.admin.build.other")) { return; } - if (isPlotArea(loc)) { + if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -700,7 +712,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onInventoryClick(final InventoryClickEvent event) { if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { @@ -708,7 +720,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler public static void onLeave(final PlayerQuitEvent event) { if (Setup.setupMap.containsKey(event.getPlayer().getName())) { @@ -717,7 +729,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { final Collection plots = PlotSquared.getPlots(event.getPlayer().getName()).values(); for (final Plot plot : plots) { - PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); final PlotManager manager = PlotSquared.getPlotManager(plot.world); manager.clearPlot(plotworld, plot, true, null); DBFunc.delete(plot.world, plot); @@ -725,13 +737,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketFill(final PlayerBucketFillEvent e) { final Block b = e.getBlockClicked(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { - Player p = e.getPlayer(); + final Player p = e.getPlayer(); if (!isInPlot(loc)) { if (BukkitMain.hasPermission(p, "plots.admin.build.road")) { return; @@ -741,7 +753,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } else { final Plot plot = getCurrentPlot(loc); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { return; } @@ -749,15 +761,15 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } else if (!plot.hasRights(e.getPlayer())) { - Flag use = FlagManager.getPlotFlag(plot, "use"); - Block block = e.getBlockClicked(); - if (use != null && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { + final Flag use = FlagManager.getPlotFlag(plot, "use"); + final Block block = e.getBlockClicked(); + if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } if (BukkitMain.hasPermission(p, "plots.admin.build.other")) { return; } - if (isPlotArea(loc)) { + if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -766,11 +778,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingPlace(final HangingPlaceEvent e) { final Block b = e.getBlock(); - Location loc = b.getLocation(); + final Location loc = b.getLocation(); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { @@ -781,7 +793,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(loc); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); @@ -792,7 +804,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { - if (isPlotArea(loc)) { + if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -802,7 +814,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { final Entity r = e.getRemover(); @@ -818,7 +830,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(l); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.destroy.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); e.setCancelled(true); @@ -840,7 +852,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { final Location l = e.getRightClicked().getLocation(); @@ -854,28 +866,28 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(l); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); return; } } else if (!plot.hasRights(p)) { - Entity entity = e.getRightClicked(); - if (entity instanceof Monster && FlagManager.isPlotFlagTrue(plot, "hostile-interact")) { + final Entity entity = e.getRightClicked(); + if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-interact")) { return; } - if (entity instanceof Animals && FlagManager.isPlotFlagTrue(plot, "animal-interact")) { + if ((entity instanceof Animals) && FlagManager.isPlotFlagTrue(plot, "animal-interact")) { return; } - if (entity instanceof Tameable && ((Tameable) entity).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-interact")) { + if ((entity instanceof Tameable) && ((Tameable) entity).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-interact")) { return; } - if (entity instanceof RideableMinecart && FlagManager.isPlotFlagTrue(plot, "vehicle-use")) { + if ((entity instanceof RideableMinecart) && FlagManager.isPlotFlagTrue(plot, "vehicle-use")) { return; } if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { - if (isPlotArea(l)) { + if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); return; @@ -885,12 +897,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onVehicleDestroy (VehicleDestroyEvent e) { + public static void onVehicleDestroy(final VehicleDestroyEvent e) { final Location l = e.getVehicle().getLocation(); if (isPlotWorld(l)) { - Entity d = e.getAttacker(); + final Entity d = e.getAttacker(); if (d instanceof Player) { final Player p = (Player) d; final PlotWorld pW = getPlotWorld(l.getWorld()); @@ -902,14 +914,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(l); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.vehicle.break.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); e.setCancelled(true); return; } return; - } + } if (!plot.hasRights(p)) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) { return; @@ -932,21 +944,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location l = e.getEntity().getLocation(); final Entity d = e.getDamager(); final Entity a = e.getEntity(); - - if (Settings.TELEPORT_DELAY != 0 && BukkitTaskManager.TELEPORT_QUEUE.size() > 0 && a instanceof Player) { - Player player = (Player) a; - String name = player.getName(); - if (BukkitTaskManager.TELEPORT_QUEUE.contains(name)) { - BukkitTaskManager.TELEPORT_QUEUE.remove(name); + if ((Settings.TELEPORT_DELAY != 0) && (TaskManager.TELEPORT_QUEUE.size() > 0) && (a instanceof Player)) { + final Player player = (Player) a; + final String name = player.getName(); + if (TaskManager.TELEPORT_QUEUE.contains(name)) { + TaskManager.TELEPORT_QUEUE.remove(name); } } - if (isPlotWorld(l)) { if (d instanceof Player) { final Player p = (Player) d; final boolean aPlr = a instanceof Player; final PlotWorld pW = getPlotWorld(l.getWorld()); - if (!aPlr && pW.PVE && (!(a instanceof ItemFrame) && !(a.getType().getTypeId() == 30) ) ) { + if (!aPlr && pW.PVE && (!(a instanceof ItemFrame) && !(a.getType().getTypeId() == 30))) { return; } else if (aPlr && pW.PVP) { return; @@ -959,7 +969,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(l); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.pve.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.unowned"); e.setCancelled(true); @@ -973,17 +983,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } assert plot != null; if (!plot.hasRights(p)) { - if (a instanceof Monster && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { + if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { return; } - if (a instanceof Animals && FlagManager.isPlotFlagTrue(plot, "animal-attack")) { + if ((a instanceof Animals) && FlagManager.isPlotFlagTrue(plot, "animal-attack")) { return; } - if (a instanceof Tameable && ((Tameable) a).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-attack")) { + if ((a instanceof Tameable) && ((Tameable) a).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-attack")) { return; } if (!BukkitMain.hasPermission(p, "plots.admin.pve.other")) { - if (isPlotArea(l)) { + if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.other"); e.setCancelled(true); return; @@ -992,12 +1002,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - if (d instanceof Arrow && isPlotArea(l) && (!(a instanceof Creature))) { + if ((d instanceof Arrow) && isPlotArea(l) && (!(a instanceof Creature))) { e.setCancelled(true); } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerEggThrow(final PlayerEggThrowEvent e) { final Location l = e.getEgg().getLocation(); @@ -1011,7 +1021,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { final Plot plot = getCurrentPlot(l); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.projectile.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.unowned"); e.setHatching(false); @@ -1019,7 +1029,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else if (!plot.hasRights(p)) { if (!BukkitMain.hasPermission(p, "plots.admin.projectile.other")) { - if (isPlotArea(l)) { + if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); e.setHatching(false); return; @@ -1029,7 +1039,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH) public void BlockCreate(final BlockPlaceEvent event) { final World world = event.getPlayer().getWorld(); @@ -1039,8 +1049,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin")) { return; } - Player player = event.getPlayer(); - Location loc = event.getBlock().getLocation(); + final Player player = event.getPlayer(); + final Location loc = event.getBlock().getLocation(); if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { @@ -1052,9 +1062,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasRights(player)) { - Flag place = FlagManager.getPlotFlag(plot, "place"); - Block block = event.getBlock(); - if (place != null && ((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), (byte) block.getData()))) { + final Flag place = FlagManager.getPlotFlag(plot, "place"); + final Block block = event.getBlock(); + if ((place != null) && ((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } if (!BukkitMain.hasPermission(player, "plots.admin.build.other")) { @@ -1066,7 +1076,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) { - if (isPlotArea(loc)) { + if (isPlotArea(loc)) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; 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 cb94b8fb5..c4a440c76 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 @@ -13,7 +13,6 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class PlayerEvents_1_8 extends PlotListener implements Listener { - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractAtEntityEvent e) { final Location l = e.getRightClicked().getLocation(); @@ -26,21 +25,20 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { } } else { final Plot plot = getCurrentPlot(l); - if (plot == null || !plot.hasOwner()) { + if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.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 (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { - if (isPlotArea(l)) { + if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); - e.setCancelled(true); + 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 163ee17e2..106e2f8f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.listeners; import java.util.ArrayList; @@ -51,78 +50,77 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings({"unused", "deprecation"}) public class PlotListener { - +@SuppressWarnings({ "unused", "deprecation" }) +public class PlotListener { public static void textures(final Player p) { if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld().getName())) { p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); } } - public static boolean booleanFlag(Plot plot, String key, boolean defaultValue) { - Flag flag = FlagManager.getPlotFlag(plot, key); - if (flag == null) { - return defaultValue; - } - Object value = flag.getValue(); - if (value instanceof Boolean) { - return (boolean) value; - } - return defaultValue; + public static boolean booleanFlag(final Plot plot, final String key, final boolean defaultValue) { + final Flag flag = FlagManager.getPlotFlag(plot, key); + if (flag == null) { + return defaultValue; + } + final Object value = flag.getValue(); + if (value instanceof Boolean) { + return (boolean) value; + } + return defaultValue; } - - public static boolean isInPlot(String world, int x, int y, int z) { + + public static boolean isInPlot(final String world, final int x, final int y, final int z) { return (PlayerFunctions.getPlot(new Location(world, x, y, z)) != null); } - + public static boolean isPlotWorld(final String world) { return PlotSquared.isPlotWorld(world); } - public static boolean isPlotArea(Location location) { - PlotWorld plotworld = PlotSquared.getWorldSettings(location.getWorld()); + public static boolean isPlotArea(final Location location) { + final PlotWorld plotworld = PlotSquared.getWorldSettings(location.getWorld()); if (plotworld.TYPE == 2) { return ClusterManager.getCluster(location) != null; } return true; } - + private static String getName(final UUID id) { if (id == null) { return "none"; } - String name = UUIDHandler.getName(id); + final String name = UUIDHandler.getName(id); if (name == null) { return "unknown"; } return name; } - + public static UUID getUUID(final String name) { return UUIDHandler.getUUID(name); } - + public static boolean enteredPlot(final Location l1, final Location l2) { final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ())); final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ())); return (p2 != null) && ((p1 == null) || !p1.equals(p2)); - } - + public static boolean leftPlot(final Location l1, final Location l2) { final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ())); final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ())); return (p1 != null) && ((p2 == null) || !p1.equals(p2)); } - + public static boolean isPlotWorld(final Location l) { return PlotSquared.isPlotWorld(l.getWorld()); } - + public static boolean isInPlot(final Location loc) { return getCurrentPlot(loc) != null; } - + public static Plot getCurrentPlot(final Location loc) { final PlotId id = PlayerFunctions.getPlot(loc); if (id == null) { @@ -134,7 +132,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld()); } - + private static WeatherType getWeatherType(String str) { str = str.toLowerCase(); if (str.equals("rain")) { @@ -142,8 +140,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } else { return WeatherType.CLEAR; } - } - + } + private static GameMode getGameMode(final String str) { switch (str) { case "creative": @@ -156,27 +154,27 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; return Bukkit.getDefaultGameMode(); } } - + public static void plotEntry(final Player player, final Plot plot) { if (plot.hasOwner()) { - Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode"); + final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode"); if (gamemodeFlag != null) { player.setGameMode(getGameMode(gamemodeFlag.getValueString())); } - Flag flyFlag = FlagManager.getPlotFlag(plot, "fly"); + final Flag flyFlag = FlagManager.getPlotFlag(plot, "fly"); if (flyFlag != null) { player.setAllowFlight((boolean) flyFlag.getValue()); } - Flag timeFlag = FlagManager.getPlotFlag(plot, "time"); + final Flag timeFlag = FlagManager.getPlotFlag(plot, "time"); if (timeFlag != null) { try { - long time = (long) timeFlag.getValue(); + final long time = (long) timeFlag.getValue(); player.setPlayerTime(time, true); } catch (final Exception e) { FlagManager.removePlotFlag(plot, "time"); } } - Flag weatherFlag = FlagManager.getPlotFlag(plot, "weather"); + final Flag weatherFlag = FlagManager.getPlotFlag(plot, "weather"); if (weatherFlag != null) { player.setPlayerWeather(getWeatherType(weatherFlag.getValueString())); } @@ -186,7 +184,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; final ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); final ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); if (AbstractTitle.TITLE_CLASS != null) { - AbstractTitle.TITLE_CLASS.sendTitle(player, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); + AbstractTitle.TITLE_CLASS.sendTitle(player, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } } { @@ -195,7 +193,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } } } - + public static void plotExit(final Player player, final Plot plot) { { final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); @@ -214,7 +212,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; player.resetPlayerWeather(); } } - + public static boolean getFlagValue(final String value) { return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase()); } 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 f2c4101ac..c19710edf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.listeners; import java.util.ArrayList; @@ -60,11 +59,11 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * * @author Citymonstret */ -@SuppressWarnings({"deprecation", "unused"}) public class PlotPlusListener extends PlotListener implements Listener { - +@SuppressWarnings({ "deprecation", "unused" }) +public class PlotPlusListener extends PlotListener implements Listener { private final static HashMap feedRunnable = new HashMap<>(); private final static HashMap healRunnable = new HashMap<>(); - + public static void startRunnable(final JavaPlugin plugin) { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override @@ -96,7 +95,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } }, 0l, 20l); } - + @EventHandler public void onInventoryClick(final InventoryClickEvent event) { final Player player = (Player) event.getWhoClicked(); @@ -133,9 +132,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; p.playEffect(p.getLocation(), Effect.RECORD_PLAY, meta.getMaterial()); PlayerFunctions.sendMessage(p, C.RECORD_PLAY.s().replaceAll("%player", player.getName()).replaceAll("%name", meta.toString())); } - } - + @EventHandler(priority = EventPriority.HIGH) public void onInteract(final BlockDamageEvent event) { final Player player = event.getPlayer(); @@ -150,7 +148,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; event.getBlock().breakNaturally(); } } - + @EventHandler(priority = EventPriority.HIGH) public void onDamage(final EntityDamageEvent event) { if (event.getEntityType() != EntityType.PLAYER) { @@ -164,21 +162,21 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; event.setCancelled(true); } } - + @EventHandler public void onItemPickup(final PlayerPickupItemEvent event) { if (isInPlot(event.getPlayer()) && !getPlot(event.getPlayer()).hasRights(event.getPlayer()) && booleanFlag(getPlot(event.getPlayer()), "drop-protection", false)) { event.setCancelled(true); } } - + @EventHandler public void onItemDrop(final PlayerDropItemEvent event) { if (isInPlot(event.getPlayer()) && !getPlot(event.getPlayer()).hasRights(event.getPlayer()) && booleanFlag(getPlot(event.getPlayer()), "item-drop", false)) { event.setCancelled(true); } } - + @EventHandler public void onPlotEnter(final PlayerEnterPlotEvent event) { final Plot plot = event.getPlot(); @@ -191,7 +189,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; if (player == null) { return; } - Player trespasser = event.getPlayer(); + final Player trespasser = event.getPlayer(); if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(trespasser))) { return; } @@ -204,7 +202,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } } } - + @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { if (feedRunnable.containsKey(event.getPlayer().getName())) { @@ -214,7 +212,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; healRunnable.remove(event.getPlayer().getName()); } } - + @EventHandler public void onPlotLeave(final PlayerLeavePlotEvent event) { event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.RECORD_PLAY, 0); @@ -234,7 +232,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; if (player == null) { return; } - Player trespasser = event.getPlayer(); + final Player trespasser = event.getPlayer(); if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(trespasser))) { return; } @@ -247,20 +245,20 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } } } - + public static class Interval { public final int interval; public final int amount; public final int max; public int count = 0; - + public Interval(final int interval, final int amount, final int max) { this.interval = interval; this.amount = amount; this.max = max; } } - + /** * Record Meta Class * @@ -268,31 +266,29 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; */ public static class RecordMeta { public final static List metaList = new ArrayList<>(); - static { for (int x = 3; x < 12; x++) { metaList.add(new RecordMeta(x + "", Material.valueOf("RECORD_" + x))); } } - private final String name; private final Material material; - + public RecordMeta(final String name, final Material material) { this.name = name; this.material = material; } - + @Override public String toString() { return this.name; } - + @Override public int hashCode() { return this.name.hashCode(); } - + public Material getMaterial() { return this.material; } 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 6a09fddc5..63e32e2ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.listeners; import java.util.Arrays; @@ -62,16 +61,14 @@ import com.sk89q.worldedit.function.mask.Mask; * @author Empire92 */ public class WorldEditListener implements Listener { - - final List monitored = Arrays.asList(new String[]{"set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "move", "stack", "naturalize", "paste", "count", "regen", "copy", "cut", ""}); - + final List monitored = Arrays.asList(new String[] { "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "move", "stack", "naturalize", "paste", "count", "regen", "copy", "cut", "" }); public final Set blockedcmds = new HashSet<>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); - + private boolean isPlotWorld(final Location l) { return (PlotSquared.isPlotWorld(l.getWorld())); } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDelete(final PlotDeleteEvent e) { final String world = e.getWorld(); @@ -92,7 +89,7 @@ public class WorldEditListener implements Listener { } PWE.setNoMask(player); } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInteract(final PlayerInteractEvent e) { final Block b = e.getClickedBlock(); @@ -115,7 +112,7 @@ public class WorldEditListener implements Listener { } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent e) { final Player p = e.getPlayer(); @@ -123,7 +120,6 @@ public class WorldEditListener implements Listener { return; } String cmd = e.getMessage().toLowerCase(); - if (cmd.contains(" ")) { cmd = cmd.substring(0, cmd.indexOf(" ")); } @@ -148,7 +144,6 @@ public class WorldEditListener implements Listener { } final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector(); final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector(); - final LocalSession session = PlotSquared.worldEdit.getSession(p); final Mask mask = session.getMask(); if (mask == null) { @@ -165,9 +160,8 @@ public class WorldEditListener implements Listener { } } } - } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerJoin(final PlayerJoinEvent e) { final Player p = e.getPlayer(); @@ -184,7 +178,7 @@ public class WorldEditListener implements Listener { PWE.removeMask(p); } } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent e) { final Location t = e.getTo(); @@ -206,7 +200,7 @@ public class WorldEditListener implements Listener { } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPortal(final PlayerPortalEvent e) { if (BukkitMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { @@ -227,7 +221,7 @@ public class WorldEditListener implements Listener { PWE.removeMask(p); } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent e) { final Player p = e.getPlayer(); 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 5ef523eae..14ea6785f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.listeners; import java.util.ArrayList; @@ -61,7 +60,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; public class WorldGuardListener implements Listener { public final ArrayList str_flags; public final ArrayList> flags; - + public WorldGuardListener(final PlotSquared plugin) { this.str_flags = new ArrayList<>(); this.flags = new ArrayList<>(); @@ -73,15 +72,15 @@ public class WorldGuardListener implements Listener { public void changeOwner(final Player requester, final UUID owner, final World world, final Plot plot) { try { - 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)); - region.setOwners(owners); + final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); + final ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); + final DefaultDomain owners = new DefaultDomain(); + owners.addPlayer(UUIDHandler.getName(owner)); + region.setOwners(owners); } catch (final Exception e) { } } - + public void removeFlag(final Player requester, final World world, final Plot plot, final String key) { final boolean op = requester.isOp(); requester.setOp(true); @@ -99,7 +98,7 @@ public class WorldGuardListener implements Listener { requester.setOp(op); } } - + public void addFlag(final Player requester, final World world, final Plot plot, final String key, final String value) { final boolean op = requester.isOp(); requester.setOp(true); @@ -117,7 +116,7 @@ public class WorldGuardListener implements Listener { requester.setOp(op); } } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMerge(final PlotMergeEvent event) { final Plot main = event.getPlot(); @@ -134,90 +133,69 @@ public class WorldGuardListener implements Listener { final Map, Object> flags = region.getFlags(); final DefaultDomain members = region.getMembers(); manager.removeRegion(main.id.x + "-" + main.id.y); - final Location location1 = PlotHelper.getPlotBottomLocAbs(world, plots.get(0)); final Location location2 = PlotHelper.getPlotTopLocAbs(world, plots.get(plots.size() - 1)); - final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); final BlockVector vector2 = new BlockVector(location2.getBlockX(), world.getMaxHeight(), location2.getBlockZ()); final ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-" + main.id.y, vector1, vector2); - rg.setFlags(flags); - rg.setOwners(owner); - rg.setMembers(members); - manager.addRegion(rg); } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onUnlink(final PlotUnlinkEvent event) { try { final World w = event.getWorld(); final ArrayList plots = event.getPlots(); final Plot main = PlotSquared.getPlots(w).get(plots.get(0)); - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(w); final ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y); - final DefaultDomain owner = region.getOwners(); final Map, Object> flags = region.getFlags(); final DefaultDomain members = region.getMembers(); - manager.removeRegion(main.id.x + "-" + main.id.y); for (int i = 1; i < plots.size(); i++) { final PlotId id = plots.get(i); final Location location1 = PlotHelper.getPlotBottomLocAbs(w, id); final Location location2 = PlotHelper.getPlotTopLocAbs(w, id); - final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); final BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ()); final ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2); - rg.setFlags(flags); - rg.setOwners(owner); - rg.setMembers(members); - manager.addRegion(rg); } } catch (final Exception e) { } } - + @EventHandler public void onPlotClaim(final PlayerClaimPlotEvent event) { try { final Player player = event.getPlayer(); final Plot plot = event.getPlot(); final RegionManager manager = PlotSquared.worldGuard.getRegionManager(plot.world); - final Location location1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId()); final Location location2 = PlotHelper.getPlotTopLoc(plot.world, plot.getId()); - final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); final BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.world.getMaxHeight(), location2.getBlockZ()); - final ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2); - final DefaultDomain owner = new DefaultDomain(); owner.addPlayer(PlotSquared.worldGuard.wrapPlayer(player)); - region.setOwners(owner); - manager.addRegion(region); } catch (final Exception e) { } } - + @EventHandler public void onPlotDelete(final PlotDeleteEvent event) { try { final PlotId plot = event.getPlotId(); final World world = Bukkit.getWorld(event.getWorld()); - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); manager.removeRegion(plot.x + "-" + plot.y); } catch (final Exception e) { @@ -226,16 +204,16 @@ public class WorldGuardListener implements Listener { public void addUser(final Player requester, final UUID user, final World world, final Plot plot) { final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); - ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); - DefaultDomain members = region.getMembers(); + final ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); + final DefaultDomain members = region.getMembers(); members.addPlayer(UUIDHandler.getName(user)); region.setMembers(members); } public void removeUser(final Player requester, final UUID user, final World world, final Plot plot) { final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); - ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); - DefaultDomain members = region.getMembers(); + final ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); + final DefaultDomain members = region.getMembers(); members.removePlayer(UUIDHandler.getName(user)); region.setMembers(members); } @@ -244,8 +222,7 @@ public class WorldGuardListener implements Listener { public void onPlotHelper(final PlayerPlotHelperEvent event) { if (event.wasAdded()) { addUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); - } - else { + } else { removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); } } @@ -254,8 +231,7 @@ public class WorldGuardListener implements Listener { public void onPlotTrusted(final PlayerPlotTrustedEvent event) { if (event.wasAdded()) { addUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); - } - else { + } else { removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java index d16e38716..1cc9b4b9e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java @@ -1,17 +1,14 @@ package com.intellectualcrafters.plot.object; - - public class BlockLoc { public int x; public int y; public int z; - public BlockLoc(int x, int y, int z) { + public BlockLoc(final int x, final int y, final int z) { this.x = x; this.y = y; this.z = z; - } @Override @@ -25,7 +22,7 @@ public class BlockLoc { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -35,8 +32,7 @@ public class BlockLoc { if (getClass() != obj.getClass()) { return false; } - BlockLoc other = (BlockLoc) obj; + final BlockLoc other = (BlockLoc) obj; return ((this.x == other.x) && (this.y == other.y) && (this.z == other.z)); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java index 39fbeda1a..b65a8adfa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; import org.bukkit.World; @@ -33,32 +32,27 @@ import org.bukkit.block.Block; * @author Citymonstret */ public class BlockWrapper { - /** * X Coordinate */ public final int x; - /** * Y Coordinate */ public final int y; - /** * Z Coordinate */ public final int z; - /** * Block ID */ public final int id; - /** * Block Data Value */ public final byte data; - + /** * Constructor * @@ -75,13 +69,13 @@ public class BlockWrapper { this.id = id; this.data = data; } - + /** * Alternative Constructor Uses block data, rather than typed data * * @param block Block from which we get the data */ - @SuppressWarnings({"deprecation", "unused"}) + @SuppressWarnings({ "deprecation", "unused" }) public BlockWrapper(final Block block) { this.x = block.getX(); this.y = block.getY(); @@ -89,7 +83,7 @@ public class BlockWrapper { this.id = block.getTypeId(); this.data = block.getData(); } - + /** * Get a block based on the block wrapper * @@ -97,7 +91,7 @@ public class BlockWrapper { * * @return block created/fetched from settings */ - @SuppressWarnings({"unused", "deprecation"}) + @SuppressWarnings({ "unused", "deprecation" }) public Block toBlock(final World world) { final Block block = world.getBlockAt(this.x, this.y, this.z); block.setTypeIdAndData(this.id, this.data, true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java index 4e8614585..c5282d48d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java @@ -1,14 +1,12 @@ package com.intellectualcrafters.plot.object; - public class ChunkLoc { public int x; public int z; - public ChunkLoc(int x, int z) { + public ChunkLoc(final int x, final int z) { this.x = x; this.z = z; - } @Override @@ -21,7 +19,7 @@ public class ChunkLoc { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -31,8 +29,7 @@ public class ChunkLoc { if (getClass() != obj.getClass()) { return false; } - ChunkLoc other = (ChunkLoc) obj; + final ChunkLoc other = (ChunkLoc) obj; return ((this.x == other.x) && (this.z == other.z)); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index f3cbe891f..420ccfd27 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -21,11 +21,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class InfoInventory implements InventoryHolder { - private final Plot plot; private final Inventory inventory; private final Player player; - + /** * Constructor * @@ -36,20 +35,20 @@ public class InfoInventory implements InventoryHolder { this.player = player; this.inventory = Bukkit.createInventory(this, 9, "Plot: " + plot.id.toString()); } - + @Override public Inventory getInventory() { return this.inventory; } - public String getName(UUID uuid) { - String name = UUIDHandler.getName(this.plot.getOwner()); + public String getName(final UUID uuid) { + final String name = UUIDHandler.getName(this.plot.getOwner()); if (name == null) { return "unknown"; } return name; } - + public InfoInventory build() { final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.hasRights(this.player), "&cIs Denied: &6" + this.plot.deny_entry(this.player)); final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers"); @@ -63,13 +62,13 @@ public class InfoInventory implements InventoryHolder { this.inventory.setItem(6, flags); return this; } - + public InfoInventory display() { this.player.closeInventory(); this.player.openInventory(this.inventory); return this; } - + private ItemStack getItem(final Material material, final String name, final String... lore) { final ItemStack stack = new ItemStack(material); final ItemMeta meta = stack.getItemMeta(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java index 887a6d4b9..0aa2d0ea0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -10,15 +10,15 @@ import java.lang.reflect.Method; * @author Citymonstret */ public class Location implements Cloneable, Comparable { - private int x, y, z; private float yaw, pitch; private String world; private boolean built; private Object o; - + + @Override public Location clone() { - return new Location(world, x, y, z, yaw, pitch); + return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch); } public Location(final String world, final int x, final int y, final int z, final float yaw, final float pitch) { @@ -31,187 +31,186 @@ public class Location implements Cloneable, Comparable { this.built = false; this.o = null; } - + public Location() { this("", 0, 0, 0, 0, 0); } - + public Location(final String world, final int x, final int y, final int z) { this(world, x, y, z, 0f, 0f); } - + public int getX() { return this.x; } - + public void setX(final int x) { this.x = x; this.built = false; } - + public int getY() { return this.y; } - + public void setY(final int y) { this.y = y; this.built = false; } - + public int getZ() { return this.z; } - + public void setZ(final int z) { this.z = z; this.built = false; } - + public String getWorld() { return this.world; } - + public void setWorld(final String world) { this.world = world; this.built = false; } - + public float getYaw() { return this.yaw; } - + public void setYaw(final float yaw) { this.yaw = yaw; this.built = false; } - + public float getPitch() { return this.pitch; } - + public void setPitch(final float pitch) { this.pitch = pitch; this.built = false; } - - public Location add(int x, int y, int z) { + + public Location add(final int x, final int y, final int z) { this.x += x; this.y += y; this.z += z; this.built = false; return this; } - + public double getEuclideanDistanceSquared(final Location l2) { - double x = getX() - l2.getX(); - double y = getY() - l2.getY(); - double z = getZ() - l2.getZ(); + final double x = getX() - l2.getX(); + final double y = getY() - l2.getY(); + final double z = getZ() - l2.getZ(); return (x * x) + (y * y) + (z * z); } - + public double getEuclideanDistance(final Location l2) { return Math.sqrt(getEuclideanDistanceSquared(l2)); } - + public boolean isInSphere(final Location origin, final int radius) { - return getEuclideanDistanceSquared(origin) < radius * radius; + return getEuclideanDistanceSquared(origin) < (radius * radius); } - + @Override public int hashCode() { int hash = 127; - hash = hash * 31 + (int) x; - hash = hash * 31 + (int) y; - hash = hash * 31 + (int) z; - hash = (int) (hash * 31 + getYaw()); - hash = (int) (hash * 31 + getPitch()); - return hash * 31 + (world == null ? 127 : world.hashCode()); + hash = (hash * 31) + this.x; + hash = (hash * 31) + this.y; + hash = (hash * 31) + this.z; + hash = (int) ((hash * 31) + getYaw()); + hash = (int) ((hash * 31) + getPitch()); + return (hash * 31) + (this.world == null ? 127 : this.world.hashCode()); } - + public boolean isInAABB(final Location min, final Location max) { - return x >= min.getX() && x <= max.getX() && y >= min.getY() && - y <= max.getY() && z >= min.getX() && z < max.getZ(); + return (this.x >= min.getX()) && (this.x <= max.getX()) && (this.y >= min.getY()) && (this.y <= max.getY()) && (this.z >= min.getX()) && (this.z < max.getZ()); } - - public void lookTowards(int x, int y) { - double l = this.x - x; - double w = this.z - z; - double c = Math.sqrt(l * l + w * w); - if ((Math.asin(w / c) / Math.PI * 180) > 90) { - setYaw((float) (180 - (-Math.asin(l / c) / Math.PI * 180))); + + public void lookTowards(final int x, final int y) { + final double l = this.x - x; + final double w = this.z - this.z; + final double c = Math.sqrt((l * l) + (w * w)); + if (((Math.asin(w / c) / Math.PI) * 180) > 90) { + setYaw((float) (180 - ((-Math.asin(l / c) / Math.PI) * 180))); } else { - setYaw((float) (-Math.asin(l / c) / Math.PI * 180)); + setYaw((float) ((-Math.asin(l / c) / Math.PI) * 180)); } this.built = false; } - - public Location subtract(int x, int y, int z) { + + public Location subtract(final int x, final int y, final int z) { this.x -= x; this.y -= y; this.z -= z; this.built = false; return this; } - + @Override - public boolean equals(Object o) { + public boolean equals(final Object o) { if (o == null) { return false; } if (!(o instanceof Location)) { return false; } - Location l = (Location) o; - return x == l.getX() && y == l.getY() && - z == l.getZ() && world.equals(l.getWorld()) && - yaw == l.getY() && pitch == l.getPitch(); + final Location l = (Location) o; + return (this.x == l.getX()) && (this.y == l.getY()) && (this.z == l.getZ()) && this.world.equals(l.getWorld()) && (this.yaw == l.getY()) && (this.pitch == l.getPitch()); } - + @Override public int compareTo(final Location o) { if (o == null) { throw new NullPointerException("Specified object was null"); } - if (x == o.getX() && y == o.getY() || z == o.getZ()) + if (((this.x == o.getX()) && (this.y == o.getY())) || (this.z == o.getZ())) { return 0; - if (x < o.getX() && y < o.getY() && z < o.getZ()) + } + if ((this.x < o.getX()) && (this.y < o.getY()) && (this.z < o.getZ())) { return -1; + } return 1; } - + @Override public String toString() { - return "\"plotsquaredlocation\":{" + "\"x\":" + x + ",\"y\":" + y + ",\"z\":" + z + ",\"yaw\":" + yaw + ",\"pitch\":" + pitch + ",\"world\":\"" + world + "\"}"; + return "\"plotsquaredlocation\":{" + "\"x\":" + this.x + ",\"y\":" + this.y + ",\"z\":" + this.z + ",\"yaw\":" + this.yaw + ",\"pitch\":" + this.pitch + ",\"world\":\"" + this.world + "\"}"; } - + private Object getBukkitWorld() { try { - Class clazz = Class.forName("org.bukkit.Bukkit"); - return clazz.getMethod("getWorld", String.class).invoke(null, world); - } catch (Exception e) { + final Class clazz = Class.forName("org.bukkit.Bukkit"); + return clazz.getMethod("getWorld", String.class).invoke(null, this.world); + } catch (final Exception e) { return null; } } - + public Object toBukkitLocation() { - if (built) { - return o; + if (this.built) { + return this.o; } try { - Constructor constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class, float.class); - built = true; - return (o = constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), x, y, z, yaw, pitch)); + final Constructor constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class, float.class); + this.built = true; + return (this.o = constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), this.x, this.y, this.z, this.yaw, this.pitch)); } catch (IllegalAccessException | InstantiationException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) { return null; } } - + /** * Please use utility class as this is not efficient */ public void teleport(final Object o) throws Exception { if (o.getClass().getName().contains("org.bukkit.entity")) { - Method m = o.getClass().getMethod("teleport", Class.forName("org.bukkit.Location")); + final Method m = o.getClass().getMethod("teleport", Class.forName("org.bukkit.Location")); m.invoke(o, toBukkitLocation()); } } 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 b3be4d640..40cfec017 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; import java.util.ArrayList; @@ -36,8 +35,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings("javadoc") public class Plot implements Cloneable { - +@SuppressWarnings("javadoc") +public class Plot implements Cloneable { /** * plot ID */ @@ -79,7 +78,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; */ public boolean hasChanged = false; public boolean countsTowardsMax = true; - + /** * Primary constructor * @@ -101,7 +100,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; this.settings.flags = new HashSet(); this.world = world; } - + /** * Constructor for saved plots * @@ -130,7 +129,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } this.world = world; } - + /** * Check if the plot has a set owner * @@ -139,7 +138,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public boolean hasOwner() { return this.owner != null; } - + /** * Check if the player is either the owner or on the helpers list * @@ -150,7 +149,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public boolean isAdded(final UUID uuid) { return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone))); } - + /** * Should the player be allowed to enter? * @@ -161,14 +160,14 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public boolean isDenied(final UUID uuid) { return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); } - + /** * Get the UUID of the owner */ public UUID getOwner() { return this.owner; } - + /** * Set the owner * @@ -177,14 +176,14 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public void setOwner(final UUID uuid) { this.owner = uuid; } - + /** * Get the plot ID */ public PlotId getId() { return this.id; } - + /** * Get a clone of the plot * @@ -198,7 +197,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; } return p; } - + /** * Deny someone (use DBFunc.addDenied() as well) * @@ -207,7 +206,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public void addDenied(final UUID uuid) { this.denied.add(uuid); } - + /** * Add someone as a helper (use DBFunc as well) * @@ -216,7 +215,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public void addHelper(final UUID uuid) { this.helpers.add(uuid); } - + /** * Add someone as a trusted user (use DBFunc as well) * @@ -225,19 +224,20 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public void addTrusted(final UUID uuid) { this.trusted.add(uuid); } - + /** * Get plot display name * * @return alias if set, else id */ + @Override public String toString() { if (this.settings.getAlias().length() > 1) { return this.settings.getAlias(); } return this.world + ";" + this.getId().x + ";" + this.getId().y; } - + /** * Remove a denied player (use DBFunc as well) * @@ -246,7 +246,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public void removeDenied(final UUID uuid) { this.denied.remove(uuid); } - + /** * Remove a helper (use DBFunc as well) * @@ -255,7 +255,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public void removeHelper(final UUID uuid) { this.helpers.remove(uuid); } - + /** * Remove a trusted user (use DBFunc as well) * @@ -264,7 +264,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public void removeTrusted(final UUID uuid) { this.trusted.remove(uuid); } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -279,7 +279,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; final Plot other = (Plot) obj; return ((this.id.x.equals(other.id.x)) && (this.id.y.equals(other.id.y)) && (this.world.equals(other.world))); } - + /** * Get the plot hashcode * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java index e6d0782f1..b27a3c0d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; /** @@ -27,12 +26,12 @@ package com.intellectualcrafters.plot.object; public class PlotBlock { public final short id; public final byte data; - + public PlotBlock(final short id, final byte data) { this.id = id; this.data = data; } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -45,12 +44,12 @@ public class PlotBlock { return false; } final PlotBlock other = (PlotBlock) obj; - return (this.id == other.id && (this.data == other.data || this.data == -1 || other.data == -1)); + return ((this.id == other.id) && ((this.data == other.data) || (this.data == -1) || (other.data == -1))); } - + @Override public int hashCode() { - return id; + return this.id; } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java index 5df277f5a..2bdef8e7c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java @@ -6,62 +6,58 @@ import java.util.UUID; import com.intellectualcrafters.plot.database.DBFunc; public class PlotCluster { - - public final String world; - - public PlotSettings settings; - public UUID owner; - - public HashSet helpers = new HashSet(); - public HashSet invited = new HashSet(); - - private PlotId pos1; - private PlotId pos2; - - public PlotId getP1() { - return this.pos1; - } - - public PlotId getP2() { - return this.pos2; - } - - public void setP1(PlotId id) { - this.pos1 = id; - } - - public void setP2(PlotId id) { - this.pos2 = id; - } - - public PlotCluster(String world, PlotId pos1, PlotId pos2, UUID owner) { - this.world = world; - this.pos1 = pos1; - this.pos2 = pos2; - this.owner = owner; - this.settings = new PlotSettings(null); - } - - public boolean hasRights(UUID uuid) { - return (owner.equals(uuid) || invited.contains(uuid)|| invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone)); + public final String world; + public PlotSettings settings; + public UUID owner; + public HashSet helpers = new HashSet(); + public HashSet invited = new HashSet(); + private PlotId pos1; + private PlotId pos2; + + public PlotId getP1() { + return this.pos1; } - - public boolean hasHelperRights(UUID uuid) { - return (owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone)); + + public PlotId getP2() { + return this.pos2; } - - public String getName() { - return this.settings.getAlias(); - } - - @Override - public int hashCode() { - return this.pos1.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { + + public void setP1(final PlotId id) { + this.pos1 = id; + } + + public void setP2(final PlotId id) { + this.pos2 = id; + } + + public PlotCluster(final String world, final PlotId pos1, final PlotId pos2, final UUID owner) { + this.world = world; + this.pos1 = pos1; + this.pos2 = pos2; + this.owner = owner; + this.settings = new PlotSettings(null); + } + + public boolean hasRights(final UUID uuid) { + return (this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)); + } + + public boolean hasHelperRights(final UUID uuid) { + return (this.owner.equals(uuid) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)); + } + + public String getName() { + return this.settings.getAlias(); + } + + @Override + public int hashCode() { + return this.pos1.hashCode(); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { return true; } if (obj == null) { @@ -72,10 +68,10 @@ public class PlotCluster { } final PlotCluster other = (PlotCluster) obj; return (this.world.equals(other.world) && this.pos1.equals(other.pos1) && this.pos2.equals(other.pos2)); - } - - @Override - public String toString() { - return world + ";" + pos1.x + ";" + pos1.y + ";" + pos2.x + ";" + pos2.y; - } + } + + @Override + public String toString() { + return this.world + ";" + this.pos1.x + ";" + this.pos1.y + ";" + this.pos2.x + ";" + this.pos2.y; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java index 127996f6e..ae8f4d2f1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java @@ -1,12 +1,11 @@ package com.intellectualcrafters.plot.object; public class PlotClusterId { - - public final PlotId pos1; - public final PlotId pos2; - - public PlotClusterId(PlotId pos1, PlotId pos2) { - this.pos1 = pos1; - this.pos2 = pos2; - } + public final PlotId pos1; + public final PlotId pos2; + + public PlotClusterId(final PlotId pos1, final PlotId pos2) { + this.pos1 = pos1; + this.pos2 = pos2; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java index 1472435bb..0effd85d2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; /** @@ -28,7 +27,7 @@ public class PlotComment { public final String comment; public final int tier; public final String senderName; - + public PlotComment(final String comment, final String senderName, final int tier) { this.comment = comment; this.tier = tier; 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 1caab0ebb..752c5e2bd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; import org.bukkit.generator.ChunkGenerator; @@ -26,12 +25,11 @@ import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.PlotSquared; public abstract class PlotGenerator extends ChunkGenerator { - public PlotGenerator(final String world) { PlotSquared.loadWorld(world, this); } - + public abstract PlotWorld getNewPlotWorld(final String world); - + public abstract PlotManager getPlotManager(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java index ba57c9016..53c46c5c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java @@ -18,11 +18,9 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; public class PlotId { - /** * x value */ @@ -31,7 +29,7 @@ public class PlotId { * y value */ public Integer y; - + /** * PlotId class (PlotId x,y values do not correspond to Block locations) * @@ -42,7 +40,7 @@ public class PlotId { this.x = x; this.y = y; } - + /** * Get a Plot Id based on a string * @@ -64,7 +62,7 @@ public class PlotId { } return new PlotId(x, y); } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -79,12 +77,12 @@ public class PlotId { final PlotId other = (PlotId) obj; return ((this.x.equals(other.x)) && (this.y.equals(other.y))); } - + @Override public String toString() { return this.x + ";" + this.y; } - + @Override public int hashCode() { if (this.x >= 0) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java index 6197014ca..5c2706b14 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java @@ -4,7 +4,7 @@ public class PlotLoc { public short x; public short z; - public PlotLoc(short x, short z) { + public PlotLoc(final short x, final short z) { this.x = x; this.z = z; } @@ -19,7 +19,7 @@ public class PlotLoc { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -29,7 +29,7 @@ public class PlotLoc { if (getClass() != obj.getClass()) { return false; } - PlotLoc other = (PlotLoc) obj; + final PlotLoc other = (PlotLoc) obj; return ((this.x == other.x) && (this.z == other.z)); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 2c63302ae..b2a18c279 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; import java.util.ArrayList; @@ -26,65 +25,62 @@ import java.util.ArrayList; import org.bukkit.block.Biome; public abstract class PlotManager { - /* * Plot locations (methods with Abs in them will not need to consider mega * plots) */ - public abstract PlotId getPlotIdAbs(final PlotWorld plotworld, final int x, final int y, final int z); - + public abstract PlotId getPlotId(final PlotWorld plotworld, final int x, final int y, final int z); - + // If you have a circular plot, just return the corner if it were a square public abstract Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid); - + // the same applies here public abstract Location getPlotTopLocAbs(final PlotWorld plotworld, final PlotId plotid); + /* * Plot clearing (return false if you do not support some method) */ public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone); - + public abstract boolean claimPlot(final PlotWorld plotworld, final Plot plot); public abstract boolean unclaimPlot(final PlotWorld plotworld, final Plot plot); public abstract Location getSignLoc(final PlotWorld plotworld, final Plot plot); - + /* * Plot set functions (return false if you do not support the specific set * method) */ - public abstract String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid); public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks); - + public abstract boolean setBiome(final Plot plot, final Biome biome); - + /* * PLOT MERGING (return false if your generator does not support plot * merging) */ public abstract boolean createRoadEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean createRoadSouth(final PlotWorld plotworld, final Plot plot); - + public abstract boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean removeRoadEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot); - + public abstract boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean startPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); - + public abstract boolean startPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); - + public abstract boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); - + public abstract boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 6a4a65829..47a8c0442 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; import java.util.ArrayList; @@ -37,7 +36,8 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings("unused") public class PlotSettings { +@SuppressWarnings("unused") +public class PlotSettings { /** * Plot */ @@ -45,7 +45,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * merged plots */ - private boolean[] merged = new boolean[]{false, false, false, false}; + private boolean[] merged = new boolean[] { false, false, false, false }; /** * plot alias */ @@ -62,7 +62,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; * Home Position */ private BlockLoc position; - + /** * Constructor * @@ -72,7 +72,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; this.alias = ""; this.plot = plot; } - + /** * Check if the plot is merged in a direction
0 = North
1 = East
2 = South
3 = West
* @@ -83,49 +83,49 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public boolean getMerged(final int direction) { return this.merged[direction]; } - + /** * Returns true if the plot is merged (i.e. if it's a mega plot) */ public boolean isMerged() { return (this.merged[0] || this.merged[1] || this.merged[2] || this.merged[3]); } - + public boolean[] getMerged() { return this.merged; } - + public void setMerged(final boolean[] merged) { this.merged = merged; } - + public void setMerged(final int direction, final boolean merged) { this.merged[direction] = merged; } - + /** * @return biome at plot loc */ public Biome getBiome() { - Location loc = PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); + final Location loc = PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); return BukkitUtil.getBiome(loc); } - + public BlockLoc getPosition() { if (this.position == null) { return new BlockLoc(0, 0, 0); } return this.position; } - - public void setPosition(BlockLoc position) { + + public void setPosition(final BlockLoc position) { this.position = position; } - + public String getAlias() { return this.alias; } - + /** * Set the plot alias * @@ -134,28 +134,28 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public void setAlias(final String alias) { this.alias = alias; } - + public String getJoinMessage() { - final Flag greeting = FlagManager.getPlotFlag(plot, "greeting"); + final Flag greeting = FlagManager.getPlotFlag(this.plot, "greeting"); if (greeting != null) { return greeting.getValueString(); } return ""; } - + /** * Get the "farewell" flag value * * @return Farewell flag */ public String getLeaveMessage() { - final Flag farewell = FlagManager.getPlotFlag(plot, "farewell"); + final Flag farewell = FlagManager.getPlotFlag(this.plot, "farewell"); if (farewell != null) { return farewell.getValueString(); } return ""; } - + public ArrayList getComments(final int tier) { final ArrayList c = new ArrayList<>(); if (this.comments == null) { @@ -168,23 +168,23 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; } return c; } - + public void setComments(final ArrayList comments) { this.comments = comments; } - + public void removeComment(final PlotComment comment) { if (this.comments.contains(comment)) { this.comments.remove(comment); } } - + public void removeComments(final ArrayList comments) { for (final PlotComment comment : comments) { removeComment(comment); } } - + public void addComment(final PlotComment comment) { if (this.comments == null) { this.comments = new ArrayList<>(); 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 55b1ba880..cf6ffd07e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; import java.util.ArrayList; @@ -41,7 +40,6 @@ import com.intellectualcrafters.plot.flag.FlagManager; * @author Jesse Boyd */ public abstract class PlotWorld { - public final static boolean AUTO_MERGE_DEFAULT = false; public final static boolean MOB_SPAWNING_DEFAULT = false; public final static Biome PLOT_BIOME_DEFAULT = Biome.FOREST; @@ -60,15 +58,11 @@ public abstract class PlotWorld { public final static boolean SPAWN_CUSTOM_DEFAULT = true; public final static boolean SPAWN_BREEDING_DEFAULT = false; public final static boolean WORLD_BORDER_DEFAULT = false; - // are plot clusters enabled // require claim in cluster - - // TODO make this configurable // make non static and static_default_valu + add config option public static List BLOCKS; - static { BLOCKS = new ArrayList<>(); for (final Material material : Material.values()) { @@ -77,7 +71,6 @@ public abstract class PlotWorld { } } } - public final String worldname; public boolean AUTO_MERGE; public boolean MOB_SPAWNING; @@ -100,21 +93,21 @@ public abstract class PlotWorld { public boolean WORLD_BORDER; public int TYPE = 0; public int TERRAIN = 0; - + public PlotWorld(final String worldname) { this.worldname = worldname; } - + /** * When a world is created, the following method will be called for each * * @param config Configuration Section */ public void loadDefaultConfiguration(final ConfigurationSection config) { - if (config.contains("generator.terrain")) { - this.TERRAIN = config.getInt("generator.terrain"); - this.TYPE = config.getInt("generator.type"); - } + if (config.contains("generator.terrain")) { + this.TERRAIN = config.getInt("generator.terrain"); + this.TYPE = config.getInt("generator.type"); + } this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome")); @@ -128,17 +121,15 @@ public abstract class PlotWorld { this.SELL_PRICE = config.getDouble("economy.prices.sell"); this.PLOT_CHAT = config.getBoolean("chat.enabled"); this.WORLD_BORDER = config.getBoolean("world.border"); - List flags = config.getStringList("flags.default"); + final List flags = config.getStringList("flags.default"); if (flags == null) { this.DEFAULT_FLAGS = new Flag[] {}; - } - else { + } else { try { this.DEFAULT_FLAGS = FlagManager.parseFlags(flags); - } - catch (Exception e) { - PlotSquared.log("&cInvalid default flags for "+this.worldname+": "+StringUtils.join(flags,",")); - this.DEFAULT_FLAGS = new Flag[]{}; + } catch (final Exception e) { + PlotSquared.log("&cInvalid default flags for " + this.worldname + ": " + StringUtils.join(flags, ",")); + this.DEFAULT_FLAGS = new Flag[] {}; } } this.PVP = config.getBoolean("event.pvp"); @@ -148,9 +139,9 @@ public abstract class PlotWorld { this.SPAWN_BREEDING = config.getBoolean("event.spawn.breeding"); loadConfiguration(config); } - + public abstract void loadConfiguration(final ConfigurationSection config); - + /** * Saving core plotworld settings * @@ -158,7 +149,6 @@ public abstract class PlotWorld { */ public void saveConfiguration(final ConfigurationSection config) { final HashMap options = new HashMap<>(); - options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT); options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString()); @@ -178,10 +168,10 @@ public abstract class PlotWorld { options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT); options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT); options.put("world.border", PlotWorld.WORLD_BORDER_DEFAULT); - if (Settings.ENABLE_CLUSTERS && this.TYPE != 0) { + if (Settings.ENABLE_CLUSTERS && (this.TYPE != 0)) { options.put("generator.terrain", this.TERRAIN); options.put("generator.type", this.TYPE); - } + } final ConfigurationNode[] settings = getSettingNodes(); /* * Saving generator specific settings @@ -189,14 +179,13 @@ public abstract class PlotWorld { for (final ConfigurationNode setting : settings) { options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue())); } - for (final String option : options.keySet()) { if (!config.contains(option)) { config.set(option, options.get(option)); } } } - + /** * Used for the /plot setup command Return null if you do not want to support this feature * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java index 1eb2a9e61..9f07ea83b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java @@ -1,13 +1,12 @@ package com.intellectualcrafters.plot.object; - public class RegionWrapper { public final int minX; public final int maxX; public final int minZ; public final int maxZ; - public RegionWrapper(int minX, int maxX, int minZ, int maxZ) { + public RegionWrapper(final int minX, final int maxX, final int minZ, final int maxZ) { this.maxX = maxX; this.minX = minX; this.maxZ = maxZ; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java index f6df20a35..bfea23147 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java @@ -18,16 +18,14 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.object; - /** * @author Empire92 */ public class StringWrapper { public final String value; - + /** * Constructor * @@ -36,7 +34,7 @@ public class StringWrapper { public StringWrapper(final String value) { this.value = value; } - + /** * Check if a wrapped string equals another one * @@ -56,12 +54,12 @@ public class StringWrapper { return false; } final StringWrapper other = (StringWrapper) obj; - if (other.value == null || this.value == null) { + if ((other.value == null) || (this.value == null)) { return false; } return other.value.toLowerCase().equals(this.value.toLowerCase()); } - + /** * Get the string value * @@ -71,7 +69,7 @@ public class StringWrapper { public String toString() { return this.value; } - + /** * Get the hash value * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/AgeableStats.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/AgeableStats.java index 779bfddc8..829a201d1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/AgeableStats.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/AgeableStats.java @@ -1,9 +1,7 @@ package com.intellectualcrafters.plot.object.entity; public class AgeableStats { - public int age; public boolean locked; public boolean adult; - } 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 fb5bc8760..094c57148 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 @@ -33,37 +33,29 @@ import org.bukkit.util.Vector; import com.intellectualcrafters.plot.PlotSquared; public class EntityWrapper { - public short id; public float yaw; public float pitch; public double x; public double y; public double z; - public short depth; - public EntityBaseStats base = null; - // Extended public ItemStack stack; public ItemStack[] inventory; public byte dataByte; public byte dataByte2; public String dataString; - - public LivingEntityStats lived; - public AgeableStats aged; - public TameableStats tamed; private HorseStats horse; - + public void storeInventory(final InventoryHolder held) { this.inventory = held.getInventory().getContents().clone(); } - + private void restoreLiving(final LivingEntity entity) { if (this.lived.loot) { entity.setCanPickupItems(this.lived.loot); @@ -72,33 +64,31 @@ public class EntityWrapper { entity.setCustomName(this.lived.name); entity.setCustomNameVisible(this.lived.visible); } - if (this.lived.potions != null && this.lived.potions.size() > 0) { + if ((this.lived.potions != null) && (this.lived.potions.size() > 0)) { entity.addPotionEffects(this.lived.potions); } entity.setRemainingAir(this.lived.air); entity.setRemoveWhenFarAway(this.lived.persistent); - - if (lived.equipped) { - EntityEquipment equipment = entity.getEquipment(); + if (this.lived.equipped) { + final EntityEquipment equipment = entity.getEquipment(); equipment.setItemInHand(this.lived.hands); equipment.setHelmet(this.lived.helmet); equipment.setChestplate(this.lived.chestplate); equipment.setLeggings(this.lived.leggings); equipment.setBoots(this.lived.boots); } - - if (lived.leashed) { + if (this.lived.leashed) { // TODO leashes -// World world = entity.getWorld(); -// Entity leash = world.spawnEntity(new Location(world, Math.floor(x) + lived.leash_x, Math.floor(y) + lived.leash_y, Math.floor(z) + lived.leash_z), EntityType.LEASH_HITCH); -// entity.setLeashHolder(leash); + // World world = entity.getWorld(); + // Entity leash = world.spawnEntity(new Location(world, Math.floor(x) + lived.leash_x, Math.floor(y) + lived.leash_y, Math.floor(z) + lived.leash_z), EntityType.LEASH_HITCH); + // entity.setLeashHolder(leash); } } - + private void restoreInventory(final InventoryHolder entity) { entity.getInventory().setContents(this.inventory); } - + public void storeLiving(final LivingEntity lived) { this.lived = new LivingEntityStats(); this.lived.potions = lived.getActivePotionEffects(); @@ -108,16 +98,13 @@ public class EntityWrapper { this.lived.health = (float) lived.getHealth(); this.lived.air = (short) lived.getRemainingAir(); this.lived.persistent = lived.getRemoveWhenFarAway(); - this.lived.leashed = lived.isLeashed(); - if (this.lived.leashed) { final Location loc = lived.getLeashHolder().getLocation(); this.lived.leash_x = (short) (this.x - loc.getBlockX()); this.lived.leash_y = (short) (this.y - loc.getBlockY()); this.lived.leash_z = (short) (this.z - loc.getBlockZ()); } - final EntityEquipment equipment = lived.getEquipment(); this.lived.equipped = equipment != null; if (this.lived.equipped) { @@ -128,7 +115,7 @@ public class EntityWrapper { this.lived.helmet = equipment.getHelmet().clone(); } } - + private void restoreTameable(final Tameable entity) { if (this.tamed.tamed) { if (this.tamed.owner != null) { @@ -137,7 +124,7 @@ public class EntityWrapper { } } } - + private void restoreAgeable(final Ageable entity) { if (!this.aged.adult) { entity.setBaby(); @@ -147,20 +134,20 @@ public class EntityWrapper { } entity.setAge(this.aged.age); } - + public void storeAgeable(final Ageable aged) { this.aged = new AgeableStats(); this.aged.age = aged.getAge(); this.aged.locked = aged.getAgeLock(); this.aged.adult = aged.isAdult(); } - + public void storeTameable(final Tameable tamed) { this.tamed = new TameableStats(); this.tamed.owner = tamed.getOwner(); this.tamed.tamed = tamed.isTamed(); } - + @SuppressWarnings("deprecation") public EntityWrapper(final org.bukkit.entity.Entity entity, final short depth) { this.depth = depth; @@ -171,11 +158,9 @@ public class EntityWrapper { this.y = loc.getY(); this.z = loc.getZ(); this.id = entity.getType().getTypeId(); - if (depth == 0) { return; } - this.base = new EntityBaseStats(); final Entity p = entity.getPassenger(); if (p != null) { @@ -188,11 +173,9 @@ public class EntityWrapper { this.base.v_x = velocity.getX(); this.base.v_y = velocity.getY(); this.base.v_z = velocity.getZ(); - if (depth == 1) { return; } - switch (entity.getType()) { case ARROW: case BOAT: @@ -230,7 +213,6 @@ public class EntityWrapper { PlotSquared.log("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); return; } - // MISC // case DROPPED_ITEM: { final Item item = (Item) entity; @@ -253,15 +235,14 @@ public class EntityWrapper { this.z = Math.floor(this.z); final Art a = painting.getArt(); this.dataByte = getOrdinal(BlockFace.values(), painting.getFacing()); - int h = a.getBlockHeight(); - if (h % 2 == 0) { - y -= 1; + final int h = a.getBlockHeight(); + if ((h % 2) == 0) { + this.y -= 1; } this.dataString = a.name(); return; } // END MISC // - // INVENTORY HOLDER // case MINECART_CHEST: { storeInventory((InventoryHolder) entity); @@ -271,7 +252,6 @@ public class EntityWrapper { storeInventory((InventoryHolder) entity); return; } - // START LIVING ENTITY // // START AGEABLE // // START TAMEABLE // @@ -298,7 +278,6 @@ public class EntityWrapper { return; } // END AMEABLE // - case SHEEP: { final Sheep sheep = (Sheep) entity; this.dataByte = (byte) ((sheep).isSheared() ? 1 : 0); @@ -307,7 +286,6 @@ public class EntityWrapper { storeLiving((LivingEntity) entity); return; } - case VILLAGER: case CHICKEN: case COW: @@ -329,13 +307,11 @@ public class EntityWrapper { storeLiving((LivingEntity) entity); return; } - case SKELETON: { // NEW this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId(); storeLiving((LivingEntity) entity); return; } - case ARMOR_STAND: { // NEW // CHECK positions final ArmorStand stand = (ArmorStand) entity; @@ -343,7 +319,6 @@ public class EntityWrapper { storeLiving((LivingEntity) entity); return; } - case ENDERMITE: // NEW case BAT: case ENDER_DRAGON: @@ -369,7 +344,7 @@ public class EntityWrapper { // END LIVING // } } - + @SuppressWarnings("deprecation") public Entity spawn(final World world, final int x_offset, final int z_offset) { final Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset); @@ -378,7 +353,7 @@ public class EntityWrapper { if (this.id == -1) { return null; } - EntityType type = EntityType.fromId(this.id); + final EntityType type = EntityType.fromId(this.id); Entity entity; switch (type) { case DROPPED_ITEM: { @@ -392,7 +367,6 @@ public class EntityWrapper { entity = world.spawnEntity(loc, type); break; } - if (this.depth == 0) { return entity; } @@ -446,7 +420,6 @@ public class EntityWrapper { PlotSquared.log("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); return entity; } - // MISC // case ITEM_FRAME: { final ItemFrame itemframe = (ItemFrame) entity; @@ -461,7 +434,6 @@ public class EntityWrapper { return entity; } // END MISC // - // INVENTORY HOLDER // case MINECART_CHEST: { restoreInventory((InventoryHolder) entity); @@ -471,7 +443,6 @@ public class EntityWrapper { restoreInventory((InventoryHolder) entity); return entity; } - // START LIVING ENTITY // // START AGEABLE // // START TAMEABLE // @@ -497,7 +468,6 @@ public class EntityWrapper { return entity; } // END AMEABLE // - case SHEEP: { final Sheep sheep = (Sheep) entity; if (this.dataByte == 1) { @@ -510,7 +480,6 @@ public class EntityWrapper { restoreLiving((LivingEntity) entity); return entity; } - case VILLAGER: case CHICKEN: case COW: @@ -536,7 +505,6 @@ public class EntityWrapper { restoreLiving((LivingEntity) entity); return entity; } - case SKELETON: { // NEW if (this.dataByte != 0) { ((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]); @@ -544,7 +512,6 @@ public class EntityWrapper { storeLiving((LivingEntity) entity); return entity; } - case ARMOR_STAND: { // NEW // CHECK positions final ArmorStand stand = (ArmorStand) entity; @@ -566,7 +533,6 @@ public class EntityWrapper { restoreLiving((LivingEntity) entity); return entity; } - case ENDERMITE: // NEW case BAT: case ENDER_DRAGON: @@ -593,7 +559,7 @@ public class EntityWrapper { } } - private byte getOrdinal(Object[] list, Object value) { + private byte getOrdinal(final Object[] list, final Object value) { for (byte i = 0; i < list.length; i++) { if (list[i].equals(value)) { return i; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/HorseStats.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/HorseStats.java index 8fc524c3e..9265667f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/HorseStats.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/HorseStats.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.object.entity; public class HorseStats { - public double jump; public boolean chest; public int variant; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/LivingEntityStats.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/LivingEntityStats.java index e482a63b8..c70028eb1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/LivingEntityStats.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/LivingEntityStats.java @@ -6,19 +6,16 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; public class LivingEntityStats { - public boolean loot; public String name; public boolean visible; public float health; public short air; public boolean persistent; - public boolean leashed; public short leash_x; public short leash_y; public short leash_z; - public boolean equipped; public ItemStack hands; public ItemStack helmet; @@ -26,5 +23,4 @@ public class LivingEntityStats { public ItemStack leggings; public ItemStack chestplate; public Collection potions; - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/TameableStats.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/TameableStats.java index 9ff08b87c..e3d347cf0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/TameableStats.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/TameableStats.java @@ -3,8 +3,6 @@ package com.intellectualcrafters.plot.object.entity; import org.bukkit.entity.AnimalTamer; public class TameableStats { - public AnimalTamer owner; public boolean tamed; - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java index de5de8ca0..dae7b8f41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java @@ -4,7 +4,7 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; public abstract class AbstractTitle { - public static AbstractTitle TITLE_CLASS; - - public abstract void sendTitle(Player player, String head, String sub, ChatColor head_color, ChatColor sub_color); + public static AbstractTitle TITLE_CLASS; + + public abstract void sendTitle(Player player, String head, String sub, ChatColor head_color, ChatColor sub_color); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java index 4050a947f..028687206 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java @@ -4,17 +4,16 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; public class DefaultTitle extends AbstractTitle { - @Override - public void sendTitle(Player player, String head, String sub, ChatColor head_color, ChatColor sub_color) { - try { - DefaultTitleManager title = new DefaultTitleManager(head,sub,1, 2, 1); - title.setTitleColor(head_color); - title.setSubtitleColor(sub_color); - title.send(player); - } - catch (Throwable e) { - AbstractTitle.TITLE_CLASS = new HackTitle(); - AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color); - } - } + @Override + public void sendTitle(final Player player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color) { + try { + final DefaultTitleManager title = new DefaultTitleManager(head, sub, 1, 2, 1); + title.setTitleColor(head_color); + title.setSubtitleColor(sub_color); + title.send(player); + } catch (final Throwable e) { + AbstractTitle.TITLE_CLASS = new HackTitle(); + AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color); + } + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java index a21d16259..6ea57eafb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java @@ -15,396 +15,389 @@ import org.bukkit.entity.Player; * * @version 1.1.0 * @author Maxim Van de Wynckel - * + * */ public class DefaultTitleManager { - /* Title packet */ - private Class packetTitle; - /* Title packet actions ENUM */ - private Class packetActions; - /* Chat serializer */ - private Class nmsChatSerializer; - private Class chatBaseComponent; - /* Title text and color */ - private String title = ""; - private ChatColor titleColor = ChatColor.WHITE; - /* Subtitle text and color */ - private String subtitle = ""; - private ChatColor subtitleColor = ChatColor.WHITE; - /* Title timings */ - private int fadeInTime = -1; - private int stayTime = -1; - private int fadeOutTime = -1; - private boolean ticks = false; - - private static final Map, Class> CORRESPONDING_TYPES = new HashMap, Class>(); - - /** - * Create a new 1.8 title - * - * @param title - * Title - * @throws ClassNotFoundException - */ - public DefaultTitleManager(String title) throws ClassNotFoundException { - this.title = title; - loadClasses(); - } - - /** - * Create a new 1.8 title - * - * @param title - * Title text - * @param subtitle - * Subtitle text - * @throws ClassNotFoundException - */ - public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException { - this.title = title; - this.subtitle = subtitle; - loadClasses(); - } - - /** - * Copy 1.8 title - * - * @param title - * Title - * @throws ClassNotFoundException - */ - public DefaultTitleManager(DefaultTitleManager title) throws ClassNotFoundException { - // Copy title - this.title = title.title; - this.subtitle = title.subtitle; - this.titleColor = title.titleColor; - this.subtitleColor = title.subtitleColor; - this.fadeInTime = title.fadeInTime; - this.fadeOutTime = title.fadeOutTime; - this.stayTime = title.stayTime; - this.ticks = title.ticks; - loadClasses(); - } - - /** - * Create a new 1.8 title - * - * @param title - * Title text - * @param subtitle - * Subtitle text - * @param fadeInTime - * Fade in time - * @param stayTime - * Stay on screen time - * @param fadeOutTime - * Fade out time - * @throws ClassNotFoundException - */ - public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException { - this.title = title; - this.subtitle = subtitle; - this.fadeInTime = fadeInTime; - this.stayTime = stayTime; - this.fadeOutTime = fadeOutTime; - loadClasses(); - } - - /** - * Load spigot and NMS classes - * @throws ClassNotFoundException - */ - private void loadClasses() throws ClassNotFoundException { - packetTitle = getNMSClass("PacketPlayOutTitle"); - packetActions = getNMSClass("EnumTitleAction"); - chatBaseComponent = getNMSClass("IChatBaseComponent"); - nmsChatSerializer = getNMSClass("ChatSerializer"); - } - - /** - * Set title text - * - * @param title - * Title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * Get title text - * - * @return Title text - */ - public String getTitle() { - return this.title; - } - - /** - * Set subtitle text - * - * @param subtitle - * Subtitle text - */ - public void setSubtitle(String subtitle) { - this.subtitle = subtitle; - } - - /** - * Get subtitle text - * - * @return Subtitle text - */ - public String getSubtitle() { - return this.subtitle; - } - - /** - * Set the title color - * - * @param color - * Chat color - */ - public void setTitleColor(ChatColor color) { - this.titleColor = color; - } - - /** - * Set the subtitle color - * - * @param color - * Chat color - */ - public void setSubtitleColor(ChatColor color) { - this.subtitleColor = color; - } - - /** - * Set title fade in time - * - * @param time - * Time - */ - public void setFadeInTime(int time) { - this.fadeInTime = time; - } - - /** - * Set title fade out time - * - * @param time - * Time - */ - public void setFadeOutTime(int time) { - this.fadeOutTime = time; - } - - /** - * Set title stay time - * - * @param time - * Time - */ - public void setStayTime(int time) { - this.stayTime = time; - } - - /** - * Set timings to ticks - */ - public void setTimingsToTicks() { - ticks = true; - } - - /** - * Set timings to seconds - */ - public void setTimingsToSeconds() { - ticks = false; - } - - /** - * Send the title to a player - * - * @param player - * Player - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException - */ - public void send(Player player) throws Exception { - if (packetTitle != null) { - // First reset previous settings - resetTitle(player); - // Send timings first - Object handle = getHandle(player); - Object connection = getField(handle.getClass(), "playerConnection").get(handle); - Object[] actions = packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), "sendPacket"); - Object packet = - packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], null, fadeInTime - * (ticks ? 1 : 20), stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20)); - // Send if set - if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) - sendPacket.invoke(connection, packet); - - // Send title - Object serialized = - getMethod(nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" - + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" - + titleColor.name().toLowerCase() + "}"); - packet = - packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized); - sendPacket.invoke(connection, packet); - if (subtitle != "") { - // Send subtitle if present - serialized = - getMethod(nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" - + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" - + subtitleColor.name().toLowerCase() + "}"); - packet = - packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[1], serialized); - sendPacket.invoke(connection, packet); - } - } - } - - /** - * Broadcast the title to all players - * @throws Exception - */ - public void broadcast() throws Exception { - for (Player p : Bukkit.getOnlinePlayers()) { - send(p); - } - } - - /** - * Clear the title - * - * @param player - * Player - */ - public void clearTitle(Player player) { - try { - // Send timings first - Object handle = getHandle(player); - Object connection = getField(handle.getClass(), "playerConnection").get(handle); - Object[] actions = packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), "sendPacket"); - Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[3], null); - sendPacket.invoke(connection, packet); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Reset the title settings - * - * @param player - * Player - */ - public void resetTitle(Player player) { - try { - // Send timings first - Object handle = getHandle(player); - Object connection = getField(handle.getClass(), "playerConnection").get(handle); - Object[] actions = packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), "sendPacket"); - Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[4], null); - sendPacket.invoke(connection, packet); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private Class getPrimitiveType(Class clazz) { - return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; - } - - private Class[] toPrimitiveTypeArray(Class[] classes) { - int a = classes != null ? classes.length : 0; - Class[] types = new Class[a]; - for (int i = 0; i < a; i++) - types[i] = getPrimitiveType(classes[i]); - return types; - } - - private static boolean equalsTypeArray(Class[] a, Class[] o) { - if (a.length != o.length) - return false; - for (int i = 0; i < a.length; i++) - if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) - return false; - return true; - } - - private Object getHandle(Object obj) { - try { - return getMethod("getHandle", obj.getClass()).invoke(obj); - } - catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private Method getMethod(String name, Class clazz, Class... paramTypes) { - Class[] t = toPrimitiveTypeArray(paramTypes); - for (Method m : clazz.getMethods()) { - Class[] types = toPrimitiveTypeArray(m.getParameterTypes()); - if (m.getName().equals(name) && equalsTypeArray(types, t)) - return m; - } - return null; - } - - private String getVersion() { - String name = Bukkit.getServer().getClass().getPackage().getName(); - String version = name.substring(name.lastIndexOf('.') + 1) + "."; - return version; - } - - private Class getNMSClass(String className) throws ClassNotFoundException { - String fullName = "net.minecraft.server." + getVersion() + className; - Class clazz = null; - clazz = Class.forName(fullName); - return clazz; - } - - private Field getField(Class clazz, String name) { - try { - Field field = clazz.getDeclaredField(name); - field.setAccessible(true); - return field; - } - catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private Method getMethod(Class clazz, String name, Class... args) { - for (Method m : clazz.getMethods()) - if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args, m.getParameterTypes()))) { - m.setAccessible(true); - return m; - } - return null; - } - - private boolean ClassListEqual(Class[] l1, Class[] l2) { - boolean equal = true; - if (l1.length != l2.length) - return false; - for (int i = 0; i < l1.length; i++) - if (l1[i] != l2[i]) { - equal = false; - break; - } - return equal; - } + /* Title packet */ + private Class packetTitle; + /* Title packet actions ENUM */ + private Class packetActions; + /* Chat serializer */ + private Class nmsChatSerializer; + private Class chatBaseComponent; + /* Title text and color */ + private String title = ""; + private ChatColor titleColor = ChatColor.WHITE; + /* Subtitle text and color */ + private String subtitle = ""; + private ChatColor subtitleColor = ChatColor.WHITE; + /* Title timings */ + private int fadeInTime = -1; + private int stayTime = -1; + private int fadeOutTime = -1; + private boolean ticks = false; + private static final Map, Class> CORRESPONDING_TYPES = new HashMap, Class>(); + + /** + * Create a new 1.8 title + * + * @param title + * Title + * @throws ClassNotFoundException + */ + public DefaultTitleManager(final String title) throws ClassNotFoundException { + this.title = title; + loadClasses(); + } + + /** + * Create a new 1.8 title + * + * @param title + * Title text + * @param subtitle + * Subtitle text + * @throws ClassNotFoundException + */ + public DefaultTitleManager(final String title, final String subtitle) throws ClassNotFoundException { + this.title = title; + this.subtitle = subtitle; + loadClasses(); + } + + /** + * Copy 1.8 title + * + * @param title + * Title + * @throws ClassNotFoundException + */ + public DefaultTitleManager(final DefaultTitleManager title) throws ClassNotFoundException { + // Copy title + this.title = title.title; + this.subtitle = title.subtitle; + this.titleColor = title.titleColor; + this.subtitleColor = title.subtitleColor; + this.fadeInTime = title.fadeInTime; + this.fadeOutTime = title.fadeOutTime; + this.stayTime = title.stayTime; + this.ticks = title.ticks; + loadClasses(); + } + + /** + * Create a new 1.8 title + * + * @param title + * Title text + * @param subtitle + * Subtitle text + * @param fadeInTime + * Fade in time + * @param stayTime + * Stay on screen time + * @param fadeOutTime + * Fade out time + * @throws ClassNotFoundException + */ + public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException { + this.title = title; + this.subtitle = subtitle; + this.fadeInTime = fadeInTime; + this.stayTime = stayTime; + this.fadeOutTime = fadeOutTime; + loadClasses(); + } + + /** + * Load spigot and NMS classes + * @throws ClassNotFoundException + */ + private void loadClasses() throws ClassNotFoundException { + this.packetTitle = getNMSClass("PacketPlayOutTitle"); + this.packetActions = getNMSClass("EnumTitleAction"); + this.chatBaseComponent = getNMSClass("IChatBaseComponent"); + this.nmsChatSerializer = getNMSClass("ChatSerializer"); + } + + /** + * Set title text + * + * @param title + * Title + */ + public void setTitle(final String title) { + this.title = title; + } + + /** + * Get title text + * + * @return Title text + */ + public String getTitle() { + return this.title; + } + + /** + * Set subtitle text + * + * @param subtitle + * Subtitle text + */ + public void setSubtitle(final String subtitle) { + this.subtitle = subtitle; + } + + /** + * Get subtitle text + * + * @return Subtitle text + */ + public String getSubtitle() { + return this.subtitle; + } + + /** + * Set the title color + * + * @param color + * Chat color + */ + public void setTitleColor(final ChatColor color) { + this.titleColor = color; + } + + /** + * Set the subtitle color + * + * @param color + * Chat color + */ + public void setSubtitleColor(final ChatColor color) { + this.subtitleColor = color; + } + + /** + * Set title fade in time + * + * @param time + * Time + */ + public void setFadeInTime(final int time) { + this.fadeInTime = time; + } + + /** + * Set title fade out time + * + * @param time + * Time + */ + public void setFadeOutTime(final int time) { + this.fadeOutTime = time; + } + + /** + * Set title stay time + * + * @param time + * Time + */ + public void setStayTime(final int time) { + this.stayTime = time; + } + + /** + * Set timings to ticks + */ + public void setTimingsToTicks() { + this.ticks = true; + } + + /** + * Set timings to seconds + */ + public void setTimingsToSeconds() { + this.ticks = false; + } + + /** + * Send the title to a player + * + * @param player + * Player + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + public void send(final Player player) throws Exception { + if (this.packetTitle != null) { + // First reset previous settings + resetTitle(player); + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20), this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20)); + // Send if set + if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) { + sendPacket.invoke(connection, packet); + } + // Send title + Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}"); + packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized); + sendPacket.invoke(connection, packet); + if (this.subtitle != "") { + // Send subtitle if present + serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name().toLowerCase() + "}"); + packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized); + sendPacket.invoke(connection, packet); + } + } + } + + /** + * Broadcast the title to all players + * @throws Exception + */ + public void broadcast() throws Exception { + for (final Player p : Bukkit.getOnlinePlayers()) { + send(p); + } + } + + /** + * Clear the title + * + * @param player + * Player + */ + public void clearTitle(final Player player) { + try { + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null); + sendPacket.invoke(connection, packet); + } catch (final Exception e) { + e.printStackTrace(); + } + } + + /** + * Reset the title settings + * + * @param player + * Player + */ + public void resetTitle(final Player player) { + try { + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null); + sendPacket.invoke(connection, packet); + } catch (final Exception e) { + e.printStackTrace(); + } + } + + private Class getPrimitiveType(final Class clazz) { + return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; + } + + private Class[] toPrimitiveTypeArray(final Class[] classes) { + final int a = classes != null ? classes.length : 0; + final Class[] types = new Class[a]; + for (int i = 0; i < a; i++) { + types[i] = getPrimitiveType(classes[i]); + } + return types; + } + + private static boolean equalsTypeArray(final Class[] a, final Class[] o) { + if (a.length != o.length) { + return false; + } + for (int i = 0; i < a.length; i++) { + if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) { + return false; + } + } + return true; + } + + private Object getHandle(final Object obj) { + try { + return getMethod("getHandle", obj.getClass()).invoke(obj); + } catch (final Exception e) { + e.printStackTrace(); + return null; + } + } + + private Method getMethod(final String name, final Class clazz, final Class... paramTypes) { + final Class[] t = toPrimitiveTypeArray(paramTypes); + for (final Method m : clazz.getMethods()) { + final Class[] types = toPrimitiveTypeArray(m.getParameterTypes()); + if (m.getName().equals(name) && equalsTypeArray(types, t)) { + return m; + } + } + return null; + } + + private String getVersion() { + final String name = Bukkit.getServer().getClass().getPackage().getName(); + final String version = name.substring(name.lastIndexOf('.') + 1) + "."; + return version; + } + + private Class getNMSClass(final String className) throws ClassNotFoundException { + final String fullName = "net.minecraft.server." + getVersion() + className; + Class clazz = null; + clazz = Class.forName(fullName); + return clazz; + } + + private Field getField(final Class clazz, final String name) { + try { + final Field field = clazz.getDeclaredField(name); + field.setAccessible(true); + return field; + } catch (final Exception e) { + e.printStackTrace(); + return null; + } + } + + private Method getMethod(final Class clazz, final String name, final Class... args) { + for (final Method m : clazz.getMethods()) { + if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) { + m.setAccessible(true); + return m; + } + } + return null; + } + + private boolean ClassListEqual(final Class[] l1, final Class[] l2) { + boolean equal = true; + if (l1.length != l2.length) { + return false; + } + for (int i = 0; i < l1.length; i++) { + if (l1[i] != l2[i]) { + equal = false; + break; + } + } + return equal; + } } 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 69a0404e3..9534e4444 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitle.java @@ -7,18 +7,17 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Settings; public class HackTitle extends AbstractTitle { - @Override - public void sendTitle(Player player, String head, String sub, ChatColor head_color, ChatColor sub_color) { - try { - HackTitleManager title = new HackTitleManager(head,sub,1, 2, 1); - title.setTitleColor(head_color); - title.setSubtitleColor(sub_color); - title.send(player); - } - catch (Throwable e) { - PlotSquared.log("&cYour server version does not support titles!"); - Settings.TITLES = false; - AbstractTitle.TITLE_CLASS = null; - } - } + @Override + public void sendTitle(final Player player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color) { + try { + final HackTitleManager title = new HackTitleManager(head, sub, 1, 2, 1); + title.setTitleColor(head_color); + title.setSubtitleColor(sub_color); + title.send(player); + } catch (final Throwable e) { + PlotSquared.log("&cYour server version does not support titles!"); + Settings.TITLES = false; + AbstractTitle.TITLE_CLASS = null; + } + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java index 7c9c5dfa7..b879bf45d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java @@ -11,477 +11,444 @@ import org.bukkit.entity.Player; /** * Minecraft 1.8 Title - * + * * @version 1.0.4 * @author Maxim Van de Wynckel */ public class HackTitleManager { - /* Title packet */ - private Class packetTitle; - /* Title packet actions ENUM */ - private Class packetActions; - /* Chat serializer */ - private Class nmsChatSerializer; - /* Title text and color */ - private String title = ""; - private ChatColor titleColor = ChatColor.WHITE; - /* Subtitle text and color */ - private String subtitle = ""; - private ChatColor subtitleColor = ChatColor.WHITE; - /* Title timings */ - private int fadeInTime = -1; - private int stayTime = -1; - private int fadeOutTime = -1; - private boolean ticks = false; - - private static final Map, Class> CORRESPONDING_TYPES = new HashMap, Class>(); - - /** - * Create a new 1.8 title - * - * @param title - * Title - * @throws ClassNotFoundException - */ - public HackTitleManager(String title) throws ClassNotFoundException { - this.title = title; - loadClasses(); - } - - /** - * Create a new 1.8 title - * - * @param title - * Title text - * @param subtitle - * Subtitle text - * @throws ClassNotFoundException - */ - public HackTitleManager(String title, String subtitle) throws ClassNotFoundException { - this.title = title; - this.subtitle = subtitle; - loadClasses(); - } - - /** - * Copy 1.8 title - * - * @param title - * Title - * @throws ClassNotFoundException - */ - public HackTitleManager(HackTitleManager title) throws ClassNotFoundException { - // Copy title - this.title = title.title; - this.subtitle = title.subtitle; - this.titleColor = title.titleColor; - this.subtitleColor = title.subtitleColor; - this.fadeInTime = title.fadeInTime; - this.fadeOutTime = title.fadeOutTime; - this.stayTime = title.stayTime; - this.ticks = title.ticks; - loadClasses(); - } - - /** - * Create a new 1.8 title - * - * @param title - * Title text - * @param subtitle - * Subtitle text - * @param fadeInTime - * Fade in time - * @param stayTime - * Stay on screen time - * @param fadeOutTime - * Fade out time - * @throws ClassNotFoundException - */ - public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, - int fadeOutTime) throws ClassNotFoundException { - this.title = title; - this.subtitle = subtitle; - this.fadeInTime = fadeInTime; - this.stayTime = stayTime; - this.fadeOutTime = fadeOutTime; - loadClasses(); - } - - /** - * Load spigot and NMS classes - * @throws ClassNotFoundException - */ - private void loadClasses() throws ClassNotFoundException { - packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle"); - packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action"); - nmsChatSerializer = getNMSClass("ChatSerializer"); - } - - /** - * Set title text - * - * @param title - * Title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * Get title text - * - * @return Title text - */ - public String getTitle() { - return this.title; - } - - /** - * Set subtitle text - * - * @param subtitle - * Subtitle text - */ - public void setSubtitle(String subtitle) { - this.subtitle = subtitle; - } - - /** - * Get subtitle text - * - * @return Subtitle text - */ - public String getSubtitle() { - return this.subtitle; - } - - /** - * Set the title color - * - * @param color - * Chat color - */ - public void setTitleColor(ChatColor color) { - this.titleColor = color; - } - - /** - * Set the subtitle color - * - * @param color - * Chat color - */ - public void setSubtitleColor(ChatColor color) { - this.subtitleColor = color; - } - - /** - * Set title fade in time - * - * @param time - * Time - */ - public void setFadeInTime(int time) { - this.fadeInTime = time; - } - - /** - * Set title fade out time - * - * @param time - * Time - */ - public void setFadeOutTime(int time) { - this.fadeOutTime = time; - } - - /** - * Set title stay time - * - * @param time - * Time - */ - public void setStayTime(int time) { - this.stayTime = time; - } - - /** - * Set timings to ticks - */ - public void setTimingsToTicks() { - ticks = true; - } - - /** - * Set timings to seconds - */ - public void setTimingsToSeconds() { - ticks = false; - } - - /** - * Send the title to a player - * - * @param player - * Player - */ - public void send(Player player) throws Exception { - if (getProtocolVersion(player) >= 47 && isSpigot() - && packetTitle != null) { - // First reset previous settings - resetTitle(player); - // Send timings first - Object handle = getHandle(player); - Object connection = getField(handle.getClass(), - "playerConnection").get(handle); - Object[] actions = packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), - "sendPacket"); - Object packet = packetTitle.getConstructor(packetActions, - Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance( - actions[2], fadeInTime * (ticks ? 1 : 20), - stayTime * (ticks ? 1 : 20), - fadeOutTime * (ticks ? 1 : 20)); - // Send if set - if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) - sendPacket.invoke(connection, packet); - - // Send title - Object serialized = getMethod(nmsChatSerializer, "a", - String.class).invoke( - null, - "{text:\"" - + ChatColor.translateAlternateColorCodes('&', - title) + "\",color:" - + titleColor.name().toLowerCase() + "}"); - packet = packetTitle.getConstructor(packetActions, - getNMSClass("IChatBaseComponent")).newInstance( - actions[0], serialized); - sendPacket.invoke(connection, packet); - if (subtitle != "") { - // Send subtitle if present - serialized = getMethod(nmsChatSerializer, "a", String.class) - .invoke(null, - "{text:\"" - + ChatColor - .translateAlternateColorCodes( - '&', subtitle) - + "\",color:" - + subtitleColor.name() - .toLowerCase() + "}"); - packet = packetTitle.getConstructor(packetActions, - getNMSClass("IChatBaseComponent")).newInstance( - actions[1], serialized); - sendPacket.invoke(connection, packet); - } - } - } - - /** - * Broadcast the title to all players - */ - public void broadcast() throws Exception { - for (Player p : Bukkit.getOnlinePlayers()) { - send(p); - } - } - - /** - * Clear the title - * - * @param player - * Player - */ - public void clearTitle(Player player) { - if (getProtocolVersion(player) >= 47 && isSpigot()) { - try { - // Send timings first - Object handle = getHandle(player); - Object connection = getField(handle.getClass(), - "playerConnection").get(handle); - Object[] actions = packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), - "sendPacket"); - Object packet = packetTitle.getConstructor(packetActions) - .newInstance(actions[3]); - sendPacket.invoke(connection, packet); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - /** - * Reset the title settings - * - * @param player - * Player - */ - public void resetTitle(Player player) { - if (getProtocolVersion(player) >= 47 && isSpigot()) { - try { - // Send timings first - Object handle = getHandle(player); - Object connection = getField(handle.getClass(), - "playerConnection").get(handle); - Object[] actions = packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), - "sendPacket"); - Object packet = packetTitle.getConstructor(packetActions) - .newInstance(actions[4]); - sendPacket.invoke(connection, packet); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - /** - * Get the protocol version of the player - * - * @param player - * Player - * @return Protocol version - */ - private int getProtocolVersion(Player player) { - int version = 0; - try { - Object handle = getHandle(player); - Object connection = getField(handle.getClass(), "playerConnection") - .get(handle); - Object networkManager = getValue("networkManager", connection); - version = (Integer) getMethod("getVersion", - networkManager.getClass()).invoke(networkManager); - - return version; - } catch (Exception ex) { - ex.printStackTrace(); - } - return version; - } - - /** - * Check if running spigot - * - * @return Spigot - */ - private boolean isSpigot() { - return Bukkit.getVersion().contains("Spigot"); - } - - /** - * Get class by url - * - * @param namespace - * Namespace url - * @return Class - */ - private Class getClass(String namespace) { - try { - return Class.forName(namespace); - } catch (Exception e) { - - } - return null; - } - - private Field getField(String name, Class clazz) throws Exception { - return clazz.getDeclaredField(name); - } - - private Object getValue(String name, Object obj) throws Exception { - Field f = getField(name, obj.getClass()); - f.setAccessible(true); - return f.get(obj); - } - - private Class getPrimitiveType(Class clazz) { - return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES - .get(clazz) : clazz; - } - - private Class[] toPrimitiveTypeArray(Class[] classes) { - int a = classes != null ? classes.length : 0; - Class[] types = new Class[a]; - for (int i = 0; i < a; i++) - types[i] = getPrimitiveType(classes[i]); - return types; - } - - private static boolean equalsTypeArray(Class[] a, Class[] o) { - if (a.length != o.length) - return false; - for (int i = 0; i < a.length; i++) - if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) - return false; - return true; - } - - private Object getHandle(Object obj) { - try { - return getMethod("getHandle", obj.getClass()).invoke(obj); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private Method getMethod(String name, Class clazz, - Class... paramTypes) { - Class[] t = toPrimitiveTypeArray(paramTypes); - for (Method m : clazz.getMethods()) { - Class[] types = toPrimitiveTypeArray(m.getParameterTypes()); - if (m.getName().equals(name) && equalsTypeArray(types, t)) - return m; - } - return null; - } - - private String getVersion() { - String name = Bukkit.getServer().getClass().getPackage().getName(); - String version = name.substring(name.lastIndexOf('.') + 1) + "."; - return version; - } - - private Class getNMSClass(String className) throws ClassNotFoundException { - String fullName = "net.minecraft.server." + getVersion() + className; - Class clazz = null; - clazz = Class.forName(fullName); - return clazz; - } - - private Field getField(Class clazz, String name) { - try { - Field field = clazz.getDeclaredField(name); - field.setAccessible(true); - return field; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private Method getMethod(Class clazz, String name, Class... args) { - for (Method m : clazz.getMethods()) - if (m.getName().equals(name) - && (args.length == 0 || ClassListEqual(args, - m.getParameterTypes()))) { - m.setAccessible(true); - return m; - } - return null; - } - - private boolean ClassListEqual(Class[] l1, Class[] l2) { - boolean equal = true; - if (l1.length != l2.length) - return false; - for (int i = 0; i < l1.length; i++) - if (l1[i] != l2[i]) { - equal = false; - break; - } - return equal; - } -} \ No newline at end of file + /* Title packet */ + private Class packetTitle; + /* Title packet actions ENUM */ + private Class packetActions; + /* Chat serializer */ + private Class nmsChatSerializer; + /* Title text and color */ + private String title = ""; + private ChatColor titleColor = ChatColor.WHITE; + /* Subtitle text and color */ + private String subtitle = ""; + private ChatColor subtitleColor = ChatColor.WHITE; + /* Title timings */ + private int fadeInTime = -1; + private int stayTime = -1; + private int fadeOutTime = -1; + private boolean ticks = false; + private static final Map, Class> CORRESPONDING_TYPES = new HashMap, Class>(); + + /** + * Create a new 1.8 title + * + * @param title + * Title + * @throws ClassNotFoundException + */ + public HackTitleManager(final String title) throws ClassNotFoundException { + this.title = title; + loadClasses(); + } + + /** + * Create a new 1.8 title + * + * @param title + * Title text + * @param subtitle + * Subtitle text + * @throws ClassNotFoundException + */ + public HackTitleManager(final String title, final String subtitle) throws ClassNotFoundException { + this.title = title; + this.subtitle = subtitle; + loadClasses(); + } + + /** + * Copy 1.8 title + * + * @param title + * Title + * @throws ClassNotFoundException + */ + public HackTitleManager(final HackTitleManager title) throws ClassNotFoundException { + // Copy title + this.title = title.title; + this.subtitle = title.subtitle; + this.titleColor = title.titleColor; + this.subtitleColor = title.subtitleColor; + this.fadeInTime = title.fadeInTime; + this.fadeOutTime = title.fadeOutTime; + this.stayTime = title.stayTime; + this.ticks = title.ticks; + loadClasses(); + } + + /** + * Create a new 1.8 title + * + * @param title + * Title text + * @param subtitle + * Subtitle text + * @param fadeInTime + * Fade in time + * @param stayTime + * Stay on screen time + * @param fadeOutTime + * Fade out time + * @throws ClassNotFoundException + */ + public HackTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException { + this.title = title; + this.subtitle = subtitle; + this.fadeInTime = fadeInTime; + this.stayTime = stayTime; + this.fadeOutTime = fadeOutTime; + loadClasses(); + } + + /** + * Load spigot and NMS classes + * @throws ClassNotFoundException + */ + private void loadClasses() throws ClassNotFoundException { + this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle"); + this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action"); + this.nmsChatSerializer = getNMSClass("ChatSerializer"); + } + + /** + * Set title text + * + * @param title + * Title + */ + public void setTitle(final String title) { + this.title = title; + } + + /** + * Get title text + * + * @return Title text + */ + public String getTitle() { + return this.title; + } + + /** + * Set subtitle text + * + * @param subtitle + * Subtitle text + */ + public void setSubtitle(final String subtitle) { + this.subtitle = subtitle; + } + + /** + * Get subtitle text + * + * @return Subtitle text + */ + public String getSubtitle() { + return this.subtitle; + } + + /** + * Set the title color + * + * @param color + * Chat color + */ + public void setTitleColor(final ChatColor color) { + this.titleColor = color; + } + + /** + * Set the subtitle color + * + * @param color + * Chat color + */ + public void setSubtitleColor(final ChatColor color) { + this.subtitleColor = color; + } + + /** + * Set title fade in time + * + * @param time + * Time + */ + public void setFadeInTime(final int time) { + this.fadeInTime = time; + } + + /** + * Set title fade out time + * + * @param time + * Time + */ + public void setFadeOutTime(final int time) { + this.fadeOutTime = time; + } + + /** + * Set title stay time + * + * @param time + * Time + */ + public void setStayTime(final int time) { + this.stayTime = time; + } + + /** + * Set timings to ticks + */ + public void setTimingsToTicks() { + this.ticks = true; + } + + /** + * Set timings to seconds + */ + public void setTimingsToSeconds() { + this.ticks = false; + } + + /** + * Send the title to a player + * + * @param player + * Player + */ + public void send(final Player player) throws Exception { + if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) { + // First reset previous settings + resetTitle(player); + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + Object packet = this.packetTitle.getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], this.fadeInTime * (this.ticks ? 1 : 20), this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20)); + // Send if set + if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) { + sendPacket.invoke(connection, packet); + } + // Send title + Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}"); + packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized); + sendPacket.invoke(connection, packet); + if (this.subtitle != "") { + // Send subtitle if present + serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name().toLowerCase() + "}"); + packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[1], serialized); + sendPacket.invoke(connection, packet); + } + } + } + + /** + * Broadcast the title to all players + */ + public void broadcast() throws Exception { + for (final Player p : Bukkit.getOnlinePlayers()) { + send(p); + } + } + + /** + * Clear the title + * + * @param player + * Player + */ + public void clearTitle(final Player player) { + if ((getProtocolVersion(player) >= 47) && isSpigot()) { + try { + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]); + sendPacket.invoke(connection, packet); + } catch (final Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Reset the title settings + * + * @param player + * Player + */ + public void resetTitle(final Player player) { + if ((getProtocolVersion(player) >= 47) && isSpigot()) { + try { + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]); + sendPacket.invoke(connection, packet); + } catch (final Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Get the protocol version of the player + * + * @param player + * Player + * @return Protocol version + */ + private int getProtocolVersion(final Player player) { + int version = 0; + try { + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object networkManager = getValue("networkManager", connection); + version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager); + return version; + } catch (final Exception ex) { + ex.printStackTrace(); + } + return version; + } + + /** + * Check if running spigot + * + * @return Spigot + */ + private boolean isSpigot() { + return Bukkit.getVersion().contains("Spigot"); + } + + /** + * Get class by url + * + * @param namespace + * Namespace url + * @return Class + */ + private Class getClass(final String namespace) { + try { + return Class.forName(namespace); + } catch (final Exception e) { + } + return null; + } + + private Field getField(final String name, final Class clazz) throws Exception { + return clazz.getDeclaredField(name); + } + + private Object getValue(final String name, final Object obj) throws Exception { + final Field f = getField(name, obj.getClass()); + f.setAccessible(true); + return f.get(obj); + } + + private Class getPrimitiveType(final Class clazz) { + return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; + } + + private Class[] toPrimitiveTypeArray(final Class[] classes) { + final int a = classes != null ? classes.length : 0; + final Class[] types = new Class[a]; + for (int i = 0; i < a; i++) { + types[i] = getPrimitiveType(classes[i]); + } + return types; + } + + private static boolean equalsTypeArray(final Class[] a, final Class[] o) { + if (a.length != o.length) { + return false; + } + for (int i = 0; i < a.length; i++) { + if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) { + return false; + } + } + return true; + } + + private Object getHandle(final Object obj) { + try { + return getMethod("getHandle", obj.getClass()).invoke(obj); + } catch (final Exception e) { + e.printStackTrace(); + return null; + } + } + + private Method getMethod(final String name, final Class clazz, final Class... paramTypes) { + final Class[] t = toPrimitiveTypeArray(paramTypes); + for (final Method m : clazz.getMethods()) { + final Class[] types = toPrimitiveTypeArray(m.getParameterTypes()); + if (m.getName().equals(name) && equalsTypeArray(types, t)) { + return m; + } + } + return null; + } + + private String getVersion() { + final String name = Bukkit.getServer().getClass().getPackage().getName(); + final String version = name.substring(name.lastIndexOf('.') + 1) + "."; + return version; + } + + private Class getNMSClass(final String className) throws ClassNotFoundException { + final String fullName = "net.minecraft.server." + getVersion() + className; + Class clazz = null; + clazz = Class.forName(fullName); + return clazz; + } + + private Field getField(final Class clazz, final String name) { + try { + final Field field = clazz.getDeclaredField(name); + field.setAccessible(true); + return field; + } catch (final Exception e) { + e.printStackTrace(); + return null; + } + } + + private Method getMethod(final Class clazz, final String name, final Class... args) { + for (final Method m : clazz.getMethods()) { + if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) { + m.setAccessible(true); + return m; + } + } + return null; + } + + private boolean ClassListEqual(final Class[] l1, final Class[] l2) { + boolean equal = true; + if (l1.length != l2.length) { + return false; + } + for (int i = 0; i < l1.length; i++) { + if (l1[i] != l2[i]) { + equal = false; + break; + } + } + return equal; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java index 599227770..23e0b8dd2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -9,15 +9,14 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.RegionWrapper; public abstract class AChunkManager { - public static AChunkManager manager = null; public static RegionWrapper CURRENT_PLOT_CLEAR = null; public static HashMap> GENERATE_BLOCKS = new HashMap<>(); public static HashMap> GENERATE_DATA = new HashMap<>(); - public static ChunkLoc getChunkChunk(Location loc) { - int x = loc.getX() >> 9; - int z = loc.getZ() >> 9; + public static ChunkLoc getChunkChunk(final Location loc) { + final int x = loc.getX() >> 9; + final int z = loc.getZ() >> 9; return new ChunkLoc(x, z); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index d030ab618..0bb395119 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -4,9 +4,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class BlockManager { - private static BlockManager manager = new BukkitUtil(); - private static long state = 1; public static long nextLong() { @@ -14,14 +12,14 @@ public abstract class BlockManager { state = xorShift64(a); return a; } - + public static long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - + public static int random(final int n) { if (n == 1) { return 0; @@ -34,35 +32,34 @@ public abstract class BlockManager { public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines); - - public static void setBlocks(String worldname, int[] x, int y[], int z[], PlotBlock[][] blocks) { - int[] id = new int[blocks.length]; - byte[] data = new byte[blocks.length]; + public static void setBlocks(final String worldname, final int[] x, final int y[], final int z[], final PlotBlock[][] blocks) { + final int[] id = new int[blocks.length]; + final byte[] data = new byte[blocks.length]; for (int i = 0; i < blocks.length; i++) { - PlotBlock[] current = blocks[i]; - int n = random(current.length); + final PlotBlock[] current = blocks[i]; + final int n = random(current.length); id[i] = current[n].id; data[i] = current[n].data; } setBlocks(worldname, x, y, z, id, data); } - public static void setBlocks(String worldname, int[] x, int y[], int z[], PlotBlock[] blocks) { - int[] id = new int[blocks.length]; - byte[] data = new byte[blocks.length]; + public static void setBlocks(final String worldname, final int[] x, final int y[], final int z[], final PlotBlock[] blocks) { + final int[] id = new int[blocks.length]; + final byte[] data = new byte[blocks.length]; for (int i = 0; i < blocks.length; i++) { - PlotBlock current = blocks[i]; + final PlotBlock current = blocks[i]; id[i] = current.id; data[i] = current.data; } setBlocks(worldname, x, y, z, id, data); } - public static void setSign(String worldname, int x, int y, int z, String[] lines) { + public static void setSign(final String worldname, final int x, final int y, final int z, final String[] lines) { manager.functionSetSign(worldname, x, y, z, lines); } - public static void setBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data) { + public static void setBlocks(final String worldname, final int[] x, final int[] y, final int[] z, final int[] id, final byte[] data) { manager.functionSetBlocks(worldname, x, y, z, id, data); } } 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 04281120b..62eea59bd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Random; import org.bukkit.Bukkit; @@ -24,284 +23,269 @@ import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ClusterManager { - public static HashMap> clusters; - private static HashSet regenerating = new HashSet<>(); - public static PlotCluster last; - - public static boolean contains(PlotCluster cluster, PlotId id) { - if (cluster.getP1().x <= id.x && cluster.getP1().y <= id.y && cluster.getP2().x >= id.x && cluster.getP2().y >= id.y) { - return true; - } - return false; - } - - public static HashSet getClusters(World world) { - return getClusters(world.getName()); - } - - public static HashSet getClusters(String world) { - if (clusters.containsKey(world)) { - return clusters.get(world); - } - return new HashSet<>(); - } - - public static Location getHome(PlotCluster cluster) { - BlockLoc home = cluster.settings.getPosition(); - Location toReturn; - if (home.y == 0) { - // default pos - PlotId center = getCenterPlot(cluster); - toReturn = PlotHelper.getPlotHome(cluster.world, center); - if (toReturn.getY() == 0) { - final PlotManager manager = PlotSquared.getPlotManager(cluster.world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world); - final Location loc = manager.getSignLoc(plotworld, PlotHelper.getPlot(cluster.world, center)); - toReturn.setY(loc.getY()); - } - } - else { - toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z); - } - int max = BukkitUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ()); - if (max > toReturn.getY()) { - toReturn.setY(max); - } - return toReturn; - } - - public static PlotId getCenterPlot(PlotCluster cluster) { - PlotId bot = cluster.getP1(); - PlotId top = cluster.getP2(); - return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); - } - - public static Location getClusterBottom(PlotCluster cluster) { - String world = cluster.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 = PlotSquared.getWorldSettings(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotTopLocAbs(plotworld, cluster.getP2()); - } - - public static PlotCluster getCluster(String world, String name) { - if (!clusters.containsKey(world)) { - return null; - } - for (PlotCluster cluster : clusters.get(world)) { - if (cluster.getName().equals(name)) { - return cluster; - } - } - return null; - } - - public static boolean contains(PlotCluster cluster, Location loc) { - String world = loc.getWorld(); - 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.getX() < loc.getX() && bot.getZ() < loc.getZ() && top.getX() > loc.getX() && top.getZ() > loc.getZ()) { + public static HashMap> clusters; + private static HashSet regenerating = new HashSet<>(); + public static PlotCluster last; + + public static boolean contains(final PlotCluster cluster, final PlotId id) { + if ((cluster.getP1().x <= id.x) && (cluster.getP1().y <= id.y) && (cluster.getP2().x >= id.x) && (cluster.getP2().y >= id.y)) { return true; } return false; } - - public static HashSet getIntersects(String world, PlotClusterId id) { - if (!clusters.containsKey(world)) { - return new HashSet<>(); - } - HashSet list = new HashSet(); - for (PlotCluster cluster : clusters.get(world)) { - if (intersects(cluster, id)) { - list.add(cluster); - } - } - return list; - } - - public static boolean intersects(PlotCluster cluster, PlotClusterId id) { - PlotId pos1 = cluster.getP1(); - PlotId pos2 = cluster.getP2(); - if (pos1.x <= id.pos2.x && pos2.x >= id.pos1.x && pos1.y <= id.pos2.y && pos2.y >= id.pos1.y) { - return true; - } - return false; + + public static HashSet getClusters(final World world) { + return getClusters(world.getName()); } - - public static PlotCluster getCluster(Plot plot) { - return getCluster(plot.world, plot.id); - } - - public static PlotCluster getCluster(Location loc) { - String world = loc.getWorld(); - if (last != null && last.world.equals(world)) { - if (contains(last, loc)) { - return last; - } - } - if (clusters == null) { - return null; - } - HashSet local = clusters.get(world); - if (local == null) { - return null; - } - for (PlotCluster cluster : local) { - if (contains(cluster, loc)) { - last = cluster; - return cluster; - } - } - return null; - } - - public static PlotCluster getCluster(String world, PlotId id) { - if (last != null && last.world.equals(world)) { - if (contains(last, id)) { - return last; - } - } - if (clusters == null) { - return null; - } - HashSet local = clusters.get(world); - if (local == null) { - return null; - } - for (PlotCluster cluster : local) { - if (contains(cluster, id)) { - last = cluster; - return cluster; - } - } - return null; - } - - public static boolean removeCluster(PlotCluster cluster) { - if (clusters != null) { - if (clusters.containsKey(cluster.world)) { - clusters.get(cluster.world).remove(cluster); - return true; - } - } - return false; - } - - public static PlotClusterId getClusterId(PlotCluster cluster) { - return new PlotClusterId(cluster.getP1(), cluster.getP2()); - } - - public static AugmentedPopulator getPopulator(PlotCluster cluster) { - World world = Bukkit.getWorld(cluster.world); - for (Iterator iterator = world.getPopulators().iterator(); iterator.hasNext();) { - BlockPopulator populator = iterator.next(); + + public static HashSet getClusters(final String world) { + if (clusters.containsKey(world)) { + return clusters.get(world); + } + return new HashSet<>(); + } + + public static Location getHome(final PlotCluster cluster) { + final BlockLoc home = cluster.settings.getPosition(); + Location toReturn; + if (home.y == 0) { + // default pos + final PlotId center = getCenterPlot(cluster); + toReturn = PlotHelper.getPlotHome(cluster.world, center); + if (toReturn.getY() == 0) { + final PlotManager manager = PlotSquared.getPlotManager(cluster.world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world); + final Location loc = manager.getSignLoc(plotworld, PlotHelper.getPlot(cluster.world, center)); + toReturn.setY(loc.getY()); + } + } else { + toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z); + } + final int max = BukkitUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ()); + if (max > toReturn.getY()) { + toReturn.setY(max); + } + return toReturn; + } + + public static PlotId getCenterPlot(final PlotCluster cluster) { + final PlotId bot = cluster.getP1(); + final PlotId top = cluster.getP2(); + return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); + } + + public static Location getClusterBottom(final PlotCluster cluster) { + final String world = cluster.world; + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); + } + + public static Location getClusterTop(final PlotCluster cluster) { + final String world = cluster.world; + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotTopLocAbs(plotworld, cluster.getP2()); + } + + public static PlotCluster getCluster(final String world, final String name) { + if (!clusters.containsKey(world)) { + return null; + } + for (final PlotCluster cluster : clusters.get(world)) { + if (cluster.getName().equals(name)) { + return cluster; + } + } + return null; + } + + public static boolean contains(final PlotCluster cluster, final Location loc) { + final String world = loc.getWorld(); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); + final Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1, 0, 1); + if ((bot.getX() < loc.getX()) && (bot.getZ() < loc.getZ()) && (top.getX() > loc.getX()) && (top.getZ() > loc.getZ())) { + return true; + } + return false; + } + + public static HashSet getIntersects(final String world, final PlotClusterId id) { + if (!clusters.containsKey(world)) { + return new HashSet<>(); + } + final HashSet list = new HashSet(); + for (final PlotCluster cluster : clusters.get(world)) { + if (intersects(cluster, id)) { + list.add(cluster); + } + } + return list; + } + + public static boolean intersects(final PlotCluster cluster, final PlotClusterId id) { + final PlotId pos1 = cluster.getP1(); + final PlotId pos2 = cluster.getP2(); + if ((pos1.x <= id.pos2.x) && (pos2.x >= id.pos1.x) && (pos1.y <= id.pos2.y) && (pos2.y >= id.pos1.y)) { + return true; + } + return false; + } + + public static PlotCluster getCluster(final Plot plot) { + return getCluster(plot.world, plot.id); + } + + public static PlotCluster getCluster(final Location loc) { + final String world = loc.getWorld(); + if ((last != null) && last.world.equals(world)) { + if (contains(last, loc)) { + return last; + } + } + if (clusters == null) { + return null; + } + final HashSet local = clusters.get(world); + if (local == null) { + return null; + } + for (final PlotCluster cluster : local) { + if (contains(cluster, loc)) { + last = cluster; + return cluster; + } + } + return null; + } + + public static PlotCluster getCluster(final String world, final PlotId id) { + if ((last != null) && last.world.equals(world)) { + if (contains(last, id)) { + return last; + } + } + if (clusters == null) { + return null; + } + final HashSet local = clusters.get(world); + if (local == null) { + return null; + } + for (final PlotCluster cluster : local) { + if (contains(cluster, id)) { + last = cluster; + return cluster; + } + } + return null; + } + + public static boolean removeCluster(final PlotCluster cluster) { + if (clusters != null) { + if (clusters.containsKey(cluster.world)) { + clusters.get(cluster.world).remove(cluster); + return true; + } + } + return false; + } + + public static PlotClusterId getClusterId(final PlotCluster cluster) { + return new PlotClusterId(cluster.getP1(), cluster.getP2()); + } + + public static AugmentedPopulator getPopulator(final PlotCluster cluster) { + final World world = Bukkit.getWorld(cluster.world); + for (final BlockPopulator populator : world.getPopulators()) { if (populator instanceof AugmentedPopulator) { if (((AugmentedPopulator) populator).cluster.equals(cluster)) { return (AugmentedPopulator) populator; } } } - return null; - } - - public static PlotId estimatePlotId(Location loc) { - PlotId a = new PlotId(0, 0); - PlotId b = new PlotId(1, 1); - int xw; - int zw; - - String world = loc.getWorld(); - PlotWorld plotworld = PlotSquared.getWorldSettings(world); - if (plotworld == null) { - xw = 39; - zw = 39; - } - else { - PlotManager manager = PlotSquared.getPlotManager(world); - Location al = manager.getPlotBottomLocAbs(plotworld, a); - Location bl = manager.getPlotBottomLocAbs(plotworld, b); - - xw = bl.getX() - al.getX(); - zw = bl.getZ() - al.getZ(); - } - - int x = loc.getX(); - int z = loc.getZ(); - - return new PlotId((x/xw) + 1,(z/zw) + 1); - } - - public static void regenCluster(final PlotCluster cluster) { - if (regenerating.contains(cluster.world + ":" + cluster.getName())) { - return; - } - regenerating.add(cluster.world + ":" + cluster.getName()); - int interval = 1; - int i = 0; - final Random rand = new Random(); + return null; + } + + public static PlotId estimatePlotId(final Location loc) { + final PlotId a = new PlotId(0, 0); + final PlotId b = new PlotId(1, 1); + int xw; + int zw; + final String world = loc.getWorld(); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + if (plotworld == null) { + xw = 39; + zw = 39; + } else { + final PlotManager manager = PlotSquared.getPlotManager(world); + final Location al = manager.getPlotBottomLocAbs(plotworld, a); + final Location bl = manager.getPlotBottomLocAbs(plotworld, b); + xw = bl.getX() - al.getX(); + zw = bl.getZ() - al.getZ(); + } + final int x = loc.getX(); + final int z = loc.getZ(); + return new PlotId((x / xw) + 1, (z / zw) + 1); + } + + public static void regenCluster(final PlotCluster cluster) { + if (regenerating.contains(cluster.world + ":" + cluster.getName())) { + return; + } + regenerating.add(cluster.world + ":" + cluster.getName()); + final int interval = 1; + int i = 0; + final Random rand = new Random(); final World world = Bukkit.getWorld(cluster.world); final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world); - - Location bot = getClusterBottom(cluster); - Location top = getClusterTop(cluster); - - int minChunkX = bot.getX() >> 4; - int maxChunkX = (top.getX() >> 4) + 1; - int minChunkZ = bot.getZ() >> 4; - int maxChunkZ = (top.getZ() >> 4) + 1; - - final AugmentedPopulator populator = getPopulator(cluster); - final ArrayList chunks = new ArrayList<>(); - - BukkitTaskManager.runTaskLater(new Runnable() { + final Location bot = getClusterBottom(cluster); + final Location top = getClusterTop(cluster); + final int minChunkX = bot.getX() >> 4; + final int maxChunkX = (top.getX() >> 4) + 1; + final int minChunkZ = bot.getZ() >> 4; + final int maxChunkZ = (top.getZ() >> 4) + 1; + final AugmentedPopulator populator = getPopulator(cluster); + final ArrayList chunks = new ArrayList<>(); + TaskManager.runTaskLater(new Runnable() { @Override public void run() { ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName()); - Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner); + final Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner); if (owner != null) { PlayerFunctions.sendMessage(owner, C.CLEARING_DONE); } } - }, interval * chunks.size() + 20); - - // chunks - for (int x = minChunkX; x <= maxChunkX; x++) { + }, (interval * chunks.size()) + 20); + // chunks + for (int x = minChunkX; x <= maxChunkX; x++) { for (int z = minChunkZ; z <= maxChunkZ; z++) { final Chunk chunk = world.getChunkAt(x, z); chunks.add(chunk); } } - for (final Chunk chunk : chunks) { - i+=interval; - BukkitTaskManager.runTaskLater(new Runnable() { + for (final Chunk chunk : chunks) { + i += interval; + TaskManager.runTaskLater(new Runnable() { @Override public void run() { - if (populator == null || plotworld.TYPE == 0) { - SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); - + if ((populator == null) || (plotworld.TYPE == 0)) { + SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); world.regenerateChunk(chunk.getX(), chunk.getZ()); chunk.unload(true, true); - } - else { + } else { populator.populate(world, rand, chunk); } } }, i); - } - } -} \ No newline at end of file + } + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java index a1dedbd40..5e1641f09 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java @@ -18,18 +18,17 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import org.bukkit.ChatColor; public class ConsoleColors { - public static String fromString(String input) { - input = input.replaceAll("&0", fromChatColor(ChatColor.BLACK)).replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)).replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN)).replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA)).replaceAll("&4", fromChatColor(ChatColor.DARK_RED)).replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE)).replaceAll("&6", fromChatColor(ChatColor.GOLD)).replaceAll("&7", fromChatColor(ChatColor.GRAY)).replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY)).replaceAll("&9", fromChatColor(ChatColor.BLUE)).replaceAll("&a", fromChatColor(ChatColor.GREEN)).replaceAll("&b", fromChatColor(ChatColor.AQUA)).replaceAll("&c", fromChatColor(ChatColor.RED)).replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE)).replaceAll("&e", fromChatColor(ChatColor.YELLOW)).replaceAll("&f", fromChatColor(ChatColor.WHITE)).replaceAll("&k", fromChatColor(ChatColor.MAGIC)).replaceAll("&l", fromChatColor(ChatColor.BOLD)).replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH)).replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)).replaceAll("&o", fromChatColor(ChatColor.ITALIC)).replaceAll("&r", fromChatColor(ChatColor.RESET)); + input = input.replaceAll("&0", fromChatColor(ChatColor.BLACK)).replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)).replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN)).replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA)).replaceAll("&4", fromChatColor(ChatColor.DARK_RED)).replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE)).replaceAll("&6", fromChatColor(ChatColor.GOLD)).replaceAll("&7", fromChatColor(ChatColor.GRAY)).replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY)).replaceAll("&9", fromChatColor(ChatColor.BLUE)).replaceAll("&a", fromChatColor(ChatColor.GREEN)).replaceAll("&b", fromChatColor(ChatColor.AQUA)).replaceAll("&c", fromChatColor(ChatColor.RED)).replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE)).replaceAll("&e", fromChatColor(ChatColor.YELLOW)).replaceAll("&f", fromChatColor(ChatColor.WHITE)).replaceAll("&k", fromChatColor(ChatColor.MAGIC)).replaceAll("&l", fromChatColor(ChatColor.BOLD)).replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH)) + .replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)).replaceAll("&o", fromChatColor(ChatColor.ITALIC)).replaceAll("&r", fromChatColor(ChatColor.RESET)); return input + "\u001B[0m"; } - + /* * public static final String ANSI_RESET = "\u001B[0m"; public static final * String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = @@ -42,11 +41,10 @@ public class ConsoleColors { * String ANSI_UNDERLINE = "\033[0m"; public static final String ANSI_ITALIC * = "\033[3m]"; */ - public static String fromChatColor(final ChatColor color) { return chatColor(color).getLin(); } - + public static ConsoleColor chatColor(final ChatColor color) { switch (color) { case RESET: @@ -84,7 +82,7 @@ public class ConsoleColors { return ConsoleColor.RESET; } } - + static enum ConsoleColor { RESET("\u001B[0m"), BLACK("\u001B[30m"), @@ -98,20 +96,19 @@ public class ConsoleColors { BOLD("\033[1m"), UNDERLINE("\033[0m"), ITALIC("\033[3m"); - private final String win; private final String lin; - + ConsoleColor(final String lin) { this.lin = lin; this.win = lin; } - + @SuppressWarnings("unused") public String getWin() { return this.win; } - + public String getLin() { return this.lin; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index 6650b123b..ef9f20719 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -1,5 +1,4 @@ package com.intellectualcrafters.plot.util; public class EconHandler { - } 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 04419cc52..3e57ce1e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -22,12 +22,10 @@ import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ExpireManager { - public static ConcurrentHashMap> expiredPlots = new ConcurrentHashMap<>(); public static ConcurrentHashMap updatingPlots = new ConcurrentHashMap<>(); public static ConcurrentHashMap timestamp = new ConcurrentHashMap<>(); @@ -36,8 +34,7 @@ public class ExpireManager { public static long getTimeStamp(final String world) { if (timestamp.containsKey(world)) { return timestamp.get(world); - } - else { + } else { timestamp.put(world, 0l); return 0; } @@ -45,21 +42,20 @@ public class ExpireManager { public static boolean updateExpired(final String world) { updatingPlots.put(world, true); - long now = System.currentTimeMillis(); + final long now = System.currentTimeMillis(); if (now > getTimeStamp(world)) { timestamp.put(world, now + 86400000l); - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - HashMap plots = getOldPlots(world); + final HashMap plots = getOldPlots(world); PlotSquared.log("&cFound " + plots.size() + " expired plots for " + world + "!"); expiredPlots.put(world, plots); updatingPlots.put(world, false); } }); return true; - } - else { + } else { updatingPlots.put(world, false); return false; } @@ -69,11 +65,11 @@ public class ExpireManager { ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, new Runnable() { @Override public void run() { - for (String world : PlotSquared.getPlotWorldsString()) { + for (final String world : PlotSquared.getPlotWorldsString()) { if (!ExpireManager.updatingPlots.containsKey(world)) { ExpireManager.updatingPlots.put(world, false); } - Boolean updating = ExpireManager.updatingPlots.get(world); + final Boolean updating = ExpireManager.updatingPlots.get(world); if (updating) { return; } @@ -81,14 +77,14 @@ public class ExpireManager { updateExpired(world); return; } - Set plots = expiredPlots.get(world).keySet(); - if (plots == null || plots.size() == 0) { + final Set plots = expiredPlots.get(world).keySet(); + if ((plots == null) || (plots.size() == 0)) { if (updateExpired(world)) { return; } continue; } - Plot plot = plots.iterator().next(); + final Plot plot = plots.iterator().next(); if (plot.owner != null) { if (UUIDHandler.uuidWrapper.getPlayer(plot.owner) != null) { expiredPlots.get(world).remove(plot); @@ -105,8 +101,8 @@ public class ExpireManager { event.setCancelled(true); return; } - for (UUID helper : plot.helpers) { - Player player = UUIDHandler.uuidWrapper.getPlayer(helper); + for (final UUID helper : plot.helpers) { + final Player player = UUIDHandler.uuidWrapper.getPlayer(helper); if (player != null) { PlayerFunctions.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString()); } @@ -115,19 +111,18 @@ public class ExpireManager { if (plot.settings.isMerged()) { Unlink.unlinkPlot(Bukkit.getWorld(world), plot); } - PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); manager.clearPlot(plotworld, plot, false, null); PlotHelper.removeSign(plot); DBFunc.delete(world, plot); PlotSquared.removePlot(world, plot.id, true); expiredPlots.get(world).remove(plot); PlotSquared.log("&cDeleted expired plot: " + plot.id); - PlotSquared.log("&3 - World: "+plot.world); + PlotSquared.log("&3 - World: " + plot.world); if (plot.hasOwner()) { - PlotSquared.log("&3 - Owner: "+UUIDHandler.getName(plot.owner)); - } - else { - PlotSquared.log("&3 - Owner: Unowned"); + PlotSquared.log("&3 - Owner: " + UUIDHandler.getName(plot.owner)); + } else { + PlotSquared.log("&3 - Owner: Unowned"); } return; } @@ -135,34 +130,33 @@ public class ExpireManager { }, 2400, 2400); } - public static boolean isExpired(UUID uuid) { - String name = UUIDHandler.getName(uuid); - if (name != null) { - OfflinePlayer op = Bukkit.getOfflinePlayer(name); - if (op.hasPlayedBefore()) { - long last = op.getLastPlayed(); - long compared = System.currentTimeMillis() - last; - if (compared >= 86400000l * Settings.AUTO_CLEAR_DAYS) { - return true; - } - } - } + public static boolean isExpired(final UUID uuid) { + final String name = UUIDHandler.getName(uuid); + if (name != null) { + final OfflinePlayer op = Bukkit.getOfflinePlayer(name); + if (op.hasPlayedBefore()) { + final long last = op.getLastPlayed(); + final long compared = System.currentTimeMillis() - last; + if (compared >= (86400000l * Settings.AUTO_CLEAR_DAYS)) { + return true; + } + } + } return false; } - public static HashMap getOldPlots(String world) { + public static HashMap getOldPlots(final String world) { final Collection plots = PlotSquared.getPlots(world).values(); final HashMap toRemove = new HashMap<>(); - HashMap remove = new HashMap<>(); - Set keep = new HashSet<>(); - for (Plot plot : plots) { - UUID uuid = plot.owner; - if (uuid == null || remove.containsKey(uuid)) { + final HashMap remove = new HashMap<>(); + final Set keep = new HashSet<>(); + for (final Plot plot : plots) { + final UUID uuid = plot.owner; + if ((uuid == null) || remove.containsKey(uuid)) { Long stamp; if (uuid == null) { stamp = 0l; - } - else { + } else { stamp = remove.get(uuid); } toRemove.put(plot, stamp); @@ -171,53 +165,49 @@ public class ExpireManager { if (keep.contains(uuid)) { continue; } - Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { keep.add(uuid); continue; } - OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if (op==null || !op.hasPlayedBefore()) { + final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); + if ((op == null) || !op.hasPlayedBefore()) { continue; } long last = op.getLastPlayed(); long compared = System.currentTimeMillis() - last; - if (compared >= 86400000l * Settings.AUTO_CLEAR_DAYS) { + if (compared >= (86400000l * Settings.AUTO_CLEAR_DAYS)) { if (Settings.AUTO_CLEAR_CHECK_DISK) { - String worldname = Bukkit.getWorlds().get(0).getName(); + final String worldname = Bukkit.getWorlds().get(0).getName(); String foldername; String filename = null; if (BukkitMain.checkVersion(1, 7, 5)) { foldername = "playerdata"; try { - filename = op.getUniqueId() +".dat"; - } - catch (Throwable e) { + filename = op.getUniqueId() + ".dat"; + } catch (final Throwable e) { filename = uuid.toString() + ".dat"; } - } - else { + } else { foldername = "players"; - String playername = UUIDHandler.getName(uuid); + final String playername = UUIDHandler.getName(uuid); if (playername != null) { filename = playername + ".dat"; } } if (filename != null) { - File playerFile = new File(worldname + File.separator + foldername + File.separator + filename); + final File playerFile = new File(worldname + File.separator + foldername + File.separator + filename); if (!playerFile.exists()) { PlotSquared.log("Could not find file: " + filename); - } - else { + } else { try { last = playerFile.lastModified(); compared = System.currentTimeMillis() - last; - if (compared < 86400000l * Settings.AUTO_CLEAR_DAYS) { + if (compared < (86400000l * Settings.AUTO_CLEAR_DAYS)) { keep.add(uuid); continue; } - } - catch (Exception e) { + } catch (final Exception e) { PlotSquared.log("Please disable disk checking in old plot auto clearing; Could not read file: " + filename); } } @@ -231,5 +221,4 @@ public class ExpireManager { } return toRemove; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java index 0d1a2e3d0..438c2b6f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import org.bukkit.Location; @@ -28,13 +27,13 @@ import org.bukkit.Location; * * @author Citymonstret */ -@SuppressWarnings({"javadoc", "unused"}) public class LSetCube { - +@SuppressWarnings({ "javadoc", "unused" }) +public class LSetCube { /** * Base locations */ private Location l1, l2; - + /** * Constructor * @@ -45,7 +44,7 @@ import org.bukkit.Location; this.l1 = l1; this.l1 = l2; } - + /** * Secondary constructor * @@ -56,7 +55,7 @@ import org.bukkit.Location; this.l1 = l1; this.l2 = l1.clone().add(size, size, size); } - + /** * Returns the absolute min. of the cube * @@ -68,7 +67,7 @@ import org.bukkit.Location; final int z = Math.min(this.l1.getBlockZ(), this.l2.getBlockZ()); return new Location(this.l1.getWorld(), x, y, z); } - + /** * Returns the absolute max. of the cube * @@ -80,7 +79,7 @@ import org.bukkit.Location; final int z = Math.max(this.l1.getBlockZ(), this.l2.getBlockZ()); return new Location(this.l1.getWorld(), x, y, z); } - + /** * Creates a LCycler for the cube. * @@ -89,7 +88,7 @@ import org.bukkit.Location; public LCycler getCycler() { return new LCycler(this); } - + /** * @author Citymonstret */ @@ -106,7 +105,7 @@ import org.bukkit.Location; * */ private Location current; - + /** * @param cube */ @@ -115,14 +114,14 @@ import org.bukkit.Location; this.max = cube.maxLoc(); this.current = this.min; } - + /** * @return */ public boolean hasNext() { return ((this.current.getBlockX() + 1) <= this.max.getBlockX()) && ((this.current.getBlockY() + 1) <= this.max.getBlockY()) && ((this.current.getBlockZ() + 1) <= this.max.getBlockZ()); } - + /** * @return */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java index 14ed465bc..10acaff29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; /** @@ -27,7 +26,6 @@ package com.intellectualcrafters.plot.util; * @author Citymonstret */ public class Lag implements Runnable { - /** * Ticks */ @@ -41,7 +39,7 @@ public class Lag implements Runnable { */ @SuppressWarnings("unused") public static long LT = 0L; - + /** * Get the server TPS * @@ -50,7 +48,7 @@ public class Lag implements Runnable { public static double getTPS() { return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math.round(getTPS(100)); } - + /** * Return the tick per second (measured in $ticks) * @@ -66,7 +64,7 @@ public class Lag implements Runnable { final long e = System.currentTimeMillis() - T[t]; return ticks / (e / 1000.0D); } - + /** * Get number of ticks since * @@ -78,7 +76,7 @@ public class Lag implements Runnable { final long t = T[tI % T.length]; return System.currentTimeMillis() - t; } - + /** * Get lag percentage * @@ -87,7 +85,7 @@ public class Lag implements Runnable { public static double getPercentage() { return Math.round((1.0D - (Lag.getTPS() / 20.0D)) * 100.0D); } - + /** * Get TPS percentage (of 20) * @@ -96,7 +94,7 @@ public class Lag implements Runnable { public static double getFullPercentage() { return getTPS() * 5.0D; } - + @Override public void run() { T[TC % T.length] = System.currentTimeMillis(); 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 7f60ae108..2ac6ede4b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import java.io.BufferedReader; @@ -38,10 +37,9 @@ import com.intellectualcrafters.plot.config.C; * @author Citymonstret */ public class Logger { - private static ArrayList entries; private static File log; - + public static void setup(final File file) { log = file; entries = new ArrayList<>(); @@ -56,7 +54,7 @@ public class Logger { PlotSquared.log(C.PREFIX.s() + "File setup error Logger#setup"); } } - + public static void write() throws IOException { final FileWriter writer = new FileWriter(log); for (final String string : entries) { @@ -64,25 +62,25 @@ public class Logger { } writer.close(); } - + public static void add(final LogLevel level, final String string) { append("[" + level.toString() + "] " + string); } - + private static void append(final String string) { entries.add("[" + new Date().toString() + "]" + string); } - + public enum LogLevel { GENERAL("General"), WARNING("Warning"), DANGER("Danger"); private final String name; - + LogLevel(final String name) { this.name = name; } - + @Override public String toString() { return this.name; 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 81e9a52d2..68bff32f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import java.util.ArrayList; @@ -46,58 +45,56 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * * @author Citymonstret */ -@SuppressWarnings({"unused", "javadoc", "deprecation"}) public class PlotHelper { +public class PlotHelper { public final static HashMap runners = new HashMap<>(); public static boolean canSendChunk = false; public static ArrayList runners_p = new ArrayList<>(); static long state = 1; public static HashMap lastPlot = new HashMap<>(); public static HashMap worldBorder = new HashMap<>(); - - public static int getBorder(String worldname) { - if (worldBorder.containsKey(worldname)) { - PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); - return worldBorder.get(worldname) + 16; - } - return Integer.MAX_VALUE; + + public static int getBorder(final String worldname) { + if (worldBorder.containsKey(worldname)) { + PlotSquared.getWorldSettings(worldname); + return worldBorder.get(worldname) + 16; + } + return Integer.MAX_VALUE; } - public static void setupBorder(String world) { - PlotWorld plotworld = PlotSquared.getWorldSettings(world); - if (!plotworld.WORLD_BORDER) { - return; - } - if (!worldBorder.containsKey(world)) { - worldBorder.put(world,0); - } - for (Plot plot : PlotSquared.getPlots(world).values()) { - updateWorldBorder(plot); - } + public static void setupBorder(final String world) { + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + if (!plotworld.WORLD_BORDER) { + return; + } + if (!worldBorder.containsKey(world)) { + worldBorder.put(world, 0); + } + for (final Plot plot : PlotSquared.getPlots(world).values()) { + updateWorldBorder(plot); + } } - public static void update(Location loc) { - String world = loc.getWorld(); - ArrayList chunks = new ArrayList<>(); + public static void update(final Location loc) { + final String world = loc.getWorld(); + final ArrayList chunks = new ArrayList<>(); final int distance = BukkitUtil.getViewDistance(); for (int cx = -distance; cx < distance; cx++) { for (int cz = -distance; cz < distance; cz++) { - ChunkLoc chunk = new ChunkLoc(cx, cz); + final ChunkLoc chunk = new ChunkLoc(cx, cz); chunks.add(chunk); } } AbstractSetBlock.setBlockManager.update(world, chunks); } - public static void createWorld(String world, String generator) { - + public static void createWorld(final String world, final String generator) { } - public static PlotId parseId(String arg) { + public static PlotId parseId(final String arg) { try { - String[] split = arg.split(";"); - return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])) ; - } - catch (Exception e) { + final String[] split = arg.split(";"); + return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + } catch (final Exception e) { return null; } } @@ -123,8 +120,8 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } return id; } - - public static ArrayList getPlotSelectionIds(PlotId pos1, final PlotId pos2) { + + public static ArrayList getPlotSelectionIds(final PlotId pos1, final PlotId pos2) { final ArrayList myplots = new ArrayList<>(); for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -145,51 +142,35 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * * @return boolean (success) */ - public static boolean mergePlots(final String world, final ArrayList plotIds, boolean removeRoads) { - + public static boolean mergePlots(final String world, final ArrayList plotIds, final boolean removeRoads) { if (plotIds.size() < 2) { return false; } final PlotId pos1 = plotIds.get(0); final PlotId pos2 = plotIds.get(plotIds.size() - 1); - final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - manager.startPlotMerge(plotworld, plotIds); - - - boolean result = false; - + final boolean result = false; for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { - - boolean changed = false; - final boolean lx = x < pos2.x; final boolean ly = y < pos2.y; - final PlotId id = new PlotId(x, y); - final Plot plot = PlotSquared.getPlots(world).get(id); - Plot plot2 = null; - if (removeRoads) { removeSign(plot); - } if (lx) { if (ly) { if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { - changed = true; if (removeRoads) { manager.removeRoadSouthEast(plotworld, plot); } } } if (!plot.settings.getMerged(1)) { - changed = true; plot2 = PlotSquared.getPlots(world).get(new PlotId(x + 1, y)); mergePlot(world, plot, plot2, removeRoads); plot.settings.setMerged(1, true); @@ -198,7 +179,6 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } if (ly) { if (!plot.settings.getMerged(2)) { - changed = true; plot2 = PlotSquared.getPlots(world).get(new PlotId(x, y + 1)); mergePlot(world, plot, plot2, removeRoads); plot.settings.setMerged(2, true); @@ -207,23 +187,17 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } } } - 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 = PlotSquared.getPlots(world).get(id); DBFunc.setMerged(world, plot, plot.settings.getMerged()); - } } - - manager.finishPlotMerge(plotworld, plotIds); - - return result; } - + /** * Merges 2 plots Removes the road inbetween
- Assumes the first plot parameter is lower
- Assumes neither * are a Mega-plot
- Assumes plots are directly next to each other
- Saves to DB @@ -232,11 +206,9 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @param lesserPlot * @param greaterPlot */ - public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, boolean removeRoads) { - + public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) { 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)) { lesserPlot.settings.setMerged(2, true); @@ -256,18 +228,15 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } } - - public static void removeSign(final Plot p) { - String world = p.world; + final String world = p.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 }); + BlockManager.setBlocks(world, new int[] { loc.getX() }, new int[] { loc.getY() }, new int[] { loc.getZ() }, new int[] { 0 }, new byte[] { 0 }); } - + public static void setSign(String name, final Plot p) { - if (name == null) { name = "unknown"; } @@ -275,22 +244,17 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; final PlotWorld plotworld = PlotSquared.getWorldSettings(p.world); final Location loc = manager.getSignLoc(plotworld, p); final String id = p.id.x + ";" + p.id.y; - String[] lines = new String[] { - C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), - C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), - C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), - C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) - }; - BukkitUtil.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines); + final String[] lines = new String[] { C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) }; + BlockManager.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines); } - + public static String getStringSized(final int max, final String string) { if (string.length() > max) { return string.substring(0, max); } return string; } - + public static void autoMerge(final String world, final Plot plot, final UUID uuid) { if (plot == null) { return; @@ -347,9 +311,8 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } update(getPlotHome(world, plot)); } - + private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { - final PlotId id_min = plots.get(0); final PlotId id_max = plots.get(plots.size() - 1); for (final PlotId myid : plots) { @@ -369,24 +332,24 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; return true; } - public static void updateWorldBorder(Plot plot) { - if (!worldBorder.containsKey(plot.world)) { - return; - } - String world = plot.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); - int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ())); - int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ())); - int max = Math.max(botmax, topmax); - if (max > border ) { - worldBorder.put(plot.world, max); - } + public static void updateWorldBorder(final Plot plot) { + if (!worldBorder.containsKey(plot.world)) { + return; + } + final String world = plot.world; + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id); + final Location top = manager.getPlotTopLocAbs(plotworld, plot.id); + final int border = worldBorder.get(plot.world); + final int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ())); + final int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ())); + final int max = Math.max(botmax, topmax); + if (max > border) { + worldBorder.put(plot.world, max); + } } - + /** * Create a plot and notify the world border and plot merger */ @@ -394,7 +357,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; if (PlotHelper.worldBorder.containsKey(plot.world)) { updateWorldBorder(plot); } - Plot p = createPlotAbs(uuid, plot); + final Plot p = createPlotAbs(uuid, plot); final PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); if (plotworld.AUTO_MERGE) { autoMerge(plot.world, p, uuid); @@ -403,7 +366,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } /** - * Create a plot without notifying the merge function or world border manager + * Create a plot without notifying the merge function or world border manager */ public static Plot createPlotAbs(final UUID uuid, final Plot plot) { final String w = plot.world; @@ -412,30 +375,30 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; DBFunc.createPlotAndSettings(p); return p; } - + public static String createId(final int x, final int z) { return x + ";" + z; } - + public static int square(final int x) { return x * x; } - + public static short[] getBlock(final String block) { if (block.contains(":")) { final String[] split = block.split(":"); - return new short[]{Short.parseShort(split[0]), Short.parseShort(split[1])}; + return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) }; } - return new short[]{Short.parseShort(block), 0}; + return new short[] { Short.parseShort(block), 0 }; } - + /** * Clear a plot and associated sections: [sign, entities, border] * * @param requester * @param plot */ - public static boolean clear(UUID uuid, final Plot plot, final boolean isDelete, final Runnable whenDone) { + public static boolean clear(final UUID uuid, final Plot plot, final boolean isDelete, final Runnable whenDone) { if (runners.containsKey(plot)) { return false; } @@ -453,10 +416,9 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; h = (prime * h) + pos1.getX(); h = (prime * h) + pos1.getZ(); state = h; - - final long start = System.currentTimeMillis(); + System.currentTimeMillis(); final Location location = PlotHelper.getPlotHomeDefault(plot); - PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); runners.put(plot, 1); if (plotworld.TERRAIN != 0) { final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); @@ -469,7 +431,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; }); return; } - Runnable run = new Runnable() { + final Runnable run = new Runnable() { @Override public void run() { PlotHelper.setBiome(world, plot, "FOREST"); @@ -480,31 +442,27 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; }; manager.clearPlot(plotworld, plot, isDelete, run); } - + public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { if (blocks.length == 1) { setSimpleCuboid(world, pos1, pos2, blocks[0]); return; } - int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); - int[] xl = new int[length]; - int[] yl = new int[length]; - int[] zl = new int[length]; - - int[] ids = new int[length]; - byte[] data = new byte[length]; - + final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); + final int[] xl = new int[length]; + final int[] yl = new int[length]; + final int[] zl = new int[length]; + final int[] ids = new int[length]; + final byte[] data = new byte[length]; int index = 0; - for (int y = pos1.getY(); y < pos2.getY(); y++) { for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - int i = BlockManager.random(blocks.length); + final int i = BlockManager.random(blocks.length); xl[index] = x; yl[index] = y; zl[index] = z; - - PlotBlock block = blocks[i]; + final PlotBlock block = blocks[i]; ids[index] = block.id; data[index] = block.data; index++; @@ -513,25 +471,21 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } BlockManager.setBlocks(world, xl, yl, zl, ids, data); } - + public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { - int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); - int[] xl = new int[length]; - int[] yl = new int[length]; - int[] zl = new int[length]; - - int[] ids = new int[length]; - byte[] data = new byte[length]; - + final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); + final int[] xl = new int[length]; + final int[] yl = new int[length]; + final int[] zl = new int[length]; + final int[] ids = new int[length]; + final byte[] data = new byte[length]; int index = 0; - for (int y = pos1.getY(); y < pos2.getY(); y++) { for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) { xl[index] = x; yl[index] = y; zl[index] = z; - ids[index] = newblock.id; data[index] = newblock.data; index++; @@ -540,36 +494,33 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } BlockManager.setBlocks(world, xl, yl, zl, ids, data); } - + public static void setBiome(final String world, final Plot plot, final String biome) { - final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; final int topX = getPlotTopLoc(world, plot.id).getX(); final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; final int topZ = getPlotTopLoc(world, plot.id).getZ(); BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); } - + public static int getHeighestBlock(final String world, final int x, final int z) { - boolean safe = false; - int id; - int result = BukkitUtil.getHeighestBlock(world, x, z); + final int result = BukkitUtil.getHeighestBlock(world, x, z); if (result == 0) { return 64; } return result; -// for (int i = 1; i < world.getMaxHeight(); i++) { -// id = world.getBlockAt(x, i, z).getTypeId(); -// if (id == 0) { -// if (safe) { -// return i; -// } -// safe = true; -// } -// } -// return 64; + // for (int i = 1; i < world.getMaxHeight(); i++) { + // id = world.getBlockAt(x, i, z).getTypeId(); + // if (id == 0) { + // if (safe) { + // return i; + // } + // safe = true; + // } + // } + // return 64; } - + /** * Get plot home * @@ -579,23 +530,22 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @return Home Location */ public static Location getPlotHome(final String w, final PlotId plotid) { - Plot plot = getPlot(w, plotid); - BlockLoc home = plot.settings.getPosition(); + final Plot plot = getPlot(w, plotid); + final BlockLoc home = plot.settings.getPosition(); final Location bot = getPlotBottomLoc(w, plotid); - PlotManager manager = PlotSquared.getPlotManager(w); - if (home == null || (home.x == 0 && home.z == 0)) { + final PlotManager manager = PlotSquared.getPlotManager(w); + if ((home == null) || ((home.x == 0) && (home.z == 0))) { final Location top = getPlotTopLoc(w, plotid); - final int x = ((top.getX() - bot.getX())/2) + bot.getX(); - final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); + final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); + final int z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ(); final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getWorldSettings(w), plot).getY()); return new Location(w, x, y, z); - } - else { - final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); + } else { + final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); return bot.add(home.x, y, home.z); } } - + /** * Retrieve the location of the default plot home position * @@ -608,7 +558,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); return l; } - + /** * Get the plot home * @@ -622,7 +572,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; public static Location getPlotHome(final String w, final Plot plot) { return getPlotHome(w, plot.id); } - + /** * Refresh the plot chunks * @@ -630,19 +580,15 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @param plot Plot Object */ public static void refreshPlotChunks(final String world, final Plot plot) { - final int bottomX = getPlotBottomLoc(world, plot.id).getX(); final int topX = getPlotTopLoc(world, plot.id).getX(); final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); final int topZ = getPlotTopLoc(world, plot.id).getZ(); - final int minChunkX = (int) Math.floor((double) bottomX / 16); final int maxChunkX = (int) Math.floor((double) topX / 16); final int minChunkZ = (int) Math.floor((double) bottomZ / 16); final int maxChunkZ = (int) Math.floor((double) topZ / 16); - final ArrayList chunks = new ArrayList<>(); - for (int x = minChunkX; x <= maxChunkX; x++) { for (int z = minChunkZ; z <= maxChunkZ; z++) { if (canSendChunk) { @@ -664,7 +610,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } } } - + /** * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot * use getPlotTopLoc(...) @@ -675,12 +621,11 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @return */ public static Location getPlotTopLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } - + /** * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega * plot use getPlotBottomLoc(...) @@ -691,12 +636,11 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @return */ public static Location getPlotBottomLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); } - + /** * Obtains the width of a plot (x width) * @@ -706,10 +650,9 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @return */ public static int getPlotWidth(final String world, final PlotId id) { - return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); } - + /** * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as * a small plot use getPlotTopLocAbs(...) @@ -720,7 +663,6 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @return */ public static Location getPlotTopLoc(final String world, PlotId id) { - final Plot plot = PlotSquared.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getTopPlot(world, plot).id; @@ -729,7 +671,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } - + /** * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot * treated as a small plot use getPlotBottomLocAbs(...) @@ -740,7 +682,6 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @return */ public static Location getPlotBottomLoc(final String world, PlotId id) { - final Plot plot = PlotSquared.getPlots(world).get(id); if (plot != null) { id = PlayerFunctions.getBottomPlot(world, plot).id; @@ -751,7 +692,6 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { - 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); @@ -765,28 +705,26 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; return true; } - public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) { + public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(world, current); - com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(world, newPlot); + final com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(world, newPlot); final Location top = PlotHelper.getPlotTopLoc(world, current); final Plot currentPlot = PlotHelper.getPlot(world, current); if (currentPlot.owner == null) { return false; } - Plot pos1 = PlayerFunctions.getBottomPlot(world, currentPlot); - Plot pos2 = PlayerFunctions.getTopPlot(world, currentPlot); - - PlotId size = PlotHelper.getSize(world, currentPlot); - if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) { + final Plot pos1 = PlayerFunctions.getBottomPlot(world, currentPlot); + final Plot pos2 = PlayerFunctions.getTopPlot(world, currentPlot); + final PlotId size = PlotHelper.getSize(world, currentPlot); + if (!PlotHelper.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { return false; } - - int offset_x = newPlot.x - pos1.id.x; - int offset_y = newPlot.y - pos1.id.y; + final int offset_x = newPlot.x - pos1.id.x; + final int offset_y = newPlot.y - pos1.id.y; final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); - for (PlotId id : selection) { + for (final PlotId id : selection) { DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); - Plot plot = PlotSquared.getPlots(world).get(id); + final Plot plot = PlotSquared.getPlots(world).get(id); PlotSquared.getPlots(world).remove(id); plot.id.x += offset_x; plot.id.y += offset_y; @@ -795,7 +733,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; AChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { @Override public void run() { - Location bot = bot1.clone().add(1, 0, 1); + final Location bot = bot1.clone().add(1, 0, 1); AChunkManager.manager.regenerateRegion(bot, top, null); TaskManager.runTaskLater(whenDone, 1); } @@ -803,15 +741,14 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; return true; } - public static PlotId getSize(String world, Plot plot) { - - PlotSettings settings = plot.settings; + public static PlotId getSize(final String world, final Plot plot) { + final PlotSettings settings = plot.settings; if (!settings.isMerged()) { - return new PlotId(1,1); + return new PlotId(1, 1); } - Plot top = PlayerFunctions.getTopPlot(world, plot); - Plot bot = PlayerFunctions.getBottomPlot(world, plot); - return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1); + final Plot top = PlayerFunctions.getTopPlot(world, plot); + final Plot bot = PlayerFunctions.getBottomPlot(world, plot); + return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1); } /** @@ -823,7 +760,6 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; * @return */ public static Plot getPlot(final String world, final PlotId id) { - if (id == null) { return null; } @@ -832,7 +768,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; } return new Plot(id, null, new ArrayList(), new ArrayList(), world); } - + /** * Returns the plot at a given location * 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 8a505e394..e9090b103 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.PlotSquared; @@ -29,25 +28,24 @@ import com.intellectualcrafters.plot.PlotSquared; * @author Citymonstret */ public class PlotSquaredException extends RuntimeException { - public PlotSquaredException(final PlotError error, final String details) { super("PlotError >> " + error.getHeader() + ": " + details); PlotSquared.log("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details); } - + public static enum PlotError { PLOTMAIN_NULL("The PlotSquared instance was null"), MISSING_DEPENDENCY("Missing Dependency"); private final String errorHeader; - + PlotError(final String errorHeader) { this.errorHeader = errorHeader; } - + public String getHeader() { return this.errorHeader; } - + @Override public String toString() { return this.getHeader(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java index 008b152d7..4277c4c1b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import org.bukkit.Location; @@ -32,8 +31,8 @@ import com.intellectualcrafters.plot.config.Settings; * * @author Citymonstret */ -@SuppressWarnings("unused") public class RUtils { - +@SuppressWarnings("unused") +public class RUtils { /** * Get the total allocated ram * @@ -42,7 +41,7 @@ import com.intellectualcrafters.plot.config.Settings; public static long getTotalRam() { return (Runtime.getRuntime().totalMemory() / 1024) / 1024; } - + /** * Get the total free ram * @@ -51,7 +50,7 @@ import com.intellectualcrafters.plot.config.Settings; public static long getFreeRam() { return (Runtime.getRuntime().freeMemory() / 1024) / 1024; } - + /** * Percentage of used ram * @@ -60,7 +59,7 @@ import com.intellectualcrafters.plot.config.Settings; public static long getRamPercentage() { return (getFreeRam() / getTotalRam()) * 100; } - + /** * Get formatted time * @@ -73,13 +72,12 @@ import com.intellectualcrafters.plot.config.Settings; final double m = (sec % 3600) / 60; final double s = sec % 60; final String string = C.TIME_FORMAT.s(); - final String s_h = (int) h + " " + ((int) h != 1 ? "hours" : "hour"); final String s_m = (int) m + " " + ((int) m != 1 ? "minutes" : "minute"); final String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second"); return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m).replaceAll("%hours%", s_h); } - + /** * Force textures on the client * @@ -88,7 +86,7 @@ import com.intellectualcrafters.plot.config.Settings; public void forceTexture(final Player p) { p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); } - + public Direction getDirection(final Location l) { final double d = ((l.getYaw() * 4.0F) / 360.0F) + 0.5D; final int i = (int) d; @@ -106,25 +104,24 @@ import com.intellectualcrafters.plot.config.Settings; return null; } } - + public boolean compareDirections(final Location l1, final Location l2) { return getDirection(l1) == getDirection(l2); } - + enum Direction { SOUTH(0), EAST(1), NORTH(2), WEST(3); private final int i; - + Direction(final int i) { this.i = i; } - + public int getInt() { return this.i; } } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java index a35e7a67c..f590a1cb7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import java.lang.reflect.Constructor; @@ -36,8 +35,8 @@ import org.bukkit.Server; * @author DPOH-VAR * @version 1.0 */ -@SuppressWarnings({"UnusedDeclaration", "rawtypes"}) public class ReflectionUtils { - +@SuppressWarnings({ "UnusedDeclaration", "rawtypes" }) +public class ReflectionUtils { /** * prefix of bukkit classes */ @@ -50,7 +49,6 @@ import org.bukkit.Server; * boolean value, TRUE if server uses forge or MCPC+ */ private static boolean forge = false; - /** check server version and class names */ static { if (Bukkit.getServer() != null) { @@ -77,14 +75,14 @@ import org.bukkit.Server; } } } - + /** * @return true if server has forge classes */ public static boolean isForge() { return forge; } - + /** * Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace * {nm} to net.minecraft @@ -105,7 +103,7 @@ import org.bukkit.Server; } throw new RuntimeException("no class found"); } - + /** * get RefClass object by real class * @@ -116,17 +114,17 @@ import org.bukkit.Server; public static RefClass getRefClass(final Class clazz) { return new RefClass(clazz); } - + /** * RefClass - utility to simplify work with reflections. */ public static class RefClass { private final Class clazz; - + private RefClass(final Class clazz) { this.clazz = clazz; } - + /** * get passed class * @@ -135,7 +133,7 @@ import org.bukkit.Server; public Class getRealClass() { return this.clazz; } - + /** * see {@link Class#isInstance(Object)} * @@ -146,7 +144,7 @@ import org.bukkit.Server; public boolean isInstance(final Object object) { return this.clazz.isInstance(object); } - + /** * get existing method by name and types * @@ -179,7 +177,7 @@ import org.bukkit.Server; throw new RuntimeException(e); } } - + /** * get existing constructor by types * @@ -211,7 +209,7 @@ import org.bukkit.Server; throw new RuntimeException(e); } } - + /** * find method by type parameters * @@ -236,22 +234,21 @@ import org.bukkit.Server; final List methods = new ArrayList<>(); Collections.addAll(methods, this.clazz.getMethods()); Collections.addAll(methods, this.clazz.getDeclaredMethods()); - findMethod: - for (final Method m : methods) { - final Class[] methodTypes = m.getParameterTypes(); - if (methodTypes.length != classes.length) { - continue; - } - for (final Class aClass : classes) { - if (!Arrays.equals(classes, methodTypes)) { - continue findMethod; + findMethod: for (final Method m : methods) { + final Class[] methodTypes = m.getParameterTypes(); + if (methodTypes.length != classes.length) { + continue; + } + for (final Class aClass : classes) { + if (!Arrays.equals(classes, methodTypes)) { + continue findMethod; + } + return new RefMethod(m); } - return new RefMethod(m); } - } throw new RuntimeException("no such method"); } - + /** * find method by name * @@ -274,7 +271,7 @@ import org.bukkit.Server; } throw new RuntimeException("no such method"); } - + /** * find method by return value * @@ -287,7 +284,7 @@ import org.bukkit.Server; public RefMethod findMethodByReturnType(final RefClass type) { return findMethodByReturnType(type.clazz); } - + /** * find method by return value * @@ -311,7 +308,7 @@ import org.bukkit.Server; } throw new RuntimeException("no such method"); } - + /** * find constructor by number of arguments * @@ -332,7 +329,7 @@ import org.bukkit.Server; } throw new RuntimeException("no such constructor"); } - + /** * get field by name * @@ -353,7 +350,7 @@ import org.bukkit.Server; throw new RuntimeException(e); } } - + /** * find field by type * @@ -366,7 +363,7 @@ import org.bukkit.Server; public RefField findField(final RefClass type) { return findField(type.clazz); } - + /** * find field by type * @@ -391,39 +388,39 @@ import org.bukkit.Server; throw new RuntimeException("no such field"); } } - + /** * Method wrapper */ public static class RefMethod { private final Method method; - + private RefMethod(final Method method) { this.method = method; method.setAccessible(true); } - + /** * @return passed method */ public Method getRealMethod() { return this.method; } - + /** * @return owner class of method */ public RefClass getRefClass() { return new RefClass(this.method.getDeclaringClass()); } - + /** * @return class of method return type */ public RefClass getReturnRefClass() { return new RefClass(this.method.getReturnType()); } - + /** * apply method to object * @@ -434,7 +431,7 @@ import org.bukkit.Server; public RefExecutor of(final Object e) { return new RefExecutor(e); } - + /** * call static method * @@ -449,14 +446,14 @@ import org.bukkit.Server; throw new RuntimeException(e); } } - + public class RefExecutor { final Object e; - + public RefExecutor(final Object e) { this.e = e; } - + /** * apply method for selected object * @@ -475,32 +472,32 @@ import org.bukkit.Server; } } } - + /** * Constructor wrapper */ public static class RefConstructor { private final Constructor constructor; - + private RefConstructor(final Constructor constructor) { this.constructor = constructor; constructor.setAccessible(true); } - + /** * @return passed constructor */ public Constructor getRealConstructor() { return this.constructor; } - + /** * @return owner class of method */ public RefClass getRefClass() { return new RefClass(this.constructor.getDeclaringClass()); } - + /** * create new instance with constructor * @@ -518,36 +515,36 @@ import org.bukkit.Server; } } } - + public static class RefField { private final Field field; - + private RefField(final Field field) { this.field = field; field.setAccessible(true); } - + /** * @return passed field */ public Field getRealField() { return this.field; } - + /** * @return owner class of field */ public RefClass getRefClass() { return new RefClass(this.field.getDeclaringClass()); } - + /** * @return type of field */ public RefClass getFieldRefClass() { return new RefClass(this.field.getType()); } - + /** * apply fiend for object * @@ -558,14 +555,14 @@ import org.bukkit.Server; public RefExecutor of(final Object e) { return new RefExecutor(e); } - + public class RefExecutor { final Object e; - + public RefExecutor(final Object e) { this.e = e; } - + /** * set field value for applied object * @@ -578,7 +575,7 @@ import org.bukkit.Server; throw new RuntimeException(e); } } - + /** * get field value for applied object * @@ -593,5 +590,4 @@ import org.bukkit.Server; } } } - } 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 bebbdb757..833d535d0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import java.io.File; @@ -74,32 +73,22 @@ public class SchematicHandler { } try { final Dimension demensions = schematic.getSchematicDimension(); - final int WIDTH = demensions.getX(); final int LENGTH = demensions.getZ(); final int HEIGHT = demensions.getY(); - final DataCollection[] blocks = schematic.getBlockCollection(); - Location l1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId()); - final int sy = BukkitUtil.getHeighestBlock(location.getWorld(), l1.getX() + 1, l1.getZ() + 1); - l1 = l1.add(1, sy - 1, 1); - - int y_offset; if (HEIGHT == BukkitUtil.getMaxHeight(location.getWorld())) { - y_offset = 0; } else { - y_offset = l1.getY(); + l1.getY(); } - - int[] xl = new int[blocks.length]; - int[] yl = new int[blocks.length]; - int[] zl = new int[blocks.length]; - int[] ids = new int[blocks.length]; - byte[] data = new byte[blocks.length]; - + final int[] xl = new int[blocks.length]; + final int[] yl = new int[blocks.length]; + final int[] zl = new int[blocks.length]; + final int[] ids = new int[blocks.length]; + final byte[] data = new byte[blocks.length]; for (int x = 0; x < WIDTH; x++) { for (int z = 0; z < LENGTH; z++) { for (int y = 0; y < HEIGHT; y++) { @@ -114,16 +103,14 @@ public class SchematicHandler { } } BlockManager.setBlocks(plot.world, xl, yl, zl, ids, data); - } catch (final Exception e) { return false; } return true; } - - public static Schematic getSchematic(final CompoundTag tag, File file) { + + public static Schematic getSchematic(final CompoundTag tag, final File file) { final Map tagMap = tag.getValue(); - byte[] addId = new byte[0]; if (tagMap.containsKey("AddBlocks")) { addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue(); @@ -131,13 +118,10 @@ public class SchematicHandler { final short width = ShortTag.class.cast(tagMap.get("Width")).getValue(); final short length = ShortTag.class.cast(tagMap.get("Length")).getValue(); final short height = ShortTag.class.cast(tagMap.get("Height")).getValue(); - final byte[] b = ByteArrayTag.class.cast(tagMap.get("Blocks")).getValue(); final byte[] d = ByteArrayTag.class.cast(tagMap.get("Data")).getValue(); final short[] blocks = new short[b.length]; - final Dimension dimension = new Dimension(width, height, length); - for (int index = 0; index < b.length; index++) { if ((index >> 1) >= addId.length) { // No corresponding // AddBlocks index @@ -150,9 +134,7 @@ public class SchematicHandler { } } } - final DataCollection[] collection = new DataCollection[b.length]; - for (int x = 0; x < b.length; x++) { collection[x] = new DataCollection(blocks[x], d[x]); } @@ -180,20 +162,18 @@ public class SchematicHandler { PlotSquared.log(file.toString() + " doesn't exist"); return null; } - try { final InputStream iStream = new FileInputStream(file); final NBTInputStream stream = new NBTInputStream(new GZIPInputStream(iStream)); final CompoundTag tag = (CompoundTag) stream.readTag(); stream.close(); return getSchematic(tag, file); - } catch (final Exception e) { PlotSquared.log(file.toString() + " is not in GZIP format"); return null; } } - + /** * Saves a schematic to a file path * @@ -208,7 +188,7 @@ public class SchematicHandler { return false; } try { - File tmp = new File(path); + final File tmp = new File(path); tmp.getParentFile().mkdirs(); final OutputStream stream = new FileOutputStream(path); final NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream)); @@ -221,7 +201,7 @@ public class SchematicHandler { } return true; } - + /** * Gets the schematic of a plot * @@ -230,19 +210,17 @@ public class SchematicHandler { * * @return tag */ - public static CompoundTag getCompoundTag(final String world, PlotId id) { + public static CompoundTag getCompoundTag(final String world, final PlotId id) { if (!PlotSquared.getPlots(world).containsKey(id)) { return null; } - final Location pos1 = PlotHelper.getPlotBottomLoc(world, id).add(1, 0, 1); final Location pos2 = PlotHelper.getPlotTopLoc(world, id); - return getCompoundTag(world, pos1, pos2); } @SuppressWarnings("deprecation") - public static CompoundTag getCompoundTag(final String world, Location pos1, Location pos2) { + public static CompoundTag getCompoundTag(final String world, final Location pos1, final Location pos2) { // loading chunks int i = 0; int j = 0; @@ -252,9 +230,7 @@ public class SchematicHandler { final Chunk chunk = BukkitUtil.getChunkAt(world, i, j); final boolean result = chunk.load(false); if (!result) { - // Plot is not even generated - return null; } } @@ -264,9 +240,8 @@ public class SchematicHandler { return null; } final int width = (pos2.getX() - pos1.getX()) + 1; - final int height = pos2.getY() - pos1.getY() + 1; + final int height = (pos2.getY() - pos1.getY()) + 1; final int length = (pos2.getZ() - pos1.getZ()) + 1; - final HashMap schematic = new HashMap<>(); schematic.put("Width", new ShortTag("Width", (short) width)); schematic.put("Length", new ShortTag("Length", (short) length)); @@ -281,34 +256,25 @@ public class SchematicHandler { final byte[] blocks = new byte[width * height * length]; byte[] addBlocks = null; final byte[] blockData = new byte[width * height * length]; - - int sx = pos1.getX(); - int ex = pos2.getX(); - - int sz = pos1.getZ(); - int ez = pos2.getZ(); - - int sy = pos1.getY(); - int ey = pos2.getY(); - + final int sx = pos1.getX(); + pos2.getX(); + final int sz = pos1.getZ(); + pos2.getZ(); + final int sy = pos1.getY(); + pos2.getY(); for (int x = 0; x < width; x++) { for (int z = 0; z < length; z++) { for (int y = 0; y < height; y++) { final int index = (y * width * length) + (z * width) + x; - - PlotBlock block = BukkitUtil.getBlock(new Location(world, sx + x, sy + y, sz + z)); - + final PlotBlock block = BukkitUtil.getBlock(new Location(world, sx + x, sy + y, sz + z)); if (block.id > 255) { if (addBlocks == null) { addBlocks = new byte[(blocks.length >> 1) + 1]; } - addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((block.id >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((block.id >> 8) & 0xF) << 4)); } - blocks[index] = (byte) block.id; blockData[index] = block.data; - // We need worldedit to save tileentity data or entities // - it uses NMS and CB internal code, which changes every // update @@ -319,14 +285,12 @@ public class SchematicHandler { schematic.put("Data", new ByteArrayTag("Data", blockData)); schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList())); schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, new ArrayList())); - if (addBlocks != null) { schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks)); } - return new CompoundTag("Schematic", schematic); } - + public static boolean pastePart(final String world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) { int length = 0; for (int i = i1; i <= i2; i++) { @@ -335,11 +299,11 @@ public class SchematicHandler { } } length = i2 - length; - int[] xl = new int[length]; - int[] yl = new int[length]; - int[] zl = new int[length]; - int[] ids = new int[length]; - byte[] data = new byte[length]; + final int[] xl = new int[length]; + final int[] yl = new int[length]; + final int[] zl = new int[length]; + final int[] ids = new int[length]; + final byte[] data = new byte[length]; int count = 0; for (int i = i1; i <= i2; i++) { final short id = blocks[i].block; @@ -347,17 +311,14 @@ public class SchematicHandler { continue; } count++; - final int area = WIDTH * LENGTH; final int r = i % (area); final int x = r % WIDTH; final int y = i / area; final int z = r / WIDTH; - xl[count] = x; yl[count] = y; zl[count] = z; - ids[count] = id; data[count] = blocks[i].data; if (y > 256) { @@ -367,7 +328,7 @@ public class SchematicHandler { BlockManager.setBlocks(world, xl, yl, zl, ids, data); return true; } - + /** * Schematic Class * @@ -377,26 +338,26 @@ public class SchematicHandler { private final DataCollection[] blockCollection; private final Dimension schematicDimension; private final File file; - + public Schematic(final DataCollection[] blockCollection, final Dimension schematicDimension, final File file) { this.blockCollection = blockCollection; this.schematicDimension = schematicDimension; this.file = file; } - + public File getFile() { return this.file; } - + public Dimension getSchematicDimension() { return this.schematicDimension; } - + public DataCollection[] getBlockCollection() { return this.blockCollection; } } - + /** * Schematic Dimensions * @@ -406,26 +367,26 @@ public class SchematicHandler { private final int x; private final int y; private final int z; - + public Dimension(final int x, final int y, final int z) { this.x = x; this.y = y; this.z = z; } - + public int getX() { return this.x; } - + public int getY() { return this.y; } - + public int getZ() { return this.z; } } - + /** * Schematic Data Collection * @@ -434,18 +395,17 @@ public class SchematicHandler { public static class DataCollection { private final short block; private final byte data; - + // public CompoundTag tag; - public DataCollection(final short block, final byte data) { this.block = block; this.data = data; } - + public short getBlock() { return this.block; } - + public byte getData() { return this.data; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java index abd77cec1..d017796fd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util; import java.util.ArrayList; @@ -29,25 +28,23 @@ import java.util.Collections; * * @author Citymonstret */ -@SuppressWarnings("unused") public class StringComparison { - +@SuppressWarnings("unused") +public class StringComparison { /** * Best Match */ private String bestMatch; - /** * Match Value *

* Can be checked for low match (< .25 or something) */ private double match = 0; - /** * The actual object */ private Object bestMatchObject; - + /** * Constructor * @@ -66,7 +63,7 @@ import java.util.Collections; } } } - + /** * Compare two strings * @@ -90,7 +87,7 @@ import java.util.Collections; } return (2.0 * intersection) / union; } - + /** * Create an ArrayList containing pairs of letters * @@ -107,7 +104,7 @@ import java.util.Collections; } return aPairs; } - + /** * Get an array containing letter pairs * @@ -123,7 +120,7 @@ import java.util.Collections; } return p; } - + /** * Get the object * @@ -132,7 +129,7 @@ import java.util.Collections; public Object getMatchObject() { return this.bestMatchObject; } - + /** * Get the best match value * @@ -141,14 +138,13 @@ import java.util.Collections; public String getBestMatch() { return this.bestMatch; } - + /** * Will return both the match number, and the actual match string * * @return object[] containing: double, String */ public Object[] getBestMatchAdvanced() { - return new Object[]{this.match, this.bestMatch}; + return new Object[] { this.match, this.bestMatch }; } - } 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 eccac27c0..fb284e553 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -5,8 +5,7 @@ import java.util.HashSet; import com.intellectualcrafters.plot.PlotSquared; public abstract class TaskManager { - - public static HashSet TELEPORT_QUEUE = new HashSet<>(); + public static HashSet TELEPORT_QUEUE = new HashSet<>(); public abstract void taskRepeat(final Runnable r, int interval); @@ -18,28 +17,33 @@ public abstract class TaskManager { public abstract void taskLaterAsync(final Runnable r, int delay); - public static void runTaskRepeat(final Runnable r, int interval) { - if (r != null) + public static void runTaskRepeat(final Runnable r, final int interval) { + if (r != null) { PlotSquared.TASK.taskRepeat(r, interval); + } } public static void runTaskAsync(final Runnable r) { - if (r != null) + if (r != null) { PlotSquared.TASK.taskAsync(r); + } } public static void runTask(final Runnable r) { - if (r != null) + if (r != null) { PlotSquared.TASK.task(r); + } } - public static void runTaskLater(final Runnable r, int delay) { - if (r != null) + public static void runTaskLater(final Runnable r, final int delay) { + if (r != null) { PlotSquared.TASK.taskLater(r, delay); + } } - public static void runTaskLaterAsync(final Runnable r, int delay) { - if (r != null) + public static void runTaskLaterAsync(final Runnable r, final int delay) { + if (r != null) { PlotSquared.TASK.taskLaterAsync(r, delay); + } } } 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 6ba807dc5..1a796fb43 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 @@ -4,25 +4,28 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.util.TaskManager; public class BukkitTaskManager extends TaskManager { - - public void taskRepeat(final Runnable r, int interval) { + @Override + public void taskRepeat(final Runnable r, final int interval) { BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval); } + @Override public void taskAsync(final Runnable r) { BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r); } + @Override public void task(final Runnable r) { BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r); } - public void taskLater(final Runnable r, int delay) { + @Override + public void taskLater(final Runnable r, final int delay) { BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay); } - + @Override - public void taskLaterAsync(Runnable r, int delay) { + public void taskLaterAsync(final Runnable r, final int delay) { BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index b8a4928c1..fd6228c91 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -20,16 +20,15 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.BlockManager; public class BukkitUtil extends BlockManager { - private static HashMap worlds = new HashMap<>(); private static String lastString = null; private static World lastWorld = null; - public static Biome getBiome(Location loc) { + public static Biome getBiome(final Location loc) { return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()); } - public static World getWorld(String string) { + public static World getWorld(final String string) { if (lastString == string) { return lastWorld; } @@ -41,21 +40,21 @@ public class BukkitUtil extends BlockManager { return world; } - public static int getMaxHeight(String world) { + public static int getMaxHeight(final String world) { return getWorld(world).getMaxHeight(); } - public static int getHeighestBlock(String world, int x, int z) { + public static int getHeighestBlock(final String world, final int x, final int z) { return getWorld(world).getHighestBlockYAt(x, z); } - public static Chunk getChunkAt(String worldname, int x, int z) { - World world = getWorld(worldname); + public static Chunk getChunkAt(final String worldname, final int x, final int z) { + final World world = getWorld(worldname); return world.getChunkAt(x, z); } - public static void update(String world, int x, int z) { - ArrayList chunks = new ArrayList<>(); + public static void update(final String world, final int x, final int z) { + final ArrayList chunks = new ArrayList<>(); final int distance = Bukkit.getViewDistance(); for (int cx = -distance; cx < distance; cx++) { for (int cz = -distance; cz < distance; cz++) { @@ -66,34 +65,33 @@ public class BukkitUtil extends BlockManager { SetBlockManager.setBlockManager.update(chunks); } - public static String getWorld(Entity entity) { + public static String getWorld(final Entity entity) { return entity.getWorld().getName(); } - public static void teleportPlayer(Player player, Location loc) { - org.bukkit.Location bukkitLoc = new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()); + public static void teleportPlayer(final Player player, final Location loc) { + final org.bukkit.Location bukkitLoc = new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()); player.teleport(bukkitLoc); } - public static List getEntities(String worldname) { + public static List getEntities(final String worldname) { return getWorld(worldname).getEntities(); } - public static void setBlock(World world, int x, int y, int z, int id, byte data) { + public static void setBlock(final World world, final int x, final int y, final int z, final int id, final byte data) { try { SetBlockManager.setBlockManager.set(world, x, y, z, id, data); - } - catch (Throwable e) { + } catch (final Throwable e) { SetBlockManager.setBlockManager = new SetBlockSlow(); SetBlockManager.setBlockManager.set(world, x, y, z, id, data); } } - public static void setBiome(String worldname, int pos1_x, int pos1_z, int pos2_x, int pos2_z, String biome) { - Biome b = Biome.valueOf(biome.toUpperCase()); - World world = getWorld(worldname); - for (int x = pos1_x; x<= pos2_x; x++) { - for (int z = pos1_z; z<= pos2_z; z++) { + public static void setBiome(final String worldname, final int pos1_x, final int pos1_z, final int pos2_x, final int pos2_z, final String biome) { + final Biome b = Biome.valueOf(biome.toUpperCase()); + final World world = getWorld(worldname); + for (int x = pos1_x; x <= pos2_x; x++) { + for (int z = pos1_z; z <= pos2_z; z++) { final Block blk = world.getBlockAt(x, 0, z); final Biome c = blk.getBiome(); if (c.equals(b)) { @@ -105,40 +103,40 @@ public class BukkitUtil extends BlockManager { } } - public static void refreshChunk(String world, int x, int z) { + public static void refreshChunk(final String world, final int x, final int z) { getWorld(world).refreshChunk(x, z); } - public static PlotBlock getBlock(Location loc) { - World world = getWorld(loc.getWorld()); - Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); + public static PlotBlock getBlock(final Location loc) { + final World world = getWorld(loc.getWorld()); + final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); if (block == null) { - return new PlotBlock((short) 0 , (byte) 0); + return new PlotBlock((short) 0, (byte) 0); } return new PlotBlock((short) block.getTypeId(), block.getData()); } - - public static Location getLocation(Entity entity) { - org.bukkit.Location loc = entity.getLocation(); - String world = loc.getWorld().getName(); + + public static Location getLocation(final Entity entity) { + final org.bukkit.Location loc = entity.getLocation(); + final String world = loc.getWorld().getName(); return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } @Override - public void functionSetBlocks(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]); - } + public void functionSetBlocks(final String worldname, final int[] x, final int[] y, final int[] z, final int[] id, final byte[] data) { + final 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]); + } } - + @Override - public void functionSetSign(String worldname, int x, int y, int z, String[] lines) { - World world = getWorld(worldname); - Block block = world.getBlockAt(x, y, z); + public void functionSetSign(final String worldname, final int x, final int y, final int z, final String[] lines) { + final World world = getWorld(worldname); + final Block block = world.getBlockAt(x, y, z); block.setType(Material.AIR); block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); - BlockState blockstate = block.getState(); + final BlockState blockstate = block.getState(); if ((blockstate instanceof Sign)) { for (int i = 0; i < lines.length; i++) { ((Sign) blockstate).setLine(i, lines[i]); @@ -146,9 +144,8 @@ public class BukkitUtil extends BlockManager { ((Sign) blockstate).update(true); } } - + public static int getViewDistance() { return Bukkit.getViewDistance(); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 302651ddb..958a7ba82 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -53,49 +53,47 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.TaskManager; public class ChunkManager extends AChunkManager { - public static MutableInt index = new MutableInt(0); public static HashMap tasks = new HashMap<>(); - public ArrayList getChunkChunks(String world) { - String directory = new File(".").getAbsolutePath() + File.separator + world + File.separator + "region"; - - File folder = new File(directory); - File[] regionFiles = folder.listFiles(); - - ArrayList chunks = new ArrayList<>(); - - for (File file : regionFiles) { - String name = file.getName(); + @Override + public ArrayList getChunkChunks(final String world) { + final String directory = new File(".").getAbsolutePath() + File.separator + world + File.separator + "region"; + final File folder = new File(directory); + final File[] regionFiles = folder.listFiles(); + final ArrayList chunks = new ArrayList<>(); + for (final File file : regionFiles) { + final String name = file.getName(); if (name.endsWith("mca")) { - String[] split = name.split("\\."); + final String[] split = name.split("\\."); try { - int x = Integer.parseInt(split[1]); - int z = Integer.parseInt(split[2]); - ChunkLoc loc = new ChunkLoc(x, z); + final int x = Integer.parseInt(split[1]); + final int z = Integer.parseInt(split[2]); + final ChunkLoc loc = new ChunkLoc(x, z); chunks.add(loc); + } catch (final Exception e) { } - catch (Exception e) { } } } - for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) { - ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5); + for (final Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) { + final ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5); if (!chunks.contains(loc)) { chunks.add(loc); } } - return chunks; } + @Override public void deleteRegionFile(final String world, final ChunkLoc loc) { - BukkitTaskManager.runTaskAsync(new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca"; - File file = new File(directory); + final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca"; + final File file = new File(directory); PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)"); if (file.exists()) { file.delete(); @@ -104,21 +102,21 @@ public class ChunkManager extends AChunkManager { }); } - public Plot hasPlot(String world, ChunkLoc chunk) { - int x1 = chunk.x << 4; - int z1 = chunk.z << 4; - int x2 = x1 + 15; - int z2 = z1 + 15; - - Location bot = new Location(world, x1, 0, z1); + @Override + public Plot hasPlot(final String world, final ChunkLoc chunk) { + final int x1 = chunk.x << 4; + final int z1 = chunk.z << 4; + final int x2 = x1 + 15; + final int z2 = z1 + 15; + final Location bot = new Location(world, x1, 0, z1); Plot plot; - plot = PlotHelper.getCurrentPlot(bot); - if (plot != null && plot.owner != null) { + plot = PlotHelper.getCurrentPlot(bot); + if ((plot != null) && (plot.owner != null)) { return plot; } - Location top = new Location(world, x2, 0, z2); - plot = PlotHelper.getCurrentPlot(top); - if (plot != null && plot.owner != null) { + final Location top = new Location(world, x2, 0, z2); + plot = PlotHelper.getCurrentPlot(top); + if ((plot != null) && (plot.owner != null)) { return plot; } return null; @@ -141,69 +139,62 @@ public class ChunkManager extends AChunkManager { private static HashMap noteBlockContents; private static HashMap> bannerColors; private static HashMap bannerBase; - private static HashSet entities; /** * Copy a region to a new location (in the same world) */ + @Override public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) { index.increment(); final int relX = newPos.getX() - pos1.getX(); final int relZ = newPos.getZ() - pos1.getZ(); final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); - final World world = Bukkit.getWorld(pos1.getWorld()); - Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); - Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); - - Chunk c3 = world.getChunkAt((pos1.getX() + relX), (pos1.getZ() + relZ)); - Chunk c4 = world.getChunkAt((pos2.getX() + relX), (pos2.getZ() + relZ)); - + final Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); + final Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); + final Chunk c3 = world.getChunkAt((pos1.getX() + relX), (pos1.getZ() + relZ)); + final Chunk c4 = world.getChunkAt((pos2.getX() + relX), (pos2.getZ() + relZ)); final int sx = pos1.getX(); final int sz = pos1.getZ(); final int ex = pos2.getX(); final int ez = pos2.getZ(); - final int c1x = c1.getX(); final int c1z = c1.getZ(); final int c2x = c2.getX(); final int c2z = c2.getZ(); - final int c3x = c3.getX(); final int c3z = c3.getZ(); final int c4x = c4.getX(); final int c4z = c4.getZ(); - final ArrayList chunks = new ArrayList<>(); final ArrayList toGenerate = new ArrayList<>(); // Load chunks - for (int x = c1x; x <= c2x; x ++) { - for (int z = c1z; z <= c2z; z ++) { - Chunk chunk = world.getChunkAt(x << 4, z << 4); + for (int x = c1x; x <= c2x; x++) { + for (int z = c1z; z <= c2z; z++) { + final Chunk chunk = world.getChunkAt(x << 4, z << 4); toGenerate.add(chunk); } } - - final Plugin plugin = (Plugin) BukkitMain.THIS; + final Plugin plugin = BukkitMain.THIS; final Integer currentIndex = index.toInteger(); final int loadTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { - long start = System.currentTimeMillis(); - while (System.currentTimeMillis() - start < 25) { + final long start = System.currentTimeMillis(); + while ((System.currentTimeMillis() - start) < 25) { if (toGenerate.size() == 0) { Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); tasks.remove(currentIndex); - BukkitTaskManager.runTask(new Runnable() { + TaskManager.runTask(new Runnable() { @Override public void run() { index.increment(); // Copy entities initMaps(); - for (int x = c3x; x <= c4x; x ++) { - for (int z = c3z; z <= c4z; z ++) { - Chunk chunk = world.getChunkAt(x, z); + for (int x = c3x; x <= c4x; x++) { + for (int z = c3z; z <= c4z; z++) { + final Chunk chunk = world.getChunkAt(x, z); chunks.add(chunk); chunk.load(false); saveEntitiesIn(chunk, region); @@ -217,28 +208,26 @@ public class ChunkManager extends AChunkManager { final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { - long start = System.currentTimeMillis(); - while (System.currentTimeMillis() - start < 25) { - int x = mx.intValue(); + final long start = System.currentTimeMillis(); + while ((System.currentTimeMillis() - start) < 25) { + final int x = mx.intValue(); for (int z = sz; z <= ez; z++) { saveBlocks(world, maxY, x, z); for (int y = 1; y <= maxY; y++) { - Block block = world.getBlockAt(x, y, z); - int id = block.getTypeId(); - byte data = block.getData(); + final Block block = world.getBlockAt(x, y, z); + final int id = block.getTypeId(); + final byte data = block.getData(); SetBlockManager.setBlockManager.set(world, x + relX, y, z + relZ, id, data); - } } mx.increment(); if (x == ex) { // done! restoreBlocks(world, relX, relZ); SetBlockManager.setBlockManager.update(chunks); - - for (Chunk chunk : chunks) { + for (final Chunk chunk : chunks) { chunk.unload(true, true); } - BukkitTaskManager.runTaskLater(whenDone, 1); + TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); tasks.remove(currentIndex); return; @@ -246,13 +235,12 @@ public class ChunkManager extends AChunkManager { } }; }, 1, 1); - tasks.put(currentIndex, task); } }); return; } - Chunk chunk = toGenerate.get(0); + final Chunk chunk = toGenerate.get(0); toGenerate.remove(0); chunk.load(true); chunks.add(chunk); @@ -263,28 +251,25 @@ public class ChunkManager extends AChunkManager { return true; } + @Override public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { index.increment(); - final Plugin plugin = (Plugin) BukkitMain.THIS; - + final Plugin plugin = BukkitMain.THIS; final World world = Bukkit.getWorld(pos1.getWorld()); - Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); - Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); - + final Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); + final Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); final int sx = pos1.getX(); final int sz = pos1.getZ(); final int ex = pos2.getX(); final int ez = pos2.getZ(); - final int c1x = c1.getX(); final int c1z = c1.getZ(); final int c2x = c2.getX(); final int c2z = c2.getZ(); - final ArrayList chunks = new ArrayList(); - for (int x = c1x; x <= c2x; x ++) { - for (int z = c1z; z <= c2z; z ++) { - Chunk chunk = world.getChunkAt(x, z); + for (int x = c1x; x <= c2x; x++) { + for (int z = c1z; z <= c2z; z++) { + final Chunk chunk = world.getChunkAt(x, z); chunk.load(false); chunks.add(chunk); } @@ -295,22 +280,22 @@ public class ChunkManager extends AChunkManager { @Override public void run() { if (chunks.size() == 0) { - BukkitTaskManager.runTaskLater(whenDone, 1); + TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); tasks.remove(currentIndex); return; } CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); - Chunk chunk = chunks.get(0); + final Chunk chunk = chunks.get(0); chunks.remove(0); - int x = chunk.getX(); - int z = chunk.getZ(); - + final int x = chunk.getX(); + final int z = chunk.getZ(); boolean loaded = true; if (!chunk.isLoaded()) { - boolean result = chunk.load(false); + final boolean result = chunk.load(false); if (!result) { - loaded = false;; + loaded = false; + ; } if (!chunk.isLoaded()) { loaded = false; @@ -318,24 +303,23 @@ public class ChunkManager extends AChunkManager { } if (loaded) { initMaps(); - int absX = x << 4; - int absZ = z << 4; + final int absX = x << 4; + final int absZ = z << 4; boolean save = false; - if (x == c1x || z == c1z) { + if ((x == c1x) || (z == c1z)) { save = true; for (int X = 0; X < 16; X++) { for (int Z = 0; Z < 16; Z++) { - if ((X + absX < sx || Z + absZ < sz) || (X + absX > ex || Z + absZ > ez)) { + if ((((X + absX) < sx) || ((Z + absZ) < sz)) || (((X + absX) > ex) || ((Z + absZ) > ez))) { saveBlocks(world, maxY, X + absX, Z + absZ); } } } - } - else if (x == c2x || z == c2z) { + } else if ((x == c2x) || (z == c2z)) { for (int X = 0; X < 16; X++) { save = true; for (int Z = 0; Z < 16; Z++) { - if ((X + absX > ex || Z + absZ > ez) || (X + absX < sx || Z + absZ < sz)) { + if ((((X + absX) > ex) || ((Z + absZ) > ez)) || (((X + absX) < sx) || ((Z + absZ) < sz))) { saveBlocks(world, maxY, X + absX, Z + absZ); } } @@ -350,8 +334,7 @@ public class ChunkManager extends AChunkManager { restoreEntities(world, 0, 0); } chunk.unload(true, true); - SetBlockManager.setBlockManager.update(Arrays.asList( new Chunk[] {chunk})); - + SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } CURRENT_PLOT_CLEAR = null; } @@ -363,7 +346,6 @@ public class ChunkManager extends AChunkManager { public static void initMaps() { GENERATE_BLOCKS = new HashMap<>(); GENERATE_DATA = new HashMap<>(); - chestContents = new HashMap<>(); furnaceContents = new HashMap<>(); dispenserContents = new HashMap<>(); @@ -375,132 +357,134 @@ public class ChunkManager extends AChunkManager { skullData = new HashMap<>(); brewTime = new HashMap<>(); jukeDisc = new HashMap<>(); - spawnerData= new HashMap<>(); + spawnerData = new HashMap<>(); noteBlockContents = new HashMap<>(); signContents = new HashMap<>(); cmdData = new HashMap<>(); - bannerBase= new HashMap<>(); + bannerBase = new HashMap<>(); bannerColors = new HashMap<>(); - entities = new HashSet<>(); } - public static boolean isIn(RegionWrapper region, int x, int z) { - return (x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ); + public static boolean isIn(final RegionWrapper region, final int x, final int z) { + return ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)); } - public static void saveEntitiesOut(Chunk chunk, RegionWrapper region) { - for (Entity entity : chunk.getEntities()) { - Location loc = BukkitUtil.getLocation(entity); - int x = loc.getX(); - int z = loc.getZ(); + public static void saveEntitiesOut(final Chunk chunk, final RegionWrapper region) { + for (final Entity entity : chunk.getEntities()) { + final Location loc = BukkitUtil.getLocation(entity); + final int x = loc.getX(); + final int z = loc.getZ(); if (isIn(region, x, z)) { continue; } if (entity.getVehicle() != null) { continue; } - EntityWrapper wrap = new EntityWrapper(entity, (short) 2); + final EntityWrapper wrap = new EntityWrapper(entity, (short) 2); entities.add(wrap); } } - public static void saveEntitiesIn(Chunk chunk, RegionWrapper region) { - for (Entity entity : chunk.getEntities()) { - Location loc = BukkitUtil.getLocation(entity); - int x = loc.getX(); - int z = loc.getZ(); + public static void saveEntitiesIn(final Chunk chunk, final RegionWrapper region) { + for (final Entity entity : chunk.getEntities()) { + final Location loc = BukkitUtil.getLocation(entity); + final int x = loc.getX(); + final int z = loc.getZ(); if (!isIn(region, x, z)) { continue; } if (entity.getVehicle() != null) { continue; } - EntityWrapper wrap = new EntityWrapper(entity, (short) 2); + final EntityWrapper wrap = new EntityWrapper(entity, (short) 2); entities.add(wrap); } } - public static void restoreEntities(World world, int x_offset, int z_offset) { - for (EntityWrapper entity : entities) { + public static void restoreEntities(final World world, final int x_offset, final int z_offset) { + for (final EntityWrapper entity : entities) { try { entity.spawn(world, x_offset, z_offset); - } - catch (Exception e) { - System.out.print("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id +" : " + EntityType.fromId(entity.id)); + } catch (final Exception e) { + System.out.print("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id)); e.printStackTrace(); } } } - public static void restoreBlocks(World world, int x_offset, int z_offset) { - for (BlockLoc loc: chestContents.keySet()) { - Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); - BlockState state = block.getState(); + public static void restoreBlocks(final World world, final int x_offset, final int z_offset) { + for (final BlockLoc loc : chestContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Chest) { - Chest chest = (Chest) state; + final Chest chest = (Chest) state; chest.getInventory().setContents(chestContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate chest: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&c[WARN] Plot clear failed to regenerate chest: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } - - for (BlockLoc loc: signContents.keySet()) { - Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); - BlockState state = block.getState(); + for (final BlockLoc loc : signContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Sign) { - Sign sign = (Sign) state; + final Sign sign = (Sign) state; int i = 0; - for (String line : signContents.get(loc)) { + for (final String line : signContents.get(loc)) { sign.setLine(i, line); i++; } state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate sign: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&c[WARN] Plot clear failed to regenerate sign: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } - - for (BlockLoc loc: dispenserContents.keySet()) { - Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); - BlockState state = block.getState(); + for (final BlockLoc loc : dispenserContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Dispenser) { ((Dispenser) (state)).getInventory().setContents(dispenserContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : dropperContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Dropper) { ((Dropper) (state)).getInventory().setContents(dropperContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : beaconContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Beacon) { ((Beacon) (state)).getInventory().setContents(beaconContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate beacon: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : jukeDisc.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Jukebox) { ((Jukebox) (state)).setPlaying(Material.getMaterial(jukeDisc.get(loc))); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to restore jukebox: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : skullData.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Skull) { - Object[] data = skullData.get(loc); + final Object[] data = skullData.get(loc); if (data[0] != null) { ((Skull) (state)).setOwner((String) data[0]); } @@ -511,110 +495,117 @@ public class ChunkManager extends AChunkManager { ((Skull) (state)).setSkullType(SkullType.values()[(int) data[2]]); } state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to restore jukebox: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : hopperContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Hopper) { ((Hopper) (state)).getInventory().setContents(hopperContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate hopper: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&c[WARN] Plot clear failed to regenerate hopper: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } - - for (BlockLoc loc: noteBlockContents.keySet()) { - Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); - BlockState state = block.getState(); + for (final BlockLoc loc : noteBlockContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof NoteBlock) { ((NoteBlock) (state)).setNote(noteBlockContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate note block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : brewTime.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof BrewingStand) { ((BrewingStand) (state)).setBrewingTime(brewTime.get(loc)); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to restore brewing stand cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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()) { - Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); - BlockState state = block.getState(); + for (final BlockLoc loc : spawnerData.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof CreatureSpawner) { ((CreatureSpawner) (state)).setCreatureTypeId(spawnerData.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to restore spawner type: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : cmdData.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof CommandBlock) { ((CommandBlock) (state)).setCommand(cmdData.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to restore command block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : brewingStandContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof BrewingStand) { ((BrewingStand) (state)).getInventory().setContents(brewingStandContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate brewing stand: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : furnaceTime.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Furnace) { - Short[] time = furnaceTime.get(loc); + final Short[] time = furnaceTime.get(loc); ((Furnace) (state)).setBurnTime(time[0]); ((Furnace) (state)).setCookTime(time[1]); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to restore furnace cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&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); - BlockState state = block.getState(); + for (final BlockLoc loc : furnaceContents.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Furnace) { ((Furnace) (state)).getInventory().setContents(furnaceContents.get(loc)); state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate furnace: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&c[WARN] Plot clear failed to regenerate furnace: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } - - for (BlockLoc loc: bannerBase.keySet()) { - Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); - BlockState state = block.getState(); + for (final BlockLoc loc : bannerBase.keySet()) { + final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); + final BlockState state = block.getState(); if (state instanceof Banner) { - Banner banner = (Banner) state; - byte base = bannerBase.get(loc); - ArrayList colors = bannerColors.get(loc); + final Banner banner = (Banner) state; + final byte base = bannerBase.get(loc); + final ArrayList colors = bannerColors.get(loc); banner.setBaseColor(DyeColor.values()[base]); - for (Byte[] color : colors) { + for (final Byte[] color : colors) { banner.addPattern(new Pattern(DyeColor.getByDyeData(color[1]), PatternType.values()[color[0]])); } state.update(true); + } else { + PlotSquared.log("&c[WARN] Plot clear failed to regenerate banner: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset); } - else { PlotSquared.log("&c[WARN] Plot clear failed to regenerate banner: "+loc.x + x_offset+","+loc.y+","+loc.z + z_offset); } } } - public static void saveBlocks(World world, int maxY, int x, int z) { - HashMap ids = new HashMap<>(); - HashMap datas = new HashMap<>(); + public static void saveBlocks(final World world, final int maxY, final int x, final int z) { + final HashMap ids = new HashMap<>(); + final HashMap datas = new HashMap<>(); for (short y = 1; y < maxY; y++) { - Block block = world.getBlockAt(x, y, z); - short id = (short) block.getTypeId(); + final Block block = world.getBlockAt(x, y, z); + final short id = (short) block.getTypeId(); if (id != 0) { ids.put(y, id); - byte data = block.getData(); + final byte data = block.getData(); if (data != 0) { datas.put(y, data); } @@ -622,109 +613,111 @@ public class ChunkManager extends AChunkManager { switch (id) { case 54: bl = new BlockLoc(x, y, z); - InventoryHolder chest = (InventoryHolder) block.getState(); - ItemStack[] inventory = chest.getInventory().getContents().clone(); + final InventoryHolder chest = (InventoryHolder) block.getState(); + final ItemStack[] inventory = chest.getInventory().getContents().clone(); chestContents.put(bl, inventory); break; case 52: bl = new BlockLoc(x, y, z); - CreatureSpawner spawner = (CreatureSpawner) block.getState(); - String type = spawner.getCreatureTypeId(); - if (type != null && type.length() != 0) { + final CreatureSpawner spawner = (CreatureSpawner) block.getState(); + final String type = spawner.getCreatureTypeId(); + if ((type != null) && (type.length() != 0)) { spawnerData.put(bl, type); } break; case 137: bl = new BlockLoc(x, y, z); - CommandBlock cmd = (CommandBlock) block.getState(); - String string = cmd.getCommand(); - if (string != null && string.length() > 0) { + final CommandBlock cmd = (CommandBlock) block.getState(); + final String string = cmd.getCommand(); + if ((string != null) && (string.length() > 0)) { cmdData.put(bl, string); } break; - case 63: case 68: case 323: + case 63: + case 68: + case 323: bl = new BlockLoc(x, y, z); - Sign sign = (Sign) block.getState(); + final Sign sign = (Sign) block.getState(); sign.getLines(); signContents.put(bl, sign.getLines().clone()); break; - case 61: case 62: + case 61: + case 62: bl = new BlockLoc(x, y, z); - Furnace furnace = (Furnace) block.getState(); - short burn = furnace.getBurnTime(); - short cook = furnace.getCookTime(); - ItemStack[] invFur = furnace.getInventory().getContents().clone(); + final Furnace furnace = (Furnace) block.getState(); + final short burn = furnace.getBurnTime(); + final short cook = furnace.getCookTime(); + final ItemStack[] invFur = furnace.getInventory().getContents().clone(); furnaceContents.put(bl, invFur); if (cook != 0) { - furnaceTime.put(bl, new Short[] {burn, cook}); + furnaceTime.put(bl, new Short[] { burn, cook }); } break; case 23: bl = new BlockLoc(x, y, z); - Dispenser dispenser = (Dispenser) block.getState(); - ItemStack[] invDis = dispenser.getInventory().getContents().clone(); + final Dispenser dispenser = (Dispenser) block.getState(); + final ItemStack[] invDis = dispenser.getInventory().getContents().clone(); dispenserContents.put(bl, invDis); break; case 158: bl = new BlockLoc(x, y, z); - Dropper dropper = (Dropper) block.getState(); - ItemStack[] invDro = dropper.getInventory().getContents().clone(); + final Dropper dropper = (Dropper) block.getState(); + final ItemStack[] invDro = dropper.getInventory().getContents().clone(); dropperContents.put(bl, invDro); break; case 117: bl = new BlockLoc(x, y, z); - BrewingStand brewingStand = (BrewingStand) block.getState(); - short time = (short) brewingStand.getBrewingTime(); + final BrewingStand brewingStand = (BrewingStand) block.getState(); + final short time = (short) brewingStand.getBrewingTime(); if (time > 0) { brewTime.put(bl, time); } - ItemStack[] invBre = brewingStand.getInventory().getContents().clone(); + final ItemStack[] invBre = brewingStand.getInventory().getContents().clone(); brewingStandContents.put(bl, invBre); break; case 25: bl = new BlockLoc(x, y, z); - NoteBlock noteBlock = (NoteBlock) block.getState(); - Note note = noteBlock.getNote(); + final NoteBlock noteBlock = (NoteBlock) block.getState(); + final Note note = noteBlock.getNote(); noteBlockContents.put(bl, note); break; case 138: bl = new BlockLoc(x, y, z); - Beacon beacon = (Beacon) block.getState(); - ItemStack[] invBea = beacon.getInventory().getContents().clone(); + final Beacon beacon = (Beacon) block.getState(); + final ItemStack[] invBea = beacon.getInventory().getContents().clone(); beaconContents.put(bl, invBea); break; case 84: bl = new BlockLoc(x, y, z); - Jukebox jukebox = (Jukebox) block.getState(); - Material playing = jukebox.getPlaying(); + final Jukebox jukebox = (Jukebox) block.getState(); + final Material playing = jukebox.getPlaying(); if (playing != null) { jukeDisc.put(bl, (short) playing.getId()); } break; case 154: bl = new BlockLoc(x, y, z); - Hopper hopper = (Hopper) block.getState(); - ItemStack[] invHop = hopper.getInventory().getContents().clone(); + final Hopper hopper = (Hopper) block.getState(); + final ItemStack[] invHop = hopper.getInventory().getContents().clone(); hopperContents.put(bl, invHop); break; case 397: bl = new BlockLoc(x, y, z); - Skull skull = (Skull) block.getState(); - String o = skull.getOwner(); - byte skulltype = getOrdinal(SkullType.values(),skull.getSkullType()); - BlockFace te = skull.getRotation(); - short rot = (short) getOrdinal(BlockFace.values(), skull.getRotation()); - skullData.put(bl, new Object[] {o, rot, skulltype}); + final Skull skull = (Skull) block.getState(); + final String o = skull.getOwner(); + final byte skulltype = getOrdinal(SkullType.values(), skull.getSkullType()); + skull.getRotation(); + final short rot = getOrdinal(BlockFace.values(), skull.getRotation()); + skullData.put(bl, new Object[] { o, rot, skulltype }); break; case 176: case 177: bl = new BlockLoc(x, y, z); - Banner banner = (Banner) block.getState(); - byte base = getOrdinal(DyeColor.values(), banner.getBaseColor()); - ArrayList types = new ArrayList<>(); - - for (Pattern pattern : banner.getPatterns()) { - types.add(new Byte[] {getOrdinal(PatternType.values(), pattern.getPattern()), pattern.getColor().getDyeData() }); + final Banner banner = (Banner) block.getState(); + final byte base = getOrdinal(DyeColor.values(), banner.getBaseColor()); + final ArrayList types = new ArrayList<>(); + for (final Pattern pattern : banner.getPatterns()) { + types.add(new Byte[] { getOrdinal(PatternType.values(), pattern.getPattern()), pattern.getColor().getDyeData() }); } bannerBase.put(bl, base); bannerColors.put(bl, types); @@ -732,12 +725,12 @@ public class ChunkManager extends AChunkManager { } } } - ChunkLoc loc = new ChunkLoc(x, z); + final ChunkLoc loc = new ChunkLoc(x, z); GENERATE_BLOCKS.put(loc, ids); GENERATE_DATA.put(loc, datas); } - private static byte getOrdinal(Object[] list, Object value) { + private static byte getOrdinal(final Object[] list, final Object value) { for (byte i = 0; i < list.length; i++) { if (list[i].equals(value)) { return i; @@ -746,6 +739,7 @@ public class ChunkManager extends AChunkManager { return 0; } + @Override public void clearAllEntities(final Plot plot) { final List entities = BukkitUtil.getEntities(plot.world); for (final Entity entity : entities) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java index ef940ce24..a9f852c4a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util.bukkit; import java.io.BufferedReader; @@ -99,7 +98,7 @@ public class Metrics { * The scheduled task */ private volatile BukkitTask task = null; - + public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -121,7 +120,7 @@ public class Metrics { this.guid = this.configuration.getString("guid"); this.debug = this.configuration.getBoolean("debug", false); } - + /** * GZip compress a string of bytes * @@ -147,7 +146,7 @@ public class Metrics { } return baos.toByteArray(); } - + /** * Appends a json encoded key/value pair to the given string builder. * @@ -178,7 +177,7 @@ public class Metrics { json.append(escapeJSON(value)); } } - + /** * Escape a string to create a valid JSON string * @@ -222,7 +221,7 @@ public class Metrics { builder.append('"'); return builder.toString(); } - + /** * Encode text as UTF-8 * @@ -233,7 +232,7 @@ public class Metrics { private static String urlEncode(final String text) throws UnsupportedEncodingException { return URLEncoder.encode(text, "UTF-8"); } - + /** * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics * website. Plotters can be added to the graph object returned. @@ -253,7 +252,7 @@ public class Metrics { // and return back return graph; } - + /** * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend * @@ -265,7 +264,7 @@ public class Metrics { } this.graphs.add(graph); } - + /** * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 @@ -286,7 +285,7 @@ public class Metrics { // Begin hitting the server with glorious data this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() { private boolean firstPost = true; - + @Override public void run() { try { @@ -330,7 +329,7 @@ public class Metrics { return true; } } - + /** * Has the server owner denied plugin metrics? * @@ -355,7 +354,7 @@ public class Metrics { return this.configuration.getBoolean("opt-out", false); } } - + /** * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. * @@ -377,7 +376,7 @@ public class Metrics { } } } - + /** * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * @@ -400,7 +399,7 @@ public class Metrics { } } } - + /** * Gets the File object of the config file that should be used to store data such as the GUID and opt-out status * @@ -417,7 +416,7 @@ public class Metrics { // return => base/plugins/PluginMetrics/config.yml return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml"); } - + /** * Generic method that posts a plugin to the metrics website */ @@ -442,7 +441,6 @@ public class Metrics { } } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { } - // END server software specific section -- all code below does not use // any code outside of this class / Java // Construct the post data @@ -557,7 +555,7 @@ public class Metrics { } } } - + /** * Check if mineshafter is present. If it is, we need to bypass it to send POST requests * @@ -571,7 +569,7 @@ public class Metrics { return false; } } - + /** * Represents a custom graph on the website */ @@ -585,11 +583,11 @@ public class Metrics { * The set of plotters that are contained within this graph */ private final Set plotters = new LinkedHashSet(); - + private Graph(final String name) { this.name = name; } - + /** * Gets the graph's name * @@ -598,7 +596,7 @@ public class Metrics { public String getName() { return this.name; } - + /** * Add a plotter to the graph, which will be used to plot entries * @@ -607,7 +605,7 @@ public class Metrics { public void addPlotter(final Plotter plotter) { this.plotters.add(plotter); } - + /** * Remove a plotter from the graph * @@ -616,7 +614,7 @@ public class Metrics { public void removePlotter(final Plotter plotter) { this.plotters.remove(plotter); } - + /** * Gets an unmodifiable set of the plotter objects in the graph * @@ -625,12 +623,12 @@ public class Metrics { public Set getPlotters() { return Collections.unmodifiableSet(this.plotters); } - + @Override public int hashCode() { return this.name.hashCode(); } - + @Override public boolean equals(final Object object) { if (!(object instanceof Graph)) { @@ -639,14 +637,14 @@ public class Metrics { final Graph graph = (Graph) object; return graph.name.equals(this.name); } - + /** * Called when the server owner decides to opt-out of BukkitMetrics while the server is running. */ protected void onOptOut() { } } - + /** * Interface used to collect custom data for a plugin */ @@ -655,14 +653,14 @@ public class Metrics { * The plot's name */ private final String name; - + /** * Construct a plotter with the default plot name */ public Plotter() { this("Default"); } - + /** * Construct a plotter with a specific plot name * @@ -671,7 +669,7 @@ public class Metrics { public Plotter(final String name) { this.name = name; } - + /** * Get the current value for the plotted point. Since this function defers to an external function it may or may * not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called @@ -680,7 +678,7 @@ public class Metrics { * @return the current value for the point to be plotted. */ public abstract int getValue(); - + /** * Get the column name for the plotted point * @@ -689,18 +687,18 @@ public class Metrics { public String getColumnName() { return this.name; } - + /** * Called after the website graphs have been updated */ public void reset() { } - + @Override public int hashCode() { return getColumnName().hashCode(); } - + @Override public boolean equals(final Object object) { if (!(object instanceof Plotter)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index bd038bb43..a3ce50d62 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util.bukkit; import org.bukkit.entity.Player; @@ -45,8 +44,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; * @author Empire92 */ public class PWE { - - public static void setMask(final Player p, final Location l, boolean force) { + public static void setMask(final Player p, final Location l, final boolean force) { try { LocalSession s; if (PlotSquared.worldEdit == null) { @@ -61,21 +59,17 @@ public class PWE { if (id != null) { final Plot plot = PlotSquared.getPlots(l.getWorld()).get(id); if (plot != null) { - if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) { - return; - } - boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)); + if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) { + return; + } + final boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)); if (r) { final String w = l.getWorld(); - final Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id); final Location tloc = PlotHelper.getPlotTopLoc(w, plot.id); - final Vector bvec = new Vector(bloc.getX() + 1, bloc.getY(), bloc.getZ() + 1); final Vector tvec = new Vector(tloc.getX(), tloc.getY(), tloc.getZ()); - final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(p).getWorld(); - final CuboidRegion region = new CuboidRegion(lw, bvec, tvec); final RegionMask mask = new RegionMask(region); s.setMask(mask); @@ -105,11 +99,11 @@ public class PWE { } return !noMask(s); } - + public static boolean noMask(final LocalSession s) { return s.getMask() == null; } - + @SuppressWarnings("deprecation") public static void setNoMask(final Player p) { try { @@ -126,12 +120,12 @@ public class PWE { // } } - + public static void removeMask(final Player p, final LocalSession s) { final Mask mask = null; s.setMask(mask); } - + public static void removeMask(final Player p) { try { LocalSession s; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java index ade190a48..3e4b404e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util.bukkit; import java.util.ArrayList; @@ -51,9 +50,8 @@ import com.intellectualcrafters.plot.util.PlotHelper; * * @author Citymonstret */ -@SuppressWarnings("javadoc") public class PlayerFunctions { - - +@SuppressWarnings("javadoc") +public class PlayerFunctions { /** * Clear a plot. Use null player if no player is present * @param player @@ -62,31 +60,27 @@ import com.intellectualcrafters.plot.util.PlotHelper; * @param isDelete */ public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { - if (runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return; } final PlotManager manager = PlotSquared.getPlotManager(world); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final int prime = 31; int h = 1; h = (prime * h) + pos1.getX(); h = (prime * h) + pos1.getZ(); state = h; - final long start = System.currentTimeMillis(); final Location location = PlotHelper.getPlotHomeDefault(plot); - PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); runners.put(plot, 1); if (plotworld.TERRAIN != 0) { final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { - if (player != null && player.isOnline()) { + if ((player != null) && player.isOnline()) { PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); } runners.remove(plot); @@ -94,12 +88,12 @@ import com.intellectualcrafters.plot.util.PlotHelper; }); return; } - Runnable run = new Runnable() { + final Runnable run = new Runnable() { @Override public void run() { PlotHelper.setBiome(world, plot, Biome.FOREST); runners.remove(plot); - if (player != null && player.isOnline()) { + if ((player != null) && player.isOnline()) { PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); } update(location); @@ -118,7 +112,6 @@ import com.intellectualcrafters.plot.util.PlotHelper; * @return */ public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) { final double cost = plotIds.size() * plotworld.MERGE_PRICE; @@ -154,21 +147,16 @@ import com.intellectualcrafters.plot.util.PlotHelper; public static boolean isInPlot(final Player player) { return getCurrentPlot(player) != null; } - + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId 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; } - if (plot2 != null) { pos2 = getTopPlot(world, plot2).id; } - final ArrayList myplots = new ArrayList<>(); for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -177,9 +165,8 @@ import com.intellectualcrafters.plot.util.PlotHelper; } return myplots; } - + public static Plot getBottomPlot(final String world, final Plot plot) { - if (plot.settings.getMerged(0)) { final Plot p = PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)); if (p == null) { @@ -196,9 +183,8 @@ import com.intellectualcrafters.plot.util.PlotHelper; } return plot; } - + public static Plot getTopPlot(final String world, final Plot plot) { - if (plot.settings.getMerged(2)) { return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); } @@ -207,7 +193,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; } return plot; } - + /** * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) * @@ -223,9 +209,8 @@ import com.intellectualcrafters.plot.util.PlotHelper; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); - } - + /** * Returns the plot id at a location (mega plots are considered) * @@ -240,16 +225,15 @@ import com.intellectualcrafters.plot.util.PlotHelper; return null; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - PlotId id = manager.getPlotId(plotworld, loc.getX(),loc.getY(), loc.getZ()); - - if (id!=null && plotworld.TYPE == 2) { - if (ClusterManager.getCluster(world, id) == null) { - return null; - } + final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ()); + if ((id != null) && (plotworld.TYPE == 2)) { + if (ClusterManager.getCluster(world, id) == null) { + return null; + } } return id; } - + /** * Returns the plot a player is currently in. * @@ -267,12 +251,11 @@ import com.intellectualcrafters.plot.util.PlotHelper; return null; } if (PlotSquared.getPlots(world).containsKey(id)) { - return PlotSquared.getPlots(world).get(id); + return PlotSquared.getPlots(world).get(id); } return new Plot(id, null, new ArrayList(), new ArrayList(), world); - } - + /** * Updates a given plot with another instance * @@ -284,7 +267,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; public static void set(final Plot plot) { PlotSquared.updatePlot(plot); } - + /** * Get the plots for a player * @@ -299,7 +282,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; } return p; } - + /** * Get the number of plots for a player * @@ -317,7 +300,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; } return count; } - + /** * Get the maximum number of plots a player is allowed * @@ -328,7 +311,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; public static int getAllowedPlots(final Player p) { return BukkitMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); } - + /** * @return PlotSquared.getPlots(); * @@ -359,7 +342,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; } plr.sendMessage(msg); } - + /** * Send a message to the player * @@ -371,7 +354,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; public static boolean sendMessage(final Player plr, final String msg) { return sendMessage(plr, msg, true); } - + public static boolean sendMessage(final Player plr, final String msg, final boolean prefix) { if ((msg.length() > 0) && !msg.equals("")) { if (plr == null) { @@ -382,7 +365,7 @@ import com.intellectualcrafters.plot.util.PlotHelper; } return true; } - + /** * Send a message to the player * @@ -403,12 +386,10 @@ import com.intellectualcrafters.plot.util.PlotHelper; } if (plr == null) { PlotSquared.log(msg); - } - else { + } else { sendMessage(plr, msg, c.usePrefix()); } } return true; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java index e6c2d2178..faa2cd2d3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java @@ -21,27 +21,23 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * @author Empire92 */ public class SendChunk { - // Ref Class private static final RefClass classWorld = getRefClass("{nms}.World"); private static final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer"); private static final RefClass classChunkCoordIntPair = getRefClass("{nms}.ChunkCoordIntPair"); private static final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); private static final RefClass classChunk = getRefClass("{nms}.Chunk"); - // Ref Method private static RefMethod methodGetHandle; - // Ref Field private static RefField chunkCoordIntPairQueue; private static RefField players; private static RefField locX; private static RefField locZ; private static RefField world; - // Ref Constructor private static RefConstructor ChunkCoordIntPairCon; - + /** * Constructor * @@ -50,25 +46,20 @@ public class SendChunk { public SendChunk() throws NoSuchMethodException { methodGetHandle = classCraftChunk.getMethod("getHandle"); chunkCoordIntPairQueue = classEntityPlayer.getField("chunkCoordIntPairQueue"); - players = classWorld.getField("players"); locX = classEntityPlayer.getField("locX"); locZ = classEntityPlayer.getField("locZ"); - world = classChunk.getField("world"); - ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); } - public static void sendChunk(List chunks) { + public static void sendChunk(final List chunks) { int diffx, diffz; final int view = Bukkit.getServer().getViewDistance() << 4; for (final Chunk chunk : chunks) { final Object c = methodGetHandle.of(chunk).call(); - final Object w = world.of(c).get(); final Object p = players.of(w).get(); - for (final Object ep : (List) p) { final int x = ((Double) locX.of(ep).get()).intValue(); final int z = ((Double) locZ.of(ep).get()).intValue(); @@ -82,11 +73,11 @@ public class SendChunk { } } } - - public static void sendChunk(String worldname, List locs) { - World myworld = Bukkit.getWorld(worldname); - ArrayList chunks = new ArrayList<>(); - for (ChunkLoc loc : locs) { + + public static void sendChunk(final String worldname, final List locs) { + final World myworld = Bukkit.getWorld(worldname); + final ArrayList chunks = new ArrayList<>(); + for (final ChunkLoc loc : locs) { chunks.add(myworld.getChunkAt(loc.x, loc.z)); } sendChunk(chunks); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index 7cd76e171..129f0cb6a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; @@ -38,18 +37,15 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * @author Empire92 */ public class SetBlockFast extends SetBlockManager { - - private static final RefClass classBlock = getRefClass("{nms}.Block"); private static final RefClass classChunk = getRefClass("{nms}.Chunk"); private static final RefClass classWorld = getRefClass("{nms}.World"); private static final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld"); - private static RefMethod methodGetHandle; private static RefMethod methodGetChunkAt; private static RefMethod methodA; private static RefMethod methodGetById; - + /** * Constructor * @@ -61,7 +57,7 @@ public class SetBlockFast extends SetBlockManager { methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class); methodGetById = classBlock.getMethod("getById", int.class); } - + /** * Set the block at the location * @@ -81,20 +77,20 @@ public class SetBlockFast extends SetBlockManager { final Object block = methodGetById.of(null).call(blockId); methodA.of(chunk).call(x & 0x0f, y, z & 0x0f, block, data); } - + /** * Update chunks * * @param player Player whose chunks we're updating */ @Override - public void update(List chunks) { + public void update(final List chunks) { if (chunks.size() == 0) { return; } if (!PlotHelper.canSendChunk) { - World world = chunks.get(0).getWorld(); - for (Chunk chunk : chunks) { + final World world = chunks.get(0).getWorld(); + for (final Chunk chunk : chunks) { world.refreshChunk(chunk.getX(), chunk.getZ()); } return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index b1ed0ca6f..1872d6607 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -18,7 +18,6 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// - package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; @@ -40,24 +39,16 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * @author Empire92 */ public class SetBlockFast_1_8 extends SetBlockManager { - - private static final RefClass classBlock = getRefClass("{nms}.Block"); private static final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); private static final RefClass classIBlockData = getRefClass("{nms}.IBlockData"); - - - - private static final RefClass classChunk = getRefClass("{nms}.Chunk"); private static final RefClass classWorld = getRefClass("{nms}.World"); private static final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld"); - private static RefMethod methodGetHandle; private static RefMethod methodGetChunkAt; private static RefMethod methodA; private static RefMethod methodGetByCombinedId; - private static RefConstructor constructorBlockPosition; /** @@ -66,15 +57,13 @@ public class SetBlockFast_1_8 extends SetBlockManager { * @throws NoSuchMethodException */ public SetBlockFast_1_8() throws NoSuchMethodException { - constructorBlockPosition = classBlockPosition.getConstructor(int.class, int.class, int.class); methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class); - methodGetHandle = classCraftWorld.getMethod("getHandle"); methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); methodA = classChunk.getMethod("a", classBlockPosition, classIBlockData); } - + /** * Set the block at the location * @@ -107,7 +96,7 @@ public class SetBlockFast_1_8 extends SetBlockManager { case 33: case 151: case 178: { - Block block = world.getBlockAt(x, y, z); + final Block block = world.getBlockAt(x, y, z); if (block.getData() == data) { if (block.getTypeId() != id) { block.setTypeId(id, false); @@ -124,25 +113,24 @@ public class SetBlockFast_1_8 extends SetBlockManager { } final Object w = methodGetHandle.of(world).call(); final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); - final Object pos = constructorBlockPosition.create((int) (x & 0x0f), y, (int) (z & 0x0f)); + final Object pos = constructorBlockPosition.create(x & 0x0f, y, z & 0x0f); final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12)); methodA.of(chunk).call(pos, combined); - } - + /** * Update chunks * * @param player Player whose chunks we're updating */ @Override - public void update(List chunks) { + public void update(final List chunks) { if (chunks.size() == 0) { return; } if (!PlotHelper.canSendChunk) { - World world = chunks.get(0).getWorld(); - for (Chunk chunk : chunks) { + final World world = chunks.get(0).getWorld(); + for (final Chunk chunk : chunks) { world.refreshChunk(chunk.getX(), chunk.getZ()); } return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java index 2fbce500a..1ea698a31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java @@ -7,11 +7,9 @@ import org.bukkit.World; import org.bukkit.block.Block; public class SetBlockSlow extends SetBlockManager { - @Override - public void set(World world, int x, int y, int z, int id, byte data) { - - Block block = world.getBlockAt(x, y, z); + public void set(final World world, final int x, final int y, final int z, final int id, final byte data) { + final Block block = world.getBlockAt(x, y, z); if (block.getData() == data) { if (block.getTypeId() != id) { block.setTypeId(id, false); @@ -24,10 +22,9 @@ public class SetBlockSlow extends SetBlockManager { } } } - + @Override - public void update(List chunks) { + public void update(final List chunks) { // TODO Auto-generated method stub } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index c818ce8c8..be8ac63fc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -21,19 +21,17 @@ import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper; public class UUIDHandler { - public static boolean CACHED = false; public static UUIDWrapper uuidWrapper = null; - /** * Map containing names and UUIDs * * @see com.google.common.collect.BiMap */ private final static BiMap uuidMap = HashBiMap.create(new HashMap()); - + public static void add(final StringWrapper name, final UUID uuid) { - if (uuid == null || name == null) { + if ((uuid == null) || (name == null)) { return; } if (!uuidMap.containsKey(name) && !uuidMap.inverse().containsKey(uuid)) { @@ -64,7 +62,7 @@ public class UUIDHandler { public static boolean uuidExists(final UUID uuid) { return uuidMap.containsValue(uuid); } - + /** * Check if a name is cached * @@ -82,126 +80,117 @@ public class UUIDHandler { if (CACHED) { return; } - PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching"); + PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching"); UUIDHandler.CACHED = true; - HashSet worlds = new HashSet<>(); + final HashSet worlds = new HashSet<>(); worlds.add(Bukkit.getWorlds().get(0).getName()); worlds.add("world"); - - HashSet uuids = new HashSet<>(); - HashSet names = new HashSet<>(); - - for (String worldname : worlds) { + final HashSet uuids = new HashSet<>(); + final HashSet names = new HashSet<>(); + for (final String worldname : worlds) { // Getting UUIDs - File playerdataFolder = new File(worldname + File.separator + "playerdata"); + final File playerdataFolder = new File(worldname + File.separator + "playerdata"); String[] dat = playerdataFolder.list(new FilenameFilter() { - public boolean accept(File f, String s) { + @Override + public boolean accept(final File f, final String s) { return s.endsWith(".dat"); } }); if (dat != null) { - for (String current : dat) { - String s = current.replaceAll(".dat$", ""); + for (final String current : dat) { + final String s = current.replaceAll(".dat$", ""); try { - UUID uuid = UUID.fromString(s); + final UUID uuid = UUID.fromString(s); uuids.add(uuid); - } - catch (Exception e) { - PlotSquared.log(C.PREFIX.s() + "Invalid playerdata: "+current); + } catch (final Exception e) { + PlotSquared.log(C.PREFIX.s() + "Invalid playerdata: " + current); } } } - // Getting names - File playersFolder = new File(worldname + File.separator + "players"); + final File playersFolder = new File(worldname + File.separator + "players"); dat = playersFolder.list(new FilenameFilter() { - public boolean accept(File f, String s) { + @Override + public boolean accept(final File f, final String s) { return s.endsWith(".dat"); } }); if (dat != null) { - for (String current : dat) { + for (final String current : dat) { names.add(current.replaceAll(".dat$", "")); } } } - UUIDWrapper wrapper = new DefaultUUIDWrapper(); + final UUIDWrapper wrapper = new DefaultUUIDWrapper(); for (UUID uuid : uuids) { try { - OfflinePlayer player = wrapper.getOfflinePlayer(uuid); + final OfflinePlayer player = wrapper.getOfflinePlayer(uuid); uuid = UUIDHandler.uuidWrapper.getUUID(player); - StringWrapper name = new StringWrapper(player.getName()); + final StringWrapper name = new StringWrapper(player.getName()); add(name, uuid); - } - catch (Throwable e) { - PlotSquared.log(C.PREFIX.s() + "&6Invalid playerdata: "+uuid.toString() + ".dat"); + } catch (final Throwable e) { + PlotSquared.log(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat"); } } - for (String name : names) { - OfflinePlayer player = Bukkit.getOfflinePlayer(name); - UUID uuid = UUIDHandler.uuidWrapper.getUUID(player); - StringWrapper nameWrap = new StringWrapper(name); + for (final String name : names) { + final OfflinePlayer player = Bukkit.getOfflinePlayer(name); + final UUID uuid = UUIDHandler.uuidWrapper.getUUID(player); + final StringWrapper nameWrap = new StringWrapper(name); add(nameWrap, uuid); } - // add the Everyone '*' UUID add(new StringWrapper("*"), DBFunc.everyone); - PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); } - public static UUID getUUID(Player player) { + public static UUID getUUID(final Player player) { return UUIDHandler.uuidWrapper.getUUID(player); } - public static UUID getUUID(OfflinePlayer player) { + public static UUID getUUID(final OfflinePlayer player) { return UUIDHandler.uuidWrapper.getUUID(player); } - public static String getName(UUID uuid) { + public static String getName(final UUID uuid) { if (uuid == null) { return null; } - // check online - Player player = uuidWrapper.getPlayer(uuid); + final Player player = uuidWrapper.getPlayer(uuid); if (player != null) { return player.getName(); } - // check cache - StringWrapper name = UUIDHandler.uuidMap.inverse().get(uuid); + final StringWrapper name = UUIDHandler.uuidMap.inverse().get(uuid); if (name != null) { return name.value; } return null; } - + public static UUID getUUID(final String name) { - if (name == null || name.length() == 0) { + if ((name == null) || (name.length() == 0)) { return null; } // check online - Player player = Bukkit.getPlayer(name); + final Player player = Bukkit.getPlayer(name); if (player != null) { - UUID uuid = UUIDHandler.uuidWrapper.getUUID(player); + final UUID uuid = UUIDHandler.uuidWrapper.getUUID(player); add(new StringWrapper(name), uuid); return uuid; } - // check cache - StringWrapper wrap = new StringWrapper(name); + final StringWrapper wrap = new StringWrapper(name); UUID uuid = UUIDHandler.uuidMap.get(wrap); if (uuid != null) { return uuid; } // Read from disk OR convert directly to offline UUID - if (Settings.UUID_FROM_DISK || uuidWrapper instanceof OfflineUUIDWrapper) { + if (Settings.UUID_FROM_DISK || (uuidWrapper instanceof OfflineUUIDWrapper)) { uuid = UUIDHandler.uuidWrapper.getUUID(name); add(new StringWrapper(name), uuid); return uuid; } - return null; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java index 169c9bcde..f251dd4d1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java @@ -7,30 +7,28 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; public class DefaultUUIDWrapper extends UUIDWrapper { - @Override public UUID getUUID(final Player player) { return player.getUniqueId(); } - + @Override public UUID getUUID(final OfflinePlayer player) { return player.getUniqueId(); } - + @Override public OfflinePlayer getOfflinePlayer(final UUID uuid) { return Bukkit.getOfflinePlayer(uuid); } - + @Override public Player getPlayer(final UUID uuid) { return Bukkit.getPlayer(uuid); } - + @Override - public UUID getUUID(String name) { + public UUID getUUID(final String name) { return Bukkit.getOfflinePlayer(name).getUniqueId(); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java index 45580f52c..1957cc0a4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java @@ -15,16 +15,15 @@ import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class OfflineUUIDWrapper extends UUIDWrapper { - private Method getOnline = null; - private Object[] arg = new Object[0]; - + private final Object[] arg = new Object[0]; + public OfflineUUIDWrapper() { try { this.getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { e.printStackTrace(); - } catch (SecurityException e) { + } catch (final SecurityException e) { e.printStackTrace(); } } @@ -33,23 +32,23 @@ public class OfflineUUIDWrapper extends UUIDWrapper { public UUID getUUID(final Player player) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); } - + @Override public UUID getUUID(final OfflinePlayer player) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); } - + @Override public OfflinePlayer getOfflinePlayer(final UUID uuid) { final BiMap map = UUIDHandler.getUuidMap().inverse(); String name; try { name = map.get(uuid).value; - } catch (NullPointerException e) { + } catch (final NullPointerException e) { name = null; } if (name != null) { - OfflinePlayer op = Bukkit.getOfflinePlayer(name); + final OfflinePlayer op = Bukkit.getOfflinePlayer(name); if (op.hasPlayedBefore()) { return op; } @@ -61,25 +60,23 @@ public class OfflineUUIDWrapper extends UUIDWrapper { } return null; } - + public Player[] getOnlinePlayers() { - if (getOnline == null) { + if (this.getOnline == null) { return Bukkit.getOnlinePlayers().toArray(new Player[0]); } try { - Object players = getOnline.invoke(Bukkit.getServer(), arg); + final Object players = this.getOnline.invoke(Bukkit.getServer(), this.arg); if (players instanceof Player[]) { return (Player[]) players; - } - else { + } else { @SuppressWarnings("unchecked") - Collection p = (Collection) players; + final Collection p = (Collection) players; return p.toArray(new Player[0]); } - } - catch (Exception e) { + } catch (final Exception e) { System.out.print("Failed to resolve online players"); - getOnline = null; + this.getOnline = null; return Bukkit.getOnlinePlayers().toArray(new Player[0]); } } @@ -93,10 +90,9 @@ public class OfflineUUIDWrapper extends UUIDWrapper { } return null; } - + @Override - public UUID getUUID(String name) { + public UUID getUUID(final String name) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java index 516309400..09b3fa649 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java @@ -7,12 +7,12 @@ import org.bukkit.entity.Player; public abstract class UUIDWrapper { public abstract UUID getUUID(Player player); - + public abstract UUID getUUID(OfflinePlayer player); public abstract UUID getUUID(String name); - + public abstract OfflinePlayer getOfflinePlayer(UUID uuid); - + public abstract Player getPlayer(UUID uuid); } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java b/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java index 7ef58979a..b05140163 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java @@ -10,8 +10,10 @@ import java.lang.annotation.Target; * * @author Citymonstret */ -@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Translation { +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Translation { String description() default ""; - + String creationDescription() default ""; } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java index e584f01e6..4973fcf2b 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java @@ -6,25 +6,24 @@ package com.intellectualsites.translation; * @author Citymonstret */ public class TranslationAsset { - private final TranslationObject trans; private final String translated; private final TranslationLanguage lang; - + public TranslationAsset(final TranslationObject trans, final String translated, final TranslationLanguage lang) { this.trans = trans; this.translated = translated; this.lang = lang; } - + public TranslationObject getObject() { return this.trans; } - + public String getTranslated() { return this.translated.replace("\n", "&-"); } - + public TranslationLanguage getLang() { return this.lang; } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java index eb7aa89d0..074bb3349 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java @@ -6,26 +6,25 @@ package com.intellectualsites.translation; * @author Citymonstret */ public abstract class TranslationFile { - /** * A method used to get the language of the file * * @return language */ public abstract TranslationLanguage getLanguage(); - + /** * Save the file */ public abstract void saveFile(); - + /** * Read from the file * * @return instance */ public abstract TranslationFile read(); - + /** * Add a value * @@ -33,5 +32,4 @@ public abstract class TranslationFile { * @param value value */ public abstract void add(String key, String value); - } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java index 02b9e2b7c..85e284a77 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java @@ -1,7 +1,6 @@ package com.intellectualsites.translation; public class TranslationLanguage { - public static final TranslationLanguage englishAmerican = (new TranslationLanguage("American English", "us", "en")); public static final TranslationLanguage englishBritish = (new TranslationLanguage("British English", "gb", "en")); public static final TranslationLanguage swedishSwedish = (new TranslationLanguage("Swedish", "sv", "se")); @@ -9,29 +8,29 @@ public class TranslationLanguage { private final String countryCode; private final String languageCode; private final String friendlyName; - + public TranslationLanguage(final String friendlyName, final String countryCode, final String languageCode) { this.friendlyName = friendlyName; this.countryCode = countryCode; this.languageCode = languageCode; } - + public static TranslationLanguage[] values() { - return new TranslationLanguage[]{englishAmerican, englishBritish, swedishSwedish}; + return new TranslationLanguage[] { englishAmerican, englishBritish, swedishSwedish }; } - + public String getName() { return this.friendlyName; } - + public String getCountryCode() { return this.countryCode; } - + public String getLanguageCode() { return this.languageCode; } - + @Override public String toString() { /* en_US */ diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java index b3e489429..1c0cfa2ac 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java @@ -15,7 +15,6 @@ import java.util.List; * @author Citymonstret */ public class TranslationManager { - /** * Objects */ @@ -24,14 +23,14 @@ public class TranslationManager { * The translations */ private final LinkedHashMap translatedObjects; - + /** * Constructor */ public TranslationManager() { - this(new TranslationObject[]{}); + this(new TranslationObject[] {}); } - + /** * Constructor * @@ -41,7 +40,7 @@ public class TranslationManager { this.translationObjects = new LinkedList(Arrays.asList(translationObjects)); this.translatedObjects = new LinkedHashMap(); } - + public static List transformEnum(final Object[] os) { final List eList = new ArrayList(); for (final Object o : os) { @@ -49,7 +48,7 @@ public class TranslationManager { } return eList; } - + public static void scan(final Class c, final TranslationManager manager) throws IllegalAccessException { final Field[] fields = c.getDeclaredFields(); Annotation annotation; @@ -65,7 +64,7 @@ public class TranslationManager { manager.addTranslationObject(new TranslationObject(key, defaultValue, t.description(), t.creationDescription())); } } - + /** * Don't use this! * @@ -74,7 +73,7 @@ public class TranslationManager { public TranslationManager instance() { return this; } - + /** * Get the translation objects * @@ -83,7 +82,7 @@ public class TranslationManager { public List translations() { return this.translationObjects; } - + /** * Add an object * @@ -95,7 +94,7 @@ public class TranslationManager { this.translationObjects.add(t); return instance(); } - + /** * Remove an object * @@ -107,7 +106,7 @@ public class TranslationManager { this.translationObjects.remove(t); return instance(); } - + public String getDescription(final String key) { for (final TranslationObject o : translations()) { if (o.getKey().equals(key) && !o.getDescription().equals("")) { @@ -116,11 +115,11 @@ public class TranslationManager { } return ""; } - + public TranslationManager addTranslation(final TranslationObject t, final TranslationAsset a) { return addTranslation(t.getKey(), a); } - + public TranslationManager addTranslation(final String key, final TranslationAsset a) { String eKey = key + "." + a.getLang().toString(); eKey = eKey.toLowerCase(); @@ -130,7 +129,7 @@ public class TranslationManager { this.translatedObjects.put(eKey, a); return instance(); } - + public TranslationAsset getTranslated(final String key, final String language) { String eKey = key + "." + language; eKey = eKey.toLowerCase(); @@ -139,7 +138,7 @@ public class TranslationManager { } return this.translatedObjects.get(key); } - + public TranslationAsset getTranslated(final String key, final TranslationLanguage language) { String eKey = key + "." + language.toString(); eKey = eKey.toLowerCase(); @@ -148,15 +147,15 @@ public class TranslationManager { } return this.translatedObjects.get(eKey); } - + public TranslationAsset getTranslated(final TranslationObject t, final TranslationLanguage l) { return getTranslated(t.getKey(), l); } - + public String getTranslation(final String key, final TranslationLanguage l) { return getTranslated(key, l).getTranslated(); } - + public TranslationObject getDefault(final String key) { for (final TranslationObject o : translations()) { if (o.getKey().equals(key.toLowerCase())) { @@ -165,7 +164,7 @@ public class TranslationManager { } return null; } - + public TranslationManager saveAll(final TranslationFile file) { for (final TranslationObject object : translations()) { final TranslationAsset o = getTranslated(object.getKey(), file.getLanguage()); @@ -173,7 +172,7 @@ public class TranslationManager { } return instance(); } - + public TranslationManager debug(final PrintStream out) { for (final TranslationObject object : translations()) { out.println(object.getKey() + ":"); @@ -183,7 +182,7 @@ public class TranslationManager { } return instance(); } - + public TranslationManager saveFile(final TranslationFile file) { file.saveFile(); return instance(); diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java index 186a9869f..e4deb1934 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java @@ -1,8 +1,6 @@ package com.intellectualsites.translation; - public class TranslationObject { - // can include a suffix | not null private final String key; // The default ("no-translation" value) | not null @@ -11,7 +9,7 @@ public class TranslationObject { private final String description; // Like a plugin name for example | can be null private final String creationDescription; - + public TranslationObject(final String key, final String defaultValue, String description, String creationDescription) { if (description == null) { description = ""; @@ -29,21 +27,20 @@ public class TranslationObject { this.description = description; this.creationDescription = creationDescription; } - + public String getKey() { return this.key; } - + public String getDefaultValue() { return this.defaultValue; } - + public String getDescription() { return this.description; } - + public String getCreationDescription() { return this.creationDescription; } - } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java index 5aa10259f..7b41e9c91 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java @@ -17,7 +17,6 @@ import org.yaml.snakeyaml.Yaml; * @author Citymonstret */ public class YamlTranslationFile extends TranslationFile { - final private TranslationLanguage language; final private String name; final private TranslationManager manager; @@ -30,7 +29,7 @@ public class YamlTranslationFile extends TranslationFile { * YAML Object */ private Yaml yaml; - + /** * Constructor * @@ -60,7 +59,7 @@ public class YamlTranslationFile extends TranslationFile { this.instance = this; this.instance = this; } - + /** * Reload */ @@ -68,7 +67,7 @@ public class YamlTranslationFile extends TranslationFile { this.map = new HashMap(); this.read(); } - + /** * Set the header * @@ -81,7 +80,7 @@ public class YamlTranslationFile extends TranslationFile { this.fancyHead = false; return this.instance; } - + /** * Set a fancy header * @@ -107,7 +106,7 @@ public class YamlTranslationFile extends TranslationFile { this.fancyHead = true; return this.instance; } - + /** * Add a translation * @@ -121,7 +120,7 @@ public class YamlTranslationFile extends TranslationFile { } this.map.put(key, value); } - + /** * Get the translation language * @@ -131,7 +130,7 @@ public class YamlTranslationFile extends TranslationFile { public TranslationLanguage getLanguage() { return this.language; } - + /** * Save the file */ @@ -167,7 +166,7 @@ public class YamlTranslationFile extends TranslationFile { e.printStackTrace(); } } - + /** * Get the YAML object * @@ -185,7 +184,7 @@ public class YamlTranslationFile extends TranslationFile { } return this.yaml; } - + /** * Read the file * 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 d22c83fa9..04c9b23f3 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java @@ -14,7 +14,6 @@ import com.intellectualsites.translation.TranslationObject; * @author Citymonstret */ public class BukkitTranslation { - /** * Get the converted string * @@ -28,7 +27,7 @@ public class BukkitTranslation { // &- = new line return asset.getTranslated().replace("&-", "\n").replace('&', '\u00A7'); } - + /** * Get the universal parent based on the plugin data folder * @@ -39,7 +38,7 @@ public class BukkitTranslation { public static File getParent() { return new File(PlotSquared.IMP.getDirectory() + File.separator + "translations"); } - + /** * The default translation language * @@ -48,7 +47,7 @@ public class BukkitTranslation { public TranslationLanguage getDefaultLanguage() { return TranslationLanguage.englishAmerican; } - + /** * Add material names to the translation list Will default to a somewhat friendly name */ diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java index 612307dc2..7fcf92f9a 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java @@ -11,17 +11,13 @@ import com.intellectualsites.translation.TranslationManager; import com.intellectualsites.translation.YamlTranslationFile; public class TranslationPlugin extends JavaPlugin { - @Translation(description = "Printed when the translator is fully loaded") private static final String TRANSLATOR_LOADED = "The translator has been loaded"; - @Translation(description = "Printed when the translator has been disabled") private static final String TRANSLATOR_DISABLED = "The translator has been disabled"; - private static TranslationManager manager; - private TranslationFile english; - + @Override public void onEnable() { // Create a new manager @@ -37,12 +33,11 @@ public class TranslationPlugin extends JavaPlugin { // That created the file, read it, and made a default header getLogger().log(Level.INFO, BukkitTranslation.convert(manager.getTranslated("translator_loaded", TranslationLanguage.englishAmerican))); } - + @Override public void onDisable() { // Add all translations and save the file manager.saveAll(this.english).saveFile(this.english); getLogger().log(Level.INFO, BukkitTranslation.convert(manager.getTranslated("translator_disabled", TranslationLanguage.englishAmerican))); } - } diff --git a/PlotSquared/src/main/resources/LICENSE b/PlotSquared/src/main/resources/LICENSE index ef7e7efc0..c95a26732 100644 --- a/PlotSquared/src/main/resources/LICENSE +++ b/PlotSquared/src/main/resources/LICENSE @@ -1,15 +1,11 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble - The GNU General Public License is a free, copyleft license for software and other kinds of works. - The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to @@ -18,35 +14,29 @@ software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. - When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. - For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. - For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. - Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of @@ -57,49 +47,37 @@ have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. - Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. - The precise terms and conditions for copying, distribution and modification follow. - TERMS AND CONDITIONS - 0. Definitions. - "This License" refers to version 3 of the GNU General Public License. - "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. - "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. - To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. - A "covered work" means either the unmodified Program or a work based on the Program. - To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. - To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. - An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) @@ -108,18 +86,14 @@ extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. - 1. Source Code. - The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. - A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. - The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major @@ -130,7 +104,6 @@ implementation is available to the public in source code form. A (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. - The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to @@ -143,16 +116,12 @@ the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. - The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. - The Corresponding Source for a work in source code form is that same work. - 2. Basic Permissions. - All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited @@ -160,7 +129,6 @@ permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. - You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose @@ -171,19 +139,15 @@ not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. - Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. - When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to @@ -191,9 +155,7 @@ the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. - 4. Conveying Verbatim Copies. - You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; @@ -201,24 +163,18 @@ keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. - You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. - 5. Conveying Modified Source Versions. - You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: - a) The work must carry prominent notices stating that you modified it, and giving a relevant date. - b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". - c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 @@ -226,12 +182,10 @@ terms of section 4, provided that you also meet all of these conditions: regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. - d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. - A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, @@ -241,19 +195,15 @@ used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. - 6. Conveying Non-Source Forms. - You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: - a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. - b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as @@ -265,13 +215,11 @@ in one of these ways: more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. - c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. - d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no @@ -284,16 +232,13 @@ in one of these ways: Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. - e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. - A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. - A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation @@ -306,7 +251,6 @@ actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. - "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from @@ -314,7 +258,6 @@ a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. - If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the @@ -325,7 +268,6 @@ by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). - The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for @@ -333,15 +275,12 @@ the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. - Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. - 7. Additional Terms. - "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall @@ -350,41 +289,32 @@ that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. - When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. - Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: - a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or - b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or - c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or - d) Limiting the use for publicity purposes of names of licensors or authors of the material; or - e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or - f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. - All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is @@ -394,46 +324,37 @@ a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. - If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. - Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. - 8. Termination. - You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). - However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. - Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. - Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. - 9. Acceptance Not Required for Having Copies. - You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission @@ -442,14 +363,11 @@ nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. - 10. Automatic Licensing of Downstream Recipients. - Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. - An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered @@ -459,7 +377,6 @@ licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. - You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of @@ -467,13 +384,10 @@ rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. - 11. Patents. - A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". - A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted @@ -483,19 +397,16 @@ consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. - Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. - In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. - If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a @@ -509,7 +420,6 @@ actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. - If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties @@ -517,7 +427,6 @@ receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. - A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are @@ -532,13 +441,10 @@ conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. - Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. - 12. No Surrender of Others' Freedom. - If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a @@ -548,9 +454,7 @@ not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Use with the GNU Affero General Public License. - Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single @@ -559,14 +463,11 @@ License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. - 14. Revised Versions of this License. - The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the @@ -575,19 +476,15 @@ version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. - If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. - Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. - 15. Disclaimer of Warranty. - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY @@ -596,9 +493,7 @@ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - 16. Limitation of Liability. - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY @@ -608,64 +503,48 @@ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - 17. Interpretation of Sections 15 and 16. - If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. - END OF TERMS AND CONDITIONS - How to Apply These Terms to Your New Programs - If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - {one line to give the program's name and a brief idea of what it does.} Copyright (C) {year} {name of author} - 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, see . - Also add information on how to contact you by electronic and paper mail. - If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. - The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". - You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . - The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with From d381f0ff6a84738a88f8145d95e3053ace2a1d31 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:47:52 +1100 Subject: [PATCH 028/124] playerfunctions --- .../plot/util/PlotHelper.java | 92 ++++++++--- .../plot/util/bukkit/PlayerFunctions.java | 151 ++---------------- .../plot/util/bukkit/UUIDHandler.java | 1 + 3 files changed, 81 insertions(+), 163 deletions(-) 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 68bff32f2..7e9d459f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -273,8 +273,8 @@ public class PlotHelper { break; } count++; - final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id; - final PlotId top = PlayerFunctions.getTopPlot(world, plot).id; + final PlotId bot = getBottomPlot(world, plot).id; + final PlotId top = getTopPlot(world, plot).id; plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); if (ownsPlots(world, plots, uuid, 0)) { final boolean result = mergePlots(world, plots, true); @@ -320,11 +320,11 @@ public class PlotHelper { if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) { return false; } - final PlotId top = PlayerFunctions.getTopPlot(world, myplot).id; + final PlotId top = getTopPlot(world, myplot).id; if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) { return false; } - final PlotId bot = PlayerFunctions.getBottomPlot(world, myplot).id; + final PlotId bot = getBottomPlot(world, myplot).id; if (((bot.x < id_min.x) && (dir != 3)) || ((bot.y < id_min.y) && (dir != 0))) { return false; } @@ -398,7 +398,7 @@ public class PlotHelper { * @param requester * @param plot */ - public static boolean clear(final UUID uuid, final Plot plot, final boolean isDelete, final Runnable whenDone) { + public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) { if (runners.containsKey(plot)) { return false; } @@ -665,7 +665,7 @@ public class PlotHelper { public static Location getPlotTopLoc(final String world, PlotId id) { final Plot plot = PlotSquared.getPlots(world).get(id); if (plot != null) { - id = PlayerFunctions.getTopPlot(world, plot).id; + id = getTopPlot(world, plot).id; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final PlotManager manager = PlotSquared.getPlotManager(world); @@ -684,7 +684,7 @@ public class PlotHelper { public static Location getPlotBottomLoc(final String world, PlotId id) { final Plot plot = PlotSquared.getPlots(world).get(id); if (plot != null) { - id = PlayerFunctions.getBottomPlot(world, plot).id; + id = getBottomPlot(world, plot).id; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); final PlotManager manager = PlotSquared.getPlotManager(world); @@ -713,8 +713,8 @@ public class PlotHelper { if (currentPlot.owner == null) { return false; } - final Plot pos1 = PlayerFunctions.getBottomPlot(world, currentPlot); - final Plot pos2 = PlayerFunctions.getTopPlot(world, currentPlot); + final Plot pos1 = getBottomPlot(world, currentPlot); + final Plot pos2 = getTopPlot(world, currentPlot); final PlotId size = PlotHelper.getSize(world, currentPlot); if (!PlotHelper.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { return false; @@ -741,23 +741,46 @@ public class PlotHelper { return true; } + public static Plot getBottomPlot(final String world, final Plot plot) { + if (plot.settings.getMerged(0)) { + 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 = PlotSquared.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)); + if (p == null) { + return plot; + } + return getBottomPlot(world, p); + } + return plot; + } + + public static Plot getTopPlot(final String world, final Plot plot) { + if (plot.settings.getMerged(2)) { + return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); + } + if (plot.settings.getMerged(1)) { + return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); + } + return plot; + } + public static PlotId getSize(final String world, final Plot plot) { final PlotSettings settings = plot.settings; if (!settings.isMerged()) { return new PlotId(1, 1); } - final Plot top = PlayerFunctions.getTopPlot(world, plot); - final Plot bot = PlayerFunctions.getBottomPlot(world, plot); + final Plot top = getTopPlot(world, plot); + final Plot bot = getBottomPlot(world, plot); return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1); } /** * Fetches the plot from the main class - * - * @param world - * @param id - * - * @return */ public static Plot getPlot(final String world, final PlotId id) { if (id == null) { @@ -769,21 +792,40 @@ public class PlotHelper { return new Plot(id, null, new ArrayList(), new ArrayList(), world); } + /** - * Returns the plot at a given location - * + * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) * @param loc - * * @return */ - public static Plot getCurrentPlot(final Location loc) { - final PlotId id = PlayerFunctions.getPlot(loc); - if (id == null) { + public static PlotId getPlotAbs(final Location loc) { + final String world = loc.getWorld(); + final PlotManager manager = PlotSquared.getPlotManager(world); + if (manager == null) { return null; } - if (PlotSquared.getPlots(loc.getWorld()).containsKey(id)) { - return PlotSquared.getPlots(loc.getWorld()).get(id); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); + } + + /** + * Returns the plot id at a location (mega plots are considered) + * @param loc + * @return + */ + public static PlotId getPlot(final Location loc) { + final String world = loc.getWorld(); + final PlotManager manager = PlotSquared.getPlotManager(world); + if (manager == null) { + return null; } - return new Plot(id, null, new ArrayList(), new ArrayList(), loc.getWorld()); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ()); + if ((id != null) && (plotworld.TYPE == 2)) { + if (ClusterManager.getCluster(world, id) == null) { + return null; + } + } + return id; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java index 3e4b404e8..ecdf998f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java @@ -25,32 +25,25 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -import net.milkbowl.vault.economy.Economy; - -import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; -import org.bukkit.block.Biome; +import org.bukkit.entity.Player; import org.bukkit.util.ChatPaginator; +import org.bukkit.ChatColor; + +import net.milkbowl.vault.economy.Economy; 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.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.AChunkManager; -import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.PlotHelper; /** * Functions involving players, plots and locations. - * - * @author Citymonstret */ -@SuppressWarnings("javadoc") public class PlayerFunctions { /** * Clear a plot. Use null player if no player is present @@ -60,46 +53,18 @@ public class PlayerFunctions { * @param isDelete */ public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { - if (runners.containsKey(plot)) { - PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); - return; - } - final PlotManager manager = PlotSquared.getPlotManager(world); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final int prime = 31; - int h = 1; - h = (prime * h) + pos1.getX(); - h = (prime * h) + pos1.getZ(); - state = h; final long start = System.currentTimeMillis(); - final Location location = PlotHelper.getPlotHomeDefault(plot); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - runners.put(plot, 1); - if (plotworld.TERRAIN != 0) { - final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); - AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { - @Override - public void run() { - if ((player != null) && player.isOnline()) { - PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); - } - runners.remove(plot); - } - }); - return; - } - final Runnable run = new Runnable() { + Runnable whenDone = new Runnable() { @Override public void run() { - PlotHelper.setBiome(world, plot, Biome.FOREST); - runners.remove(plot); if ((player != null) && player.isOnline()) { - PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); + PlayerFunctions.sendMessage(player, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); } - update(location); } }; - manager.clearPlot(plotworld, plot, isDelete, run); + if (!PlotHelper.clearAsPlayer(plot, isDelete, whenDone)) { + PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); + } } /** @@ -125,7 +90,7 @@ public class PlayerFunctions { PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } - return mergePlots(world, plotIds, true); + return PlotHelper.mergePlots(world, plotIds, true); } public static String getPlayerName(final UUID uuid) { @@ -152,10 +117,10 @@ public class PlayerFunctions { final Plot plot1 = PlotSquared.getPlots(world).get(pos1); final Plot plot2 = PlotSquared.getPlots(world).get(pos2); if (plot1 != null) { - pos1 = getBottomPlot(world, plot1).id; + pos1 = PlotHelper.getBottomPlot(world, plot1).id; } if (plot2 != null) { - pos2 = getTopPlot(world, plot2).id; + pos2 = PlotHelper.getTopPlot(world, plot2).id; } final ArrayList myplots = new ArrayList<>(); for (int x = pos1.x; x <= pos2.x; x++) { @@ -166,74 +131,6 @@ public class PlayerFunctions { return myplots; } - public static Plot getBottomPlot(final String world, final Plot plot) { - if (plot.settings.getMerged(0)) { - 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 = PlotSquared.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)); - if (p == null) { - return plot; - } - return getBottomPlot(world, p); - } - return plot; - } - - public static Plot getTopPlot(final String world, final Plot plot) { - if (plot.settings.getMerged(2)) { - return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); - } - if (plot.settings.getMerged(1)) { - return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); - } - return plot; - } - - /** - * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) - * - * @param loc - * - * @return - */ - public static PlotId getPlotAbs(final Location loc) { - final String world = loc.getWorld(); - final PlotManager manager = PlotSquared.getPlotManager(world); - if (manager == null) { - return null; - } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); - } - - /** - * Returns the plot id at a location (mega plots are considered) - * - * @param loc - * - * @return - */ - public static PlotId getPlot(final Location loc) { - final String world = loc.getWorld(); - final PlotManager manager = PlotSquared.getPlotManager(world); - if (manager == null) { - return null; - } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ()); - if ((id != null) && (plotworld.TYPE == 2)) { - if (ClusterManager.getCluster(world, id) == null) { - return null; - } - } - return id; - } - /** * Returns the plot a player is currently in. * @@ -245,7 +142,7 @@ public class PlayerFunctions { if (!PlotSquared.isPlotWorld(player.getWorld().getName())) { return null; } - final PlotId id = getPlot(BukkitUtil.getLocation(player)); + final PlotId id = PlotHelper.getPlot(BukkitUtil.getLocation(player)); final String world = player.getWorld().getName(); if (id == null) { return null; @@ -256,18 +153,6 @@ public class PlayerFunctions { return new Plot(id, null, new ArrayList(), new ArrayList(), world); } - /** - * Updates a given plot with another instance - * - * @param plot - * - * @deprecated - */ - @Deprecated - public static void set(final Plot plot) { - PlotSquared.updatePlot(plot); - } - /** * Get the plots for a player * @@ -312,16 +197,6 @@ public class PlayerFunctions { return BukkitMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); } - /** - * @return PlotSquared.getPlots(); - * - * @deprecated - */ - @Deprecated - public static Set getPlots() { - return PlotSquared.getPlots(); - } - /** * \\previous\\ * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index be8ac63fc..98f5076ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -8,6 +8,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; From 31159488c12390900fe1a98e82cfe9c85c852940 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:52:48 +1100 Subject: [PATCH 029/124] chunk --- .../com/intellectualcrafters/plot/util/PlotHelper.java | 10 +++++++++- .../plot/util/bukkit/ChunkManager.java | 6 +++--- .../plot/util/bukkit/PlayerFunctions.java | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) 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 7e9d459f6..88d2fac5e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -813,7 +813,7 @@ public class PlotHelper { * @param loc * @return */ - public static PlotId getPlot(final Location loc) { + public static PlotId getPlotId(final Location loc) { final String world = loc.getWorld(); final PlotManager manager = PlotSquared.getPlotManager(world); if (manager == null) { @@ -828,4 +828,12 @@ public class PlotHelper { } return id; } + + public static Plot getPlot(final Location loc) { + PlotId id = getPlotId(loc); + if (id == null) { + return null; + } + return getPlot(loc.getWorld(), id); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 958a7ba82..48dd55fad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -110,12 +110,12 @@ public class ChunkManager extends AChunkManager { final int z2 = z1 + 15; final Location bot = new Location(world, x1, 0, z1); Plot plot; - plot = PlotHelper.getCurrentPlot(bot); + plot = PlotHelper.getPlot(bot); if ((plot != null) && (plot.owner != null)) { return plot; } final Location top = new Location(world, x2, 0, z2); - plot = PlotHelper.getCurrentPlot(top); + plot = PlotHelper.getPlot(top); if ((plot != null) && (plot.owner != null)) { return plot; } @@ -743,7 +743,7 @@ public class ChunkManager extends AChunkManager { public void clearAllEntities(final Plot plot) { final List entities = BukkitUtil.getEntities(plot.world); for (final Entity entity : entities) { - final PlotId id = PlayerFunctions.getPlot(BukkitUtil.getLocation(entity)); + final PlotId id = PlotHelper.getPlotId(BukkitUtil.getLocation(entity)); if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java index ecdf998f2..e1807473f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java @@ -142,7 +142,7 @@ public class PlayerFunctions { if (!PlotSquared.isPlotWorld(player.getWorld().getName())) { return null; } - final PlotId id = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + final PlotId id = PlotHelper.getPlotId(BukkitUtil.getLocation(player)); final String world = player.getWorld().getName(); if (id == null) { return null; From 14691d8dce163191f8dc3aa37f23aeabe83c721c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:53:17 +1100 Subject: [PATCH 030/124] PWE --- .../java/com/intellectualcrafters/plot/util/bukkit/PWE.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index a3ce50d62..81ff80b2e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -55,7 +55,7 @@ public class PWE { if (!PlotSquared.isPlotWorld(p.getWorld().getName())) { removeMask(p); } - final PlotId id = PlayerFunctions.getPlot(l); + final PlotId id = PlotHelper.getPlotId(l); if (id != null) { final Plot plot = PlotSquared.getPlots(l.getWorld()).get(id); if (plot != null) { From d2b7a743090f2556f93a2154c19c05cb244063d5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:54:36 +1100 Subject: [PATCH 031/124] inv --- .../com/intellectualcrafters/plot/object/InfoInventory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index 420ccfd27..040b5877f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -50,7 +50,8 @@ public class InfoInventory implements InventoryHolder { } public InfoInventory build() { - final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.hasRights(this.player), "&cIs Denied: &6" + this.plot.deny_entry(this.player)); + UUID uuid = UUIDHandler.getUUID(player); + final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers"); final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players"); final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players"); From 18f53bb6390bf7677b16439c00799927d1698e43 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:57:25 +1100 Subject: [PATCH 032/124] aug --- .../intellectualcrafters/plot/generator/AugmentedPopulator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7d6fa0dee..88e272282 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -169,7 +169,7 @@ public class AugmentedPopulator extends BlockPopulator { continue; } } - PlotHelper.setBlock(world, xx, blockInfo.y, zz, blockInfo.id, (byte) 0); + SetBlockManager.setBlockManager.set(world, xx, blockInfo.y, zz, blockInfo.id, (byte) 0); } } for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) { From 7e859fdfa699f710bdcc4e7ff841363d8985eb5e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 18:10:07 +1100 Subject: [PATCH 033/124] WE listener --- .../plot/listeners/WorldEditListener.java | 35 ++- .../plot/listeners/WorldGuardListener.java | 245 ------------------ .../plot/util/EconHandler.java | 1 + .../plot/util/bukkit/BukkitUtil.java | 4 + 4 files changed, 26 insertions(+), 259 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java 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 63e32e2ba..ca83a8132 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -48,6 +48,7 @@ import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -66,7 +67,7 @@ public class WorldEditListener implements Listener { public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); private boolean isPlotWorld(final Location l) { - return (PlotSquared.isPlotWorld(l.getWorld())); + return (PlotSquared.isPlotWorld(l.getWorld().getName())); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @@ -105,10 +106,11 @@ public class WorldEditListener implements Listener { if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) { return; } - final Plot plot = PlotHelper.getCurrentPlot(b.getLocation()); + com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(b.getLocation()); + final Plot plot = PlotHelper.getPlot(loc); if (plot != null) { if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { - PWE.setMask(p, l, false); + PWE.setMask(p, loc, false); } } } @@ -116,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 (!PlotSquared.isPlotWorld(p.getWorld()) || BukkitMain.hasPermission(p, "plots.worldedit.bypass")) { + if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || BukkitMain.hasPermission(p, "plots.worldedit.bypass")) { return; } String cmd = e.getMessage().toLowerCase(); @@ -124,7 +126,7 @@ public class WorldEditListener implements Listener { cmd = cmd.substring(0, cmd.indexOf(" ")); } if (this.restrictedcmds.contains(cmd)) { - final Plot plot = PlayerFunctions.getCurrentPlot(p); + final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(p)); if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { e.setCancelled(true); } @@ -173,7 +175,8 @@ public class WorldEditListener implements Listener { return; } if (isPlotWorld(l)) { - PWE.setMask(p, l, false); + com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(l); + PWE.setMask(p, loc, false); } else { PWE.removeMask(p); } @@ -192,11 +195,13 @@ public class WorldEditListener implements Listener { return; } } - if ((f.getBlockX() != t.getBlockX()) || (f.getBlockZ() != t.getBlockZ())) { - final PlotId idF = PlayerFunctions.getPlot(f); - final PlotId idT = PlayerFunctions.getPlot(t); + com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f); + com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); + if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) { + final PlotId idF = PlotHelper.getPlotId(locf); + final PlotId idT = PlotHelper.getPlotId(loct); if ((idT != null) && !(idF == idT)) { - PWE.setMask(p, t, false); + PWE.setMask(p, loct, false); } } } @@ -214,7 +219,8 @@ public class WorldEditListener implements Listener { return; } if (isPlotWorld(t)) { - PWE.setMask(p, t, false); + com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); + PWE.setMask(p, loct, false); return; } if ((f != null) && isPlotWorld(f)) { @@ -231,14 +237,15 @@ public class WorldEditListener implements Listener { } } final Location t = e.getTo(); - final Location q = new Location(t.getWorld(), t.getBlockX(), 64, t.getZ()); + com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); final Location f = e.getFrom(); - if (!isPlotWorld(q)) { + if (!PlotSquared.isPlotWorld(loct.getWorld())) { if (isPlotWorld(f)) { PWE.removeMask(p); } return; } - PWE.setMask(p, q, false); + + PWE.setMask(p, loct, false); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java deleted file mode 100644 index 14ea6785f..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ /dev/null @@ -1,245 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.listeners; - -import java.util.ArrayList; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; -import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; -import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; -import com.intellectualcrafters.plot.events.PlotDeleteEvent; -import com.intellectualcrafters.plot.events.PlotMergeEvent; -import com.intellectualcrafters.plot.events.PlotUnlinkEvent; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldguard.domains.DefaultDomain; -import com.sk89q.worldguard.protection.flags.DefaultFlag; -import com.sk89q.worldguard.protection.flags.Flag; -import com.sk89q.worldguard.protection.managers.RegionManager; -import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; -import com.sk89q.worldguard.protection.regions.ProtectedRegion; - -/** - * Created 2014-09-24 for PlotSquared - * - * @author Citymonstret - * @author Empire92 - */ -public class WorldGuardListener implements Listener { - public final ArrayList str_flags; - public final ArrayList> flags; - - public WorldGuardListener(final PlotSquared plugin) { - this.str_flags = new ArrayList<>(); - this.flags = new ArrayList<>(); - for (final Flag flag : DefaultFlag.getFlags()) { - this.str_flags.add(flag.getName()); - this.flags.add(flag); - } - } - - public void changeOwner(final Player requester, final UUID owner, final World world, final Plot plot) { - try { - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); - final ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); - final DefaultDomain owners = new DefaultDomain(); - owners.addPlayer(UUIDHandler.getName(owner)); - region.setOwners(owners); - } catch (final Exception e) { - } - } - - public void removeFlag(final Player requester, final World world, final Plot plot, final String key) { - final boolean op = requester.isOp(); - requester.setOp(true); - try { - 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)) { - requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key); - } - } - } catch (final Exception e) { - requester.setOp(op); - } finally { - requester.setOp(op); - } - } - - public void addFlag(final Player requester, final World world, final Plot plot, final String key, final String value) { - final boolean op = requester.isOp(); - requester.setOp(true); - try { - 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)) { - requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value); - } - } - } catch (final Exception e) { - requester.setOp(op); - } finally { - requester.setOp(op); - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onMerge(final PlotMergeEvent event) { - final Plot main = event.getPlot(); - final ArrayList plots = event.getPlots(); - final World world = event.getWorld(); - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); - for (final PlotId plot : plots) { - if (!plot.equals(main.getId())) { - manager.removeRegion(plot.x + "-" + plot.y); - } - } - final ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y); - final DefaultDomain owner = region.getOwners(); - final Map, Object> flags = region.getFlags(); - final DefaultDomain members = region.getMembers(); - manager.removeRegion(main.id.x + "-" + main.id.y); - final Location location1 = PlotHelper.getPlotBottomLocAbs(world, plots.get(0)); - final Location location2 = PlotHelper.getPlotTopLocAbs(world, plots.get(plots.size() - 1)); - final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); - final BlockVector vector2 = new BlockVector(location2.getBlockX(), world.getMaxHeight(), location2.getBlockZ()); - final ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-" + main.id.y, vector1, vector2); - rg.setFlags(flags); - rg.setOwners(owner); - rg.setMembers(members); - manager.addRegion(rg); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onUnlink(final PlotUnlinkEvent event) { - try { - final World w = event.getWorld(); - final ArrayList plots = event.getPlots(); - final Plot main = PlotSquared.getPlots(w).get(plots.get(0)); - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(w); - final ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y); - final DefaultDomain owner = region.getOwners(); - final Map, Object> flags = region.getFlags(); - final DefaultDomain members = region.getMembers(); - manager.removeRegion(main.id.x + "-" + main.id.y); - for (int i = 1; i < plots.size(); i++) { - final PlotId id = plots.get(i); - final Location location1 = PlotHelper.getPlotBottomLocAbs(w, id); - final Location location2 = PlotHelper.getPlotTopLocAbs(w, id); - final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); - final BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ()); - final ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2); - rg.setFlags(flags); - rg.setOwners(owner); - rg.setMembers(members); - manager.addRegion(rg); - } - } catch (final Exception e) { - } - } - - @EventHandler - public void onPlotClaim(final PlayerClaimPlotEvent event) { - try { - final Player player = event.getPlayer(); - final Plot plot = event.getPlot(); - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(plot.world); - final Location location1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId()); - final Location location2 = PlotHelper.getPlotTopLoc(plot.world, plot.getId()); - final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); - final BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.world.getMaxHeight(), location2.getBlockZ()); - final ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2); - final DefaultDomain owner = new DefaultDomain(); - owner.addPlayer(PlotSquared.worldGuard.wrapPlayer(player)); - region.setOwners(owner); - manager.addRegion(region); - } catch (final Exception e) { - } - } - - @EventHandler - public void onPlotDelete(final PlotDeleteEvent event) { - try { - final PlotId plot = event.getPlotId(); - final World world = Bukkit.getWorld(event.getWorld()); - 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 = PlotSquared.worldGuard.getRegionManager(world); - final ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); - final DefaultDomain members = region.getMembers(); - members.addPlayer(UUIDHandler.getName(user)); - region.setMembers(members); - } - - public void removeUser(final Player requester, final UUID user, final World world, final Plot plot) { - final RegionManager manager = PlotSquared.worldGuard.getRegionManager(world); - final ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); - final DefaultDomain members = region.getMembers(); - members.removePlayer(UUIDHandler.getName(user)); - region.setMembers(members); - } - - @EventHandler - public void onPlotHelper(final PlayerPlotHelperEvent event) { - if (event.wasAdded()) { - addUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); - } else { - removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); - } - } - - @EventHandler - public void onPlotTrusted(final PlayerPlotTrustedEvent event) { - if (event.wasAdded()) { - addUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); - } else { - removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); - } - } - - @EventHandler - public void onPlotDenied(final PlayerPlotTrustedEvent event) { - if (event.wasAdded()) { - removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot()); - } - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index ef9f20719..bae9074f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -1,4 +1,5 @@ package com.intellectualcrafters.plot.util; public class EconHandler { + // TODO economy shit } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index fd6228c91..6190060b6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -28,6 +28,10 @@ public class BukkitUtil extends BlockManager { return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()); } + public static Location getLocation(org.bukkit.Location loc) { + return new Location(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } + public static World getWorld(final String string) { if (lastString == string) { return lastWorld; From 145dce8b8e48483ada22524f25ad5803210db3a8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 18:14:45 +1100 Subject: [PATCH 034/124] PlotListener --- .../plot/listeners/PlotListener.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) 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 106e2f8f8..b9955b925 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -28,7 +28,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.WeatherType; -import org.bukkit.block.Biome; +import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -43,14 +43,13 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret * @author Empire92 */ -@SuppressWarnings({ "unused", "deprecation" }) public class PlotListener { public static void textures(final Player p) { if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld().getName())) { @@ -71,7 +70,7 @@ public class PlotListener { } public static boolean isInPlot(final String world, final int x, final int y, final int z) { - return (PlayerFunctions.getPlot(new Location(world, x, y, z)) != null); + return (PlotHelper.getPlot(new Location(world, x, y, z)) != null); } public static boolean isPlotWorld(final String world) { @@ -102,14 +101,14 @@ public class PlotListener { } public static boolean enteredPlot(final Location l1, final Location l2) { - final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ())); - final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ())); + final PlotId p1 = PlotHelper.getPlotId(l1); + final PlotId p2 = PlotHelper.getPlotId(l2); return (p2 != null) && ((p1 == null) || !p1.equals(p2)); } public static boolean leftPlot(final Location l1, final Location l2) { - final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ())); - final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ())); + final PlotId p1 = PlotHelper.getPlotId(l1); + final PlotId p2 = PlotHelper.getPlotId(l2); return (p1 != null) && ((p2 == null) || !p1.equals(p2)); } @@ -122,7 +121,7 @@ public class PlotListener { } public static Plot getCurrentPlot(final Location loc) { - final PlotId id = PlayerFunctions.getPlot(loc); + final PlotId id = PlotHelper.getPlotId(loc); if (id == null) { return null; } @@ -130,7 +129,7 @@ public class PlotListener { 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()); + return new Plot(id, null, new ArrayList(), new ArrayList(), loc.getWorld()); } private static WeatherType getWeatherType(String str) { @@ -181,8 +180,6 @@ public class PlotListener { if ((booleanFlag(plot, "titles", false) || Settings.TITLES) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) { final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + ""); final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); - final ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); - final ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); if (AbstractTitle.TITLE_CLASS != null) { AbstractTitle.TITLE_CLASS.sendTitle(player, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } From a9ef50b6bcbfdd0089122358b50577b02efbe99f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 18:20:39 +1100 Subject: [PATCH 035/124] plotplus --- .../plot/listeners/PlotPlusListener.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) 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 c19710edf..15c376d1c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -51,6 +52,8 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -103,18 +106,20 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } event.setCancelled(true); - if (!isInPlot(player)) { + final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + if (plot == null) { PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return; } - final Plot plot = getPlot(player); - if (!plot.hasRights(player)) { + UUID uuid = UUIDHandler.getUUID(player); + if (!plot.isAdded(uuid)) { PlayerFunctions.sendMessage(player, C.NO_PLOT_PERMS); return; } final Set plotPlayers = new HashSet<>(); for (final Player p : player.getWorld().getPlayers()) { - if (isInPlot(p) && getPlot(p).equals(plot)) { + Plot newPlot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + if (plot.equals(newPlot)) { plotPlayers.add(p); } } @@ -140,10 +145,10 @@ public class PlotPlusListener extends PlotListener implements Listener { if (player.getGameMode() != GameMode.SURVIVAL) { return; } - if (!isInPlot(player)) { + final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + if (plot == null) { return; } - final Plot plot = getPlot(player); if (booleanFlag(plot, "instabreak", false)) { event.getBlock().breakNaturally(); } @@ -155,24 +160,37 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } final Player player = (Player) event.getEntity(); - if (!isInPlot(player)) { + final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + if (plot == null) { return; } - if (booleanFlag(getPlot(player), "invincible", false)) { + if (booleanFlag(plot, "invincible", false)) { event.setCancelled(true); } } @EventHandler public void onItemPickup(final PlayerPickupItemEvent event) { - if (isInPlot(event.getPlayer()) && !getPlot(event.getPlayer()).hasRights(event.getPlayer()) && booleanFlag(getPlot(event.getPlayer()), "drop-protection", false)) { + final Player player = event.getPlayer(); + final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + if (plot == null) { + return; + } + UUID uuid = UUIDHandler.getUUID(player); + if (plot.isAdded(uuid) && booleanFlag(plot, "drop-protection", false)) { event.setCancelled(true); } } @EventHandler public void onItemDrop(final PlayerDropItemEvent event) { - if (isInPlot(event.getPlayer()) && !getPlot(event.getPlayer()).hasRights(event.getPlayer()) && booleanFlag(getPlot(event.getPlayer()), "item-drop", false)) { + final Player player = event.getPlayer(); + final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + if (plot == null) { + return; + } + UUID uuid = UUIDHandler.getUUID(player); + if (plot.isAdded(uuid) && booleanFlag(plot, "item-drop", false)) { event.setCancelled(true); } } From c0cf2f85cc805f3ef66a23ed4f274f94ee5621cc Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 18:24:23 +1100 Subject: [PATCH 036/124] PE1_8 --- .../plot/listeners/PlayerEvents_1_8.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) 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 c4a440c76..256f41c32 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 @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.listeners; -import org.bukkit.Location; +import java.util.UUID; + import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -9,13 +10,17 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents_1_8 extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractAtEntityEvent e) { - final Location l = e.getRightClicked().getLocation(); + final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { @@ -24,17 +29,20 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { e.setCancelled(true); } } else { - final Plot plot = getCurrentPlot(l); + final Plot plot = PlotHelper.getPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.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 (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { - if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); - e.setCancelled(true); + } else { + UUID uuid = UUIDHandler.getUUID(p); + if (!plot.isAdded(uuid)) { + if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { + if (isPlotArea(l)) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); + e.setCancelled(true); + } } } } From 9e0d255eda0e4530943cd81efaec9e83f19ca209 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 18:26:36 +1100 Subject: [PATCH 037/124] FFL --- .../plot/listeners/ForceFieldListener.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index 24b4fa881..9d3ac6d03 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.listeners; import java.util.HashSet; import java.util.Set; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -34,6 +35,7 @@ import org.bukkit.util.Vector; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret @@ -46,7 +48,8 @@ public class ForceFieldListener implements Listener { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !PlayerFunctions.isInPlot(oPlayer) || !PlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } - if (!plot.hasRights(oPlayer)) { + UUID uuid = UUIDHandler.getUUID(oPlayer); + if (!plot.isAdded(uuid)) { players.add(oPlayer); } } @@ -59,7 +62,8 @@ public class ForceFieldListener implements Listener { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !PlayerFunctions.isInPlot(oPlayer) || !PlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } - if (plot.hasRights(oPlayer)) { + UUID uuid = UUIDHandler.getUUID(oPlayer); + if (plot.isAdded(uuid)) { return oPlayer; } } @@ -98,7 +102,8 @@ public class ForceFieldListener implements Listener { final Plot plot = PlayerFunctions.getCurrentPlot(player); if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) { if (!PlotListener.booleanFlag(plot, "forcefield", false)) { - if (plot.hasRights(player)) { + UUID uuid = UUIDHandler.getUUID(player); + if (plot.isAdded(uuid)) { final Set players = getNearbyPlayers(player, plot); for (final Player oPlayer : players) { oPlayer.setVelocity(calculateVelocity(player, oPlayer)); From 2f771832a8aa5a23932819c85ad2c38767597ea3 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 18:30:12 +1100 Subject: [PATCH 038/124] OH NO!!!!!!!!!!!!!!!!!!!!!! THIS IS HORRIBLE --- .../plot/listeners/PlayerEvents.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 0d5ac8bae..e2410e116 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -30,7 +30,6 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; @@ -92,6 +91,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotGenerator; @@ -148,8 +148,15 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final StringWrapper name = new StringWrapper(username); final UUID uuid = UUIDHandler.getUUID(player); UUIDHandler.add(name, uuid); + Location loc = BukkitUtil.getLocation(player.getLocation()); // textures(event.getPlayer()); - if (isInPlot(event.getPlayer().getLocation())) { + Plot plot = PlotHelper.getPlot(loc); + if (plot == null) { + return; + } + + + if (isInPlot(loc)) { if (Settings.TELEPORT_ON_LOGIN) { BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer()))); PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); From 202ec71bb21fe51f34326ff3460790b3a8eba470 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 19:47:33 +1100 Subject: [PATCH 039/124] ... --- .../plot/listeners/PlayerEvents.java | 172 ++++++++---------- .../plot/listeners/PlotListener.java | 6 +- 2 files changed, 80 insertions(+), 98 deletions(-) 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 e2410e116..f10b074bb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -143,110 +143,96 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!player.hasPlayedBefore()) { player.saveData(); } - // UUID stuff final String username = player.getName(); final StringWrapper name = new StringWrapper(username); final UUID uuid = UUIDHandler.getUUID(player); UUIDHandler.add(name, uuid); Location loc = BukkitUtil.getLocation(player.getLocation()); - // textures(event.getPlayer()); Plot plot = PlotHelper.getPlot(loc); if (plot == null) { return; } - - - if (isInPlot(loc)) { - if (Settings.TELEPORT_ON_LOGIN) { - BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer()))); - PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); - } else { - plotEntry(event.getPlayer(), getCurrentPlot(event.getPlayer().getLocation())); - } + if (Settings.TELEPORT_ON_LOGIN) { + BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(plot)); + PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); } + plotEntry(player, plot); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void PlayerMove(final PlayerMoveEvent event) { - try { + Location f = BukkitUtil.getLocation(event.getFrom()); + Location t = BukkitUtil.getLocation(event.getTo()); + if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) { final Player player = event.getPlayer(); - final Location f = event.getFrom(); - final Location t = event.getTo(); - final Location q = new Location(t.getWorld(), t.getBlockX(), 0, t.getZ()); - if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { - if ((Settings.TELEPORT_DELAY != 0) && (TaskManager.TELEPORT_QUEUE.size() > 0)) { - final String name = player.getName(); - if (TaskManager.TELEPORT_QUEUE.contains(name)) { - TaskManager.TELEPORT_QUEUE.remove(name); - } + if (Settings.TELEPORT_DELAY != 0) { + TaskManager.TELEPORT_QUEUE.remove(player.getName()); + } + String worldname = t.getWorld(); + if (!isPlotWorld(worldname)) { + return; + } + if (PlotHelper.worldBorder.containsKey(worldname)) { + final int border = PlotHelper.getBorder(worldname); + boolean passed = true; + if (t.getX() > border) { + event.getTo().setX(border); + } else if (t.getX() < -border) { + event.getTo().setX(-border); + } else if (t.getZ() > border) { + event.getTo().setZ(border); + } else if (t.getZ() < -border) { + event.getTo().setZ(-border); } - if (!isPlotWorld(player.getWorld())) { + else { + passed = false; + } + if (passed) { + PlayerFunctions.sendMessage(player, C.BORDER); return; } - final String worldname = q.getWorld().getName(); - if (PlotHelper.worldBorder.containsKey(worldname)) { - final int border = PlotHelper.getBorder(worldname); - boolean passed = false; - if (t.getBlockX() > border) { - q.setX(border); - passed = true; - } else if (t.getBlockX() < -border) { - q.setX(-border); - passed = true; - } - if (t.getBlockZ() > border) { - q.setZ(border); - passed = true; - } else if (t.getBlockZ() < -border) { - q.setZ(-border); - passed = true; - } - if (passed) { - q.setY(t.getBlockY()); - event.setTo(q); - PlayerFunctions.sendMessage(player, C.BORDER); - return; - } - } - Plot plot = getCurrentPlot(q); - if (plot != null) { - if (plot.deny_entry(player)) { + } + Plot plot = getCurrentPlot(t); + if (plot != null) { + if (plot.denied.size() > 0) { + UUID uuid = UUIDHandler.getUUID(player); + if (plot.isDenied(uuid)) { if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; } } - if (!plot.equals(getCurrentPlot(f))) { - plotEntry(player, plot); - } - } else if (leftPlot(f, event.getTo())) { - plot = getCurrentPlot(f); - plotExit(player, plot); } + if (!plot.equals(getCurrentPlot(f))) { + plotEntry(player, plot); + } + } else if (leftPlot(f, t)) { + plot = getCurrentPlot(f); + plotExit(player, plot); } - } catch (final Exception e) { - // Gotta catch 'em all. } } @EventHandler(priority = EventPriority.HIGHEST) public static void onChat(final AsyncPlayerChatEvent event) { - final World world = event.getPlayer().getWorld(); + Player player = event.getPlayer(); + final String world = player.getWorld().getName(); if (!isPlotWorld(world)) { return; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world.getName()); + final PlotWorld plotworld = PlotSquared.getWorldSettings(world); if (!plotworld.PLOT_CHAT) { return; } - if (getCurrentPlot(event.getPlayer().getLocation()) == null) { + Location loc = BukkitUtil.getLocation(player); + if (getCurrentPlot(loc) == null) { return; } final String message = event.getMessage(); String format = C.PLOT_CHAT_FORMAT.s(); final String sender = event.getPlayer().getDisplayName(); - final Plot plot = getCurrentPlot(event.getPlayer().getLocation()); + final Plot plot = getCurrentPlot(loc); final PlotId id = plot.id; final Set recipients = event.getRecipients(); recipients.clear(); @@ -267,7 +253,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } final Player player = event.getPlayer(); - final Location loc = event.getBlock().getLocation(); + final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); final Plot plot = getCurrentPlot(loc); if (plot != null) { if (event.getBlock().getY() == 0) { @@ -282,7 +268,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } - if (!plot.hasRights(event.getPlayer())) { + if (!plot.isAdded(event.getPlayer())) { final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Block block = event.getBlock(); if ((destroy != null) && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { @@ -355,7 +341,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Block b = event.getBlock(); final Player p = (Player) e; - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (!isInPlot(loc)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); @@ -370,7 +356,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } - } else if (!plot.hasRights(p)) { + } else if (!plot.isAdded(p)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); @@ -399,7 +385,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBS(final BlockSpreadEvent e) { final Block b = e.getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { if (isPlotArea(e.getBlock().getLocation())) { @@ -412,7 +398,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBF(final BlockFormEvent e) { final Block b = e.getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { if (isPlotArea(e.getBlock().getLocation())) { @@ -425,7 +411,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBD(final BlockDamageEvent e) { final Block b = e.getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { if (isPlotArea(e.getBlock().getLocation())) { @@ -438,7 +424,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onFade(final BlockFadeEvent e) { final Block b = e.getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { if (isPlotArea(e.getBlock().getLocation())) { @@ -451,7 +437,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onChange(final BlockFromToEvent e) { final Block b = e.getToBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { if (isPlotArea(e.getBlock().getLocation())) { @@ -464,7 +450,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onGrow(final BlockGrowEvent e) { final Block b = e.getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { if (isPlotArea(e.getBlock().getLocation())) { @@ -490,7 +476,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonRetract(final BlockPistonRetractEvent e) { final Block b = e.getRetractLocation().getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) { if (!isInPlot(loc)) { if (isPlotArea(e.getBlock().getLocation())) { @@ -546,7 +532,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 (!plot.hasRights(player)) { + if (!plot.isAdded(player)) { if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { return; } @@ -613,7 +599,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } final Block b = e.getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (b != null) { if (e.getPlayer() != null) { final Player p = e.getPlayer(); @@ -631,7 +617,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - } else if (!plot.hasRights(p)) { + } else if (!plot.isAdded(p)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); @@ -651,9 +637,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onTeleport(final PlayerTeleportEvent event) { - final Location f = event.getFrom(); - final Location t = event.getTo(); - final Location q = new Location(t.getWorld(), t.getBlockX(), 64, t.getZ()); + final Location f = BukkitUtil.getLocation(event.getFrom()); + final Location t = BukkitUtil.getLocation(event.getTo()); + final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ()); if (isPlotWorld(q)) { if (isInPlot(q)) { final Plot plot = getCurrentPlot(q); @@ -672,7 +658,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi plotExit(event.getPlayer(), plot); } } - if ((q.getBlockX() >= 29999999) || (q.getBlockX() <= -29999999) || (q.getBlockZ() >= 29999999) || (q.getBlockZ() <= -29999999)) { + if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) { event.setCancelled(true); return; } @@ -683,7 +669,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { final BlockFace bf = e.getBlockFace(); final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { @@ -702,7 +688,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; - } else if (!plot.hasRights(e.getPlayer())) { + } else if (!plot.isAdded(e.getPlayer())) { final Flag use = FlagManager.getPlotFlag(plot, "use"); if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { return; @@ -748,7 +734,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketFill(final PlayerBucketFillEvent e) { final Block b = e.getBlockClicked(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { @@ -767,7 +753,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; - } else if (!plot.hasRights(e.getPlayer())) { + } else if (!plot.isAdded(e.getPlayer())) { final Flag use = FlagManager.getPlotFlag(plot, "use"); final Block block = e.getBlockClicked(); if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { @@ -789,7 +775,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingPlace(final HangingPlaceEvent e) { final Block b = e.getBlock(); - final Location loc = b.getLocation(); + final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { @@ -806,7 +792,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - } else if (!plot.hasRights(p)) { + } else if (!plot.isAdded(p)) { if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) { return; } @@ -843,7 +829,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - } else if (!plot.hasRights(p)) { + } else if (!plot.isAdded(p)) { if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { return; } @@ -879,7 +865,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - } else if (!plot.hasRights(p)) { + } else if (!plot.isAdded(p)) { final Entity entity = e.getRightClicked(); if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-interact")) { return; @@ -929,7 +915,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (!plot.hasRights(p)) { + if (!plot.isAdded(p)) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) { return; } @@ -989,7 +975,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } assert plot != null; - if (!plot.hasRights(p)) { + if (!plot.isAdded(p)) { if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { return; } @@ -1034,7 +1020,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setHatching(false); return; } - } else if (!plot.hasRights(p)) { + } else if (!plot.isAdded(p)) { if (!BukkitMain.hasPermission(p, "plots.admin.projectile.other")) { if (isPlotArea(l)) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); @@ -1057,7 +1043,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } final Player player = event.getPlayer(); - final Location loc = event.getBlock().getLocation(); + final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { @@ -1068,7 +1054,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } - if (!plot.hasRights(player)) { + if (!plot.isAdded(player)) { final Flag place = FlagManager.getPlotFlag(plot, "place"); final Block block = event.getBlock(); if ((place != null) && ((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { 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 b9955b925..a49f32473 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -125,11 +125,7 @@ public class PlotListener { if (id == null) { return null; } - final String world = loc.getWorld(); - if (PlotSquared.getPlots(world).containsKey(id)) { - return PlotSquared.getPlots(world).get(id); - } - return new Plot(id, null, new ArrayList(), new ArrayList(), loc.getWorld()); + return PlotHelper.getPlot(loc.getWorld(), id); } private static WeatherType getWeatherType(String str) { From 0dc0b29ea705303e350f743313bb41e5e77cdd55 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 19:51:34 +1100 Subject: [PATCH 040/124] . --- .../plot/listeners/PlayerEvents.java | 120 +++++++++--------- 1 file changed, 63 insertions(+), 57 deletions(-) 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 f10b074bb..04c9a5d69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -122,7 +122,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi PlotSquared.loadWorld(world.getName(), null); } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onChunkLoad(final ChunkLoadEvent event) { final String worldname = event.getWorld().getName(); @@ -136,7 +136,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onJoin(final PlayerJoinEvent event) { final Player player = event.getPlayer(); @@ -147,8 +147,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final StringWrapper name = new StringWrapper(username); final UUID uuid = UUIDHandler.getUUID(player); UUIDHandler.add(name, uuid); - Location loc = BukkitUtil.getLocation(player.getLocation()); - Plot plot = PlotHelper.getPlot(loc); + final Location loc = BukkitUtil.getLocation(player.getLocation()); + final Plot plot = PlotHelper.getPlot(loc); if (plot == null) { return; } @@ -158,17 +158,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } plotEntry(player, plot); } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void PlayerMove(final PlayerMoveEvent event) { - Location f = BukkitUtil.getLocation(event.getFrom()); - Location t = BukkitUtil.getLocation(event.getTo()); + final Location f = BukkitUtil.getLocation(event.getFrom()); + final Location t = BukkitUtil.getLocation(event.getTo()); if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) { final Player player = event.getPlayer(); if (Settings.TELEPORT_DELAY != 0) { TaskManager.TELEPORT_QUEUE.remove(player.getName()); } - String worldname = t.getWorld(); + final String worldname = t.getWorld(); if (!isPlotWorld(worldname)) { return; } @@ -183,8 +183,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.getTo().setZ(border); } else if (t.getZ() < -border) { event.getTo().setZ(-border); - } - else { + } else { passed = false; } if (passed) { @@ -195,7 +194,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi Plot plot = getCurrentPlot(t); if (plot != null) { if (plot.denied.size() > 0) { - UUID uuid = UUIDHandler.getUUID(player); + final UUID uuid = UUIDHandler.getUUID(player); if (plot.isDenied(uuid)) { if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); @@ -213,10 +212,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onChat(final AsyncPlayerChatEvent event) { - Player player = event.getPlayer(); + final Player player = event.getPlayer(); final String world = player.getWorld().getName(); if (!isPlotWorld(world)) { return; @@ -225,19 +224,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!plotworld.PLOT_CHAT) { return; } - Location loc = BukkitUtil.getLocation(player); - if (getCurrentPlot(loc) == null) { + final Location loc = BukkitUtil.getLocation(player); + final Plot plot = getCurrentPlot(loc); + if (plot == null) { return; } final String message = event.getMessage(); String format = C.PLOT_CHAT_FORMAT.s(); final String sender = event.getPlayer().getDisplayName(); - final Plot plot = getCurrentPlot(loc); final PlotId id = plot.id; final Set recipients = event.getRecipients(); recipients.clear(); for (final Player p : Bukkit.getOnlinePlayers()) { - if (getCurrentPlot(p.getLocation()) == plot) { + if (getCurrentPlot(BukkitUtil.getLocation(p)) == plot) { recipients.add(p); } } @@ -245,14 +244,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi format = ChatColor.translateAlternateColorCodes('&', format); event.setFormat(format); } - + @EventHandler(priority = EventPriority.HIGH) public static void BlockDestroy(final BlockBreakEvent event) { - final World world = event.getPlayer().getWorld(); + final Player player = event.getPlayer(); + final String world = player.getWorld().getName(); if (!isPlotWorld(world)) { return; } - final Player player = event.getPlayer(); final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); final Plot plot = getCurrentPlot(loc); if (plot != null) { @@ -268,7 +267,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } - if (!plot.isAdded(event.getPlayer())) { + final UUID uuid = UUIDHandler.getUUID(player); + if (!plot.isAdded(uuid)) { final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Block block = event.getBlock(); if ((destroy != null) && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { @@ -292,7 +292,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onBigBoom(final EntityExplodeEvent event) { final World world = event.getLocation().getWorld(); @@ -325,7 +325,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { final World world = event.getBlock().getWorld(); @@ -356,19 +356,22 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } - } else if (!plot.isAdded(p)) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { - if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); - event.setCancelled(true); - return; + } else { + final UUID uuid = UUIDHandler.getUUID(p); + if (!plot.isAdded(uuid)) { + if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { + if (isPlotArea(loc)) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + event.setCancelled(true); + return; + } } } } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityBlockForm(final EntityBlockFormEvent e) { final World world = e.getBlock().getWorld(); @@ -381,7 +384,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBS(final BlockSpreadEvent e) { final Block b = e.getBlock(); @@ -394,7 +397,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBF(final BlockFormEvent e) { final Block b = e.getBlock(); @@ -407,7 +410,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBD(final BlockDamageEvent e) { final Block b = e.getBlock(); @@ -420,7 +423,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onFade(final BlockFadeEvent e) { final Block b = e.getBlock(); @@ -433,7 +436,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onChange(final BlockFromToEvent e) { final Block b = e.getToBlock(); @@ -446,7 +449,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onGrow(final BlockGrowEvent e) { final Block b = e.getBlock(); @@ -459,7 +462,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonExtend(final BlockPistonExtendEvent e) { if (isInPlot(e.getBlock().getLocation())) { @@ -472,7 +475,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonRetract(final BlockPistonRetractEvent e) { final Block b = e.getRetractLocation().getBlock(); @@ -485,7 +488,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onStructureGrow(final StructureGrowEvent e) { final List blocks = e.getBlocks(); @@ -502,7 +505,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractEvent event) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) { @@ -512,7 +515,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (block == null) { return; } - final World world = event.getPlayer().getWorld(); + final Player player = event.getPlayer(); + final String world = player.getWorld().getName(); if (!isPlotWorld(world)) { return; } @@ -532,7 +536,8 @@ 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 (!plot.isAdded(player)) { + final UUID uuid = UUIDHandler.getUUID(player); + if (!plot.isAdded(uuid)) { if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { return; } @@ -551,7 +556,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void MobSpawn(final CreatureSpawnEvent event) { final World world = event.getLocation().getWorld(); @@ -578,7 +583,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBlockIgnite(final BlockIgniteEvent e) { final World world; @@ -634,7 +639,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onTeleport(final PlayerTeleportEvent event) { final Location f = BukkitUtil.getLocation(event.getFrom()); @@ -664,7 +669,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { final BlockFace bf = e.getBlockFace(); @@ -705,7 +710,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onInventoryClick(final InventoryClickEvent event) { if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { @@ -713,7 +718,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler public static void onLeave(final PlayerQuitEvent event) { if (Setup.setupMap.containsKey(event.getPlayer().getName())) { @@ -730,7 +735,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketFill(final PlayerBucketFillEvent e) { final Block b = e.getBlockClicked(); @@ -771,7 +776,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingPlace(final HangingPlaceEvent e) { final Block b = e.getBlock(); @@ -807,7 +812,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { final Entity r = e.getRemover(); @@ -845,7 +850,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { final Location l = e.getRightClicked().getLocation(); @@ -890,7 +895,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onVehicleDestroy(final VehicleDestroyEvent e) { final Location l = e.getVehicle().getLocation(); @@ -931,7 +936,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { final Location l = e.getEntity().getLocation(); @@ -1000,7 +1005,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerEggThrow(final PlayerEggThrowEvent e) { final Location l = e.getEgg().getLocation(); @@ -1032,10 +1037,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH) public void BlockCreate(final BlockPlaceEvent event) { - final World world = event.getPlayer().getWorld(); + final Player player = event.getPlayer(); + final String world = player.getWorld().getName(); if (!isPlotWorld(world)) { return; } From 439a1d440a6b6189b09187f36a8ee526a246b873 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 19:55:04 +1100 Subject: [PATCH 041/124] pw --- .../plot/PlotSquared.java | 4 +-- .../plot/commands/Auto.java | 4 +-- .../plot/commands/Buy.java | 2 +- .../plot/commands/Claim.java | 4 +-- .../plot/commands/Cluster.java | 2 +- .../plot/commands/CreateRoadSchematic.java | 2 +- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugClear.java | 4 +-- .../plot/commands/DebugRoadRegen.java | 2 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/Info.java | 2 +- .../plot/commands/Merge.java | 2 +- .../plot/commands/Reload.java | 2 +- .../plot/commands/Set.java | 2 +- .../plot/commands/Template.java | 2 +- .../plot/commands/Trim.java | 4 +-- .../plot/commands/Unclaim.java | 2 +- .../plot/commands/Unlink.java | 2 +- .../plot/flag/FlagManager.java | 4 +-- .../plot/generator/AugmentedPopulator.java | 2 +- .../plot/generator/HybridGen.java | 2 +- .../plot/generator/HybridPlotManager.java | 6 ++-- .../plot/listeners/PlayerEvents.java | 9 +++--- .../plot/listeners/PlotListener.java | 2 +- .../plot/object/PlotHologram.java | 2 +- .../plot/util/ClusterManager.java | 12 +++---- .../plot/util/ExpireManager.java | 2 +- .../plot/util/PlotHelper.java | 32 +++++++++---------- .../plot/util/bukkit/PlayerFunctions.java | 2 +- 29 files changed, 60 insertions(+), 61 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 17998101c..e158cf2db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -92,7 +92,7 @@ public class PlotSquared { plots.get(world).put(plot.id, plot); } - public static PlotWorld getWorldSettings(final String world) { + public static PlotWorld getPlotWorld(final String world) { if (plotworlds.containsKey(world)) { return plotworlds.get(world); } @@ -196,7 +196,7 @@ public class PlotSquared { } public static void loadWorld(final String world, final PlotGenerator generator) { - if (getWorldSettings(world) != null) { + if (getPlotWorld(world) != null) { return; } final Set worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet()); 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 8fdceb51d..582537c24 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -133,7 +133,7 @@ public class Auto extends SubCommand { } return false; } - final PlotWorld pWorld = PlotSquared.getWorldSettings(world.getName()); + final PlotWorld pWorld = PlotSquared.getPlotWorld(world.getName()); if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY) { double cost = pWorld.PLOT_PRICE; cost = (size_x * size_z) * cost; @@ -160,7 +160,7 @@ public class Auto extends SubCommand { // } } final String worldname = world.getName(); - final PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); + final PlotWorld plotworld = PlotSquared.getPlotWorld(worldname); if (plotworld.TYPE == 2) { final Location loc = BukkitUtil.getLocation(plr); final Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); 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 c4d31f562..729214950 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -87,7 +87,7 @@ public class Buy extends SubCommand { final PlotId id = plot.id; final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; final int size = PlayerFunctions.getPlotSelectionIds(id, id2).size(); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (plotworld.USE_ECONOMY) { price += plotworld.PLOT_PRICE * size; initPrice += plotworld.SELL_PRICE * size; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 82ac5733c..8a10cacfc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -62,7 +62,7 @@ public class Claim extends SubCommand { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } final World world = plot.world; - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id); if (plotworld.SCHEMATIC_ON_CLAIM) { SchematicHandler.Schematic sch; @@ -98,7 +98,7 @@ public class Claim extends SubCommand { if (plot.hasOwner()) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } - final PlotWorld world = PlotSquared.getWorldSettings(plot.world); + final PlotWorld world = PlotSquared.getPlotWorld(plot.world); if (PlotSquared.useEconomy && world.USE_ECONOMY) { final double cost = world.PLOT_PRICE; if (cost > 0d) { 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 7a5ee1227..4d9c3e25d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -176,7 +176,7 @@ public class Cluster extends SubCommand { return false; } } - final PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld()); + final PlotWorld plotworld = PlotSquared.getPlotWorld(plr.getWorld()); if (plotworld.TYPE == 2) { final ArrayList toRemove = new ArrayList<>(); for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { 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 24b37bf43..298bc09d6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -41,7 +41,7 @@ public class CreateRoadSchematic extends SubCommand { PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return false; } - if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { + if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } final Plot plot = PlayerFunctions.getCurrentPlot(player); 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 1e061579f..efa51ca31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -94,7 +94,7 @@ 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 = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final ArrayList plots = new ArrayList<>(); for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) { final Plot plot = PlotHelper.getPlot(world, id); 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 214026a95..9fe93bd54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -53,7 +53,7 @@ public class DebugClear extends SubCommand { if (id == null) { PlotSquared.log("Invalid Plot ID: " + args[0]); } else { - if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getWorldSettings(world) instanceof SquarePlotWorld)) { + if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) { PlotSquared.log("Invalid plot world: " + world); } else { final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); @@ -82,7 +82,7 @@ public class DebugClear extends SubCommand { } return true; } - if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getWorldSettings(plr.getWorld()) instanceof SquarePlotWorld)) { + if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getPlotWorld(plr.getWorld()) instanceof SquarePlotWorld)) { return sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = PlayerFunctions.getCurrentPlot(plr); 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 7d0af13c3..44119ce2e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -39,7 +39,7 @@ public class DebugRoadRegen extends SubCommand { @Override public boolean execute(final Player player, final String... args) { - if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { + if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); 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 2fb966fa8..6083c60b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -51,7 +51,7 @@ public class Delete extends SubCommand { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.world); + final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world); 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) { 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 225f17c5a..239126d80 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -71,7 +71,7 @@ public class Info extends SubCommand { PlayerFunctions.sendMessage(null, C.INFO_SYNTAX_CONSOLE); return false; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(args[0]); + final PlotWorld plotworld = PlotSquared.getPlotWorld(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/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index bc2432b4d..efe7ee710 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -142,7 +142,7 @@ public class Merge extends SubCommand { return false; } } - final PlotWorld plotWorld = PlotSquared.getWorldSettings(world); + final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); if (PlotSquared.useEconomy && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; cost = plots.size() * cost; 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 200e021d7..9e054c535 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -41,7 +41,7 @@ public class Reload extends SubCommand { PlotSquared.setupConfig(); C.setupTranslations(); for (final String pw : PlotSquared.getPlotWorlds()) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(pw); + final PlotWorld plotworld = PlotSquared.getPlotWorld(pw); plotworld.loadDefaultConfiguration(PlotSquared.config.getConfigurationSection("worlds." + pw)); } MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 38625d8c8..b12466047 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -237,7 +237,7 @@ public class Set extends SubCommand { } // Get components final World world = plr.getWorld(); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); final String[] components = manager.getPlotComponents(world, plotworld, plot.id); for (final String component : components) { 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 607e395c3..6b9a4d344 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -46,7 +46,7 @@ public class Template extends SubCommand { return false; } final World world = Bukkit.getWorld(args[1]); - final PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]); + final PlotWorld plotworld = PlotSquared.getPlotWorld(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 0d27ccf08..80cf9a4e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -90,7 +90,7 @@ public class Trim extends SubCommand { return false; } final World world = Bukkit.getWorld(args[1]); - if ((world == null) || (PlotSquared.getWorldSettings(world) == null)) { + if ((world == null) || (PlotSquared.getPlotWorld(world) == null)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD); return false; } @@ -209,7 +209,7 @@ public class Trim extends SubCommand { // public static void updateUnmodifiedPlots(final World world) { // final SquarePlotManager manager = (SquarePlotManager) PlotSquared.getPlotManager(world); - // final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getWorldSettings(world); + // final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getPlotWorld(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..."); 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 3ff765574..b11024293 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -52,7 +52,7 @@ public class Unclaim extends SubCommand { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.world); + final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world); if (PlotSquared.useEconomy && pWorld.USE_ECONOMY) { final double c = pWorld.SELL_PRICE; if (c > 0d) { 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 2e9573215..6e70eabba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -91,7 +91,7 @@ public class Unlink extends SubCommand { return false; } final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.startPlotUnlink(world, plotworld, ids); for (final PlotId id : ids) { final Plot myplot = PlotSquared.getPlots(world).get(id); 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 060a84f55..00f2433ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -80,7 +80,7 @@ public class FlagManager { if ((settings.flags != null) && (settings.flags.size() > 0)) { flags.addAll(settings.flags); } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if ((plotworld != null) && (plotworld.DEFAULT_FLAGS != null) && (plotworld.DEFAULT_FLAGS.length > 0)) { flags.addAll(Arrays.asList(plotworld.DEFAULT_FLAGS)); } @@ -177,7 +177,7 @@ public class FlagManager { public static Set getSettingFlags(final String world, final PlotSettings settings) { final Set plotflags = settings.flags; - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if ((plotworld != null) && (plotworld.DEFAULT_FLAGS != null) && (plotworld.DEFAULT_FLAGS.length > 0)) { final HashSet flagStrings = new HashSet<>(); for (final 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 88e272282..7a7b1769d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -52,7 +52,7 @@ public class AugmentedPopulator extends BlockPopulator { public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { this.cluster = cluster; this.generator = generator; - this.plotworld = PlotSquared.getWorldSettings(world); + this.plotworld = PlotSquared.getPlotWorld(world); this.manager = generator.getPlotManager(); this.p = p; this.b = b; 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 4675de0e6..ed144089a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -90,7 +90,7 @@ public class HybridGen extends PlotGenerator { public HybridGen(final String world) { super(world); if (this.plotworld == null) { - this.plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); + this.plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); } this.plotsize = this.plotworld.PLOT_WIDTH; this.pathsize = this.plotworld.ROAD_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 6556605cb..6f3531aa2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -60,7 +60,7 @@ public class HybridPlotManager extends ClassicPlotManager { final int botz = bottom.getBlockZ(); final int topx = top.getBlockX(); final int topz = top.getBlockZ(); - final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getWorldSettings(world); + final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getPlotWorld(world); final PlotBlock[] air = new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) }; int changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK); if (changes == -1) { @@ -111,7 +111,7 @@ public class HybridPlotManager extends ClassicPlotManager { final World world = Bukkit.getWorld(plot.world); final Location bot = PlotHelper.getPlotBottomLoc(world, plot.id); final Location top = PlotHelper.getPlotTopLoc(world, plot.id); - final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); + final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); final int sx = (bot.getBlockX() - plotworld.ROAD_WIDTH) + 1; final int sz = bot.getBlockZ() + 1; final int sy = plotworld.ROAD_HEIGHT; @@ -217,7 +217,7 @@ public class HybridPlotManager extends ClassicPlotManager { final int ez = z + 15; final Location bot = new Location(world, x, 0, z); final Location top = new Location(world, ex, 0, ez); - final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getWorldSettings(world); + final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); if (!plotworld.ROAD_SCHEMATIC_ENABLED) { return false; } 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 04c9a5d69..82519be36 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -520,8 +520,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - final Player player = event.getPlayer(); - final Location loc = event.getClickedBlock().getLocation(); + final Location loc = BukkitUtil.getLocation(event.getClickedBlock().getLocation()); if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { @@ -559,18 +558,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void MobSpawn(final CreatureSpawnEvent event) { - final World world = event.getLocation().getWorld(); if (event.getEntity() instanceof Player) { return; } + Location loc = BukkitUtil.getLocation(event.getLocation()); + final String world = loc.getWorld(); if (!isPlotWorld(world)) { return; } - final Location loc = event.getLocation(); if (!isPlotArea(loc)) { return; } - final PlotWorld pW = getPlotWorld(world); + final PlotWorld pW = PlotSquared.getPlotWorld(world); final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) && pW.SPAWN_EGGS) { event.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 a49f32473..64571a2c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -78,7 +78,7 @@ public class PlotListener { } public static boolean isPlotArea(final Location location) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(location.getWorld()); + final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); if (plotworld.TYPE == 2) { return ClusterManager.getCluster(location) != null; } 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 1eab594d2..99953d5a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java @@ -25,7 +25,7 @@ // public PlotHologram(final String world, final PlotId id) { // this.id = id; // this.world = world; -// this.hologram = createHologram(PlotSquared.getPlotManager(world).getSignLoc(Bukkit.getWorld(world), PlotSquared.getWorldSettings(world), PlotHelper.getPlot(Bukkit.getWorld(world), id))); +// this.hologram = createHologram(PlotSquared.getPlotManager(world).getSignLoc(Bukkit.getWorld(world), PlotSquared.getPlotWorld(world), PlotHelper.getPlot(Bukkit.getWorld(world), id))); // } // // public static Hologram createHologram(final org.bukkit.Location location) { 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 62eea59bd..46d3ee806 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -60,7 +60,7 @@ public class ClusterManager { toReturn = PlotHelper.getPlotHome(cluster.world, center); if (toReturn.getY() == 0) { final PlotManager manager = PlotSquared.getPlotManager(cluster.world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(cluster.world); final Location loc = manager.getSignLoc(plotworld, PlotHelper.getPlot(cluster.world, center)); toReturn.setY(loc.getY()); } @@ -82,14 +82,14 @@ public class ClusterManager { public static Location getClusterBottom(final PlotCluster cluster) { final String world = cluster.world; - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); } public static Location getClusterTop(final PlotCluster cluster) { final String world = cluster.world; - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, cluster.getP2()); } @@ -109,7 +109,7 @@ public class ClusterManager { public static boolean contains(final PlotCluster cluster, final Location loc) { final String world = loc.getWorld(); final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); final Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1, 0, 1); if ((bot.getX() < loc.getX()) && (bot.getZ() < loc.getZ()) && (top.getX() > loc.getX()) && (top.getZ() > loc.getZ())) { @@ -221,7 +221,7 @@ public class ClusterManager { int xw; int zw; final String world = loc.getWorld(); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (plotworld == null) { xw = 39; zw = 39; @@ -246,7 +246,7 @@ public class ClusterManager { int i = 0; final Random rand = new Random(); final World world = Bukkit.getWorld(cluster.world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(cluster.world); final Location bot = getClusterBottom(cluster); final Location top = getClusterTop(cluster); final int minChunkX = bot.getX() >> 4; 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 3e57ce1e4..e1ac03167 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -111,7 +111,7 @@ public class ExpireManager { if (plot.settings.isMerged()) { Unlink.unlinkPlot(Bukkit.getWorld(world), plot); } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.clearPlot(plotworld, plot, false, null); PlotHelper.removeSign(plot); DBFunc.delete(world, plot); 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 88d2fac5e..0346e5731 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -55,14 +55,14 @@ public class PlotHelper { public static int getBorder(final String worldname) { if (worldBorder.containsKey(worldname)) { - PlotSquared.getWorldSettings(worldname); + PlotSquared.getPlotWorld(worldname); return worldBorder.get(worldname) + 16; } return Integer.MAX_VALUE; } public static void setupBorder(final String world) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (!plotworld.WORLD_BORDER) { return; } @@ -149,7 +149,7 @@ public class PlotHelper { final PlotId pos1 = plotIds.get(0); final PlotId pos2 = plotIds.get(plotIds.size() - 1); final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.startPlotMerge(plotworld, plotIds); final boolean result = false; for (int x = pos1.x; x <= pos2.x; x++) { @@ -208,7 +208,7 @@ public class PlotHelper { */ public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) { final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (lesserPlot.id.x.equals(greaterPlot.id.x)) { if (!lesserPlot.settings.getMerged(2)) { lesserPlot.settings.setMerged(2, true); @@ -231,7 +231,7 @@ public class PlotHelper { public static void removeSign(final Plot p) { final String world = p.world; final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(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 }); } @@ -241,7 +241,7 @@ public class PlotHelper { name = "unknown"; } final PlotManager manager = PlotSquared.getPlotManager(p.world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(p.world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(p.world); final Location loc = manager.getSignLoc(plotworld, p); final String id = p.id.x + ";" + p.id.y; final String[] lines = new String[] { C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) }; @@ -338,7 +338,7 @@ public class PlotHelper { } final String world = plot.world; final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id); final Location top = manager.getPlotTopLocAbs(plotworld, plot.id); final int border = worldBorder.get(plot.world); @@ -358,7 +358,7 @@ public class PlotHelper { updateWorldBorder(plot); } final Plot p = createPlotAbs(uuid, plot); - final PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); if (plotworld.AUTO_MERGE) { autoMerge(plot.world, p, uuid); } @@ -418,7 +418,7 @@ public class PlotHelper { state = h; System.currentTimeMillis(); final Location location = PlotHelper.getPlotHomeDefault(plot); - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); runners.put(plot, 1); if (plotworld.TERRAIN != 0) { final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); @@ -538,7 +538,7 @@ public class PlotHelper { final Location top = getPlotTopLoc(w, plotid); final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); final int z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ(); - final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getWorldSettings(w), plot).getY()); + final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(w), plot).getY()); return new Location(w, x, y, z); } else { final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); @@ -621,7 +621,7 @@ public class PlotHelper { * @return */ public static Location getPlotTopLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } @@ -636,7 +636,7 @@ public class PlotHelper { * @return */ public static Location getPlotBottomLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); } @@ -667,7 +667,7 @@ public class PlotHelper { if (plot != null) { id = getTopPlot(world, plot).id; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } @@ -686,7 +686,7 @@ public class PlotHelper { if (plot != null) { id = getBottomPlot(world, plot).id; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); } @@ -804,7 +804,7 @@ public class PlotHelper { if (manager == null) { return null; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); } @@ -819,7 +819,7 @@ public class PlotHelper { if (manager == null) { return null; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ()); if ((id != null) && (plotworld.TYPE == 2)) { if (ClusterManager.getCluster(world, id) == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java index e1807473f..c8746b7f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java @@ -77,7 +77,7 @@ public class PlayerFunctions { * @return */ public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) { final double cost = plotIds.size() * plotworld.MERGE_PRICE; if (cost > 0d) { From f11c089a9785b77f68d48bf82feb114025d6d14e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 20:23:17 +1100 Subject: [PATCH 042/124] . --- .../plot/listeners/PlayerEvents.java | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) 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 82519be36..a8dc0ae16 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -220,7 +220,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - final PlotWorld plotworld = PlotSquared.getWorldSettings(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (!plotworld.PLOT_CHAT) { return; } @@ -295,18 +295,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onBigBoom(final EntityExplodeEvent event) { - final World world = event.getLocation().getWorld(); + final String world = event.getLocation().getWorld().getName(); if (!isPlotWorld(world)) { return; } - final Location loc = event.getLocation(); + final Location loc = BukkitUtil.getLocation(event.getLocation()); final Plot plot = getCurrentPlot(loc); if ((plot != null) && plot.hasOwner()) { if (FlagManager.isPlotFlagTrue(plot, "explosion")) { final Iterator iter = event.blockList().iterator(); while (iter.hasNext()) { final Block b = iter.next(); - if (!plot.equals(getCurrentPlot(b.getLocation()))) { + if (!plot.equals(getCurrentPlot(BukkitUtil.getLocation(b.getLocation())))) { iter.remove(); } } @@ -328,7 +328,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { - final World world = event.getBlock().getWorld(); + final String world = event.getBlock().getWorld().getName(); if (!isPlotWorld(world)) { return; } @@ -374,12 +374,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityBlockForm(final EntityBlockFormEvent e) { - final World world = e.getBlock().getWorld(); + final String world = e.getBlock().getWorld().getName(); if (!isPlotWorld(world)) { return; } if ((!(e.getEntity() instanceof Player))) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -391,7 +391,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -404,7 +404,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -417,7 +417,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -430,7 +430,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -443,7 +443,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -456,7 +456,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -465,10 +465,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonExtend(final BlockPistonExtendEvent e) { - if (isInPlot(e.getBlock().getLocation())) { + if (isInPlot(BukkitUtil.getLocation(e.getBlock().getLocation()))) { for (final Block block : e.getBlocks()) { - if (!isInPlot(block.getLocation())) { - if (isPlotArea(e.getBlock().getLocation())) { + Plot plot = getCurrentPlot(BukkitUtil.getLocation(block.getLocation())); + if (plot != null) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -482,7 +483,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) { if (!isInPlot(loc)) { - if (isPlotArea(e.getBlock().getLocation())) { + if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } @@ -562,7 +563,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } Location loc = BukkitUtil.getLocation(event.getLocation()); - final String world = loc.getWorld(); + final String world = loc.getWorld().getName(); if (!isPlotWorld(world)) { return; } @@ -585,13 +586,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBlockIgnite(final BlockIgniteEvent e) { - final World world; + final String world; if (e.getBlock() != null) { - world = e.getBlock().getWorld(); + world = e.getBlock().getWorld().getName(); } else if (e.getIgnitingEntity() != null) { - world = e.getIgnitingEntity().getWorld(); + world = e.getIgnitingEntity().getWorld().getName(); } else if (e.getPlayer() != null) { - world = e.getPlayer().getWorld(); + world = e.getPlayer().getWorld().getName(); } else { return; } @@ -726,7 +727,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { final Collection plots = PlotSquared.getPlots(event.getPlayer().getName()).values(); for (final Plot plot : plots) { - final PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); final PlotManager manager = PlotSquared.getPlotManager(plot.world); manager.clearPlot(plotworld, plot, true, null); DBFunc.delete(plot.world, plot); @@ -979,7 +980,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } assert plot != null; - if (!plot.isAdded(p)) { + UUID uuid = UUIDHandler.getUUID(p); + if (!plot.isAdded(uuid)) { if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { return; } @@ -1007,7 +1009,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerEggThrow(final PlayerEggThrowEvent e) { - final Location l = e.getEgg().getLocation(); + final Location l = BukkitUtil.getLocation(e.getEgg().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { From 923a78a927c1fc04370ed9680152c93ddc530c7e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 21:16:44 +1100 Subject: [PATCH 043/124] jklasdklasdkml lk;as l;asd --- .../plot/listeners/PlayerEvents.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 a8dc0ae16..0593d9cd8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -492,18 +492,29 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onStructureGrow(final StructureGrowEvent e) { + if (!isPlotWorld(e.getWorld().getName())) { + return; + } final List blocks = e.getBlocks(); boolean remove = false; for (int i = blocks.size() - 1; i >= 0; i--) { - if (remove || isPlotWorld(blocks.get(i).getLocation())) { + if (remove) { + e.getBlocks().remove(i); remove = true; - final Location loc = blocks.get(i).getLocation(); if (!isInPlot(loc)) { if (isPlotArea(loc)) { e.getBlocks().remove(i); } } } + else { + final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation()); + if (!isPlotArea(loc)) { + remove = true; + e.getBlocks().remove(i); + } + } + } } From e6c3c143b6dbb6e8835257a925df9c3e0deaf66e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 21:25:58 +1100 Subject: [PATCH 044/124] growth --- .../plot/listeners/PlayerEvents.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) 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 0593d9cd8..28c77f999 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -498,23 +498,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final List blocks = e.getBlocks(); boolean remove = false; for (int i = blocks.size() - 1; i >= 0; i--) { - if (remove) { + final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation()); + Plot plot = getCurrentPlot(loc); + if (plot == null || !plot.hasOwner()) { e.getBlocks().remove(i); - remove = true; - if (!isInPlot(loc)) { - if (isPlotArea(loc)) { - e.getBlocks().remove(i); - } - } } - else { - final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation()); - if (!isPlotArea(loc)) { - remove = true; - e.getBlocks().remove(i); - } - } - } } From fab06a00637722588a994e0350d62e2dc5048f7c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 21:30:49 +1100 Subject: [PATCH 045/124] main --- .../intellectualcrafters/plot/BukkitMain.java | 4 ++-- .../plot/listeners/PlayerEvents.java | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 4c690bbf6..fe78f82e7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -93,7 +93,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { // TODO restructure this public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) { - final Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot); + final Plot bot = PlotHelper.getBottomPlot(player.getWorld().getName(), plot); final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, bot); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -247,7 +247,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { final Entity[] entities = chunk.getEntities(); Entity entity; for (int i = entities.length - 1; i >= 0; i--) { - if (!((entity = entities[i]) instanceof Player) && !.isInPlot(entity.getLocation())) { + if (!((entity = entities[i]) instanceof Player) && (PlotHelper.getPlot(BukkitUtil.getLocation(entity)) == null)) { entity.remove(); } } 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 28c77f999..3f4520a43 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -562,7 +562,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } Location loc = BukkitUtil.getLocation(event.getLocation()); - final String world = loc.getWorld().getName(); + final String world = loc.getWorld(); if (!isPlotWorld(world)) { return; } @@ -621,12 +621,15 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - } else if (!plot.isAdded(p)) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { - if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); - e.setCancelled(true); - return; + } else { + UUID uuid = UUIDHandler.getUUID(p); + if (!plot.isAdded(uuid)) + if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { + if (isPlotArea(loc)) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + e.setCancelled(true); + return; + } } } } From 89fcb6b6008c94d5c524799004310023fd15d185 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Fri, 20 Feb 2015 11:53:18 +0100 Subject: [PATCH 046/124] Started changing to PlotPlayer --- .../intellectualcrafters/plot/BukkitMain.java | 100 ++++++++---------- .../intellectualcrafters/plot/IPlotMain.java | 12 ++- .../plot/commands/BukkitCommand.java | 19 ++++ .../plot/commands/CommandPermission.java | 5 +- .../plot/commands/MainCommand.java | 42 ++++---- .../plot/commands/SubCommand.java | 13 ++- .../plot/object/PlotPlayer.java | 43 ++++++++ .../plot/util/bukkit/PlayerFunctions.java | 35 +++--- 8 files changed, 158 insertions(+), 111 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 4c690bbf6..3355d61c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -1,7 +1,24 @@ package com.intellectualcrafters.plot; -import java.io.File; -import java.util.Arrays; +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.Settings; +import com.intellectualcrafters.plot.database.PlotMeConverter; +import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; +import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.listeners.*; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.ConsoleColors; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.*; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -18,46 +35,17 @@ import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; -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.Settings; -import com.intellectualcrafters.plot.database.PlotMeConverter; -import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; -import com.intellectualcrafters.plot.events.PlotDeleteEvent; -import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.listeners.ForceFieldListener; -import com.intellectualcrafters.plot.listeners.InventoryListener; -import com.intellectualcrafters.plot.listeners.PlayerEvents; -import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; -import com.intellectualcrafters.plot.listeners.PlotListener; -import com.intellectualcrafters.plot.listeners.PlotPlusListener; -import com.intellectualcrafters.plot.listeners.WorldEditListener; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.ConsoleColors; -import com.intellectualcrafters.plot.util.PlotHelper; -import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.Metrics; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; -import com.intellectualcrafters.plot.util.bukkit.SendChunk; -import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; -import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8; -import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; -import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; + +import java.io.File; +import java.util.Arrays; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS = null; public static PlotSquared MAIN = null; // TODO restructure this - public static boolean hasPermission(final Player player, final String perm) { + public static boolean hasPermission(final PlotPlayer p, final String perm) { + final Player player = Bukkit.getPlayer(p + ""); if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { return true; } @@ -74,9 +62,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return false; } - + // TODO restructure this - public static int hasPermissionRange(final Player player, final String stub, final int range) { + public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) { return Byte.MAX_VALUE; } @@ -136,6 +124,24 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static void worldLoad(final WorldLoadEvent event) { UUIDHandler.cacheAll(); } + + public static boolean checkVersion(final int major, final int minor, final int minor2) { + try { + final String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\."); + final int a = Integer.parseInt(version[0]); + final 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 (final Exception e) { + return false; + } + } @EventHandler public void PlayerCommand(final PlayerCommandPreprocessEvent event) { @@ -270,24 +276,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { return new HybridGen(world); } - public static boolean checkVersion(final int major, final int minor, final int minor2) { - try { - final String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\."); - final int a = Integer.parseInt(version[0]); - final 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 (final Exception e) { - return false; - } - } - @Override public void registerPlayerEvents() { getServer().getPluginManager().registerEvents(new PlayerEvents(), this); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index dba352914..f7f7250ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -1,11 +1,11 @@ package com.intellectualcrafters.plot; -import java.io.File; - +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.TaskManager; import net.milkbowl.vault.economy.Economy; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.TaskManager; +import java.io.File; public interface IPlotMain { public void log(String message); @@ -41,4 +41,8 @@ public interface IPlotMain { public void getGenerator(String world, String name); public boolean callRemovePlot(String world, PlotId id); + + public boolean hasPermission(final PlotPlayer player, final String permission); + + public void sendMessage(final PlotPlayer player, final String message); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java new file mode 100644 index 000000000..9c6415e89 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java @@ -0,0 +1,19 @@ +package com.intellectualcrafters.plot.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +/** + * Created 2015-02-20 for PlotSquared + * + * @author Citymonstret + */ +public class BukkitCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { + MainCommand + 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 b93041ab4..7f84e6d75 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -20,9 +20,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.BukkitMain; +import com.intellectualcrafters.plot.object.PlotPlayer; /** * Created by Citymonstret on 2014-08-03. @@ -47,7 +46,7 @@ public class CommandPermission { * * @return true of player has the required permission node */ - public boolean hasPermission(final Player player) { + public boolean hasPermission(final PlotPlayer player) { return BukkitMain.hasPermission(player, this.permission); } } 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 6b27b0e37..aeabc7fee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -20,29 +20,27 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** * PlotSquared command class * * @author Citymonstret */ -public class MainCommand implements CommandExecutor, TabCompleter { +public class MainCommand { /** * Main Permission Node */ @@ -52,13 +50,13 @@ public class MainCommand implements CommandExecutor, TabCompleter { addAll(Arrays.asList(_subCommands)); } }; - - public static boolean no_permission(final Player player, final String permission) { + + public static boolean no_permission(final PlotPlayer player, final String permission) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission); return false; } - - public static List getCommands(final SubCommand.CommandCategory category, final Player player) { + + public static List getCommands(final SubCommand.CommandCategory category, final PlotPlayer player) { final List cmds = new ArrayList<>(); for (final SubCommand c : subCommands) { if (!c.isPlayer || (player != null)) { @@ -69,8 +67,8 @@ public class MainCommand implements CommandExecutor, TabCompleter { } return cmds; } - - public static List helpMenu(final Player player, final SubCommand.CommandCategory category, int page) { + + public static List helpMenu(final PlotPlayer player, final SubCommand.CommandCategory category, int page) { List commands; if (category != null) { commands = getCommands(category, player); @@ -109,10 +107,8 @@ public class MainCommand implements CommandExecutor, TabCompleter { private static String t(final String s) { return ChatColor.translateAlternateColorCodes('&', s); } - - @Override - public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) { - final Player player = (sender instanceof Player) ? (Player) sender : null; + + public boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { if (!BukkitMain.hasPermission(player, PlotSquared.MAIN_PERMISSION)) { return no_permission(player, PlotSquared.MAIN_PERMISSION); } @@ -166,7 +162,7 @@ public class MainCommand implements CommandExecutor, TabCompleter { for (final String string : helpMenu(player, cato, page)) { help.append(string).append("\n"); } - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', help.toString())); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', help.toString())); // return PlayerFunctions.sendMessage(player, help.toString()); } else { for (final SubCommand command : subCommands) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 742073d7c..eca8c3fff 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -20,14 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; + import java.util.ArrayList; import java.util.Arrays; -import org.bukkit.entity.Player; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; - /** * SubCommand class * @@ -127,7 +126,7 @@ public abstract class SubCommand { * * @return true on success, false on failure */ - public abstract boolean execute(final Player plr, final String... args); + public abstract boolean execute(final PlotPlayer plr, final String... args); /** * Execute the command as console @@ -148,7 +147,7 @@ public abstract class SubCommand { * @see com.intellectualcrafters.plot.util.bukkit.PlayerFunctions#sendMessage(org.bukkit.entity.Player, * com.intellectualcrafters.plot.config.C, String...) */ - public boolean sendMessage(final Player plr, final C c, final String... args) { + public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { PlayerFunctions.sendMessage(plr, c, args); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java new file mode 100644 index 000000000..def9810e1 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -0,0 +1,43 @@ +package com.intellectualcrafters.plot.object; + +import com.intellectualcrafters.plot.BukkitMain; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +import java.util.UUID; + +/** + * Created 2015-02-20 for PlotSquared + * + * @author Citymonstret + */ +public class PlotPlayer { + + private final String name; + private final Location location; + + public PlotPlayer(final String name, final Location location) { + this.name = name; + this.location = location; + } + + @Override + public String toString() { + return this.name; + } + + public Location getLocation() { + return this.location; + } + + public UUID getUUID() { + return UUIDHandler.getUUID(name); + } + + public boolean hasPermission(final String perm) { + return BukkitMain.hasPermission(this, perm); + } + + public void sendMessage(final String message) { + return BukkitMain.sendMessage( final PlotPlayer player); + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java index c8746b7f6..8a0b03c90 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java @@ -20,26 +20,25 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.util.bukkit; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.ChatPaginator; -import org.bukkit.ChatColor; - -import net.milkbowl.vault.economy.Economy; - 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; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlotHelper; +import net.milkbowl.vault.economy.Economy; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.bukkit.util.ChatPaginator; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; /** * Functions involving players, plots and locations. @@ -193,7 +192,7 @@ public class PlayerFunctions { * * @return */ - public static int getAllowedPlots(final Player p) { + public static int getAllowedPlots(final PlotPlayer p) { return BukkitMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); } @@ -203,7 +202,7 @@ public class PlayerFunctions { * @param plr * @param msg Was used to wrap the chat client length (Packets out--) */ - public static void sendMessageWrapped(final Player plr, String msg) { + public static void sendMessageWrapped(final PlotPlayer plr, String msg) { if (msg.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) { final String[] ss = ChatPaginator.wordWrap(msg, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH); final StringBuilder b = new StringBuilder(); @@ -226,11 +225,11 @@ public class PlayerFunctions { * * @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...)) */ - public static boolean sendMessage(final Player plr, final String msg) { + public static boolean sendMessage(final PlotPlayer plr, final String msg) { return sendMessage(plr, msg, true); } - - public static boolean sendMessage(final Player plr, final String msg, final boolean prefix) { + + public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) { if ((msg.length() > 0) && !msg.equals("")) { if (plr == null) { PlotSquared.log(C.PREFIX.s() + msg); @@ -249,7 +248,7 @@ public class PlayerFunctions { * * @return */ - public static boolean sendMessage(final Player plr, final C c, final String... args) { + public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { if (c.s().length() > 1) { String msg = c.s(); if ((args != null) && (args.length > 0)) { From 16f5cc1f36b26b17f10d63ed3cca014571e4821c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 22:23:48 +1100 Subject: [PATCH 047/124] PlotPlayer --- .../intellectualcrafters/plot/BukkitMain.java | 85 +- .../plot/PlotSquared.java | 10 +- .../plot/commands/Auto.java | 26 +- .../plot/commands/Buy.java | 4 +- .../plot/commands/Claim.java | 8 +- .../plot/commands/Clear.java | 4 +- .../plot/commands/Cluster.java | 10 +- .../plot/commands/Condense.java | 12 +- .../plot/commands/Copy.java | 4 +- .../plot/commands/CreateRoadSchematic.java | 4 +- .../plot/commands/Debug.java | 10 +- .../plot/commands/DebugClaimTest.java | 8 +- .../plot/commands/DebugClear.java | 24 +- .../plot/commands/Info.java | 6 +- .../plot/commands/Merge.java | 16 +- .../plot/commands/Move.java | 8 +- .../plot/commands/Paste.java | 4 +- .../plot/commands/Schematic.java | 10 +- .../plot/commands/Set.java | 6 +- .../plot/commands/SetOwner.java | 4 +- .../plot/commands/Swap.java | 6 +- .../plot/commands/TP.java | 4 +- .../plot/commands/Target.java | 6 +- .../plot/commands/Trim.java | 6 +- .../plot/commands/Unlink.java | 12 +- .../plot/generator/AugmentedPopulator.java | 2 +- .../plot/generator/ClassicPlotManager.java | 86 +- .../plot/generator/HybridPlotManager.java | 130 +-- .../plot/generator/SquarePlotManager.java | 16 +- .../plot/listeners/PlayerEvents.java | 162 +-- .../plot/listeners/PlayerEvents_1_8.java | 4 +- .../plot/listeners/PlotListener.java | 16 +- .../plot/listeners/PlotPlusListener.java | 14 +- .../plot/listeners/WorldEditListener.java | 10 +- .../plot/object/BukkitPlayer.java | 73 ++ .../plot/object/PlotPlayer.java | 40 +- .../plot/object/PlotSettings.java | 4 +- .../plot/util/ClusterManager.java | 7 +- .../plot/util/ExpireManager.java | 5 +- .../plot/util/MainUtil.java | 964 ++++++++++++++++++ .../plot/util/Permissions.java | 54 + .../plot/util/SchematicHandler.java | 6 +- .../plot/util/bukkit/ChunkManager.java | 11 +- .../plot/util/bukkit/PWE.java | 46 +- .../plot/util/bukkit/PlayerFunctions.java | 106 +- .../plot/util/bukkit/SetBlockFast.java | 6 +- .../plot/util/bukkit/SetBlockFast_1_8.java | 6 +- 47 files changed, 1501 insertions(+), 564 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 66dd2077f..74228ddac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -15,7 +15,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.ConsoleColors; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.*; import com.sk89q.worldedit.bukkit.WorldEditPlugin; @@ -43,83 +43,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS = null; public static PlotSquared MAIN = null; - // TODO restructure this - public static boolean hasPermission(final PlotPlayer p, final String perm) { - final Player player = Bukkit.getPlayer(p + ""); - 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; - } - - // TODO restructure this - public static int hasPermissionRange(final PlotPlayer 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; - } - - // TODO restructure this - public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) { - final Plot bot = PlotHelper.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(bot.world, bot); - final int x = location.getX(); - final 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")) { - PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT); - BukkitUtil.teleportPlayer(player, location); - return true; - } - PlayerFunctions.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + ""); - 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; - } - PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT); - BukkitUtil.teleportPlayer(player, location); - } - }, Settings.TELEPORT_DELAY * 20); - return true; - } - return !event.isCancelled(); - } - @EventHandler public static void worldLoad(final WorldLoadEvent event) { UUIDHandler.cacheAll(); @@ -253,7 +176,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { final Entity[] entities = chunk.getEntities(); Entity entity; for (int i = entities.length - 1; i >= 0; i--) { - if (!((entity = entities[i]) instanceof Player) && (PlotHelper.getPlot(BukkitUtil.getLocation(entity)) == null)) { + if (!((entity = entities[i]) instanceof Player) && (MainUtil.getPlot(BukkitUtil.getLocation(entity)) == null)) { entity.remove(); } } @@ -346,9 +269,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } try { new SendChunk(); - PlotHelper.canSendChunk = true; + MainUtil.canSendChunk = true; } catch (final Throwable e) { - PlotHelper.canSendChunk = false; + MainUtil.canSendChunk = false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index e158cf2db..b9742a59b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -52,7 +52,7 @@ import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.Logger; import com.intellectualcrafters.plot.util.Logger.LogLevel; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.bukkit.WorldEditPlugin; @@ -184,12 +184,12 @@ public class PlotSquared { } } plots.get(world).remove(id); - if (PlotHelper.lastPlot.containsKey(world)) { - final PlotId last = PlotHelper.lastPlot.get(world); + if (MainUtil.lastPlot.containsKey(world)) { + final PlotId last = MainUtil.lastPlot.get(world); final int last_max = Math.max(last.x, last.y); final int this_max = Math.max(id.x, id.y); if (this_max < last_max) { - PlotHelper.lastPlot.put(world, id); + MainUtil.lastPlot.put(world, id); } } return true; @@ -226,7 +226,7 @@ public class PlotSquared { } // Now add it addPlotWorld(world, plotWorld, plotManager); - PlotHelper.setupBorder(world); + MainUtil.setupBorder(world); } else { if (!worlds.contains(world)) { return; 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 582537c24..415994b05 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; @@ -163,7 +163,7 @@ public class Auto extends SubCommand { final PlotWorld plotworld = PlotSquared.getPlotWorld(worldname); if (plotworld.TYPE == 2) { final Location loc = BukkitUtil.getLocation(plr); - final Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + final Plot plot = MainUtil.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } @@ -182,7 +182,7 @@ public class Auto extends SubCommand { // for (int i = 0; i <= max; i++) { final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); - final Plot current = PlotHelper.getPlot(worldname, currentId); + final Plot current = MainUtil.getPlot(worldname, currentId); if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) { Claim.claimPlot(plr, current, true, true); return true; @@ -196,19 +196,19 @@ public class Auto extends SubCommand { boolean br = false; if ((size_x == 1) && (size_z == 1)) { while (!br) { - final Plot plot = PlotHelper.getPlot(worldname, getLastPlot(worldname)); + final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname)); if ((plot.owner == null)) { Claim.claimPlot(plr, plot, true, true); br = true; } - PlotHelper.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1)); + MainUtil.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1)); } } else { boolean lastPlot = true; while (!br) { final PlotId start = getNextPlot(getLastPlot(worldname), 1); // Checking if the current set of plots is a viable option. - PlotHelper.lastPlot.put(worldname, start); + MainUtil.lastPlot.put(worldname, start); if (lastPlot) { } if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) { @@ -217,29 +217,29 @@ public class Auto extends SubCommand { lastPlot = false; } final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1); - if (PlotHelper.isUnowned(worldname, start, end)) { + if (MainUtil.isUnowned(worldname, start, end)) { for (int i = start.x; i <= end.x; i++) { for (int j = start.y; j <= end.y; j++) { - final Plot plot = PlotHelper.getPlot(worldname, new PlotId(i, j)); + final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j)); final boolean teleport = ((i == end.x) && (j == end.y)); Claim.claimPlot(plr, plot, teleport, true); } } - if (!PlotHelper.mergePlots(plr, worldname, PlayerFunctions.getPlotSelectionIds(start, end))) { + if (!MainUtil.mergePlots(plr, worldname, PlayerFunctions.getPlotSelectionIds(start, end))) { return false; } br = true; } } } - PlotHelper.lastPlot.put(worldname, new PlotId(0, 0)); + MainUtil.lastPlot.put(worldname, new PlotId(0, 0)); return true; } public PlotId getLastPlot(final String world) { - if ((PlotHelper.lastPlot == null) || !PlotHelper.lastPlot.containsKey(world)) { - PlotHelper.lastPlot.put(world, new PlotId(0, 0)); + if ((MainUtil.lastPlot == null) || !MainUtil.lastPlot.containsKey(world)) { + MainUtil.lastPlot.put(world, new PlotId(0, 0)); } - return PlotHelper.lastPlot.get(world); + return MainUtil.lastPlot.get(world); } } 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 729214950..4a1410b8b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -59,7 +59,7 @@ public class Buy extends SubCommand { try { final String[] split = args[0].split(";"); final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - plot = PlotHelper.getPlot(world, id); + plot = MainUtil.getPlot(world, id); } catch (final Exception e) { return sendMessage(plr, C.NOT_VALID_PLOT_ID); } 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 8a10cacfc..b4aa672bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; @@ -55,8 +55,8 @@ public class Claim extends SubCommand { final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - PlotHelper.createPlot(player, plot); - PlotHelper.setSign(player, plot); + MainUtil.createPlot(player, plot); + MainUtil.setSign(player, plot); PlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); @@ -77,7 +77,7 @@ public class Claim extends SubCommand { SchematicHandler.paste(BukkitUtil.getLocation(entity), sch, plot2, 0, 0); } PlotSquared.getPlotManager(plot.world).claimPlot(world, plotworld, plot); - PlotHelper.update(BukkitUtil.getLocation(entity)); + MainUtil.update(BukkitUtil.getLocation(entity)); } return event.isCancelled(); } 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 82e63b284..56515a7ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -52,7 +52,7 @@ public class Clear extends SubCommand { if (!PlotSquared.isPlotWorld(world)) { PlotSquared.log("Invalid plot world: " + world); } else { - final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); + final Plot plot = MainUtil.getPlot(Bukkit.getWorld(world), id); if (plot == null) { PlotSquared.log("Could not find plot " + args[0] + " in world " + world); } else { 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 4d9c3e25d..6a3bed257 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -100,8 +100,8 @@ public class Cluster extends SubCommand { return false; } // check pos1 / pos2 - final PlotId pos1 = PlotHelper.parseId(args[2]); - final PlotId pos2 = PlotHelper.parseId(args[3]); + final PlotId pos1 = MainUtil.parseId(args[2]); + final PlotId pos2 = MainUtil.parseId(args[3]); if ((pos1 == null) || (pos2 == null)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; @@ -219,8 +219,8 @@ public class Cluster extends SubCommand { return false; } // check pos1 / pos2 - final PlotId pos1 = PlotHelper.parseId(args[1]); - final PlotId pos2 = PlotHelper.parseId(args[2]); + final PlotId pos1 = MainUtil.parseId(args[1]); + final PlotId pos2 = MainUtil.parseId(args[2]); if ((pos1 == null) || (pos2 == null)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; 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 8927ac563..177038dee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Condense extends SubCommand { @@ -91,13 +91,13 @@ public class Condense extends SubCommand { final List free = new ArrayList<>(); PlotId start = new PlotId(0, 0); while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) { - final Plot plot = PlotHelper.getPlot(world, start); + final Plot plot = MainUtil.getPlot(world, start); if (!plot.hasOwner()) { free.add(plot.id); } start = Auto.getNextPlot(start, 1); } - PlotHelper.move(world, to_move.get(0), free.get(0), new Runnable() { + MainUtil.move(world, to_move.get(0), free.get(0), new Runnable() { @Override public void run() { if (!TASK) { @@ -108,7 +108,7 @@ public class Condense extends SubCommand { free.remove(0); int index = 0; for (final PlotId id : to_move) { - final Plot plot = PlotHelper.getPlot(world, id); + final Plot plot = MainUtil.getPlot(world, id); if (plot.hasOwner()) { break; } @@ -119,7 +119,7 @@ public class Condense extends SubCommand { } index = 0; for (final PlotId id : free) { - final Plot plot = PlotHelper.getPlot(world, id); + final Plot plot = MainUtil.getPlot(world, id); if (!plot.hasOwner()) { break; } @@ -139,7 +139,7 @@ public class Condense extends SubCommand { return; } sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0)); - PlotHelper.move(world, to_move.get(0), free.get(0), this); + MainUtil.move(world, to_move.get(0), free.get(0), this); } }); TASK = true; 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 595b6ec72..9155eb44c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -50,7 +50,7 @@ public class Copy extends SubCommand { PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); return false; } - final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); + final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); final PlotSelection selection = new PlotSelection(size, plr.getWorld(), plot); if (PlotSelection.currentSelection.containsKey(plr.getName())) { PlotSelection.currentSelection.remove(plr.getName()); 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 298bc09d6..6fe230b68 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class CreateRoadSchematic extends SubCommand { @@ -47,7 +47,7 @@ public class CreateRoadSchematic extends SubCommand { final Plot plot = PlayerFunctions.getCurrentPlot(player); final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); - PlotHelper.update(BukkitUtil.getLocation(entity)); + MainUtil.update(BukkitUtil.getLocation(entity)); PlayerFunctions.sendMessage(player, "&6Saved new road schematic"); return true; } 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 12f78918c..5e8fa1503 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -27,7 +27,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.util.Lag; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.RUtils; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; @@ -71,10 +71,10 @@ public class Debug extends SubCommand { // PlotHelper.getWorldFolderSize() + "MB")); 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))); - information.append(getLine(line, " - Loaded Tile Entities", PlotHelper.getTileEntities(world))); - information.append(getLine(line, " - Loaded Chunks", PlotHelper.getLoadedChunks(world))); + information.append(getLine(line, "World: " + world.getName() + " size", MainUtil.getWorldFolderSize(world))); + information.append(getLine(line, " - Entities", MainUtil.getEntities(world))); + information.append(getLine(line, " - Loaded Tile Entities", MainUtil.getTileEntities(world))); + information.append(getLine(line, " - Loaded Chunks", MainUtil.getLoadedChunks(world))); } information.append(getSection(section, "RAM")); information.append(getLine(line, "Free Ram", RUtils.getFreeRam() + "MB")); 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 efa51ca31..b096bf018 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -62,8 +62,8 @@ public class DebugClaimTest extends SubCommand { final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - PlotHelper.createPlot(player, plot); - PlotHelper.setSign(player, plot); + MainUtil.createPlot(player, plot); + MainUtil.setSign(player, plot); PlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); @@ -97,7 +97,7 @@ public class DebugClaimTest extends SubCommand { final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final ArrayList plots = new ArrayList<>(); for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) { - final Plot plot = PlotHelper.getPlot(world, id); + final Plot plot = MainUtil.getPlot(world, id); final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id); if (contains) { PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id); 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 9fe93bd54..fca76528f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -56,22 +56,22 @@ public class DebugClear extends SubCommand { if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) { PlotSquared.log("Invalid plot world: " + world); } else { - final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); + final Plot plot = MainUtil.getPlot(Bukkit.getWorld(world), id); if (plot == null) { PlotSquared.log("Could not find plot " + args[0] + " in world " + world); } else { final World bukkitWorld = Bukkit.getWorld(world); - final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id); - if (PlotHelper.runners.containsKey(plot)) { + final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); + if (MainUtil.runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return false; } - PlotHelper.runners.put(plot, 1); + MainUtil.runners.put(plot, 1); ChunkManager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { - PlotHelper.runners.remove(plot); + MainUtil.runners.remove(plot); PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); PlotSquared.log("&aDone!"); } @@ -94,17 +94,17 @@ public class DebugClear extends SubCommand { } assert plot != null; final World bukkitWorld = plr.getWorld(); - final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id); - if (PlotHelper.runners.containsKey(plot)) { + final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); + if (MainUtil.runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return false; } - PlotHelper.runners.put(plot, 1); + MainUtil.runners.put(plot, 1); ChunkManager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { - PlotHelper.runners.remove(plot); + MainUtil.runners.remove(plot); PlayerFunctions.sendMessage(plr, "&aDone!"); } }); 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 239126d80..68446eb5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.object.InfoInventory; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -79,7 +79,7 @@ public class Info extends SubCommand { try { final String[] split = args[1].split(";"); final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - plot = PlotHelper.getPlot(Bukkit.getWorld(plotworld.worldname), id); + plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id); if (plot == null) { PlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID); return false; @@ -227,7 +227,7 @@ public class Info extends SubCommand { private Biome getBiomeAt(final Plot plot) { final World w = Bukkit.getWorld(plot.world); - final Location bl = PlotHelper.getPlotTopLoc(w, plot.id); + final Location bl = MainUtil.getPlotTopLoc(w, plot.id); return bl.getBlock().getBiome(); } } 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 efe7ee710..2971839a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -128,10 +128,10 @@ public class Merge extends SubCommand { } final PlotId botId = plots.get(0); final PlotId topId = plots.get(plots.size() - 1); - final PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id; - final PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id; - final PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id; - final PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id; + final PlotId bot1 = PlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, botId)).id; + final PlotId bot2 = PlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, topId)).id; + final PlotId top1 = PlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, topId)).id; + final PlotId top2 = PlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, botId)).id; bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y)); top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y)); plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top); @@ -164,9 +164,9 @@ public class Merge extends SubCommand { return false; } PlayerFunctions.sendMessage(plr, "&cPlots have been merged"); - PlotHelper.mergePlots(world, plots, true); - PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot); - PlotHelper.update(plr.getLocation()); + MainUtil.mergePlots(world, plots, true); + MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot); + MainUtil.update(plr.getLocation()); return true; } } 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 39d78be0c..4209dedd7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -24,7 +24,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** @@ -47,8 +47,8 @@ public class Move extends SubCommand { return false; } final World world = plr.getWorld(); - final PlotId plot1 = PlotHelper.parseId(args[0]); - final PlotId plot2 = PlotHelper.parseId(args[1]); + final PlotId plot1 = MainUtil.parseId(args[0]); + final PlotId plot2 = MainUtil.parseId(args[1]); if ((plot1 == null) || (plot2 == null)) { PlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move "); return false; @@ -57,7 +57,7 @@ public class Move extends SubCommand { PlayerFunctions.sendMessage(plr, "DUPLICATE ID"); return false; } - if (PlotHelper.move(world, plot1, plot2, new Runnable() { + if (MainUtil.move(world, plot1, plot2, new Runnable() { @Override public void run() { PlayerFunctions.sendMessage(plr, "MOVE SUCCESS"); 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 16c27699f..bd0b84c31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -50,7 +50,7 @@ public class Paste extends SubCommand { return false; } assert plot != null; - final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); + final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); if (PlotSelection.currentSelection.containsKey(plr.getName())) { final PlotSelection selection = PlotSelection.currentSelection.get(plr.getName()); if (size != selection.getWidth()) { 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 4a134b7c8..4b555592f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; @@ -101,8 +101,8 @@ public class Schematic extends SubCommand { final int z; final Plot plot2 = PlayerFunctions.getCurrentPlot(plr); final Dimension dem = schematic.getSchematicDimension(); - final Location bot = PlotHelper.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1); - final int length2 = PlotHelper.getPlotWidth(plr.getWorld(), plot2.id); + final Location bot = MainUtil.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1); + final int length2 = MainUtil.getPlotWidth(plr.getWorld(), plot2.id); if ((dem.getX() > length2) || (dem.getZ() > length2)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2)); Schematic.this.running = false; @@ -131,7 +131,7 @@ public class Schematic extends SubCommand { final int start = Schematic.this.counter * 5000; if (start > blen) { sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); - PlotHelper.update(plr.getLocation()); + MainUtil.update(plr.getLocation()); Schematic.this.running = false; Bukkit.getScheduler().cancelTask(Schematic.this.task); return; @@ -167,7 +167,7 @@ public class Schematic extends SubCommand { final int l1 = schematic.getSchematicDimension().getX(); final int l2 = schematic.getSchematicDimension().getZ(); final Plot plot = PlayerFunctions.getCurrentPlot(plr); - final int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id); + final int length = MainUtil.getPlotWidth(plr.getWorld(), plot.id); if ((l1 < length) || (l2 < length)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); break; 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 b12466047..9fc4b40c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -46,7 +46,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -177,7 +177,7 @@ public class Set extends SubCommand { } //set to current location final World world = plr.getWorld(); - final Location base = PlotHelper.getPlotBottomLoc(world, plot.id); + final Location base = MainUtil.getPlotBottomLoc(world, plot.id); base.setY(0); final Location relative = plr.getLocation().subtract(base); final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); @@ -231,7 +231,7 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); return true; } - PlotHelper.setBiome(plr.getWorld(), plot, biome); + MainUtil.setBiome(plr.getWorld(), plot, biome); PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); return true; } 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 6f2266b24..7634e80a7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -83,7 +83,7 @@ public class SetOwner extends SubCommand { PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); } } - PlotHelper.setSign(world, args[0], plot); + MainUtil.setSign(world, args[0], plot); PlayerFunctions.sendMessage(plr, C.SET_OWNER); return true; } 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 291cc0e5d..8691d4d83 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -86,10 +86,10 @@ public class Swap extends SubCommand { } PlotSelection.swap(world, plot.id, plotid); // TODO Requires testing!! - DBFunc.dbManager.swapPlots(plot, PlotHelper.getPlot(world, plotid)); + DBFunc.dbManager.swapPlots(plot, MainUtil.getPlot(world, plotid)); // TODO Requires testing!! PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS); - PlotHelper.update(plr.getLocation()); + MainUtil.update(plr.getLocation()); return true; } } 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 de091975e..7a417e4bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; /** @@ -65,7 +65,7 @@ public class TP extends SubCommand { } try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); - PlotSquared.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid)); + PlotSquared.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid)); return true; } catch (final Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); 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 5a1de4393..e94e9dfcc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -26,7 +26,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public class Target extends SubCommand { @@ -41,12 +41,12 @@ public class Target extends SubCommand { return false; } if (args.length == 1) { - final PlotId id = PlotHelper.parseId(args[1]); + final PlotId id = MainUtil.parseId(args[1]); if (id == null) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } - final Location loc = PlotHelper.getPlotHome(plr.getWorld(), id); + final Location loc = MainUtil.getPlotHome(plr.getWorld(), id); plr.setCompassTarget(loc); PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET); return true; 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 80cf9a4e4..5bb545090 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; @@ -190,8 +190,8 @@ public class Trim extends SubCommand { } final Plot plot = plots.get(0); plots.remove(0); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id); - final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); + final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id); + final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); final Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ()); final Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ()); chunks.remove(ChunkManager.getChunkChunk(pos1)); 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 6e70eabba..0569a23ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -67,7 +67,7 @@ public class Unlink extends SubCommand { return false; } try { - PlotHelper.update(plr.getLocation()); + MainUtil.update(plr.getLocation()); } catch (final Exception e) { // execute(final Player plr, final String... args) { try { @@ -112,7 +112,7 @@ public class Unlink extends SubCommand { for (int y = pos1.y; y <= pos2.y; y++) { final boolean lx = x < pos2.x; final boolean ly = y < pos2.y; - final Plot p = PlotHelper.getPlot(world, new PlotId(x, y)); + final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); if (lx) { manager.createRoadEast(plotworld, p); if (ly) { @@ -122,16 +122,16 @@ public class Unlink extends SubCommand { if (ly) { manager.createRoadSouth(plotworld, p); } - PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot); } } manager.finishPlotUnlink(world, plotworld, ids); for (final PlotId id : ids) { - final Plot myPlot = PlotHelper.getPlot(world, id); + final Plot myPlot = MainUtil.getPlot(world, id); if (plot.hasOwner()) { final String name = UUIDHandler.getName(myPlot.owner); if (name != null) { - PlotHelper.setSign(world, name, myPlot); + MainUtil.setSign(world, name, myPlot); } } } 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 7a7b1769d..cd69cf2c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -18,7 +18,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.AChunkManager; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; 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 a22103198..9aa9bd496 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -10,7 +10,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; /** * A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot) @@ -37,9 +37,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final Location pos1 = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid); - PlotHelper.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks); + final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(world, plotid); + MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks); return true; } @@ -48,31 +48,31 @@ public abstract class ClassicPlotManager extends SquarePlotManager { if (dpw.ROAD_WIDTH == 0) { return false; } - final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); - final Location top = PlotHelper.getPlotTopLoc(w, plotid); + final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); + final Location top = MainUtil.getPlotTopLoc(w, plotid); int x, z; z = bottom.getBlockZ(); for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - PlotHelper.setBlock(w, x, y, z, blocks); + MainUtil.setBlock(w, x, y, z, blocks); } } x = top.getBlockX() + 1; for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - PlotHelper.setBlock(w, x, y, z, blocks); + MainUtil.setBlock(w, x, y, z, blocks); } } z = top.getBlockZ() + 1; for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - PlotHelper.setBlock(w, x, y, z, blocks); + MainUtil.setBlock(w, x, y, z, blocks); } } x = bottom.getBlockX(); for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - PlotHelper.setBlock(w, x, y, z, blocks); + MainUtil.setBlock(w, x, y, z, blocks); } } return true; @@ -83,24 +83,24 @@ public abstract class ClassicPlotManager extends SquarePlotManager { if (dpw.ROAD_WIDTH == 0) { return false; } - final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid); - final Location top = PlotHelper.getPlotTopLoc(w, plotid); + final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); + final Location top = MainUtil.getPlotTopLoc(w, plotid); int x, z; z = bottom.getBlockZ(); for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) { - PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } x = top.getBlockX() + 1; for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) { - PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } z = top.getBlockZ() + 1; for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) { - PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } x = bottom.getBlockX(); for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) { - PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } return true; } @@ -118,13 +118,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos1.getBlockZ() - 1; final int ez = pos2.getBlockZ() + 2; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); - PlotHelper.setCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); - PlotHelper.setCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); + MainUtil.setCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); + MainUtil.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); + MainUtil.setCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); + MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @@ -138,13 +138,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int sx = pos1.getBlockX() - 1; final int ex = pos2.getBlockX() + 2; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); - PlotHelper.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING); - PlotHelper.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); + MainUtil.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); + MainUtil.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING); + MainUtil.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK); + MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @@ -157,9 +157,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos2.getBlockZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + MainUtil.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @@ -173,9 +173,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos1.getBlockZ(); final int ez = pos2.getBlockZ() + 1; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); + MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); + MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } @@ -189,9 +189,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int sx = pos1.getBlockX(); final int ex = pos2.getBlockX() + 1; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); + MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); + MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } @@ -204,9 +204,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = loc.getBlockZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - PlotHelper.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); - PlotHelper.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); + MainUtil.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); + MainUtil.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); return true; } @@ -277,7 +277,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { @Override public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final Location bot = PlotHelper.getPlotBottomLoc(plotworld.worldname, plot.id); + final Location bot = MainUtil.getPlotBottomLoc(plotworld.worldname, plot.id); return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getBlockX(), dpw.ROAD_HEIGHT + 1, bot.getBlockZ() - 1); } } 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 6f3531aa2..b101631f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -40,7 +40,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; @@ -54,8 +54,8 @@ public class HybridPlotManager extends ClassicPlotManager { public static boolean checkModified(final Plot plot, int requiredChanges) { final World world = Bukkit.getWorld(plot.world); - final Location bottom = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location top = PlotHelper.getPlotTopLoc(world, plot.id); + final Location bottom = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + final Location top = MainUtil.getPlotTopLoc(world, plot.id); final int botx = bottom.getBlockX(); final int botz = bottom.getBlockZ(); final int topx = top.getBlockX(); @@ -109,8 +109,8 @@ public class HybridPlotManager extends ClassicPlotManager { public boolean setupRoadSchematic(final Plot plot) { final World world = Bukkit.getWorld(plot.world); - final Location bot = PlotHelper.getPlotBottomLoc(world, plot.id); - final Location top = PlotHelper.getPlotTopLoc(world, plot.id); + final Location bot = MainUtil.getPlotBottomLoc(world, plot.id); + final Location top = MainUtil.getPlotTopLoc(world, plot.id); final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); final int sx = (bot.getBlockX() - plotworld.ROAD_WIDTH) + 1; final int sz = bot.getBlockZ() + 1; @@ -231,13 +231,13 @@ public class HybridPlotManager extends ClassicPlotManager { chunk.load(false); } if (id1 != null) { - final Plot p1 = PlotHelper.getPlot(world, id1); + final Plot p1 = MainUtil.getPlot(world, id1); if ((p1 != null) && p1.hasOwner() && p1.settings.isMerged()) { toCheck = true; } } if ((id2 != null) && !toCheck) { - final Plot p2 = PlotHelper.getPlot(world, id2); + final Plot p2 = MainUtil.getPlot(world, id2); if ((p2 != null) && p2.hasOwner() && p2.settings.isMerged()) { toCheck = true; } @@ -269,13 +269,13 @@ public class HybridPlotManager extends ClassicPlotManager { final ChunkLoc loc = new ChunkLoc(absX, absZ); final HashMap blocks = plotworld.G_SCH.get(loc); for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT); y++) { - PlotHelper.setBlock(world, x + X, sy + y, z + Z, 0, (byte) 0); + MainUtil.setBlock(world, x + X, sy + y, z + Z, 0, (byte) 0); } if (blocks != null) { final HashMap datas = plotworld.G_SCH_DATA.get(loc); if (datas == null) { for (final Short y : blocks.keySet()) { - PlotHelper.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0); + MainUtil.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0); } } else { for (final Short y : blocks.keySet()) { @@ -283,7 +283,7 @@ public class HybridPlotManager extends ClassicPlotManager { if (data == null) { data = 0; } - PlotHelper.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), data); + MainUtil.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), data); } } } @@ -310,7 +310,7 @@ public class HybridPlotManager extends ClassicPlotManager { final HashMap datas = hpw.G_SCH_DATA.get(loc); if (datas == null) { for (final Short y : blocks.keySet()) { - PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0); + MainUtil.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0); } } else { for (final Short y : blocks.keySet()) { @@ -318,7 +318,7 @@ public class HybridPlotManager extends ClassicPlotManager { if (data == null) { data = 0; } - PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data); + MainUtil.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data); } } } @@ -328,11 +328,11 @@ public class HybridPlotManager extends ClassicPlotManager { if (block.id != 0) { for (final PlotId id : plotIds) { setWall(world, plotworld, id, new PlotBlock[] { ((ClassicPlotWorld) plotworld).WALL_BLOCK }); - final Plot plot = PlotHelper.getPlot(world, id); + final Plot plot = MainUtil.getPlot(world, id); if (plot.hasOwner()) { final String name = UUIDHandler.getName(plot.owner); if (name != null) { - PlotHelper.setSign(world, name, plot); + MainUtil.setSign(world, name, plot); } } } @@ -348,17 +348,17 @@ public class HybridPlotManager extends ClassicPlotManager { */ @Override public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { - PlotHelper.runners.put(plot, 1); + MainUtil.runners.put(plot, 1); final Plugin plugin = PlotSquared.getMain(); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.runners.remove(plot); + MainUtil.runners.remove(plot); } }, 90L); final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld); - final Location pos1 = PlotHelper.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLocAbs(world, plot.id); + final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id); final PlotBlock[] plotfloor = dpw.TOP_BLOCK; final PlotBlock[] filling = dpw.MAIN_BLOCK; // PlotBlock wall = dpw.WALL_BLOCK; @@ -384,19 +384,19 @@ public class HybridPlotManager extends ClassicPlotManager { @Override public void run() { if ((pos2.getBlockX() - pos1.getBlockX()) < 48) { - PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); } }, 5L); } @@ -409,8 +409,8 @@ public class HybridPlotManager extends ClassicPlotManager { final int startZ = (pos1.getBlockZ() / 16) * 16; final int chunkX = 16 + pos2.getBlockX(); final int chunkZ = 16 + pos2.getBlockZ(); - final Location l1 = PlotHelper.getPlotBottomLoc(world, plot.id); - final Location l2 = PlotHelper.getPlotTopLoc(world, plot.id); + final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id); + final Location l2 = MainUtil.getPlotTopLoc(world, plot.id); final int plotMinX = l1.getBlockX() + 1; final int plotMinZ = l1.getBlockZ() + 1; final int plotMaxX = l2.getBlockX(); @@ -419,23 +419,23 @@ public class HybridPlotManager extends ClassicPlotManager { Location mx = null; for (int i = startX; i < chunkX; i += 16) { for (int j = startZ; j < chunkZ; j += 16) { - final Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j)); + final Plot plot1 = MainUtil.getCurrentPlot(new Location(world, i, 0, j)); if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) { break; } - final Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j)); + final Plot plot2 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j)); if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) { break; } - final Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + final Plot plot3 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) { break; } - final Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15)); + final Plot plot4 = MainUtil.getCurrentPlot(new Location(world, i, 0, j + 15)); if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) { break; } - final Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + final Plot plot5 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) { break; } @@ -451,19 +451,19 @@ public class HybridPlotManager extends ClassicPlotManager { final Location max = mx; final Location min = mn; if (min == null) { - PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); } }, 5L); } @@ -487,19 +487,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); } }, 1L); } @@ -511,19 +511,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); } }, 1L); } @@ -535,19 +535,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); } }, 1L); } @@ -559,19 +559,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); } }, 1L); } @@ -583,19 +583,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); } }, 1L); } @@ -607,19 +607,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); } }, 1L); } @@ -631,19 +631,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); } }, 1L); } @@ -655,19 +655,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); TaskManager.runTask(whenDone); } }, 1L); 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 58740422e..aced4227a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -10,7 +10,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; @@ -20,8 +20,8 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; public abstract class SquarePlotManager extends GridPlotManager { @Override public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whendone) { - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); + final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); ChunkManager.regenerateRegion(pos1, pos2, whendone); return true; } @@ -170,11 +170,11 @@ public abstract class SquarePlotManager extends GridPlotManager { */ @Override public boolean setBiome(final World world, final Plot plot, final Biome biome) { - final int bottomX = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX() - 1; - final int topX = PlotHelper.getPlotTopLoc(world, plot.id).getBlockX() + 1; - final int bottomZ = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1; - final int topZ = PlotHelper.getPlotTopLoc(world, plot.id).getBlockZ() + 1; - final Block block = world.getBlockAt(PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 1, 1)); + final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getBlockX() - 1; + final int topX = MainUtil.getPlotTopLoc(world, plot.id).getBlockX() + 1; + final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getBlockZ() - 1; + final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getBlockZ() + 1; + final Block block = world.getBlockAt(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 1, 1)); final Biome current = block.getBiome(); if (biome.equals(current)) { return false; 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 3f4520a43..0dba37f39 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -99,7 +99,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; @@ -122,13 +122,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi PlotSquared.loadWorld(world.getName(), null); } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onChunkLoad(final ChunkLoadEvent event) { final String worldname = event.getWorld().getName(); final Chunk chunk = event.getChunk(); - if (PlotHelper.worldBorder.containsKey(worldname)) { - final int border = PlotHelper.getBorder(worldname); + if (MainUtil.worldBorder.containsKey(worldname)) { + final int border = MainUtil.getBorder(worldname); final int x = Math.abs(chunk.getX() << 4); final int z = Math.abs(chunk.getZ() << 4); if ((x > border) || (z > border)) { @@ -136,7 +136,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onJoin(final PlayerJoinEvent event) { final Player player = event.getPlayer(); @@ -148,17 +148,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final UUID uuid = UUIDHandler.getUUID(player); UUIDHandler.add(name, uuid); final Location loc = BukkitUtil.getLocation(player.getLocation()); - final Plot plot = PlotHelper.getPlot(loc); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return; } if (Settings.TELEPORT_ON_LOGIN) { - BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(plot)); + BukkitUtil.teleportPlayer(player, MainUtil.getPlotHomeDefault(plot)); PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); } plotEntry(player, plot); } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void PlayerMove(final PlayerMoveEvent event) { final Location f = BukkitUtil.getLocation(event.getFrom()); @@ -172,8 +172,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(worldname)) { return; } - if (PlotHelper.worldBorder.containsKey(worldname)) { - final int border = PlotHelper.getBorder(worldname); + if (MainUtil.worldBorder.containsKey(worldname)) { + final int border = MainUtil.getBorder(worldname); boolean passed = true; if (t.getX() > border) { event.getTo().setX(border); @@ -212,7 +212,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onChat(final AsyncPlayerChatEvent event) { final Player player = event.getPlayer(); @@ -244,7 +244,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi format = ChatColor.translateAlternateColorCodes('&', format); event.setFormat(format); } - + @EventHandler(priority = EventPriority.HIGH) public static void BlockDestroy(final BlockBreakEvent event) { final Player player = event.getPlayer(); @@ -292,7 +292,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onBigBoom(final EntityExplodeEvent event) { final String world = event.getLocation().getWorld().getName(); @@ -325,7 +325,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { final String world = event.getBlock().getWorld().getName(); @@ -371,7 +371,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityBlockForm(final EntityBlockFormEvent e) { final String world = e.getBlock().getWorld().getName(); @@ -384,7 +384,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBS(final BlockSpreadEvent e) { final Block b = e.getBlock(); @@ -397,7 +397,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBF(final BlockFormEvent e) { final Block b = e.getBlock(); @@ -410,7 +410,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBD(final BlockDamageEvent e) { final Block b = e.getBlock(); @@ -423,7 +423,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onFade(final BlockFadeEvent e) { final Block b = e.getBlock(); @@ -436,7 +436,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onChange(final BlockFromToEvent e) { final Block b = e.getToBlock(); @@ -449,7 +449,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onGrow(final BlockGrowEvent e) { final Block b = e.getBlock(); @@ -462,7 +462,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonExtend(final BlockPistonExtendEvent e) { if (isInPlot(BukkitUtil.getLocation(e.getBlock().getLocation()))) { @@ -476,7 +476,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonRetract(final BlockPistonRetractEvent e) { final Block b = e.getRetractLocation().getBlock(); @@ -489,7 +489,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onStructureGrow(final StructureGrowEvent e) { if (!isPlotWorld(e.getWorld().getName())) { @@ -505,7 +505,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractEvent event) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) { @@ -555,7 +555,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void MobSpawn(final CreatureSpawnEvent event) { if (event.getEntity() instanceof Player) { @@ -582,9 +582,31 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBlockIgnite(final BlockIgniteEvent e) { + Player player = e.getPlayer(); + final Block b = e.getBlock(); + final Location loc; + if (b != null) { + loc = BukkitUtil.getLocation(b.getLocation()); + } + else { + Entity ent = e.getIgnitingEntity(); + if (ent != null) { + loc = BukkitUtil.getLocation(ent); + } + else { + if (player != null) { + loc = BukkitUtil.getLocation(player); + } + else { + return; + } + } + } + + final String world; if (e.getBlock() != null) { world = e.getBlock().getWorld().getName(); @@ -602,46 +624,41 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - final Block b = e.getBlock(); - final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (b != null) { - if (e.getPlayer() != null) { - final Player p = e.getPlayer(); - if (!isInPlot(loc)) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + Player player = e.getPlayer(); + if (player == null) { + if (isPlotArea(loc)) { + e.setCancelled(true); + } + return; + } + final Player p = e.getPlayer(); + if (!isInPlot(loc)) { + if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + e.setCancelled(true); + return; + } + } else { + final Plot plot = getCurrentPlot(loc); + if ((plot == null) || !plot.hasOwner()) { + if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + e.setCancelled(true); + return; + } + } else { + UUID uuid = UUIDHandler.getUUID(p); + if (!plot.isAdded(uuid)) if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { + if (isPlotArea(loc)) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } - } else { - final Plot plot = getCurrentPlot(loc); - if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); - e.setCancelled(true); - return; - } - } else { - UUID uuid = UUIDHandler.getUUID(p); - if (!plot.isAdded(uuid)) - if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { - if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); - e.setCancelled(true); - return; - } - } - } - } - } - } else { - if (isPlotArea(loc)) { - e.setCancelled(true); } } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onTeleport(final PlayerTeleportEvent event) { final Location f = BukkitUtil.getLocation(event.getFrom()); @@ -650,7 +667,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(q)) { if (isInPlot(q)) { final Plot plot = getCurrentPlot(q); - if (plot.deny_entry(event.getPlayer())) { + + if (plot.isDenied(event.getPlayer())) { PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED); event.setCancelled(true); return; @@ -671,7 +689,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { final BlockFace bf = e.getBlockFace(); @@ -712,7 +730,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onInventoryClick(final InventoryClickEvent event) { if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { @@ -720,7 +738,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler public static void onLeave(final PlayerQuitEvent event) { if (Setup.setupMap.containsKey(event.getPlayer().getName())) { @@ -737,7 +755,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketFill(final PlayerBucketFillEvent e) { final Block b = e.getBlockClicked(); @@ -778,7 +796,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingPlace(final HangingPlaceEvent e) { final Block b = e.getBlock(); @@ -814,7 +832,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { final Entity r = e.getRemover(); @@ -852,7 +870,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { final Location l = e.getRightClicked().getLocation(); @@ -897,7 +915,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onVehicleDestroy(final VehicleDestroyEvent e) { final Location l = e.getVehicle().getLocation(); @@ -938,7 +956,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { final Location l = e.getEntity().getLocation(); @@ -1008,7 +1026,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerEggThrow(final PlayerEggThrowEvent e) { final Location l = BukkitUtil.getLocation(e.getEgg().getLocation()); @@ -1040,7 +1058,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH) public void BlockCreate(final BlockPlaceEvent event) { final Player player = event.getPlayer(); 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 256f41c32..d1d642b60 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 @@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -29,7 +29,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { e.setCancelled(true); } } else { - final Plot plot = PlotHelper.getPlot(l); + final Plot plot = MainUtil.getPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); 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 64571a2c8..d1754a687 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -70,7 +70,7 @@ public class PlotListener { } public static boolean isInPlot(final String world, final int x, final int y, final int z) { - return (PlotHelper.getPlot(new Location(world, x, y, z)) != null); + return (MainUtil.getPlot(new Location(world, x, y, z)) != null); } public static boolean isPlotWorld(final String world) { @@ -101,14 +101,14 @@ public class PlotListener { } public static boolean enteredPlot(final Location l1, final Location l2) { - final PlotId p1 = PlotHelper.getPlotId(l1); - final PlotId p2 = PlotHelper.getPlotId(l2); + final PlotId p1 = MainUtil.getPlotId(l1); + final PlotId p2 = MainUtil.getPlotId(l2); return (p2 != null) && ((p1 == null) || !p1.equals(p2)); } public static boolean leftPlot(final Location l1, final Location l2) { - final PlotId p1 = PlotHelper.getPlotId(l1); - final PlotId p2 = PlotHelper.getPlotId(l2); + final PlotId p1 = MainUtil.getPlotId(l1); + final PlotId p2 = MainUtil.getPlotId(l2); return (p1 != null) && ((p2 == null) || !p1.equals(p2)); } @@ -121,11 +121,11 @@ public class PlotListener { } public static Plot getCurrentPlot(final Location loc) { - final PlotId id = PlotHelper.getPlotId(loc); + final PlotId id = MainUtil.getPlotId(loc); if (id == null) { return null; } - return PlotHelper.getPlot(loc.getWorld(), id); + return MainUtil.getPlot(loc.getWorld(), id); } private static WeatherType getWeatherType(String str) { 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 15c376d1c..183ff5d6e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -52,7 +52,7 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -106,7 +106,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } event.setCancelled(true); - final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return; @@ -118,7 +118,7 @@ public class PlotPlusListener extends PlotListener implements Listener { } final Set plotPlayers = new HashSet<>(); for (final Player p : player.getWorld().getPlayers()) { - Plot newPlot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + Plot newPlot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot.equals(newPlot)) { plotPlayers.add(p); } @@ -145,7 +145,7 @@ public class PlotPlusListener extends PlotListener implements Listener { if (player.getGameMode() != GameMode.SURVIVAL) { return; } - final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { return; } @@ -160,7 +160,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } final Player player = (Player) event.getEntity(); - final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { return; } @@ -172,7 +172,7 @@ public class PlotPlusListener extends PlotListener implements Listener { @EventHandler public void onItemPickup(final PlayerPickupItemEvent event) { final Player player = event.getPlayer(); - final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { return; } @@ -185,7 +185,7 @@ public class PlotPlusListener extends PlotListener implements Listener { @EventHandler public void onItemDrop(final PlayerDropItemEvent event) { final Player player = event.getPlayer(); - final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player)); + final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { return; } 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 ca83a8132..a9e85a832 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -47,7 +47,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; @@ -107,7 +107,7 @@ public class WorldEditListener implements Listener { return; } com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(b.getLocation()); - final Plot plot = PlotHelper.getPlot(loc); + final Plot plot = MainUtil.getPlot(loc); if (plot != null) { if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { PWE.setMask(p, loc, false); @@ -126,7 +126,7 @@ public class WorldEditListener implements Listener { cmd = cmd.substring(0, cmd.indexOf(" ")); } if (this.restrictedcmds.contains(cmd)) { - final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(p)); + final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(p)); if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { e.setCancelled(true); } @@ -198,8 +198,8 @@ public class WorldEditListener implements Listener { com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f); com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) { - final PlotId idF = PlotHelper.getPlotId(locf); - final PlotId idT = PlotHelper.getPlotId(loct); + final PlotId idF = MainUtil.getPlotId(locf); + final PlotId idT = MainUtil.getPlotId(loct); if ((idT != null) && !(idF == idT)) { PWE.setMask(p, loct, false); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java new file mode 100644 index 000000000..f20bf2043 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -0,0 +1,73 @@ +package com.intellectualcrafters.plot.object; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class BukkitPlayer implements PlotPlayer { + + public final Player player; + UUID uuid; + String name; + + public BukkitPlayer(Player player, String name, UUID uuid) { + this.player = player; + this.name = name; + this.uuid = uuid; + } + + public BukkitPlayer(Player player) { + this.player = player; + } + + @Override + public Location getLocation() { + return BukkitUtil.getLocation(this.player); + } + + @Override + public UUID getUUID() { + if (this.uuid == null) { + this.uuid = UUIDHandler.getUUID(this.player); + } + return this.uuid; + } + + @Override + public boolean hasPermission(String perm) { + return player.hasPermission(perm); + } + + @Override + public void sendMessage(String message) { + this.player.sendMessage(message); + } + + @Override + public void teleport(Location loc) { + this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ())); + + } + + @Override + public boolean isOp() { + return this.player.isOp(); + } + + @Override + public String getName() { + if (this.name == null) { + this.name = player.getName(); + } + return this.name; + } + + @Override + public boolean isOnline() { + return this.player.isOnline(); + } + +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index def9810e1..2d0b7d62c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -10,34 +10,20 @@ import java.util.UUID; * * @author Citymonstret */ -public class PlotPlayer { +public interface PlotPlayer { + public Location getLocation(); - private final String name; - private final Location location; + public UUID getUUID(); - public PlotPlayer(final String name, final Location location) { - this.name = name; - this.location = location; - } + public boolean hasPermission(final String perm); - @Override - public String toString() { - return this.name; - } - - public Location getLocation() { - return this.location; - } - - public UUID getUUID() { - return UUIDHandler.getUUID(name); - } - - public boolean hasPermission(final String perm) { - return BukkitMain.hasPermission(this, perm); - } - - public void sendMessage(final String message) { - return BukkitMain.sendMessage( final PlotPlayer player); - } + public void sendMessage(final String message); + + public void teleport(final Location loc); + + public boolean isOp(); + + public boolean isOnline(); + + public String getName(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 47a8c0442..cf5928a1f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -27,7 +27,7 @@ import org.bukkit.block.Biome; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** @@ -107,7 +107,7 @@ public class PlotSettings { * @return biome at plot loc */ public Biome getBiome() { - final Location loc = PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); + final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); return BukkitUtil.getBiome(loc); } 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 46d3ee806..b313f4d8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; @@ -57,11 +58,11 @@ public class ClusterManager { if (home.y == 0) { // default pos final PlotId center = getCenterPlot(cluster); - toReturn = PlotHelper.getPlotHome(cluster.world, center); + toReturn = MainUtil.getPlotHome(cluster.world, center); if (toReturn.getY() == 0) { final PlotManager manager = PlotSquared.getPlotManager(cluster.world); final PlotWorld plotworld = PlotSquared.getPlotWorld(cluster.world); - final Location loc = manager.getSignLoc(plotworld, PlotHelper.getPlot(cluster.world, center)); + final Location loc = manager.getSignLoc(plotworld, MainUtil.getPlot(cluster.world, center)); toReturn.setY(loc.getY()); } } else { @@ -261,7 +262,7 @@ public class ClusterManager { ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName()); final Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner); if (owner != null) { - PlayerFunctions.sendMessage(owner, C.CLEARING_DONE); + MainUtil.sendMessage(new BukkitPlayer(owner), C.CLEARING_DONE); } } }, (interval * chunks.size()) + 20); 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 e1ac03167..e7794a636 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; @@ -104,7 +105,7 @@ public class ExpireManager { for (final UUID helper : plot.helpers) { final Player player = UUIDHandler.uuidWrapper.getPlayer(helper); if (player != null) { - PlayerFunctions.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString()); + MainUtil.sendMessage(new BukkitPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString()); } } final PlotManager manager = PlotSquared.getPlotManager(world); @@ -113,7 +114,7 @@ public class ExpireManager { } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.clearPlot(plotworld, plot, false, null); - PlotHelper.removeSign(plot); + MainUtil.removeSign(plot); DBFunc.delete(world, plot); PlotSquared.removePlot(world, plot.id, true); expiredPlots.get(world).remove(plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java new file mode 100644 index 000000000..d08a764f5 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -0,0 +1,964 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// 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.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.UUID; + +import org.bukkit.ChatColor; +import org.bukkit.util.ChatPaginator; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; +import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.PlotSettings; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.SendChunk; + +/** + * plot functions + * + * @author Citymonstret + */ +public class MainUtil { + public final static HashMap runners = new HashMap<>(); + public static boolean canSendChunk = false; + public static ArrayList runners_p = new ArrayList<>(); + static long state = 1; + public static HashMap lastPlot = new HashMap<>(); + public static HashMap worldBorder = new HashMap<>(); + + public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) { + final Plot bot = MainUtil.getBottomPlot(plot); + + // TODO +// boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot); + boolean result = true; + // TOOD ^ remove that + + if (!result) { + final Location location = MainUtil.getPlotHome(bot.world, bot); + if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) { + sendMessage(player, C.TELEPORTED_TO_PLOT); + player.teleport(location); + return true; + } + sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + ""); + final String name = player.getName(); + TaskManager.TELEPORT_QUEUE.add(name); + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + if (!TaskManager.TELEPORT_QUEUE.contains(name)) { + sendMessage(player, C.TELEPORT_FAILED); + return; + } + TaskManager.TELEPORT_QUEUE.remove(name); + if (!player.isOnline()) { + return; + } + sendMessage(player, C.TELEPORTED_TO_PLOT); + player.teleport(location); + } + }, Settings.TELEPORT_DELAY * 20); + return true; + } + return !result; + } + + public static int getBorder(final String worldname) { + if (worldBorder.containsKey(worldname)) { + PlotSquared.getPlotWorld(worldname); + return worldBorder.get(worldname) + 16; + } + return Integer.MAX_VALUE; + } + + public static void setupBorder(final String world) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + if (!plotworld.WORLD_BORDER) { + return; + } + if (!worldBorder.containsKey(world)) { + worldBorder.put(world, 0); + } + for (final Plot plot : PlotSquared.getPlots(world).values()) { + updateWorldBorder(plot); + } + } + + public static void update(final Location loc) { + final String world = loc.getWorld(); + final ArrayList chunks = new ArrayList<>(); + final int distance = BukkitUtil.getViewDistance(); + for (int cx = -distance; cx < distance; cx++) { + for (int cz = -distance; cz < distance; cz++) { + final ChunkLoc chunk = new ChunkLoc(cx, cz); + chunks.add(chunk); + } + } + AbstractSetBlock.setBlockManager.update(world, chunks); + } + + public static void createWorld(final String world, final String generator) { + } + + public static PlotId parseId(final String arg) { + try { + final String[] split = arg.split(";"); + return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + } catch (final Exception e) { + return null; + } + } + + /** + * direction 0 = north, 1 = south, etc: + * + * @param id + * @param direction + * + * @return + */ + public static PlotId getPlotIdRelative(final PlotId id, final int direction) { + switch (direction) { + case 0: + return new PlotId(id.x, id.y - 1); + case 1: + return new PlotId(id.x + 1, id.y); + case 2: + return new PlotId(id.x, id.y + 1); + case 3: + return new PlotId(id.x - 1, id.y); + } + return id; + } + + public static ArrayList getPlotSelectionIds(final PlotId pos1, final PlotId pos2) { + final ArrayList myplots = new ArrayList<>(); + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + myplots.add(new PlotId(x, y)); + } + } + return myplots; + } + + /** + * Completely merges a set of plots
(There are no checks to make sure you supply the correct + * arguments)
- Misuse of this method can result in unusable plots
- the set of plots must belong to one + * owner and be rectangular
- the plot array must be sorted in ascending order
- Road will be removed where + * required
- changes will be saved to DB
+ * + * @param world + * @param plotIds + * + * @return boolean (success) + */ + public static boolean mergePlots(final String world, final ArrayList plotIds, final boolean removeRoads) { + if (plotIds.size() < 2) { + return false; + } + final PlotId pos1 = plotIds.get(0); + final PlotId pos2 = plotIds.get(plotIds.size() - 1); + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + manager.startPlotMerge(plotworld, plotIds); + final boolean result = false; + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final boolean lx = x < pos2.x; + final boolean ly = y < pos2.y; + final PlotId id = new PlotId(x, y); + final Plot plot = PlotSquared.getPlots(world).get(id); + Plot plot2 = null; + if (removeRoads) { + removeSign(plot); + } + if (lx) { + if (ly) { + if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { + if (removeRoads) { + manager.removeRoadSouthEast(plotworld, plot); + } + } + } + if (!plot.settings.getMerged(1)) { + 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); + } + } + if (ly) { + if (!plot.settings.getMerged(2)) { + 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); + } + } + } + } + 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 = PlotSquared.getPlots(world).get(id); + DBFunc.setMerged(world, plot, plot.settings.getMerged()); + } + } + manager.finishPlotMerge(plotworld, plotIds); + return result; + } + + /** + * Merges 2 plots Removes the road inbetween
- Assumes the first plot parameter is lower
- Assumes neither + * are a Mega-plot
- Assumes plots are directly next to each other
- Saves to DB + * + * @param world + * @param lesserPlot + * @param greaterPlot + */ + public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) { + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + if (lesserPlot.id.x.equals(greaterPlot.id.x)) { + if (!lesserPlot.settings.getMerged(2)) { + lesserPlot.settings.setMerged(2, true); + greaterPlot.settings.setMerged(0, true); + if (removeRoads) { + manager.removeRoadSouth(plotworld, lesserPlot); + } + } + } else { + if (!lesserPlot.settings.getMerged(1)) { + lesserPlot.settings.setMerged(1, true); + greaterPlot.settings.setMerged(3, true); + if (removeRoads) { + manager.removeRoadEast(plotworld, lesserPlot); + } + } + } + } + + public static void removeSign(final Plot p) { + final String world = p.world; + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(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 }); + } + + public static void setSign(String name, final Plot p) { + if (name == null) { + name = "unknown"; + } + final PlotManager manager = PlotSquared.getPlotManager(p.world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(p.world); + final Location loc = manager.getSignLoc(plotworld, p); + final String id = p.id.x + ";" + p.id.y; + final String[] lines = new String[] { C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) }; + BlockManager.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines); + } + + public static String getStringSized(final int max, final String string) { + if (string.length() > max) { + return string.substring(0, max); + } + return string; + } + + public static void autoMerge(final String world, final Plot plot, final UUID uuid) { + if (plot == null) { + return; + } + if (plot.owner == null) { + return; + } + if (!plot.owner.equals(uuid)) { + return; + } + ArrayList plots; + boolean merge = true; + int count = 0; + while (merge) { + if (count > 16) { + break; + } + count++; + final PlotId bot = getBottomPlot(plot).id; + final PlotId top = getTopPlot(world, plot).id; + plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); + if (ownsPlots(world, plots, uuid, 0)) { + final boolean result = mergePlots(world, plots, true); + if (result) { + merge = true; + continue; + } + } + plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); + if (ownsPlots(world, plots, uuid, 1)) { + final boolean result = mergePlots(world, plots, true); + if (result) { + merge = true; + continue; + } + } + plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); + if (ownsPlots(world, plots, uuid, 2)) { + final boolean result = mergePlots(world, plots, true); + if (result) { + merge = true; + continue; + } + } + plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); + if (ownsPlots(world, plots, uuid, 3)) { + final boolean result = mergePlots(world, plots, true); + if (result) { + merge = true; + continue; + } + } + merge = false; + } + update(getPlotHome(world, plot)); + } + + private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { + final PlotId id_min = plots.get(0); + final PlotId id_max = plots.get(plots.size() - 1); + for (final PlotId myid : plots) { + final Plot myplot = PlotSquared.getPlots(world).get(myid); + if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) { + return false; + } + final PlotId top = getTopPlot(world, myplot).id; + if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) { + return false; + } + final PlotId bot = getBottomPlot(myplot).id; + if (((bot.x < id_min.x) && (dir != 3)) || ((bot.y < id_min.y) && (dir != 0))) { + return false; + } + } + return true; + } + + public static void updateWorldBorder(final Plot plot) { + if (!worldBorder.containsKey(plot.world)) { + return; + } + final String world = plot.world; + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id); + final Location top = manager.getPlotTopLocAbs(plotworld, plot.id); + final int border = worldBorder.get(plot.world); + final int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ())); + final int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ())); + final int max = Math.max(botmax, topmax); + if (max > border) { + worldBorder.put(plot.world, max); + } + } + + /** + * Create a plot and notify the world border and plot merger + */ + public static boolean createPlot(final UUID uuid, final Plot plot) { + if (MainUtil.worldBorder.containsKey(plot.world)) { + updateWorldBorder(plot); + } + final Plot p = createPlotAbs(uuid, plot); + final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); + if (plotworld.AUTO_MERGE) { + autoMerge(plot.world, p, uuid); + } + return true; + } + + /** + * Create a plot without notifying the merge function or world border manager + */ + public static Plot createPlotAbs(final UUID uuid, final Plot plot) { + final String w = plot.world; + final Plot p = new Plot(plot.id, uuid, new ArrayList(), new ArrayList(), w); + PlotSquared.updatePlot(p); + DBFunc.createPlotAndSettings(p); + return p; + } + + public static String createId(final int x, final int z) { + return x + ";" + z; + } + + public static int square(final int x) { + return x * x; + } + + public static short[] getBlock(final String block) { + if (block.contains(":")) { + final String[] split = block.split(":"); + return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) }; + } + return new short[] { Short.parseShort(block), 0 }; + } + + /** + * Clear a plot and associated sections: [sign, entities, border] + * + * @param requester + * @param plot + */ + public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) { + if (runners.containsKey(plot)) { + return false; + } + AChunkManager.manager.clearAllEntities(plot); + clear(plot.world, plot, isDelete, whenDone); + removeSign(plot); + return true; + } + + public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { + final PlotManager manager = PlotSquared.getPlotManager(world); + final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + final int prime = 31; + int h = 1; + h = (prime * h) + pos1.getX(); + h = (prime * h) + pos1.getZ(); + state = h; + System.currentTimeMillis(); + final Location location = MainUtil.getPlotHomeDefault(plot); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + runners.put(plot, 1); + if (plotworld.TERRAIN != 0) { + final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); + AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { + @Override + public void run() { + runners.remove(plot); + TaskManager.runTask(whenDone); + } + }); + return; + } + final Runnable run = new Runnable() { + @Override + public void run() { + MainUtil.setBiome(world, plot, "FOREST"); + runners.remove(plot); + TaskManager.runTask(whenDone); + update(location); + } + }; + manager.clearPlot(plotworld, plot, isDelete, run); + } + + public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { + if (blocks.length == 1) { + setSimpleCuboid(world, pos1, pos2, blocks[0]); + return; + } + final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); + final int[] xl = new int[length]; + final int[] yl = new int[length]; + final int[] zl = new int[length]; + final int[] ids = new int[length]; + final byte[] data = new byte[length]; + int index = 0; + for (int y = pos1.getY(); y < pos2.getY(); y++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { + final int i = BlockManager.random(blocks.length); + xl[index] = x; + yl[index] = y; + zl[index] = z; + final PlotBlock block = blocks[i]; + ids[index] = block.id; + data[index] = block.data; + index++; + } + } + } + BlockManager.setBlocks(world, xl, yl, zl, ids, data); + } + + public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { + final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); + final int[] xl = new int[length]; + final int[] yl = new int[length]; + final int[] zl = new int[length]; + final int[] ids = new int[length]; + final byte[] data = new byte[length]; + int index = 0; + for (int y = pos1.getY(); y < pos2.getY(); y++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { + xl[index] = x; + yl[index] = y; + zl[index] = z; + ids[index] = newblock.id; + data[index] = newblock.data; + index++; + } + } + } + BlockManager.setBlocks(world, xl, yl, zl, ids, data); + } + + public static void setBiome(final String world, final Plot plot, final String biome) { + final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; + final int topX = getPlotTopLoc(world, plot.id).getX(); + final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; + final int topZ = getPlotTopLoc(world, plot.id).getZ(); + BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); + } + + public static int getHeighestBlock(final String world, final int x, final int z) { + final int result = BukkitUtil.getHeighestBlock(world, x, z); + if (result == 0) { + return 64; + } + return result; + // for (int i = 1; i < world.getMaxHeight(); i++) { + // id = world.getBlockAt(x, i, z).getTypeId(); + // if (id == 0) { + // if (safe) { + // return i; + // } + // safe = true; + // } + // } + // return 64; + } + + /** + * Get plot home + * + * @param w World in which the plot is located + * @param plotid Plot ID + * + * @return Home Location + */ + public static Location getPlotHome(final String w, final PlotId plotid) { + final Plot plot = getPlot(w, plotid); + final BlockLoc home = plot.settings.getPosition(); + final Location bot = getPlotBottomLoc(w, plotid); + final PlotManager manager = PlotSquared.getPlotManager(w); + if ((home == null) || ((home.x == 0) && (home.z == 0))) { + final Location top = getPlotTopLoc(w, plotid); + final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); + final int z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ(); + final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(w), plot).getY()); + return new Location(w, x, y, z); + } else { + final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); + return bot.add(home.x, y, home.z); + } + } + + /** + * Retrieve the location of the default plot home position + * + * @param plot Plot + * + * @return the location + */ + public static Location getPlotHomeDefault(final Plot plot) { + final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0); + l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); + return l; + } + + /** + * Get the plot home + * + * @param w World + * @param plot Plot Object + * + * @return Plot Home Location + * + * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + */ + public static Location getPlotHome(final String w, final Plot plot) { + return getPlotHome(w, plot.id); + } + + /** + * Refresh the plot chunks + * + * @param world World in which the plot is located + * @param plot Plot Object + */ + public static void refreshPlotChunks(final String world, final Plot plot) { + final int bottomX = getPlotBottomLoc(world, plot.id).getX(); + final int topX = getPlotTopLoc(world, plot.id).getX(); + final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); + final int topZ = getPlotTopLoc(world, plot.id).getZ(); + final int minChunkX = (int) Math.floor((double) bottomX / 16); + final int maxChunkX = (int) Math.floor((double) topX / 16); + final int minChunkZ = (int) Math.floor((double) bottomZ / 16); + final int maxChunkZ = (int) Math.floor((double) topZ / 16); + final ArrayList chunks = new ArrayList<>(); + for (int x = minChunkX; x <= maxChunkX; x++) { + for (int z = minChunkZ; z <= maxChunkZ; z++) { + if (canSendChunk) { + final ChunkLoc chunk = new ChunkLoc(x, z); + chunks.add(chunk); + } else { + BukkitUtil.refreshChunk(world, x, z); + } + } + } + try { + SendChunk.sendChunk(world, chunks); + } catch (final Throwable e) { + canSendChunk = false; + for (int x = minChunkX; x <= maxChunkX; x++) { + for (int z = minChunkZ; z <= maxChunkZ; z++) { + BukkitUtil.refreshChunk(world, x, z); + } + } + } + } + + /** + * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot + * use getPlotTopLoc(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotTopLocAbs(final String world, final PlotId id) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotTopLocAbs(plotworld, id); + } + + /** + * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega + * plot use getPlotBottomLoc(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotBottomLocAbs(final String world, final PlotId id) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotBottomLocAbs(plotworld, id); + } + + /** + * Obtains the width of a plot (x width) + * + * @param world + * @param id + * + * @return + */ + public static int getPlotWidth(final String world, final PlotId id) { + return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); + } + + /** + * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as + * a small plot use getPlotTopLocAbs(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotTopLoc(final String world, PlotId id) { + final Plot plot = PlotSquared.getPlots(world).get(id); + if (plot != null) { + id = getTopPlot(world, plot).id; + } + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotTopLocAbs(plotworld, id); + } + + /** + * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot + * treated as a small plot use getPlotBottomLocAbs(...) + * + * @param world + * @param id + * + * @return + */ + public static Location getPlotBottomLoc(final String world, PlotId id) { + final Plot plot = PlotSquared.getPlots(world).get(id); + if (plot != null) { + id = getBottomPlot(plot).id; + } + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotManager manager = PlotSquared.getPlotManager(world); + return manager.getPlotBottomLocAbs(plotworld, id); + } + + public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { + 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 (PlotSquared.getPlots(world).get(id) != null) { + if (PlotSquared.getPlots(world).get(id).owner != null) { + return false; + } + } + } + } + return true; + } + + public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { + final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current); + final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); + final Location top = MainUtil.getPlotTopLoc(world, current); + final Plot currentPlot = MainUtil.getPlot(world, current); + if (currentPlot.owner == null) { + return false; + } + final Plot pos1 = getBottomPlot(currentPlot); + final Plot pos2 = getTopPlot(world, currentPlot); + final PlotId size = MainUtil.getSize(world, currentPlot); + if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { + return false; + } + final int offset_x = newPlot.x - pos1.id.x; + final int offset_y = newPlot.y - pos1.id.y; + final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); + for (final PlotId id : selection) { + DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); + final Plot plot = PlotSquared.getPlots(world).get(id); + PlotSquared.getPlots(world).remove(id); + plot.id.x += offset_x; + plot.id.y += offset_y; + PlotSquared.getPlots(world).put(plot.id, plot); + } + AChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { + @Override + public void run() { + final Location bot = bot1.clone().add(1, 0, 1); + AChunkManager.manager.regenerateRegion(bot, top, null); + TaskManager.runTaskLater(whenDone, 1); + } + }); + return true; + } + + /** + * Send a message to the player + * + * @param plr Player to recieve message + * @param msg Message to send + * + * @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...)) + */ + public static boolean sendMessage(final PlotPlayer plr, final String msg) { + return sendMessage(plr, msg, true); + } + + public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) { + if ((msg.length() > 0) && !msg.equals("")) { + if (plr == null) { + PlotSquared.log(C.PREFIX.s() + msg); + } else { + sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); + } + } + return true; + } + + /** + * \\previous\\ + * + * @param plr + * @param msg Was used to wrap the chat client length (Packets out--) + */ + public static void sendMessageWrapped(final PlotPlayer plr, String msg) { + if (msg.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) { + final String[] ss = ChatPaginator.wordWrap(msg, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH); + final StringBuilder b = new StringBuilder(); + for (final String p : ss) { + b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n "); + } + msg = b.toString(); + } + if (msg.endsWith("\n")) { + msg = msg.substring(0, msg.length() - 2); + } + plr.sendMessage(msg); + } + + /** + * Send a message to the player + * + * @param plr Player to recieve message + * @param c Caption to send + * + * @return + */ + public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { + if (c.s().length() > 1) { + String msg = c.s(); + if ((args != null) && (args.length > 0)) { + for (final String str : args) { + if (msg.contains("%s")) { + msg = msg.replaceFirst("%s", str); + } + } + } + if (plr == null) { + PlotSquared.log(msg); + } else { + sendMessage(plr, msg, c.usePrefix()); + } + } + return true; + } + + public static Plot getBottomPlot(final Plot plot) { + if (plot.settings.getMerged(0)) { + final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1)); + if (p == null) { + return plot; + } + return getBottomPlot(p); + } + if (plot.settings.getMerged(3)) { + final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y)); + if (p == null) { + return plot; + } + return getBottomPlot(p); + } + return plot; + } + + public static Plot getTopPlot(final String world, final Plot plot) { + if (plot.settings.getMerged(2)) { + return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); + } + if (plot.settings.getMerged(1)) { + return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); + } + return plot; + } + + public static PlotId getSize(final String world, final Plot plot) { + final PlotSettings settings = plot.settings; + if (!settings.isMerged()) { + return new PlotId(1, 1); + } + final Plot top = getTopPlot(world, plot); + final Plot bot = getBottomPlot(plot); + return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1); + } + + /** + * Fetches the plot from the main class + */ + public static Plot getPlot(final String world, final PlotId id) { + if (id == null) { + return null; + } + if (PlotSquared.getPlots(world).containsKey(id)) { + return PlotSquared.getPlots(world).get(id); + } + return new Plot(id, null, new ArrayList(), new ArrayList(), world); + } + + + /** + * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) + * @param loc + * @return + */ + public static PlotId getPlotAbs(final Location loc) { + final String world = loc.getWorld(); + final PlotManager manager = PlotSquared.getPlotManager(world); + if (manager == null) { + return null; + } + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); + } + + /** + * Returns the plot id at a location (mega plots are considered) + * @param loc + * @return + */ + public static PlotId getPlotId(final Location loc) { + final String world = loc.getWorld(); + final PlotManager manager = PlotSquared.getPlotManager(world); + if (manager == null) { + return null; + } + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ()); + if ((id != null) && (plotworld.TYPE == 2)) { + if (ClusterManager.getCluster(world, id) == null) { + return null; + } + } + return id; + } + + /** + * Get the maximum number of plots a player is allowed + * + * @param p + * @return + */ + public static int getAllowedPlots(final PlotPlayer p) { + return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); + } + + public static Plot getPlot(final Location loc) { + PlotId id = getPlotId(loc); + if (id == null) { + return null; + } + return getPlot(loc.getWorld(), id); + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java new file mode 100644 index 000000000..6bf280849 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -0,0 +1,54 @@ +package com.intellectualcrafters.plot.util; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.PlotPlayer; + +public class Permissions { + // ADMIN + public static String ADMIN = "plots.admin"; + // BUILD + public static String BUILD_OTHER = "plots.admin.build.other"; + public static String BUILD_ROAD = "plots.admin.build.road"; + public static String BUILD_UNOWNED = "plots.admin.build.unowned"; + // INTERACT + public static String INTERACT_OTHER = "plots.admin.interact.other"; + public static String INTERACT_ROAD = "plots.admin.interact.road"; + public static String INTERACT_UNOWNED = "plots.admin.interact.unowned"; + // BREAK + public static String BREAK_OTHER = "plots.admin.break.other"; + public static String BREAK_ROAD = "plots.admin.break.road"; + public static String BREAK_UNOWNED = "plots.admin.break.unowned"; + + public static boolean hasPermission(final PlotPlayer player, final String perm) { + if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) { + 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; + } + + public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { + if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) { + 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; + } +} 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 833d535d0..bbe7ead4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -77,7 +77,7 @@ public class SchematicHandler { final int LENGTH = demensions.getZ(); final int HEIGHT = demensions.getY(); final DataCollection[] blocks = schematic.getBlockCollection(); - Location l1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId()); + Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId()); final int sy = BukkitUtil.getHeighestBlock(location.getWorld(), l1.getX() + 1, l1.getZ() + 1); l1 = l1.add(1, sy - 1, 1); if (HEIGHT == BukkitUtil.getMaxHeight(location.getWorld())) { @@ -214,8 +214,8 @@ public class SchematicHandler { if (!PlotSquared.getPlots(world).containsKey(id)) { return null; } - final Location pos1 = PlotHelper.getPlotBottomLoc(world, id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(world, id); + final Location pos1 = MainUtil.getPlotBottomLoc(world, id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(world, id); return getCompoundTag(world, pos1, pos2); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 48dd55fad..109be47c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -45,6 +45,7 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -52,7 +53,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.AChunkManager; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; public class ChunkManager extends AChunkManager { @@ -110,12 +111,12 @@ public class ChunkManager extends AChunkManager { final int z2 = z1 + 15; final Location bot = new Location(world, x1, 0, z1); Plot plot; - plot = PlotHelper.getPlot(bot); + plot = MainUtil.getPlot(bot); if ((plot != null) && (plot.owner != null)) { return plot; } final Location top = new Location(world, x2, 0, z2); - plot = PlotHelper.getPlot(top); + plot = MainUtil.getPlot(top); if ((plot != null) && (plot.owner != null)) { return plot; } @@ -743,11 +744,11 @@ public class ChunkManager extends AChunkManager { public void clearAllEntities(final Plot plot) { final List entities = BukkitUtil.getEntities(plot.world); for (final Entity entity : entities) { - final PlotId id = PlotHelper.getPlotId(BukkitUtil.getLocation(entity)); + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); + MainUtil.teleportPlayer(new BukkitPlayer(player), BukkitUtil.getLocation(entity), plot); PlotListener.plotExit(player, plot); } else { entity.remove(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index 81ff80b2e..f3ba0dd30 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -26,15 +26,16 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.RegionMask; import com.sk89q.worldedit.regions.CuboidRegion; @@ -44,32 +45,30 @@ import com.sk89q.worldedit.regions.CuboidRegion; * @author Empire92 */ public class PWE { - public static void setMask(final Player p, final Location l, final boolean force) { + public static void setMask(final PlotPlayer p, final Location l, final boolean force) { try { - LocalSession s; - if (PlotSquared.worldEdit == null) { - s = WorldEdit.getInstance().getSession(p.getName()); - } else { - s = PlotSquared.worldEdit.getSession(p); - } - if (!PlotSquared.isPlotWorld(p.getWorld().getName())) { + LocalSession s = WorldEdit.getInstance().getSession(p.getName()); + if (!PlotSquared.isPlotWorld(l.getWorld())) { removeMask(p); } - final PlotId id = PlotHelper.getPlotId(l); + final PlotId id = MainUtil.getPlotId(l); if (id != null) { final Plot plot = PlotSquared.getPlots(l.getWorld()).get(id); if (plot != null) { if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) { return; } - final boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)); + final boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(p.getUUID())) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUUID()); if (r) { final String w = l.getWorld(); - final Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id); - final Location tloc = PlotHelper.getPlotTopLoc(w, plot.id); + final Location bloc = MainUtil.getPlotBottomLoc(w, plot.id); + final Location tloc = MainUtil.getPlotTopLoc(w, plot.id); final Vector bvec = new Vector(bloc.getX() + 1, bloc.getY(), bloc.getZ() + 1); final Vector tvec = new Vector(tloc.getX(), tloc.getY(), tloc.getZ()); - final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(p).getWorld(); + + + // FIXME unchecked casting + final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player).getWorld(); final CuboidRegion region = new CuboidRegion(lw, bvec, tvec); final RegionMask mask = new RegionMask(region); s.setMask(mask); @@ -77,8 +76,8 @@ public class PWE { } } } - if (force ^ (noMask(s) && !BukkitMain.hasPermission(p, "plots.worldedit.bypass"))) { - final BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(p); + if (force ^ (noMask(s) && !p.hasPermission("plots.worldedit.bypass"))) { + final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); } @@ -113,7 +112,7 @@ public class PWE { } else { s = PlotSquared.worldEdit.getSession(p); } - final BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(p); + final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); 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) { @@ -121,19 +120,14 @@ public class PWE { } } - public static void removeMask(final Player p, final LocalSession s) { + public static void removeMask(final PlotPlayer p, final LocalSession s) { final Mask mask = null; s.setMask(mask); } - public static void removeMask(final Player p) { + public static void removeMask(final PlotPlayer p) { try { - LocalSession s; - if (PlotSquared.worldEdit == null) { - s = WorldEdit.getInstance().getSession(p.getName()); - } else { - s = PlotSquared.worldEdit.getSession(p); - } + LocalSession s = WorldEdit.getInstance().getSession(p.getName()); removeMask(p, s); } catch (final Exception e) { // throw new diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java index 8a0b03c90..a5e7b82e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java @@ -24,12 +24,16 @@ 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.BukkitPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; + import net.milkbowl.vault.economy.Economy; + import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -57,12 +61,12 @@ public class PlayerFunctions { @Override public void run() { if ((player != null) && player.isOnline()) { - PlayerFunctions.sendMessage(player, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); + MainUtil.sendMessage(new BukkitPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); } } }; - if (!PlotHelper.clearAsPlayer(plot, isDelete, whenDone)) { - PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); + if (!MainUtil.clearAsPlayer(plot, isDelete, whenDone)) { + MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); } } @@ -82,14 +86,14 @@ public class PlayerFunctions { if (cost > 0d) { final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < cost) { - PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost); + MainUtil.sendMessage(new BukkitPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); return false; } economy.withdrawPlayer(plr, cost); - PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + ""); + MainUtil.sendMessage(new BukkitPlayer(plr), C.REMOVED_BALANCE, cost + ""); } } - return PlotHelper.mergePlots(world, plotIds, true); + return MainUtil.mergePlots(world, plotIds, true); } public static String getPlayerName(final UUID uuid) { @@ -116,10 +120,10 @@ public class PlayerFunctions { final Plot plot1 = PlotSquared.getPlots(world).get(pos1); final Plot plot2 = PlotSquared.getPlots(world).get(pos2); if (plot1 != null) { - pos1 = PlotHelper.getBottomPlot(world, plot1).id; + pos1 = MainUtil.getBottomPlot(plot1).id; } if (plot2 != null) { - pos2 = PlotHelper.getTopPlot(world, plot2).id; + pos2 = MainUtil.getTopPlot(world, plot2).id; } final ArrayList myplots = new ArrayList<>(); for (int x = pos1.x; x <= pos2.x; x++) { @@ -141,7 +145,7 @@ public class PlayerFunctions { if (!PlotSquared.isPlotWorld(player.getWorld().getName())) { return null; } - final PlotId id = PlotHelper.getPlotId(BukkitUtil.getLocation(player)); + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(player)); final String world = player.getWorld().getName(); if (id == null) { return null; @@ -184,86 +188,4 @@ public class PlayerFunctions { } return count; } - - /** - * Get the maximum number of plots a player is allowed - * - * @param p - * - * @return - */ - public static int getAllowedPlots(final PlotPlayer p) { - return BukkitMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); - } - - /** - * \\previous\\ - * - * @param plr - * @param msg Was used to wrap the chat client length (Packets out--) - */ - public static void sendMessageWrapped(final PlotPlayer plr, String msg) { - if (msg.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) { - final String[] ss = ChatPaginator.wordWrap(msg, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH); - final StringBuilder b = new StringBuilder(); - for (final String p : ss) { - b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n "); - } - msg = b.toString(); - } - if (msg.endsWith("\n")) { - msg = msg.substring(0, msg.length() - 2); - } - plr.sendMessage(msg); - } - - /** - * Send a message to the player - * - * @param plr Player to recieve message - * @param msg Message to send - * - * @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...)) - */ - public static boolean sendMessage(final PlotPlayer plr, final String msg) { - return sendMessage(plr, msg, true); - } - - public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) { - if ((msg.length() > 0) && !msg.equals("")) { - if (plr == null) { - PlotSquared.log(C.PREFIX.s() + msg); - } else { - sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); - } - } - return true; - } - - /** - * Send a message to the player - * - * @param plr Player to recieve message - * @param c Caption to send - * - * @return - */ - public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { - if (c.s().length() > 1) { - String msg = c.s(); - if ((args != null) && (args.length > 0)) { - for (final String str : args) { - if (msg.contains("%s")) { - msg = msg.replaceFirst("%s", str); - } - } - } - if (plr == null) { - PlotSquared.log(msg); - } else { - sendMessage(plr, msg, c.usePrefix()); - } - } - return true; - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index 129f0cb6a..8e12c094c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -27,7 +27,7 @@ import java.util.List; import org.bukkit.Chunk; import org.bukkit.World; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; @@ -88,7 +88,7 @@ public class SetBlockFast extends SetBlockManager { if (chunks.size() == 0) { return; } - if (!PlotHelper.canSendChunk) { + if (!MainUtil.canSendChunk) { final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { world.refreshChunk(chunk.getX(), chunk.getZ()); @@ -98,7 +98,7 @@ public class SetBlockFast extends SetBlockManager { try { SendChunk.sendChunk(chunks); } catch (final Throwable e) { - PlotHelper.canSendChunk = false; + MainUtil.canSendChunk = false; } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 1872d6607..6f649df01 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -28,7 +28,7 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Block; -import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; @@ -128,7 +128,7 @@ public class SetBlockFast_1_8 extends SetBlockManager { if (chunks.size() == 0) { return; } - if (!PlotHelper.canSendChunk) { + if (!MainUtil.canSendChunk) { final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { world.refreshChunk(chunk.getX(), chunk.getZ()); @@ -138,7 +138,7 @@ public class SetBlockFast_1_8 extends SetBlockManager { try { SendChunk.sendChunk(chunks); } catch (final Throwable e) { - PlotHelper.canSendChunk = false; + MainUtil.canSendChunk = false; } } } From 632a6e4268f27f7392a7da2c4f84d78157739eea Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 22:23:53 +1100 Subject: [PATCH 048/124] . --- .../plot/config/Permissions.java | 18 - .../plot/util/PlotHelper.java | 839 ------------------ 2 files changed, 857 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java deleted file mode 100644 index 97a8c8593..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.intellectualcrafters.plot.config; - -public class Permissions { - // ADMIN - public static String ADMIN = "plots.admin"; - // BUILD - public static String BUILD_OTHER = "plots.admin.build.other"; - public static String BUILD_ROAD = "plots.admin.build.road"; - public static String BUILD_UNOWNED = "plots.admin.build.unowned"; - // INTERACT - public static String INTERACT_OTHER = "plots.admin.interact.other"; - public static String INTERACT_ROAD = "plots.admin.interact.road"; - public static String INTERACT_UNOWNED = "plots.admin.interact.unowned"; - // BREAK - public static String BREAK_OTHER = "plots.admin.break.other"; - public static String BREAK_ROAD = "plots.admin.break.road"; - public static String BREAK_UNOWNED = "plots.admin.break.unowned"; -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java deleted file mode 100644 index 0346e5731..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ /dev/null @@ -1,839 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.UUID; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.ChunkLoc; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotSettings; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; -import com.intellectualcrafters.plot.util.bukkit.SendChunk; - -/** - * plot functions - * - * @author Citymonstret - */ -public class PlotHelper { - public final static HashMap runners = new HashMap<>(); - public static boolean canSendChunk = false; - public static ArrayList runners_p = new ArrayList<>(); - static long state = 1; - public static HashMap lastPlot = new HashMap<>(); - public static HashMap worldBorder = new HashMap<>(); - - public static int getBorder(final String worldname) { - if (worldBorder.containsKey(worldname)) { - PlotSquared.getPlotWorld(worldname); - return worldBorder.get(worldname) + 16; - } - return Integer.MAX_VALUE; - } - - public static void setupBorder(final String world) { - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - if (!plotworld.WORLD_BORDER) { - return; - } - if (!worldBorder.containsKey(world)) { - worldBorder.put(world, 0); - } - for (final Plot plot : PlotSquared.getPlots(world).values()) { - updateWorldBorder(plot); - } - } - - public static void update(final Location loc) { - final String world = loc.getWorld(); - final ArrayList chunks = new ArrayList<>(); - final int distance = BukkitUtil.getViewDistance(); - for (int cx = -distance; cx < distance; cx++) { - for (int cz = -distance; cz < distance; cz++) { - final ChunkLoc chunk = new ChunkLoc(cx, cz); - chunks.add(chunk); - } - } - AbstractSetBlock.setBlockManager.update(world, chunks); - } - - public static void createWorld(final String world, final String generator) { - } - - public static PlotId parseId(final String arg) { - try { - final String[] split = arg.split(";"); - return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - } catch (final Exception e) { - return null; - } - } - - /** - * direction 0 = north, 1 = south, etc: - * - * @param id - * @param direction - * - * @return - */ - public static PlotId getPlotIdRelative(final PlotId id, final int direction) { - switch (direction) { - case 0: - return new PlotId(id.x, id.y - 1); - case 1: - return new PlotId(id.x + 1, id.y); - case 2: - return new PlotId(id.x, id.y + 1); - case 3: - return new PlotId(id.x - 1, id.y); - } - return id; - } - - public static ArrayList getPlotSelectionIds(final PlotId pos1, final PlotId pos2) { - final ArrayList myplots = new ArrayList<>(); - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - myplots.add(new PlotId(x, y)); - } - } - return myplots; - } - - /** - * Completely merges a set of plots
(There are no checks to make sure you supply the correct - * arguments)
- Misuse of this method can result in unusable plots
- the set of plots must belong to one - * owner and be rectangular
- the plot array must be sorted in ascending order
- Road will be removed where - * required
- changes will be saved to DB
- * - * @param world - * @param plotIds - * - * @return boolean (success) - */ - public static boolean mergePlots(final String world, final ArrayList plotIds, final boolean removeRoads) { - if (plotIds.size() < 2) { - return false; - } - final PlotId pos1 = plotIds.get(0); - final PlotId pos2 = plotIds.get(plotIds.size() - 1); - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - manager.startPlotMerge(plotworld, plotIds); - final boolean result = false; - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - final boolean lx = x < pos2.x; - final boolean ly = y < pos2.y; - final PlotId id = new PlotId(x, y); - final Plot plot = PlotSquared.getPlots(world).get(id); - Plot plot2 = null; - if (removeRoads) { - removeSign(plot); - } - if (lx) { - if (ly) { - if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { - if (removeRoads) { - manager.removeRoadSouthEast(plotworld, plot); - } - } - } - if (!plot.settings.getMerged(1)) { - 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); - } - } - if (ly) { - if (!plot.settings.getMerged(2)) { - 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); - } - } - } - } - 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 = PlotSquared.getPlots(world).get(id); - DBFunc.setMerged(world, plot, plot.settings.getMerged()); - } - } - manager.finishPlotMerge(plotworld, plotIds); - return result; - } - - /** - * Merges 2 plots Removes the road inbetween
- Assumes the first plot parameter is lower
- Assumes neither - * are a Mega-plot
- Assumes plots are directly next to each other
- Saves to DB - * - * @param world - * @param lesserPlot - * @param greaterPlot - */ - public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) { - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - if (lesserPlot.id.x.equals(greaterPlot.id.x)) { - if (!lesserPlot.settings.getMerged(2)) { - lesserPlot.settings.setMerged(2, true); - greaterPlot.settings.setMerged(0, true); - if (removeRoads) { - manager.removeRoadSouth(plotworld, lesserPlot); - } - } - } else { - if (!lesserPlot.settings.getMerged(1)) { - lesserPlot.settings.setMerged(1, true); - greaterPlot.settings.setMerged(3, true); - if (removeRoads) { - manager.removeRoadEast(plotworld, lesserPlot); - } - } - } - } - - public static void removeSign(final Plot p) { - final String world = p.world; - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(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 }); - } - - public static void setSign(String name, final Plot p) { - if (name == null) { - name = "unknown"; - } - final PlotManager manager = PlotSquared.getPlotManager(p.world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(p.world); - final Location loc = manager.getSignLoc(plotworld, p); - final String id = p.id.x + ";" + p.id.y; - final String[] lines = new String[] { C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) }; - BlockManager.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines); - } - - public static String getStringSized(final int max, final String string) { - if (string.length() > max) { - return string.substring(0, max); - } - return string; - } - - public static void autoMerge(final String world, final Plot plot, final UUID uuid) { - if (plot == null) { - return; - } - if (plot.owner == null) { - return; - } - if (!plot.owner.equals(uuid)) { - return; - } - ArrayList plots; - boolean merge = true; - int count = 0; - while (merge) { - if (count > 16) { - break; - } - count++; - final PlotId bot = getBottomPlot(world, plot).id; - final PlotId top = getTopPlot(world, plot).id; - plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); - if (ownsPlots(world, plots, uuid, 0)) { - final boolean result = mergePlots(world, plots, true); - if (result) { - merge = true; - continue; - } - } - plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); - if (ownsPlots(world, plots, uuid, 1)) { - final boolean result = mergePlots(world, plots, true); - if (result) { - merge = true; - continue; - } - } - plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); - if (ownsPlots(world, plots, uuid, 2)) { - final boolean result = mergePlots(world, plots, true); - if (result) { - merge = true; - continue; - } - } - plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); - if (ownsPlots(world, plots, uuid, 3)) { - final boolean result = mergePlots(world, plots, true); - if (result) { - merge = true; - continue; - } - } - merge = false; - } - update(getPlotHome(world, plot)); - } - - private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { - final PlotId id_min = plots.get(0); - final PlotId id_max = plots.get(plots.size() - 1); - for (final PlotId myid : plots) { - final Plot myplot = PlotSquared.getPlots(world).get(myid); - if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) { - return false; - } - final PlotId top = getTopPlot(world, myplot).id; - if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) { - return false; - } - final PlotId bot = getBottomPlot(world, myplot).id; - if (((bot.x < id_min.x) && (dir != 3)) || ((bot.y < id_min.y) && (dir != 0))) { - return false; - } - } - return true; - } - - public static void updateWorldBorder(final Plot plot) { - if (!worldBorder.containsKey(plot.world)) { - return; - } - final String world = plot.world; - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id); - final Location top = manager.getPlotTopLocAbs(plotworld, plot.id); - final int border = worldBorder.get(plot.world); - final int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ())); - final int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ())); - final int max = Math.max(botmax, topmax); - if (max > border) { - worldBorder.put(plot.world, max); - } - } - - /** - * Create a plot and notify the world border and plot merger - */ - public static boolean createPlot(final UUID uuid, final Plot plot) { - if (PlotHelper.worldBorder.containsKey(plot.world)) { - updateWorldBorder(plot); - } - final Plot p = createPlotAbs(uuid, plot); - final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); - if (plotworld.AUTO_MERGE) { - autoMerge(plot.world, p, uuid); - } - return true; - } - - /** - * Create a plot without notifying the merge function or world border manager - */ - public static Plot createPlotAbs(final UUID uuid, final Plot plot) { - final String w = plot.world; - final Plot p = new Plot(plot.id, uuid, new ArrayList(), new ArrayList(), w); - PlotSquared.updatePlot(p); - DBFunc.createPlotAndSettings(p); - return p; - } - - public static String createId(final int x, final int z) { - return x + ";" + z; - } - - public static int square(final int x) { - return x * x; - } - - public static short[] getBlock(final String block) { - if (block.contains(":")) { - final String[] split = block.split(":"); - return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) }; - } - return new short[] { Short.parseShort(block), 0 }; - } - - /** - * Clear a plot and associated sections: [sign, entities, border] - * - * @param requester - * @param plot - */ - public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) { - if (runners.containsKey(plot)) { - return false; - } - AChunkManager.manager.clearAllEntities(plot); - clear(plot.world, plot, isDelete, whenDone); - removeSign(plot); - return true; - } - - public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { - final PlotManager manager = PlotSquared.getPlotManager(world); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final int prime = 31; - int h = 1; - h = (prime * h) + pos1.getX(); - h = (prime * h) + pos1.getZ(); - state = h; - System.currentTimeMillis(); - final Location location = PlotHelper.getPlotHomeDefault(plot); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - runners.put(plot, 1); - if (plotworld.TERRAIN != 0) { - final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); - AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { - @Override - public void run() { - runners.remove(plot); - TaskManager.runTask(whenDone); - } - }); - return; - } - final Runnable run = new Runnable() { - @Override - public void run() { - PlotHelper.setBiome(world, plot, "FOREST"); - runners.remove(plot); - TaskManager.runTask(whenDone); - update(location); - } - }; - manager.clearPlot(plotworld, plot, isDelete, run); - } - - public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { - if (blocks.length == 1) { - setSimpleCuboid(world, pos1, pos2, blocks[0]); - return; - } - final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); - final int[] xl = new int[length]; - final int[] yl = new int[length]; - final int[] zl = new int[length]; - final int[] ids = new int[length]; - final byte[] data = new byte[length]; - int index = 0; - for (int y = pos1.getY(); y < pos2.getY(); y++) { - for (int x = pos1.getX(); x < pos2.getX(); x++) { - for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - final int i = BlockManager.random(blocks.length); - xl[index] = x; - yl[index] = y; - zl[index] = z; - final PlotBlock block = blocks[i]; - ids[index] = block.id; - data[index] = block.data; - index++; - } - } - } - BlockManager.setBlocks(world, xl, yl, zl, ids, data); - } - - public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { - final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); - final int[] xl = new int[length]; - final int[] yl = new int[length]; - final int[] zl = new int[length]; - final int[] ids = new int[length]; - final byte[] data = new byte[length]; - int index = 0; - for (int y = pos1.getY(); y < pos2.getY(); y++) { - for (int x = pos1.getX(); x < pos2.getX(); x++) { - for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - xl[index] = x; - yl[index] = y; - zl[index] = z; - ids[index] = newblock.id; - data[index] = newblock.data; - index++; - } - } - } - BlockManager.setBlocks(world, xl, yl, zl, ids, data); - } - - public static void setBiome(final String world, final Plot plot, final String biome) { - final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; - final int topX = getPlotTopLoc(world, plot.id).getX(); - final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; - final int topZ = getPlotTopLoc(world, plot.id).getZ(); - BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); - } - - public static int getHeighestBlock(final String world, final int x, final int z) { - final int result = BukkitUtil.getHeighestBlock(world, x, z); - if (result == 0) { - return 64; - } - return result; - // for (int i = 1; i < world.getMaxHeight(); i++) { - // id = world.getBlockAt(x, i, z).getTypeId(); - // if (id == 0) { - // if (safe) { - // return i; - // } - // safe = true; - // } - // } - // return 64; - } - - /** - * Get plot home - * - * @param w World in which the plot is located - * @param plotid Plot ID - * - * @return Home Location - */ - public static Location getPlotHome(final String w, final PlotId plotid) { - final Plot plot = getPlot(w, plotid); - final BlockLoc home = plot.settings.getPosition(); - final Location bot = getPlotBottomLoc(w, plotid); - final PlotManager manager = PlotSquared.getPlotManager(w); - if ((home == null) || ((home.x == 0) && (home.z == 0))) { - final Location top = getPlotTopLoc(w, plotid); - final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); - final int z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ(); - final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(w), plot).getY()); - return new Location(w, x, y, z); - } else { - final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); - return bot.add(home.x, y, home.z); - } - } - - /** - * Retrieve the location of the default plot home position - * - * @param plot Plot - * - * @return the location - */ - public static Location getPlotHomeDefault(final Plot plot) { - final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0); - l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); - return l; - } - - /** - * Get the plot home - * - * @param w World - * @param plot Plot Object - * - * @return Plot Home Location - * - * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) - */ - public static Location getPlotHome(final String w, final Plot plot) { - return getPlotHome(w, plot.id); - } - - /** - * Refresh the plot chunks - * - * @param world World in which the plot is located - * @param plot Plot Object - */ - public static void refreshPlotChunks(final String world, final Plot plot) { - final int bottomX = getPlotBottomLoc(world, plot.id).getX(); - final int topX = getPlotTopLoc(world, plot.id).getX(); - final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); - final int topZ = getPlotTopLoc(world, plot.id).getZ(); - final int minChunkX = (int) Math.floor((double) bottomX / 16); - final int maxChunkX = (int) Math.floor((double) topX / 16); - final int minChunkZ = (int) Math.floor((double) bottomZ / 16); - final int maxChunkZ = (int) Math.floor((double) topZ / 16); - final ArrayList chunks = new ArrayList<>(); - for (int x = minChunkX; x <= maxChunkX; x++) { - for (int z = minChunkZ; z <= maxChunkZ; z++) { - if (canSendChunk) { - final ChunkLoc chunk = new ChunkLoc(x, z); - chunks.add(chunk); - } else { - BukkitUtil.refreshChunk(world, x, z); - } - } - } - try { - SendChunk.sendChunk(world, chunks); - } catch (final Throwable e) { - canSendChunk = false; - for (int x = minChunkX; x <= maxChunkX; x++) { - for (int z = minChunkZ; z <= maxChunkZ; z++) { - BukkitUtil.refreshChunk(world, x, z); - } - } - } - } - - /** - * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot - * use getPlotTopLoc(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotTopLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotTopLocAbs(plotworld, id); - } - - /** - * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega - * plot use getPlotBottomLoc(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotBottomLocAbs(final String world, final PlotId id) { - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotBottomLocAbs(plotworld, id); - } - - /** - * Obtains the width of a plot (x width) - * - * @param world - * @param id - * - * @return - */ - public static int getPlotWidth(final String world, final PlotId id) { - return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); - } - - /** - * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as - * a small plot use getPlotTopLocAbs(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotTopLoc(final String world, PlotId id) { - final Plot plot = PlotSquared.getPlots(world).get(id); - if (plot != null) { - id = getTopPlot(world, plot).id; - } - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotTopLocAbs(plotworld, id); - } - - /** - * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot - * treated as a small plot use getPlotBottomLocAbs(...) - * - * @param world - * @param id - * - * @return - */ - public static Location getPlotBottomLoc(final String world, PlotId id) { - final Plot plot = PlotSquared.getPlots(world).get(id); - if (plot != null) { - id = getBottomPlot(world, plot).id; - } - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final PlotManager manager = PlotSquared.getPlotManager(world); - return manager.getPlotBottomLocAbs(plotworld, id); - } - - public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { - 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 (PlotSquared.getPlots(world).get(id) != null) { - if (PlotSquared.getPlots(world).get(id).owner != null) { - return false; - } - } - } - } - return true; - } - - public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { - final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(world, current); - final com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(world, newPlot); - final Location top = PlotHelper.getPlotTopLoc(world, current); - final Plot currentPlot = PlotHelper.getPlot(world, current); - if (currentPlot.owner == null) { - return false; - } - final Plot pos1 = getBottomPlot(world, currentPlot); - final Plot pos2 = getTopPlot(world, currentPlot); - final PlotId size = PlotHelper.getSize(world, currentPlot); - if (!PlotHelper.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { - return false; - } - final int offset_x = newPlot.x - pos1.id.x; - final int offset_y = newPlot.y - pos1.id.y; - final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); - for (final PlotId id : selection) { - DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); - final Plot plot = PlotSquared.getPlots(world).get(id); - PlotSquared.getPlots(world).remove(id); - plot.id.x += offset_x; - plot.id.y += offset_y; - PlotSquared.getPlots(world).put(plot.id, plot); - } - AChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { - @Override - public void run() { - final Location bot = bot1.clone().add(1, 0, 1); - AChunkManager.manager.regenerateRegion(bot, top, null); - TaskManager.runTaskLater(whenDone, 1); - } - }); - return true; - } - - public static Plot getBottomPlot(final String world, final Plot plot) { - if (plot.settings.getMerged(0)) { - 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 = PlotSquared.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)); - if (p == null) { - return plot; - } - return getBottomPlot(world, p); - } - return plot; - } - - public static Plot getTopPlot(final String world, final Plot plot) { - if (plot.settings.getMerged(2)) { - return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); - } - if (plot.settings.getMerged(1)) { - return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); - } - return plot; - } - - public static PlotId getSize(final String world, final Plot plot) { - final PlotSettings settings = plot.settings; - if (!settings.isMerged()) { - return new PlotId(1, 1); - } - final Plot top = getTopPlot(world, plot); - final Plot bot = getBottomPlot(world, plot); - return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1); - } - - /** - * Fetches the plot from the main class - */ - public static Plot getPlot(final String world, final PlotId id) { - if (id == null) { - return null; - } - if (PlotSquared.getPlots(world).containsKey(id)) { - return PlotSquared.getPlots(world).get(id); - } - return new Plot(id, null, new ArrayList(), new ArrayList(), world); - } - - - /** - * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) - * @param loc - * @return - */ - public static PlotId getPlotAbs(final Location loc) { - final String world = loc.getWorld(); - final PlotManager manager = PlotSquared.getPlotManager(world); - if (manager == null) { - return null; - } - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); - } - - /** - * Returns the plot id at a location (mega plots are considered) - * @param loc - * @return - */ - public static PlotId getPlotId(final Location loc) { - final String world = loc.getWorld(); - final PlotManager manager = PlotSquared.getPlotManager(world); - if (manager == null) { - return null; - } - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ()); - if ((id != null) && (plotworld.TYPE == 2)) { - if (ClusterManager.getCluster(world, id) == null) { - return null; - } - } - return id; - } - - public static Plot getPlot(final Location loc) { - PlotId id = getPlotId(loc); - if (id == null) { - return null; - } - return getPlot(loc.getWorld(), id); - } -} From afd0218f408bcebbcef4257bb956370cc203dc7c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 22:24:58 +1100 Subject: [PATCH 049/124] . --- .../intellectualcrafters/plot/BukkitMain.java | 2 +- .../plot/commands/Auto.java | 24 +-- .../plot/commands/Ban.java | 8 +- .../plot/commands/Buy.java | 12 +- .../plot/commands/Claim.java | 10 +- .../plot/commands/Clear.java | 8 +- .../plot/commands/Clipboard.java | 4 +- .../plot/commands/Cluster.java | 160 +++++++-------- .../plot/commands/Comment.java | 6 +- .../plot/commands/Condense.java | 48 ++--- .../plot/commands/Copy.java | 12 +- .../plot/commands/CreateRoadSchematic.java | 10 +- .../plot/commands/DEOP.java | 8 +- .../plot/commands/Database.java | 6 +- .../plot/commands/Debug.java | 6 +- .../plot/commands/DebugClaimTest.java | 30 +-- .../plot/commands/DebugClear.java | 14 +- .../plot/commands/DebugExec.java | 52 ++--- .../plot/commands/DebugFixFlags.java | 12 +- .../plot/commands/DebugLoadTest.java | 4 +- .../plot/commands/DebugRoadRegen.java | 4 +- .../plot/commands/DebugSaveTest.java | 4 +- .../plot/commands/Delete.java | 10 +- .../plot/commands/Denied.java | 34 ++-- .../plot/commands/FlagCmd.java | 76 +++---- .../plot/commands/Helpers.java | 30 +-- .../plot/commands/Home.java | 10 +- .../plot/commands/Inbox.java | 34 ++-- .../plot/commands/Info.java | 30 +-- .../plot/commands/Kick.java | 18 +- .../plot/commands/MainCommand.java | 14 +- .../plot/commands/Merge.java | 48 ++--- .../plot/commands/Move.java | 14 +- .../plot/commands/MusicSubcommand.java | 6 +- .../plot/commands/OP.java | 8 +- .../plot/commands/Paste.java | 14 +- .../plot/commands/Purge.java | 32 +-- .../plot/commands/Rate.java | 6 +- .../plot/commands/Reload.java | 4 +- .../plot/commands/Schematic.java | 52 ++--- .../plot/commands/Set.java | 62 +++--- .../plot/commands/SetOwner.java | 20 +- .../plot/commands/Setup.java | 22 +- .../plot/commands/SubCommand.java | 6 +- .../plot/commands/Swap.java | 28 +-- .../plot/commands/TP.java | 8 +- .../plot/commands/Target.java | 10 +- .../plot/commands/Template.java | 10 +- .../plot/commands/Trim.java | 16 +- .../plot/commands/Trusted.java | 30 +-- .../plot/commands/Unban.java | 8 +- .../plot/commands/Unclaim.java | 12 +- .../plot/commands/Unlink.java | 18 +- .../plot/commands/WE_Anywhere.java | 8 +- .../plot/commands/list.java | 18 +- .../plot/commands/plugin.java | 4 +- .../plot/generator/SquarePlotManager.java | 16 +- .../plot/listeners/ForceFieldListener.java | 10 +- .../plot/listeners/InventoryListener.java | 4 +- .../plot/listeners/PlayerEvents.java | 88 ++++---- .../plot/listeners/PlayerEvents_1_8.java | 8 +- .../plot/listeners/PlotPlusListener.java | 12 +- .../plot/listeners/WorldEditListener.java | 8 +- .../plot/util/ClusterManager.java | 2 +- .../plot/util/ExpireManager.java | 2 +- .../plot/util/MainUtil.java | 2 +- .../util/bukkit/BukkitPlayerFunctions.java | 191 ++++++++++++++++++ 67 files changed, 849 insertions(+), 658 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 74228ddac..9a218daab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -76,7 +76,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (Settings.USE_PLOTME_ALIAS) { player.performCommand(message.replace("/plotme", "plots")); } else { - PlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME); + BukkitPlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME); } event.setCancelled(true); } 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 415994b05..1e3912f18 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Auto extends SubCommand { public Auto() { @@ -87,7 +87,7 @@ public class Auto extends SubCommand { if (PlotSquared.isPlotWorld(plr.getWorld().getName())) { world = plr.getWorld(); } else { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } } @@ -98,10 +98,10 @@ public class Auto extends SubCommand { size_x = Integer.parseInt(split[0]); size_z = Integer.parseInt(split[1]); if ((size_x < 1) || (size_z < 1)) { - PlayerFunctions.sendMessage(plr, "&cError: size<=0"); + BukkitPlayerFunctions.sendMessage(plr, "&cError: size<=0"); } if ((size_x > 4) || (size_z > 4)) { - PlayerFunctions.sendMessage(plr, "&cError: size>4"); + BukkitPlayerFunctions.sendMessage(plr, "&cError: size>4"); } if (args.length > 1) { schematic = args[1]; @@ -121,15 +121,15 @@ public class Auto extends SubCommand { } } if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) { - PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); + BukkitPlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); return false; } - final int diff = PlayerFunctions.getPlayerPlotCount(world, plr) - PlayerFunctions.getAllowedPlots(plr); + final int diff = BukkitPlayerFunctions.getPlayerPlotCount(world, plr) - BukkitPlayerFunctions.getAllowedPlots(plr); if ((diff + (size_x * size_z)) > 0) { if (diff < 0) { - PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); + BukkitPlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); } else { - PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); + BukkitPlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } return false; } @@ -154,7 +154,7 @@ public class Auto extends SubCommand { return true; } if (!BukkitMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { - PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); + BukkitPlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return true; } // } @@ -170,7 +170,7 @@ public class Auto extends SubCommand { final PlotCluster cluster = ClusterManager.getCluster(loc); // Must be standing in a cluster if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } final PlotId bot = cluster.getP1(); @@ -190,7 +190,7 @@ public class Auto extends SubCommand { id = getNextPlot(id, 1); } // no free plots - PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS); return false; } boolean br = false; @@ -225,7 +225,7 @@ public class Auto extends SubCommand { Claim.claimPlot(plr, plot, teleport, true); } } - if (!MainUtil.mergePlots(plr, worldname, PlayerFunctions.getPlotSelectionIds(start, end))) { + if (!MainUtil.mergePlots(plr, worldname, BukkitPlayerFunctions.getPlotSelectionIds(start, end))) { return false; } br = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java index 31c43dcef..b8ea0de8c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * Created 2014-11-09 for PlotSquared @@ -19,12 +19,12 @@ public class Ban extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { - return PlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!plot.hasRights(plr)) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 4a1410b8b..a757c88b1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -64,12 +64,12 @@ public class Buy extends SubCommand { return sendMessage(plr, C.NOT_VALID_PLOT_ID); } } else { - plot = PlayerFunctions.getCurrentPlot(plr); + plot = BukkitPlayerFunctions.getCurrentPlot(plr); } if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions.getAllowedPlots(plr)) { + if (BukkitPlayerFunctions.getPlayerPlotCount(world, plr) >= BukkitPlayerFunctions.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } if (!plot.hasOwner()) { @@ -85,8 +85,8 @@ public class Buy extends SubCommand { double initPrice = (double) flag.getValue(); double price = initPrice; final PlotId id = plot.id; - final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; - final int size = PlayerFunctions.getPlotSelectionIds(id, id2).size(); + final PlotId id2 = BukkitPlayerFunctions.getTopPlot(world, plot).id; + final int size = BukkitPlayerFunctions.getPlotSelectionIds(id, id2).size(); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (plotworld.USE_ECONOMY) { price += plotworld.PLOT_PRICE * size; @@ -108,7 +108,7 @@ public class Buy extends SubCommand { } plot.owner = UUIDHandler.getUUID(plr); DBFunc.setOwner(plot, plot.owner); - PlayerFunctions.sendMessage(plr, C.CLAIMED); + BukkitPlayerFunctions.sendMessage(plr, C.CLAIMED); return true; } } 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 b4aa672bf..32a7f2435 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * @author Citymonstret @@ -57,7 +57,7 @@ public class Claim extends SubCommand { if (!event.isCancelled()) { MainUtil.createPlot(player, plot); MainUtil.setSign(player, plot); - PlayerFunctions.sendMessage(player, C.CLAIMED); + BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } @@ -88,13 +88,13 @@ public class Claim extends SubCommand { if (args.length >= 1) { schematic = args[0]; } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions.getAllowedPlots(plr)) { + if (BukkitPlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= BukkitPlayerFunctions.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (plot.hasOwner()) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } 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 56515a7ec..ef54fc659 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Clear extends SubCommand { @@ -64,11 +64,11 @@ public class Clear extends SubCommand { } return true; } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { 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))) { + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.clear")) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java index 5b25afe0c..4cb00e79b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java @@ -24,7 +24,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Clipboard extends SubCommand { public Clipboard() { @@ -42,7 +42,7 @@ public class Clipboard extends SubCommand { final int total = selection.getBlocks().length; String message = C.CLIPBOARD_INFO.s(); message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + ""); - PlayerFunctions.sendMessage(plr, message); + BukkitPlayerFunctions.sendMessage(plr, message); return true; } } 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 6a3bed257..4fbedab0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -42,7 +42,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Cluster extends SubCommand { @@ -55,7 +55,7 @@ public class Cluster extends SubCommand { // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome if (args.length == 0) { // return arguments - PlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); return false; } final String sub = args[0].toLowerCase(); @@ -63,26 +63,26 @@ public class Cluster extends SubCommand { case "l": case "list": { if (!BukkitMain.hasPermission(plr, "plots.cluster.list")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.list"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.list"); return false; } if (args.length != 1) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list"); return false; } final HashSet clusters = ClusterManager.getClusters(plr.getWorld()); - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); for (final PlotCluster cluster : clusters) { // Ignore unmanaged clusters final String name = "'" + cluster.getName() + "' : " + cluster.toString(); if (UUIDHandler.getUUID(plr).equals(cluster.owner)) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name); } else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name); } else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name); } else { - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString()); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString()); } } return true; @@ -90,27 +90,27 @@ public class Cluster extends SubCommand { case "c": case "create": { if (!BukkitMain.hasPermission(plr, "plots.cluster.create")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create"); return false; } if (args.length != 4) { final PlotId id = ClusterManager.estimatePlotId(plr.getLocation()); - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create "); - PlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create "); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id); return false; } // check pos1 / pos2 final PlotId pos1 = MainUtil.parseId(args[2]); final PlotId pos2 = MainUtil.parseId(args[3]); if ((pos1 == null) || (pos2 == null)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } // check if name is taken final String name = args[1]; for (final PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) { if (name.equals(cluster.getName())) { - PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); + BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } } @@ -118,7 +118,7 @@ public class Cluster extends SubCommand { final PlotClusterId id = new PlotClusterId(pos1, pos2); final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); if ((intersects.size() > 0) || (pos2.x < pos1.x) || (pos2.y < pos1.y)) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + ""); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + ""); return false; } // create cluster @@ -142,37 +142,37 @@ public class Cluster extends SubCommand { PlotSquared.config.createSection("worlds." + world); PlotSquared.loadWorld(plr.getWorld()); } - PlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED); return true; } case "disband": case "del": case "delete": { if (!BukkitMain.hasPermission(plr, "plots.cluster.delete")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); return false; } if ((args.length != 1) && (args.length != 2)) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { if (!BukkitMain.hasPermission(plr, "plots.cluster.delete.other")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); return false; } } @@ -205,35 +205,35 @@ public class Cluster extends SubCommand { ClusterManager.last = null; ClusterManager.clusters.get(cluster.world).remove(cluster); ClusterManager.regenCluster(cluster); - PlayerFunctions.sendMessage(plr, C.CLUSTER_DELETED); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_DELETED); return true; } case "res": case "resize": { if (!BukkitMain.hasPermission(plr, "plots.cluster.resize")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize"); return false; } if (args.length != 3) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster resize "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster resize "); return false; } // check pos1 / pos2 final PlotId pos1 = MainUtil.parseId(args[1]); final PlotId pos2 = MainUtil.parseId(args[2]); if ((pos1 == null) || (pos2 == null)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } // check if in cluster final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { if (!BukkitMain.hasPermission(plr, "plots.cluster.resize.other")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other"); return false; } } @@ -241,76 +241,76 @@ public class Cluster extends SubCommand { final PlotClusterId id = new PlotClusterId(pos1, pos2); final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); if (intersects.size() > 1) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + ""); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + ""); return false; } // resize cluster DBFunc.resizeCluster(cluster, id); - PlayerFunctions.sendMessage(plr, C.CLUSTER_RESIZED); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_RESIZED); return true; } case "reg": case "regenerate": case "regen": { if (!BukkitMain.hasPermission(plr, "plots.cluster.delete")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen"); return false; } if ((args.length != 1) && (args.length != 2)) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { if (!BukkitMain.hasPermission(plr, "plots.cluster.regen.other")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen.other"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen.other"); return false; } } ClusterManager.regenCluster(cluster); - PlayerFunctions.sendMessage(plr, C.CLUSTER_REGENERATED); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_REGENERATED); return true; } case "add": case "inv": case "invite": { if (!BukkitMain.hasPermission(plr, "plots.cluster.invite")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite"); return false; } if (args.length != 2) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster invite "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster invite "); return false; } // check if in cluster final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { if (!BukkitMain.hasPermission(plr, "plots.cluster.invite.other")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other"); return false; } } // check uuid final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!cluster.hasRights(uuid)) { @@ -320,43 +320,43 @@ public class Cluster extends SubCommand { DBFunc.setInvited(world, cluster, uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { - PlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); + BukkitPlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); } } - PlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_USER); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_USER); return true; } case "k": case "remove": case "kick": { if (!BukkitMain.hasPermission(plr, "plots.cluster.kick")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick"); return false; } if (args.length != 2) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick "); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { if (!BukkitMain.hasPermission(plr, "plots.cluster.kick.other")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); return false; } } // check uuid final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } // Can't kick if the player is yourself, the owner, or not added to the cluster if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.hasRights(uuid)) { - PlayerFunctions.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName()); + BukkitPlayerFunctions.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName()); return false; } if (cluster.helpers.contains(uuid)) { @@ -367,7 +367,7 @@ public class Cluster extends SubCommand { DBFunc.removeInvited(cluster, uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { - PlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); + BukkitPlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); @@ -376,40 +376,40 @@ public class Cluster extends SubCommand { DBFunc.delete(world, plot); } } - PlayerFunctions.sendMessage(plr, C.CLUSTER_KICKED_USER); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_KICKED_USER); return true; } case "quit": case "leave": { if (!BukkitMain.hasPermission(plr, "plots.cluster.leave")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); return false; } if ((args.length != 1) && (args.length != 2)) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } final UUID uuid = UUIDHandler.getUUID(plr); if (!cluster.hasRights(uuid)) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED); return false; } if (uuid.equals(cluster.owner)) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_CANNOT_LEAVE); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_CANNOT_LEAVE); return false; } if (cluster.helpers.contains(uuid)) { @@ -418,7 +418,7 @@ public class Cluster extends SubCommand { } cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); - PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { @@ -432,83 +432,83 @@ public class Cluster extends SubCommand { case "helper": case "helpers": { if (!BukkitMain.hasPermission(plr, "plots.cluster.helpers")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.helpers"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.helpers"); return false; } if (args.length != 3) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } final UUID uuid = UUIDHandler.getUUID(args[2]); if (uuid == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (args[1].toLowerCase().equals("add")) { cluster.helpers.add(uuid); - return PlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_HELPER); + return BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_HELPER); } if (args[1].toLowerCase().equals("remove")) { cluster.helpers.remove(uuid); - return PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); + return BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); } - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); return false; } case "spawn": case "home": case "tp": { if (!BukkitMain.hasPermission(plr, "plots.cluster.tp")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp"); return false; } if (args.length != 2) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp "); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } final UUID uuid = UUIDHandler.getUUID(plr); if (!cluster.hasRights(uuid)) { if (!BukkitMain.hasPermission(plr, "plots.cluster.tp.other")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); return false; } } plr.teleport(ClusterManager.getHome(cluster)); - return PlayerFunctions.sendMessage(plr, C.CLUSTER_TELEPORTING); + return BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_TELEPORTING); } case "i": case "info": case "show": case "information": { if (!BukkitMain.hasPermission(plr, "plots.cluster.info")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); return false; } if ((args.length != 1) && (args.length != 2)) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } @@ -526,28 +526,28 @@ public class Cluster extends SubCommand { message = message.replaceAll("%name%", name); message = message.replaceAll("%size%", size); message = message.replaceAll("%rights%", rights); - PlayerFunctions.sendMessage(plr, message); + BukkitPlayerFunctions.sendMessage(plr, message); return true; } case "sh": case "setspawn": case "sethome": { if (!BukkitMain.hasPermission(plr, "plots.cluster.sethome")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); return false; } if ((args.length != 1) && (args.length != 2)) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { if (!BukkitMain.hasPermission(plr, "plots.cluster.sethome.other")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other"); return false; } } @@ -557,10 +557,10 @@ public class Cluster extends SubCommand { final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); cluster.settings.setPosition(blockloc); DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); - return PlayerFunctions.sendMessage(plr, C.POSITION_SET); + return BukkitPlayerFunctions.sendMessage(plr, C.POSITION_SET); } } - PlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); + BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); return false; } } 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 927a5f2db..a1272e78a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Comment extends SubCommand { public Comment() { @@ -40,10 +40,10 @@ public class Comment extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!plot.hasOwner()) { return sendMessage(plr, C.NOT_IN_PLOT); } 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 177038dee..5b61ac92b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Condense extends SubCommand { public static boolean TASK = false; @@ -48,35 +48,35 @@ public class Condense extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (plr != null) { - PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); + BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; } if ((args.length != 2) && (args.length != 3)) { - PlayerFunctions.sendMessage(plr, "/plot condense [radius]"); + BukkitPlayerFunctions.sendMessage(plr, "/plot condense [radius]"); return false; } final String worldname = args[0]; final World world = Bukkit.getWorld(worldname); if ((world == null) || !PlotSquared.isPlotWorld(worldname)) { - PlayerFunctions.sendMessage(plr, "INVALID WORLD"); + BukkitPlayerFunctions.sendMessage(plr, "INVALID WORLD"); return false; } switch (args[1].toLowerCase()) { case "start": { if (args.length == 2) { - PlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " start "); + BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " start "); return false; } if (TASK) { - PlayerFunctions.sendMessage(plr, "TASK ALREADY STARTED"); + BukkitPlayerFunctions.sendMessage(plr, "TASK ALREADY STARTED"); return false; } if (args.length == 2) { - PlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " start "); + BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " start "); return false; } if (!StringUtils.isNumeric(args[2])) { - PlayerFunctions.sendMessage(plr, "INVALID RADIUS"); + BukkitPlayerFunctions.sendMessage(plr, "INVALID RADIUS"); return false; } final int radius = Integer.parseInt(args[2]); @@ -84,7 +84,7 @@ public class Condense extends SubCommand { final int size = plots.size(); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { - PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); + BukkitPlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); return false; } final List to_move = new ArrayList<>(getPlots(plots, radius)); @@ -143,25 +143,25 @@ public class Condense extends SubCommand { } }); TASK = true; - PlayerFunctions.sendMessage(plr, "TASK STARTED..."); + BukkitPlayerFunctions.sendMessage(plr, "TASK STARTED..."); return true; } case "stop": { if (!TASK) { - PlayerFunctions.sendMessage(plr, "TASK ALREADY STOPPED"); + BukkitPlayerFunctions.sendMessage(plr, "TASK ALREADY STOPPED"); return false; } TASK = false; - PlayerFunctions.sendMessage(plr, "TASK STOPPED"); + BukkitPlayerFunctions.sendMessage(plr, "TASK STOPPED"); return true; } case "info": { if (args.length == 2) { - PlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " info "); + BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " info "); return false; } if (!StringUtils.isNumeric(args[2])) { - PlayerFunctions.sendMessage(plr, "INVALID RADIUS"); + BukkitPlayerFunctions.sendMessage(plr, "INVALID RADIUS"); return false; } final int radius = Integer.parseInt(args[2]); @@ -169,23 +169,23 @@ public class Condense extends SubCommand { final int size = plots.size(); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { - PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); + BukkitPlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); return false; } final int max_move = getPlots(plots, minimum_radius).size(); final int user_move = getPlots(plots, radius).size(); - PlayerFunctions.sendMessage(plr, "=== DEFAULT EVAL ==="); - PlayerFunctions.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius); - PlayerFunctions.sendMessage(plr, "MAXIMUM MOVES: " + max_move); - PlayerFunctions.sendMessage(plr, "=== INPUT EVAL ==="); - PlayerFunctions.sendMessage(plr, "INPUT RADIUS: " + radius); - PlayerFunctions.sendMessage(plr, "ESTIMATED MOVES: " + user_move); - PlayerFunctions.sendMessage(plr, "ESTIMATED TIME: " + "No idea, times will drastically change based on the system performance and load"); - PlayerFunctions.sendMessage(plr, "&e - Radius is measured in plot width"); + BukkitPlayerFunctions.sendMessage(plr, "=== DEFAULT EVAL ==="); + BukkitPlayerFunctions.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius); + BukkitPlayerFunctions.sendMessage(plr, "MAXIMUM MOVES: " + max_move); + BukkitPlayerFunctions.sendMessage(plr, "=== INPUT EVAL ==="); + BukkitPlayerFunctions.sendMessage(plr, "INPUT RADIUS: " + radius); + BukkitPlayerFunctions.sendMessage(plr, "ESTIMATED MOVES: " + user_move); + BukkitPlayerFunctions.sendMessage(plr, "ESTIMATED TIME: " + "No idea, times will drastically change based on the system performance and load"); + BukkitPlayerFunctions.sendMessage(plr, "&e - Radius is measured in plot width"); return true; } } - PlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " [radius]"); + BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " [radius]"); return false; } 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 9155eb44c..951e55ceb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -26,7 +26,7 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Copy extends SubCommand { @@ -36,18 +36,18 @@ public class Copy extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.copy")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } assert plot != null; if (plot.settings.isMerged()) { - PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); + BukkitPlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); return false; } final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); 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 6fe230b68..7542b0f11 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class CreateRoadSchematic extends SubCommand { public CreateRoadSchematic() { @@ -37,18 +37,18 @@ public class CreateRoadSchematic extends SubCommand { @Override public boolean execute(final Player player, final String... args) { - if (!PlayerFunctions.isInPlot(player)) { - PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(player)) { + BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return false; } if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - final Plot plot = PlayerFunctions.getCurrentPlot(player); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); MainUtil.update(BukkitUtil.getLocation(entity)); - PlayerFunctions.sendMessage(player, "&6Saved new road schematic"); + BukkitPlayerFunctions.sendMessage(player, "&6Saved new road schematic"); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java index 884208be4..bd055260b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * Created 2014-11-09 for PlotSquared @@ -19,12 +19,12 @@ public class DEOP extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { - return PlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!plot.hasRights(plr)) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 a610d6481..b29d9e030 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -15,7 +15,7 @@ import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -36,7 +36,7 @@ public class Database extends SubCommand { } else { final Player p = UUIDHandler.uuidWrapper.getPlayer(uuid); if ((p != null) && p.isOnline()) { - return PlayerFunctions.sendMessage(p, msg); + return BukkitPlayerFunctions.sendMessage(p, msg); } else { return sendMessageU(null, msg); } @@ -141,7 +141,7 @@ public class Database extends SubCommand { if (player == null) { PlotSquared.log(msg); } else { - PlayerFunctions.sendMessage(player, msg); + BukkitPlayerFunctions.sendMessage(player, msg); } return true; } 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 5e8fa1503..65716a4d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.util.Lag; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.RUtils; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Debug extends SubCommand { public Debug() { @@ -43,7 +43,7 @@ public class Debug extends SubCommand { for (final C c : C.values()) { msg.append(c.s()).append("\n"); } - PlayerFunctions.sendMessage(plr, msg.toString()); + BukkitPlayerFunctions.sendMessage(plr, msg.toString()); return true; } StringBuilder information; @@ -84,7 +84,7 @@ public class Debug extends SubCommand { information.append(getLine(line, "View all captions", "/plot debug msg")); } { - PlayerFunctions.sendMessage(plr, information.toString()); + BukkitPlayerFunctions.sendMessage(plr, information.toString()); } return true; } 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 b096bf018..92d8db244 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -42,7 +42,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -64,7 +64,7 @@ public class DebugClaimTest extends SubCommand { if (!event.isCancelled()) { MainUtil.createPlot(player, plot); MainUtil.setSign(player, plot); - PlayerFunctions.sendMessage(player, C.CLAIMED); + BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } @@ -76,11 +76,11 @@ public class DebugClaimTest extends SubCommand { public boolean execute(final Player plr, final String... args) { if (plr == null) { if (args.length < 3) { - 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}"); + return !BukkitPlayerFunctions.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) || !PlotSquared.isPlotWorld(world)) { - return !PlayerFunctions.sendMessage(null, "&cInvalid plot world!"); + return !BukkitPlayerFunctions.sendMessage(null, "&cInvalid plot world!"); } PlotId min, max; try { @@ -89,18 +89,18 @@ public class DebugClaimTest extends SubCommand { min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1])); max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1])); } catch (final Exception e) { - return !PlayerFunctions.sendMessage(null, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area."); + return !BukkitPlayerFunctions.sendMessage(null, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area."); } - 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)"); + BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while..."); + BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)"); final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final ArrayList plots = new ArrayList<>(); - for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) { + for (final PlotId id : BukkitPlayerFunctions.getPlotSelectionIds(min, max)) { final Plot plot = MainUtil.getPlot(world, id); final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id); if (contains) { - PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id); + BukkitPlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id); continue; } final Location loc = manager.getSignLoc(world, plotworld, plot); @@ -132,30 +132,30 @@ public class DebugClaimTest extends SubCommand { uuid = UUIDHandler.getUUID(line); } if (uuid != null) { - PlayerFunctions.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); + BukkitPlayerFunctions.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); plot.owner = uuid; plot.hasChanged = true; plots.add(plot); } else { - PlayerFunctions.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line); + BukkitPlayerFunctions.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line); } } } } } if (plots.size() > 0) { - PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!"); + BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!"); DBFunc.createPlots(plots); DBFunc.createAllSettingsAndHelpers(plots); for (final Plot plot : plots) { PlotSquared.updatePlot(plot); } - PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); + BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); } else { - PlayerFunctions.sendMessage(null, "No plots were found for the given search."); + BukkitPlayerFunctions.sendMessage(null, "No plots were found for the given search."); } } else { - PlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused."); + BukkitPlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused."); } return true; } 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 fca76528f..7514de024 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugClear extends SubCommand { @@ -64,7 +64,7 @@ public class DebugClear extends SubCommand { final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); if (MainUtil.runners.containsKey(plot)) { - PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); + BukkitPlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return false; } MainUtil.runners.put(plot, 1); @@ -82,11 +82,11 @@ public class DebugClear extends SubCommand { } return true; } - if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getPlotWorld(plr.getWorld()) instanceof SquarePlotWorld)) { + if (!BukkitPlayerFunctions.isInPlot(plr) || !(PlotSquared.getPlotWorld(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))) { + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.debugclear")) { @@ -97,7 +97,7 @@ public class DebugClear extends SubCommand { final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); if (MainUtil.runners.containsKey(plot)) { - PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); + BukkitPlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return false; } MainUtil.runners.put(plot, 1); @@ -105,7 +105,7 @@ public class DebugClear extends SubCommand { @Override public void run() { MainUtil.runners.remove(plot); - PlayerFunctions.sendMessage(plr, "&aDone!"); + BukkitPlayerFunctions.sendMessage(plr, "&aDone!"); } }); // sign 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 dbccadcec..0b2d77319 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.ExpireManager; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugExec extends SubCommand { @@ -59,77 +59,77 @@ public class DebugExec extends SubCommand { if (ExpireManager.task != -1) { Bukkit.getScheduler().cancelTask(ExpireManager.task); } else { - return PlayerFunctions.sendMessage(null, "Task already halted"); + return BukkitPlayerFunctions.sendMessage(null, "Task already halted"); } ExpireManager.task = -1; - return PlayerFunctions.sendMessage(null, "Cancelled task."); + return BukkitPlayerFunctions.sendMessage(null, "Cancelled task."); } case "start-expire": { if (ExpireManager.task == -1) { ExpireManager.runTask(); } else { - return PlayerFunctions.sendMessage(null, "Plot expiry task already started"); + return BukkitPlayerFunctions.sendMessage(null, "Plot expiry task already started"); } - return PlayerFunctions.sendMessage(null, "Started plot expiry task"); + return BukkitPlayerFunctions.sendMessage(null, "Started plot expiry task"); } case "update-expired": { if (args.length > 1) { final World world = Bukkit.getWorld(args[1]); if (world == null) { - return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + return BukkitPlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); } - PlayerFunctions.sendMessage(null, "Updating expired plot list"); + BukkitPlayerFunctions.sendMessage(null, "Updating expired plot list"); ExpireManager.updateExpired(args[1]); return true; } - return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired "); + return BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired "); } case "show-expired": { if (args.length > 1) { final World world = Bukkit.getWorld(args[1]); if ((world == null) || !ExpireManager.expiredPlots.containsKey(args[1])) { - return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + return BukkitPlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); } - PlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):"); + BukkitPlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):"); for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { final Plot plot = entry.getKey(); final Long stamp = entry.getValue(); - PlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); + BukkitPlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); } return true; } - return PlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired "); + return BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired "); } case "seen": { if (args.length != 2) { - return PlayerFunctions.sendMessage(null, "Use /plot debugexec seen "); + return BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec seen "); } final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { - return PlayerFunctions.sendMessage(null, "player not found: " + args[1]); + return BukkitPlayerFunctions.sendMessage(null, "player not found: " + args[1]); } final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); if ((op == null) || !op.hasPlayedBefore()) { - return PlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]); + return BukkitPlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]); } final Timestamp stamp = new Timestamp(op.getLastPlayed()); final Date date = new Date(stamp.getTime()); - PlayerFunctions.sendMessage(null, "PLAYER: " + args[1]); - PlayerFunctions.sendMessage(null, "UUID: " + uuid); - PlayerFunctions.sendMessage(null, "Object: " + date.toGMTString()); - PlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString()); - PlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString()); + BukkitPlayerFunctions.sendMessage(null, "PLAYER: " + args[1]); + BukkitPlayerFunctions.sendMessage(null, "UUID: " + uuid); + BukkitPlayerFunctions.sendMessage(null, "Object: " + date.toGMTString()); + BukkitPlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString()); + BukkitPlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString()); return true; } case "trim-check": { if (args.length != 2) { - PlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check "); - PlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim"); - return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run"); + BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check "); + BukkitPlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim"); + return BukkitPlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run"); } final World world = Bukkit.getWorld(args[1]); if ((world == null) || !PlotSquared.isPlotWorld(args[1])) { - return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + return BukkitPlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); } final ArrayList empty = new ArrayList<>(); final boolean result = Trim.getTrimRegions(empty, world, new Runnable() { @@ -160,13 +160,13 @@ public class DebugExec extends SubCommand { } }); if (!result) { - PlayerFunctions.sendMessage(null, "Trim task already started!"); + BukkitPlayerFunctions.sendMessage(null, "Trim task already started!"); } return result; } } } - PlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); + BukkitPlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); return true; } } 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 8f740f6c1..156b96f32 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class DebugFixFlags extends SubCommand { public DebugFixFlags() { @@ -44,19 +44,19 @@ public class DebugFixFlags extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (plr != null) { - PlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); return false; } if (args.length != 1) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags "); return false; } final World world = Bukkit.getWorld(args[0]); if ((world == null) || !PlotSquared.isPlotWorld(world)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); return false; } - PlayerFunctions.sendMessage(plr, "&8--- &6Starting task &8 ---"); + BukkitPlayerFunctions.sendMessage(plr, "&8--- &6Starting task &8 ---"); for (final Plot plot : PlotSquared.getPlots(world).values()) { final Set flags = plot.settings.flags; final ArrayList toRemove = new ArrayList(); @@ -73,7 +73,7 @@ public class DebugFixFlags extends SubCommand { DBFunc.setFlags(plot.world, plot, plot.settings.flags); } } - PlayerFunctions.sendMessage(plr, "&aDone!"); + BukkitPlayerFunctions.sendMessage(plr, "&aDone!"); return true; } } 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 6c2ebfec8..d45698f46 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -26,7 +26,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * @author Citymonstret @@ -49,7 +49,7 @@ public class DebugLoadTest extends SubCommand { PlotSquared.log("&3===END OF STACKTRACE==="); } } else { - PlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.."); + BukkitPlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.."); } return true; } 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 44119ce2e..8561f4610 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class DebugRoadRegen extends SubCommand { @@ -48,7 +48,7 @@ public class DebugRoadRegen extends SubCommand { if (result) { SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } - PlayerFunctions.sendMessage(player, "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); + BukkitPlayerFunctions.sendMessage(player, "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return true; } } 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 cfb5816ad..a1d956532 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -27,7 +27,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * @author Citymonstret @@ -45,7 +45,7 @@ public class DebugSaveTest extends SubCommand { DBFunc.createPlots(plots); DBFunc.createAllSettingsAndHelpers(plots); } else { - PlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused"); + BukkitPlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused"); } return true; } 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 6083c60b7..b27c20dc2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Delete extends SubCommand { @@ -40,11 +40,11 @@ public class Delete extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { 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))) { + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !BukkitMain.hasPermission(plr, "plots.admin.command.delete")) { @@ -65,7 +65,7 @@ public class Delete extends SubCommand { plot.clear(plr, true); DBFunc.delete(plr.getWorld().getName(), plot); } else { - PlayerFunctions.sendMessage(plr, "Plot deletion has been denied."); + BukkitPlayerFunctions.sendMessage(plr, "Plot deletion has been denied."); } return true; } 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 26a7980cc..397ffecb7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") @@ -42,20 +42,20 @@ public class Denied extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 2) { - PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); + BukkitPlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); return true; } - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.denied")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } if (args[0].equalsIgnoreCase("add")) { @@ -66,12 +66,12 @@ public class Denied extends SubCommand { uuid = UUIDHandler.getUUID(args[1]); } if (uuid == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!plot.denied.contains(uuid)) { if (plot.owner.equals(uuid)) { - PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); + BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); return false; } if (plot.trusted.contains(uuid)) { @@ -87,29 +87,29 @@ public class Denied extends SubCommand { final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { - PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); return false; } final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { - final Plot pl = PlayerFunctions.getCurrentPlot(player); + final Plot pl = BukkitPlayerFunctions.getCurrentPlot(player); if ((pl != null) && pl.id.equals(plot.id)) { - PlayerFunctions.sendMessage(player, C.YOU_BE_DENIED); + BukkitPlayerFunctions.sendMessage(player, C.YOU_BE_DENIED); player.teleport(player.getWorld().getSpawnLocation()); } } - PlayerFunctions.sendMessage(plr, C.DENIED_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.DENIED_ADDED); return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { final UUID uuid = DBFunc.everyone; if (!plot.denied.contains(uuid)) { - PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); return true; } plot.removeDenied(uuid); DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); - PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); @@ -117,9 +117,9 @@ public class Denied extends SubCommand { DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); - PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); } else { - PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); + BukkitPlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); return true; } 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 24165dfe2..7baf99bdb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class FlagCmd extends SubCommand { public FlagCmd() { @@ -53,12 +53,12 @@ public class FlagCmd extends SubCommand { * plot flag list */ if (args.length == 0) { - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); return false; } - final Plot plot = PlayerFunctions.getCurrentPlot(player); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); if (plot == null) { - PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return false; } if (!plot.hasOwner()) { @@ -66,88 +66,88 @@ public class FlagCmd extends SubCommand { return false; } if (!plot.hasRights(player) && !BukkitMain.hasPermission(player, "plots.set.flag.other")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other"); return false; } switch (args[0].toLowerCase()) { case "info": { if (!BukkitMain.hasPermission(player, "plots.set.flag")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.info"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.info"); return false; } if (args.length != 2) { - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1]); if (af == null) { - PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); + BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); return false; } // flag key - PlayerFunctions.sendMessage(player, C.FLAG_KEY, af.getKey()); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_KEY, af.getKey()); // flag type - PlayerFunctions.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName()); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName()); // Flag type description - PlayerFunctions.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); - PlayerFunctions.sendMessage(player, "&cNot implemented."); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); + BukkitPlayerFunctions.sendMessage(player, "&cNot implemented."); } case "set": { if (!BukkitMain.hasPermission(player, "plots.set.flag")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); return false; } if (args.length < 3) { - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set "); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); + BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); return false; } final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed); final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); return false; } - PlayerFunctions.sendMessage(player, C.FLAG_ADDED); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "remove": { if (!BukkitMain.hasPermission(player, "plots.flag.remove")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove"); return false; } if ((args.length != 2) && (args.length != 3)) { - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove [values]"); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove [values]"); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()); if (flag == null) { - PlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT); return false; } if ((args.length == 3) && flag.getAbstractFlag().isList()) { @@ -157,36 +157,36 @@ public class FlagCmd extends SubCommand { } else { final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); if (!result) { - PlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED); return false; } } - PlayerFunctions.sendMessage(player, C.FLAG_REMOVED); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_REMOVED); PlotListener.plotEntry(player, plot); return true; } case "add": { if (!BukkitMain.hasPermission(player, "plots.flag.add")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.add"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.add"); return false; } if (args.length < 3) { - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add "); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); + BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); return false; } Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase()); @@ -197,21 +197,21 @@ public class FlagCmd extends SubCommand { } final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); return false; } DBFunc.setFlags(plot.world, plot, plot.settings.flags); - PlayerFunctions.sendMessage(player, C.FLAG_ADDED); + BukkitPlayerFunctions.sendMessage(player, C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "list": { if (!BukkitMain.hasPermission(player, "plots.flag.list")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.list"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.list"); return false; } if (args.length != 1) { - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list"); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list"); return false; } final HashMap> flags = new HashMap<>(); @@ -228,11 +228,11 @@ public class FlagCmd extends SubCommand { message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", "); prefix = "\n"; } - PlayerFunctions.sendMessage(player, message); + BukkitPlayerFunctions.sendMessage(player, message); return true; } } - PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); + BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); 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 997d847a8..64a8d5c2f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Helpers extends SubCommand { @@ -41,20 +41,20 @@ public class Helpers extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 2) { - PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); + BukkitPlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); return true; } - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.helpers")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } if (args[0].equalsIgnoreCase("add")) { @@ -65,12 +65,12 @@ public class Helpers extends SubCommand { uuid = UUIDHandler.getUUID(args[1]); } if (uuid == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!plot.helpers.contains(uuid)) { if (plot.owner.equals(uuid)) { - PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); + BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); return false; } if (plot.trusted.contains(uuid)) { @@ -86,21 +86,21 @@ public class Helpers extends SubCommand { final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { - PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); return false; } - PlayerFunctions.sendMessage(plr, C.HELPER_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.HELPER_ADDED); return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { final UUID uuid = DBFunc.everyone; if (!plot.helpers.contains(uuid)) { - PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); return true; } plot.removeHelper(uuid); DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); - PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); @@ -108,9 +108,9 @@ public class Helpers extends SubCommand { DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); - PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); } else { - PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); + BukkitPlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); return true; } 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 54a9e19fa..832007503 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -67,20 +67,20 @@ public class Home extends SubCommand { return true; } } - PlayerFunctions.sendMessage(plr, C.NOT_YOUR_PLOT); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_YOUR_PLOT); return false; } - PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return true; } if ((id > (plots.length)) || (id < 1)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return false; } teleportPlayer(plr, plots[id - 1]); return true; } else { - PlayerFunctions.sendMessage(plr, C.NO_PLOTS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOTS); return true; } } 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 3e204817b..4fb2cc82c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Inbox extends SubCommand { @@ -50,13 +50,13 @@ public class Inbox extends SubCommand { report = true; } } - if (!PlayerFunctions.isInPlot(plr) && !report) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr) && !report) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot != null) && !plot.hasOwner()) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } Integer tier; @@ -80,7 +80,7 @@ public class Inbox extends SubCommand { if (tier <= 0) { tier = 0; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); return false; } break; @@ -88,7 +88,7 @@ public class Inbox extends SubCommand { if (tier <= 1) { tier = 1; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner"); return false; } break; @@ -96,7 +96,7 @@ public class Inbox extends SubCommand { if (tier <= 2) { tier = 2; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper"); return false; } break; @@ -104,7 +104,7 @@ public class Inbox extends SubCommand { if (tier <= 3) { tier = 3; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted"); return false; } break; @@ -112,7 +112,7 @@ public class Inbox extends SubCommand { if (tier <= 4) { tier = 4; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone"); return false; } break; @@ -120,12 +120,12 @@ public class Inbox extends SubCommand { if (tier <= 0) { tier = -1; } else { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); return false; } break; default: - PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4)); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4)); return false; } } else { @@ -149,7 +149,7 @@ public class Inbox extends SubCommand { if (args.length == 2) { final String[] split = args[1].toLowerCase().split(":"); if (!split[0].equals("clear")) { - PlayerFunctions.sendMessage(plr, "&c/plot inbox [tier] [clear][:#]"); + BukkitPlayerFunctions.sendMessage(plr, "&c/plot inbox [tier] [clear][:#]"); return; } if (split.length > 1) { @@ -158,10 +158,10 @@ public class Inbox extends SubCommand { final PlotComment comment = comments.get(index - 1); DBFunc.removeComment(world, plot, comment); plot.settings.removeComment(comment); - PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment"); return; } catch (final Exception e) { - PlayerFunctions.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]"); + BukkitPlayerFunctions.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]"); return; } } @@ -169,7 +169,7 @@ public class Inbox extends SubCommand { DBFunc.removeComment(world, plot, comment); } plot.settings.removeComments(comments); - PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); + BukkitPlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); } else { final List recipients = Arrays.asList("A", "O", "H", "T", "E"); int count = 1; @@ -183,7 +183,7 @@ public class Inbox extends SubCommand { if (comments.size() == 0) { message.append("&cNo messages."); } - PlayerFunctions.sendMessage(plr, message.toString()); + BukkitPlayerFunctions.sendMessage(plr, message.toString()); } } }); 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 68446eb5b..15078754a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -39,7 +39,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -58,22 +58,22 @@ public class Info extends SubCommand { if (player != null) { world = player.getWorld(); if (!PlotSquared.isPlotWorld(world)) { - PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT_WORLD); + BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT_WORLD); return false; } - if (!PlayerFunctions.isInPlot(player)) { - PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(player)) { + BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return false; } - plot = PlayerFunctions.getCurrentPlot(player); + plot = BukkitPlayerFunctions.getCurrentPlot(player); } else { if (args.length < 2) { - PlayerFunctions.sendMessage(null, C.INFO_SYNTAX_CONSOLE); + BukkitPlayerFunctions.sendMessage(null, C.INFO_SYNTAX_CONSOLE); return false; } final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); if (plotworld == null) { - PlayerFunctions.sendMessage(player, C.NOT_VALID_WORLD); + BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_WORLD); return false; } try { @@ -81,7 +81,7 @@ public class Info extends SubCommand { final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id); if (plot == null) { - PlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID); + BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID); return false; } world = Bukkit.getWorld(args[0]); @@ -91,7 +91,7 @@ public class Info extends SubCommand { args = new String[0]; } } catch (final Exception e) { - PlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE); + BukkitPlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE); return false; } } @@ -109,7 +109,7 @@ public class Info extends SubCommand { } // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { - PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); + BukkitPlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); return true; } String owner = "none"; @@ -123,13 +123,13 @@ public class Info extends SubCommand { if (args.length == 1) { info = getCaption(args[0].toLowerCase()); if (info == null) { - PlayerFunctions.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); + BukkitPlayerFunctions.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); return false; } } info = format(info, world, plot, player); - PlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER); - PlayerFunctions.sendMessage(player, info, false); + BukkitPlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER); + BukkitPlayerFunctions.sendMessage(player, info, false); return true; } @@ -162,8 +162,8 @@ public class Info extends SubCommand { private String format(String info, final World world, final Plot plot, final Player player) { final PlotId id = plot.id; - final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; - final int num = PlayerFunctions.getPlotSelectionIds(id, id2).size(); + final PlotId id2 = BukkitPlayerFunctions.getTopPlot(world, plot).id; + final int num = BukkitPlayerFunctions.getPlotSelectionIds(id, id2).size(); final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; final String biome = getBiomeAt(plot).toString(); final String helpers = getPlayerList(plot.helpers); 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 410c1c105..7be8d38dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -26,7 +26,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({ "unused", "deprecation", "javadoc" }) @@ -37,26 +37,26 @@ public class Kick extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, "You're not in a plot."); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, "You're not in a plot."); return false; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.kick")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if (args.length != 1) { - PlayerFunctions.sendMessage(plr, "&c/plot kick "); + BukkitPlayerFunctions.sendMessage(plr, "&c/plot kick "); return false; } if (Bukkit.getPlayer(args[0]) == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } final Player player = Bukkit.getPlayer(args[0]); - if (!player.getWorld().equals(plr.getWorld()) || !PlayerFunctions.isInPlot(player) || (PlayerFunctions.getCurrentPlot(player) == null) || !PlayerFunctions.getCurrentPlot(player).equals(plot)) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); + if (!player.getWorld().equals(plr.getWorld()) || !BukkitPlayerFunctions.isInPlot(player) || (BukkitPlayerFunctions.getCurrentPlot(player) == null) || !BukkitPlayerFunctions.getCurrentPlot(player).equals(plot)) { + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); return false; } player.teleport(player.getWorld().getSpawnLocation()); 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 aeabc7fee..85d2b3139 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -25,7 +25,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -52,7 +52,7 @@ public class MainCommand { }; public static boolean no_permission(final PlotPlayer player, final String permission) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission); return false; } @@ -120,7 +120,7 @@ public class MainCommand { builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands")); - return PlayerFunctions.sendMessage(player, builder.toString()); + return BukkitPlayerFunctions.sendMessage(player, builder.toString()); } final String cat = args[1]; SubCommand.CommandCategory cato = null; @@ -136,7 +136,7 @@ public class MainCommand { for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } - return PlayerFunctions.sendMessage(player, builder.toString(), false); + return BukkitPlayerFunctions.sendMessage(player, builder.toString(), false); } final StringBuilder help = new StringBuilder(); int page = 0; @@ -173,21 +173,21 @@ public class MainCommand { if ((player != null) || !command.isPlayer) { return command.execute(player, arguments); } else { - return !PlayerFunctions.sendMessage(null, C.IS_CONSOLE); + return !BukkitPlayerFunctions.sendMessage(null, C.IS_CONSOLE); } } else { return no_permission(player, command.permission.permission.toLowerCase()); } } } - PlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND); + BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND); final String[] commands = new String[subCommands.size()]; for (int x = 0; x < subCommands.size(); x++) { commands[x] = subCommands.get(x).cmd; } /* Let's try to get a proper usage string */ final String command = new StringComparison(args[0], commands).getBestMatch(); - return PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); + return BukkitPlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new // StringComparsion(args[0], commands).getBestMatch()); } 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 2971839a8..de582fdf9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -37,7 +37,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -75,23 +75,23 @@ public class Merge extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } final boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge"); if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if (args.length < 1) { - PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); - PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); + BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); + BukkitPlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); return false; } int direction = -1; @@ -102,43 +102,43 @@ public class Merge extends SubCommand { } } if (direction == -1) { - PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); - PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); + BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); + BukkitPlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); return false; } final World world = plr.getWorld(); - PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id; - PlotId top = PlayerFunctions.getTopPlot(world, plot).id; + PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id; + PlotId top = BukkitPlayerFunctions.getTopPlot(world, plot).id; ArrayList plots; switch (direction) { case 0: // north = -y - plots = PlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); + plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); break; case 1: // east = +x - plots = PlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); + plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); break; case 2: // south = +y - plots = PlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); + plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); break; case 3: // west = -x - plots = PlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); + plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); break; default: return false; } final PlotId botId = plots.get(0); final PlotId topId = plots.get(plots.size() - 1); - final PlotId bot1 = PlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, botId)).id; - final PlotId bot2 = PlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, topId)).id; - final PlotId top1 = PlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, topId)).id; - final PlotId top2 = PlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, botId)).id; + final PlotId bot1 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, botId)).id; + final PlotId bot2 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, topId)).id; + final PlotId top1 = BukkitPlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, topId)).id; + final PlotId top2 = BukkitPlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, botId)).id; bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y)); top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y)); - plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top); + plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, bot, top); for (final PlotId myid : plots) { 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())); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; } } @@ -160,10 +160,10 @@ public class Merge extends SubCommand { Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { event.setCancelled(true); - PlayerFunctions.sendMessage(plr, "&cMerge has been cancelled"); + BukkitPlayerFunctions.sendMessage(plr, "&cMerge has been cancelled"); return false; } - PlayerFunctions.sendMessage(plr, "&cPlots have been merged"); + BukkitPlayerFunctions.sendMessage(plr, "&cPlots have been merged"); MainUtil.mergePlots(world, plots, true); MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot); MainUtil.update(plr.getLocation()); 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 4209dedd7..485e59fe7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * Created 2014-08-01 for PlotSquared @@ -40,32 +40,32 @@ public class Move extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (plr == null) { - PlayerFunctions.sendMessage(plr, "MUST BE EXECUTED BY PLAYER"); + BukkitPlayerFunctions.sendMessage(plr, "MUST BE EXECUTED BY PLAYER"); } if (args.length != 2) { - PlayerFunctions.sendMessage(plr, "/plot move "); + BukkitPlayerFunctions.sendMessage(plr, "/plot move "); return false; } final World world = plr.getWorld(); final PlotId plot1 = MainUtil.parseId(args[0]); final PlotId plot2 = MainUtil.parseId(args[1]); if ((plot1 == null) || (plot2 == null)) { - PlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move "); + BukkitPlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move "); return false; } if (plot1 == plot2) { - PlayerFunctions.sendMessage(plr, "DUPLICATE ID"); + BukkitPlayerFunctions.sendMessage(plr, "DUPLICATE ID"); return false; } if (MainUtil.move(world, plot1, plot2, new Runnable() { @Override public void run() { - PlayerFunctions.sendMessage(plr, "MOVE SUCCESS"); + BukkitPlayerFunctions.sendMessage(plr, "MOVE SUCCESS"); } })) { return true; } else { - PlayerFunctions.sendMessage(plr, "MOVE FAILED"); + BukkitPlayerFunctions.sendMessage(plr, "MOVE FAILED"); return false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index bb8720c03..a261ef6ed 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -31,7 +31,7 @@ import org.bukkit.inventory.meta.ItemMeta; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class MusicSubcommand extends SubCommand { public MusicSubcommand() { @@ -40,11 +40,11 @@ public class MusicSubcommand extends SubCommand { @Override public boolean execute(final Player player, final String... args) { - if (!PlayerFunctions.isInPlot(player)) { + if (!BukkitPlayerFunctions.isInPlot(player)) { sendMessage(player, C.NOT_IN_PLOT); return true; } - final Plot plot = PlayerFunctions.getCurrentPlot(player); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); if (!plot.hasRights(player)) { sendMessage(player, C.NO_PLOT_PERMS); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java index 7a7f0f4ae..4dd26c6df 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * Created 2014-11-09 for PlotSquared @@ -19,12 +19,12 @@ public class OP extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { - return PlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!plot.hasRights(plr)) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 bd0b84c31..7d165a62f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -26,7 +26,7 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Paste extends SubCommand { @@ -36,17 +36,17 @@ public class Paste extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.paste")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } - if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { - PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); + if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + BukkitPlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); return false; } assert plot != null; 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 94f078bf5..14baa41c5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({ "javadoc" }) @@ -55,47 +55,47 @@ public class Purge extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (plr != null) { - PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); + BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; } if (args.length == 1) { final String arg = args[0].toLowerCase(); final PlotId id = getId(arg); if (id != null) { - PlayerFunctions.sendMessage(plr, "/plot purge x;z &l"); + BukkitPlayerFunctions.sendMessage(plr, "/plot purge x;z &l"); return false; } final UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - PlayerFunctions.sendMessage(plr, "/plot purge " + args[0] + " &l"); + BukkitPlayerFunctions.sendMessage(plr, "/plot purge " + args[0] + " &l"); return false; } if (arg.equals("player")) { - PlayerFunctions.sendMessage(plr, "/plot purge &l "); + BukkitPlayerFunctions.sendMessage(plr, "/plot purge &l "); return false; } if (arg.equals("unowned")) { - PlayerFunctions.sendMessage(plr, "/plot purge unowned &l"); + BukkitPlayerFunctions.sendMessage(plr, "/plot purge unowned &l"); return false; } if (arg.equals("unknown")) { - PlayerFunctions.sendMessage(plr, "/plot purge unknown &l"); + BukkitPlayerFunctions.sendMessage(plr, "/plot purge unknown &l"); return false; } if (arg.equals("all")) { - PlayerFunctions.sendMessage(plr, "/plot purge all &l"); + BukkitPlayerFunctions.sendMessage(plr, "/plot purge all &l"); return false; } - PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); return false; } if (args.length != 2) { - PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); return false; } final World world = Bukkit.getWorld(args[1]); if ((world == null) || !PlotSquared.isPlotWorld(world)) { - PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD); + BukkitPlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD); return false; } final String worldname = world.getName(); @@ -123,7 +123,7 @@ public class Purge extends SubCommand { if (arg.equals("all")) { final Set ids = PlotSquared.getPlots(world).keySet(); if (ids.size() == 0) { - return PlayerFunctions.sendMessage(null, "&cNo plots found"); + return BukkitPlayerFunctions.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); @@ -140,7 +140,7 @@ public class Purge extends SubCommand { } } if (ids.size() == 0) { - return PlayerFunctions.sendMessage(null, "&cNo plots found"); + return BukkitPlayerFunctions.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); @@ -154,17 +154,17 @@ public class Purge extends SubCommand { } } if (ids.size() == 0) { - return PlayerFunctions.sendMessage(null, "&cNo plots found"); + return BukkitPlayerFunctions.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } - PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); return false; } private boolean finishPurge(final int amount) { - PlayerFunctions.sendMessage(null, C.PURGE_SUCCESS, amount + ""); + BukkitPlayerFunctions.sendMessage(null, C.PURGE_SUCCESS, amount + ""); return false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index a66ed1a45..adf401365 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({ "unused", "deprecated", "javadoc" }) @@ -44,11 +44,11 @@ public class Rate extends SubCommand { sendMessage(plr, C.RATING_NOT_VALID); return true; } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!plot.hasOwner()) { sendMessage(plr, C.RATING_NOT_OWNED); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index 9e054c535..945b676f7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Reload extends SubCommand { public Reload() { @@ -46,7 +46,7 @@ public class Reload extends SubCommand { } MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); } catch (final Exception e) { - PlayerFunctions.sendMessage(plr, C.RELOAD_FAILED); + BukkitPlayerFunctions.sendMessage(plr, C.RELOAD_FAILED); } return true; } 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 4b555592f..61920af69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -40,7 +40,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Schematic extends SubCommand { @@ -70,19 +70,19 @@ public class Schematic extends SubCommand { return false; } if (!BukkitMain.hasPermission(plr, "plots.schematic.paste")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); return false; } if (args.length < 2) { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); break; } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { sendMessage(plr, C.NOT_IN_PLOT); break; } if (this.running) { - PlayerFunctions.sendMessage(plr, "&cTask is already running."); + BukkitPlayerFunctions.sendMessage(plr, "&cTask is already running."); return false; } final String file2 = args[1]; @@ -99,7 +99,7 @@ public class Schematic extends SubCommand { } final int x; final int z; - final Plot plot2 = PlayerFunctions.getCurrentPlot(plr); + final Plot plot2 = BukkitPlayerFunctions.getCurrentPlot(plr); final Dimension dem = schematic.getSchematicDimension(); final Location bot = MainUtil.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1); final int length2 = MainUtil.getPlotWidth(plr.getWorld(), plot2.id); @@ -151,7 +151,7 @@ public class Schematic extends SubCommand { return false; } if (!BukkitMain.hasPermission(plr, "plots.schematic.test")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); return false; } if (args.length < 2) { @@ -166,7 +166,7 @@ public class Schematic extends SubCommand { } final int l1 = schematic.getSchematicDimension().getX(); final int l2 = schematic.getSchematicDimension().getZ(); - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); final int length = MainUtil.getPlotWidth(plr.getWorld(), plot.id); if ((l1 < length) || (l2 < length)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); @@ -177,20 +177,20 @@ public class Schematic extends SubCommand { case "saveall": case "exportall": if (plr != null) { - PlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); return false; } if (args.length != 2) { - PlayerFunctions.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall "); + BukkitPlayerFunctions.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall "); return false; } final HashMap plotmap = PlotSquared.getPlots(args[1]); if ((plotmap == null) || (plotmap.size() == 0)) { - PlayerFunctions.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall "); + BukkitPlayerFunctions.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall "); return false; } if (this.running) { - PlayerFunctions.sendMessage(null, "&cTask is already running."); + BukkitPlayerFunctions.sendMessage(null, "&cTask is already running."); return false; } PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); @@ -216,17 +216,17 @@ public class Schematic extends SubCommand { final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { - PlayerFunctions.sendMessage(null, "&7 - Skipped plot &c" + plot.id); + BukkitPlayerFunctions.sendMessage(null, "&7 - Skipped plot &c" + plot.id); } else { Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { @Override public void run() { - PlayerFunctions.sendMessage(null, "&6ID: " + plot.id); + BukkitPlayerFunctions.sendMessage(null, "&6ID: " + plot.id); final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + worldname + "," + owner + ".schematic"); if (!result) { - PlayerFunctions.sendMessage(null, "&7 - Failed to save &c" + plot.id); + BukkitPlayerFunctions.sendMessage(null, "&7 - Failed to save &c" + plot.id); } else { - PlayerFunctions.sendMessage(null, "&7 - &aExport success: " + plot.id); + BukkitPlayerFunctions.sendMessage(null, "&7 - &aExport success: " + plot.id); } } }); @@ -238,21 +238,21 @@ public class Schematic extends SubCommand { case "export": case "save": if (!BukkitMain.hasPermission(plr, "plots.schematic.save")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); return false; } if (this.running) { - PlayerFunctions.sendMessage(plr, "&cTask is already running."); + BukkitPlayerFunctions.sendMessage(plr, "&cTask is already running."); return false; } final String world; final Plot p2; if (plr != null) { - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot myplot = PlayerFunctions.getCurrentPlot(plr); + final Plot myplot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!myplot.hasRights(plr)) { sendMessage(plr, C.NO_PLOT_PERMS); return false; @@ -266,16 +266,16 @@ public class Schematic extends SubCommand { final String[] split = args[2].split(";"); final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) { - PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); + BukkitPlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } p2 = PlotSquared.getPlots(world).get(i); } catch (final Exception e) { - PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); + BukkitPlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } } else { - PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); + BukkitPlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } } @@ -297,17 +297,17 @@ public class Schematic extends SubCommand { final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { - PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); + BukkitPlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); } else { Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { @Override public void run() { - PlayerFunctions.sendMessage(plr, "&6ID: " + plot.id); + BukkitPlayerFunctions.sendMessage(plr, "&6ID: " + plot.id); final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + world + "," + owner.trim() + ".schematic"); if (!result) { - PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c" + plot.id); + BukkitPlayerFunctions.sendMessage(plr, "&7 - Failed to save &c" + plot.id); } else { - PlayerFunctions.sendMessage(plr, "&7 - &aExport success: " + plot.id); + BukkitPlayerFunctions.sendMessage(plr, "&7 - &aExport success: " + plot.id); } } }); 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 9fc4b40c1..3e142d6d0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -48,7 +48,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -65,21 +65,21 @@ public class Set extends SubCommand { @SuppressWarnings("deprecation") @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!plot.hasOwner()) { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; } if (!plot.hasRights(plr) && !BukkitMain.hasPermission(plr, "plots.admin.command.set")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if (args.length < 1) { - PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); + BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); return false; } for (int i = 0; i < aliases.length; i++) { @@ -91,7 +91,7 @@ public class Set extends SubCommand { /* TODO: Implement option */ // final boolean advanced_permissions = true; if (!BukkitMain.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); return false; } if (args[0].equalsIgnoreCase("flag")) { @@ -104,7 +104,7 @@ public class Set extends SubCommand { message += "," + StringUtils.join(PlotSquared.worldGuardListener.str_flags, "&c, &6"); } } - PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); + BukkitPlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } AbstractFlag af; @@ -114,11 +114,11 @@ public class Set extends SubCommand { af = new AbstractFlag(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); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION); return false; } if (args.length == 2) { @@ -129,15 +129,15 @@ public class Set extends SubCommand { return false; } } - PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT); + BukkitPlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT); return false; } final boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase()); if (!result) { - PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED); return false; } - PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.FLAG_REMOVED); PlotListener.plotEntry(plr, plot); return true; } @@ -145,7 +145,7 @@ public class Set extends SubCommand { final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed_value = af.parseValueRaw(value); if (parsed_value == null) { - PlayerFunctions.sendMessage(plr, af.getValueDesc()); + BukkitPlayerFunctions.sendMessage(plr, af.getValueDesc()); return false; } if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotSquared.worldGuardListener != null)) { @@ -155,14 +155,14 @@ public class Set extends SubCommand { final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed_value); final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED); return false; } - PlayerFunctions.sendMessage(plr, C.FLAG_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.FLAG_ADDED); PlotListener.plotEntry(plr, plot); return true; } catch (final Exception e) { - PlayerFunctions.sendMessage(plr, "&c" + e.getMessage()); + BukkitPlayerFunctions.sendMessage(plr, "&c" + e.getMessage()); return false; } } @@ -173,7 +173,7 @@ public class Set extends SubCommand { DBFunc.setPosition(plr.getWorld().getName(), plot, ""); return true; } - return PlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT); + return BukkitPlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT); } //set to current location final World world = plr.getWorld(); @@ -183,35 +183,35 @@ public class Set extends SubCommand { final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); plot.settings.setPosition(blockloc); DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); - return PlayerFunctions.sendMessage(plr, C.POSITION_SET); + return BukkitPlayerFunctions.sendMessage(plr, C.POSITION_SET); } if (args[0].equalsIgnoreCase("alias")) { if (args.length < 2) { - PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS); + BukkitPlayerFunctions.sendMessage(plr, C.MISSING_ALIAS); return false; } final String alias = args[1]; if (alias.length() >= 50) { - PlayerFunctions.sendMessage(plr, C.ALIAS_TOO_LONG); + BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_TOO_LONG); return false; } for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) { if (p.settings.getAlias().equalsIgnoreCase(alias)) { - PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); + BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } if (UUIDHandler.nameExists(new StringWrapper(alias))) { - PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); + BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } } DBFunc.setAlias(plr.getWorld().getName(), plot, alias); - PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); + BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); return true; } if (args[0].equalsIgnoreCase("biome")) { if (args.length < 2) { - PlayerFunctions.sendMessage(plr, C.NEED_BIOME); + BukkitPlayerFunctions.sendMessage(plr, C.NEED_BIOME); return true; } if (args[1].length() < 2) { @@ -228,11 +228,11 @@ public class Set extends SubCommand { * } */ if (biome == null) { - PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); + BukkitPlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); return true; } MainUtil.setBiome(plr.getWorld(), plot, biome); - PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); + BukkitPlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); return true; } // Get components @@ -243,7 +243,7 @@ public class Set extends SubCommand { for (final String component : components) { if (component.equalsIgnoreCase(args[0])) { if (args.length < 2) { - PlayerFunctions.sendMessage(plr, C.NEED_BLOCK); + BukkitPlayerFunctions.sendMessage(plr, C.NEED_BLOCK); return true; } PlotBlock[] blocks; @@ -253,12 +253,12 @@ public class Set extends SubCommand { try { blocks = new PlotBlock[] { new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0) }; } catch (final Exception e2) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK); return false; } } manager.setComponent(world, plotworld, plot.id, component, blocks); - PlayerFunctions.sendMessage(plr, C.GENERATING_COMPONENT); + BukkitPlayerFunctions.sendMessage(plr, C.GENERATING_COMPONENT); return true; } } @@ -280,7 +280,7 @@ public class Set extends SubCommand { return true; } } - PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); + BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 7634e80a7..ddfe50082 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class SetOwner extends SubCommand { @@ -52,28 +52,28 @@ public class SetOwner extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || (plot.owner == null)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } if (args.length < 1) { - PlayerFunctions.sendMessage(plr, C.NEED_USER); + BukkitPlayerFunctions.sendMessage(plr, C.NEED_USER); return false; } if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.setowner")) { - PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } final World world = plr.getWorld(); - final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id; - final PlotId top = PlayerFunctions.getTopPlot(world, plot).id; - final ArrayList plots = PlayerFunctions.getPlotSelectionIds(bot, top); + final PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id; + final PlotId top = BukkitPlayerFunctions.getTopPlot(world, plot).id; + final ArrayList plots = BukkitPlayerFunctions.getPlotSelectionIds(bot, top); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); final UUID uuid = getUUID(args[0]); if (uuid == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } current.owner = uuid; @@ -84,7 +84,7 @@ public class SetOwner extends SubCommand { } } MainUtil.setSign(world, args[0], plot); - PlayerFunctions.sendMessage(plr, C.SET_OWNER); + BukkitPlayerFunctions.sendMessage(plr, C.SET_OWNER); return true; } } 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 da4ff9416..64344c33e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Setup extends SubCommand { public final static Map setupMap = new HashMap<>(); @@ -93,13 +93,13 @@ public class Setup extends SubCommand { updateGenerators(); final String prefix = "\n&8 - &7"; sendMessage(plr, C.SETUP_INIT); - PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + BukkitPlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); return false; } if (args.length == 1) { if (args[0].equalsIgnoreCase("cancel")) { setupMap.remove(plr.getName()); - PlayerFunctions.sendMessage(plr, "&aCancelled setup"); + BukkitPlayerFunctions.sendMessage(plr, "&aCancelled setup"); return false; } if (args[0].equalsIgnoreCase("back")) { @@ -120,14 +120,14 @@ public class Setup extends SubCommand { case 0: { // choose generator if ((args.length != 1) || !this.generators.containsKey(args[0])) { final String prefix = "\n&8 - &7"; - PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + BukkitPlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); sendMessage(plr, C.SETUP_INIT); return false; } object.generator = args[0]; object.current++; final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : ""; - PlayerFunctions.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); + BukkitPlayerFunctions.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); break; } case 1: { // choose world type @@ -138,7 +138,7 @@ public class Setup extends SubCommand { types = Arrays.asList(new String[] { "default", "augmented" }); } if ((args.length != 1) || !types.contains(args[0].toLowerCase())) { - PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); + BukkitPlayerFunctions.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); return false; } object.type = types.indexOf(args[0].toLowerCase()); @@ -150,7 +150,7 @@ public class Setup extends SubCommand { final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); } else { - PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + BukkitPlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); } object.current++; break; @@ -158,7 +158,7 @@ public class Setup extends SubCommand { case 2: { // Choose terrain final List terrain = Arrays.asList(new String[] { "none", "ore", "all" }); if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) { - PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + BukkitPlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); return false; } object.terrain = terrain.indexOf(args[0].toLowerCase()); @@ -172,7 +172,7 @@ public class Setup extends SubCommand { } case 3: { // world setup if (object.setup_index == object.step.length) { - PlayerFunctions.sendMessage(plr, "&6What do you want your world to be called?"); + BukkitPlayerFunctions.sendMessage(plr, "&6What do you want your world to be called?"); object.setup_index = 0; object.current++; return true; @@ -202,11 +202,11 @@ public class Setup extends SubCommand { } case 4: { if (args.length != 1) { - PlayerFunctions.sendMessage(plr, "&cYou need to choose a world name!"); + BukkitPlayerFunctions.sendMessage(plr, "&cYou need to choose a world name!"); return false; } if (Bukkit.getWorld(args[0]) != null) { - PlayerFunctions.sendMessage(plr, "&cThat world name is already taken!"); + BukkitPlayerFunctions.sendMessage(plr, "&cThat world name is already taken!"); } object.world = args[0]; setupMap.remove(plr.getName()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index eca8c3fff..bcfe550a5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -22,7 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import java.util.ArrayList; import java.util.Arrays; @@ -144,11 +144,11 @@ public abstract class SubCommand { * @param c Caption * @param args Arguments (%s's) * - * @see com.intellectualcrafters.plot.util.bukkit.PlayerFunctions#sendMessage(org.bukkit.entity.Player, + * @see com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions#sendMessage(org.bukkit.entity.Player, * com.intellectualcrafters.plot.config.C, String...) */ public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { - PlayerFunctions.sendMessage(plr, c, args); + BukkitPlayerFunctions.sendMessage(plr, c, args); return true; } 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 8691d4d83..5a71ea0a5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -46,21 +46,21 @@ public class Swap extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { - PlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); - PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); return false; } - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.swap")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if ((plot != null) && plot.settings.isMerged()) { - PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); + BukkitPlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); return false; } final String id = args[0]; @@ -70,25 +70,25 @@ public class Swap extends SubCommand { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotSquared.getPlots(world).get(plotid); if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.swap")) { - PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); return false; } } catch (final Exception e) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); - PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); return false; } assert plot != null; if (plot.id.equals(plotid)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); - PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); return false; } PlotSelection.swap(world, plot.id, plotid); // TODO Requires testing!! DBFunc.dbManager.swapPlots(plot, MainUtil.getPlot(world, plotid)); // TODO Requires testing!! - PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS); + BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS); MainUtil.update(plr.getLocation()); return true; } 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 7a417e4bc..5dace5842 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * @author Citymonstret @@ -43,7 +43,7 @@ public class TP extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { - PlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); return false; } final String id = args[0]; @@ -55,7 +55,7 @@ public class TP extends SubCommand { } } if (!PlotSquared.isPlotWorld(world)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } Plot temp; @@ -68,7 +68,7 @@ public class TP extends SubCommand { PlotSquared.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid)); return true; } catch (final Exception e) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); } return false; } 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 e94e9dfcc..957aa2f92 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Target extends SubCommand { public Target() { @@ -37,21 +37,21 @@ public class Target extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (!PlotSquared.isPlotWorld(plr.getWorld())) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } if (args.length == 1) { final PlotId id = MainUtil.parseId(args[1]); if (id == null) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } final Location loc = MainUtil.getPlotHome(plr.getWorld(), id); plr.setCompassTarget(loc); - PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET); + BukkitPlayerFunctions.sendMessage(plr, C.COMPASS_TARGET); return true; } - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot target "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot target "); 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 6b9a4d344..55068666f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -32,7 +32,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Template extends SubCommand { public Template() { @@ -42,23 +42,23 @@ public class Template extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length != 2) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); + BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); return false; } final World world = Bukkit.getWorld(args[1]); final PlotWorld plotworld = PlotSquared.getPlotWorld(args[1]); if ((world == null) || (plotworld == null)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); return false; } switch (args[0].toLowerCase()) { case "import": { // TODO import template - PlayerFunctions.sendMessage(plr, "TODO"); + BukkitPlayerFunctions.sendMessage(plr, "TODO"); return true; } case "export": { - PlayerFunctions.sendMessage(plr, "TODO"); + BukkitPlayerFunctions.sendMessage(plr, "TODO"); } } // TODO allow world settings (including schematics to be packed into a single file) 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 5bb545090..d665c91f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Trim extends SubCommand { public static boolean TASK = false; @@ -63,35 +63,35 @@ public class Trim extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (plr != null) { - PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); + BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; } if (args.length == 1) { final String arg = args[0].toLowerCase(); final PlotId id = getId(arg); if (id != null) { - PlayerFunctions.sendMessage(plr, "/plot trim x;z &l"); + BukkitPlayerFunctions.sendMessage(plr, "/plot trim x;z &l"); return false; } if (arg.equals("all")) { - PlayerFunctions.sendMessage(plr, "/plot trim all &l"); + BukkitPlayerFunctions.sendMessage(plr, "/plot trim all &l"); return false; } - PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); return false; } if (args.length != 2) { - PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); return false; } final String arg = args[0].toLowerCase(); if (!arg.equals("all")) { - PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); + BukkitPlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); return false; } final World world = Bukkit.getWorld(args[1]); if ((world == null) || (PlotSquared.getPlotWorld(world) == null)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD); + BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD); return false; } if (Trim.TASK) { 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 2258308dc..c91a0df17 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") @@ -42,20 +42,20 @@ public class Trusted extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 2) { - PlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); + BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; } - if (!PlayerFunctions.isInPlot(plr)) { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + if (!BukkitPlayerFunctions.isInPlot(plr)) { + BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.trusted")) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } if (args[0].equalsIgnoreCase("add")) { @@ -66,12 +66,12 @@ public class Trusted extends SubCommand { uuid = UUIDHandler.getUUID(args[1]); } if (uuid == null) { - PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!plot.trusted.contains(uuid)) { if (plot.owner.equals(uuid)) { - PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); + BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); return false; } if (plot.helpers.contains(uuid)) { @@ -87,21 +87,21 @@ public class Trusted extends SubCommand { final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { - PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); return false; } - PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { final UUID uuid = DBFunc.everyone; if (!plot.trusted.contains(uuid)) { - PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); + BukkitPlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); return true; } plot.removeTrusted(uuid); DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); - PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); @@ -109,9 +109,9 @@ public class Trusted extends SubCommand { DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); - PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); + BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); } else { - PlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); + BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; } return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java index 0412ee321..e36dc937b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * Created 2014-11-09 for PlotSquared @@ -19,12 +19,12 @@ public class Unban extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (args.length < 1) { - return PlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (!plot.hasRights(plr)) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 b11024293..ea0fe0d55 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Unclaim extends SubCommand { @@ -41,11 +41,11 @@ public class Unclaim extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { 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))) { + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !BukkitMain.hasPermission(plr, "plots.admin.command.unclaim")) { @@ -69,9 +69,9 @@ public class Unclaim extends SubCommand { DBFunc.delete(worldname, plot); // TODO set wall block } else { - PlayerFunctions.sendMessage(plr, "Plot removal has been denied."); + BukkitPlayerFunctions.sendMessage(plr, "Plot removal has been denied."); } - PlayerFunctions.sendMessage(plr, C.UNCLAIM_SUCCESS); + BukkitPlayerFunctions.sendMessage(plr, C.UNCLAIM_SUCCESS); return true; } } 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 0569a23ee..0f3159866 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -51,19 +51,19 @@ public class Unlink extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!PlayerFunctions.isInPlot(plr)) { + if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = PlayerFunctions.getCurrentPlot(plr); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.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))) { + if (BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_IMPOSSIBLE); } final World world = plr.getWorld(); if (!unlinkPlot(world, plot)) { - PlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled"); + BukkitPlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled"); return false; } try { @@ -76,14 +76,14 @@ public class Unlink extends SubCommand { ex.printStackTrace(); } } - PlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!"); + BukkitPlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!"); return true; } public static boolean unlinkPlot(final World world, final Plot plot) { - final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id; - final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id; - final ArrayList ids = PlayerFunctions.getPlotSelectionIds(pos1, pos2); + final PlotId pos1 = BukkitPlayerFunctions.getBottomPlot(world, plot).id; + final PlotId pos2 = BukkitPlayerFunctions.getTopPlot(world, plot).id; + final ArrayList ids = BukkitPlayerFunctions.getPlotSelectionIds(pos1, pos2); final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { 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 371d53149..33f56eb09 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 @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.util.bukkit.PWE; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class WE_Anywhere extends SubCommand { public WE_Anywhere() { @@ -35,15 +35,15 @@ public class WE_Anywhere extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { if (PlotSquared.worldEdit == null) { - PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); + BukkitPlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); return false; } if (BukkitMain.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { PWE.removeMask(plr); - PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask"); + BukkitPlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask"); } else { PWE.setMask(plr, plr.getLocation(), true); - PlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask"); + BukkitPlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask"); } return true; } 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 6e0c93330..a614872c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -65,7 +65,7 @@ public class list extends SubCommand { } else { builder.append(getArgumentList(new String[] { "all" })); } - PlayerFunctions.sendMessage(plr, builder.toString()); + BukkitPlayerFunctions.sendMessage(plr, builder.toString()); return true; } if (args[0].equalsIgnoreCase("forsale") && (plr != null)) { @@ -83,11 +83,11 @@ public class list extends SubCommand { } } if (idx == 0) { - PlayerFunctions.sendMessage(plr, C.NO_PLOTS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOTS); return true; } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "Includes").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots")); - PlayerFunctions.sendMessage(plr, string.toString()); + BukkitPlayerFunctions.sendMessage(plr, string.toString()); return true; } if (args[0].equalsIgnoreCase("mine") && (plr != null)) { @@ -99,11 +99,11 @@ public class list extends SubCommand { idx++; } if (idx == 0) { - PlayerFunctions.sendMessage(plr, C.NO_PLOTS); + BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOTS); return true; } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "You have").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots")); - PlayerFunctions.sendMessage(plr, string.toString()); + BukkitPlayerFunctions.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("shared") && (plr != null)) { final StringBuilder string = new StringBuilder(); @@ -114,7 +114,7 @@ public class list extends SubCommand { } } 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()); + BukkitPlayerFunctions.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("all")) { // Current page @@ -152,7 +152,7 @@ public class list extends SubCommand { 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%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots")); - PlayerFunctions.sendMessage(plr, string.toString()); + BukkitPlayerFunctions.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("world") && (plr != null)) { final StringBuilder string = new StringBuilder(); @@ -162,7 +162,7 @@ public class list extends SubCommand { 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 is").replaceAll("%num%", plots.values().size() + "").replaceAll("%plot%", plots.values().size() == 1 ? "plot" : "plots")); - PlayerFunctions.sendMessage(plr, string.toString()); + BukkitPlayerFunctions.sendMessage(plr, string.toString()); return true; } else { // execute(plr); 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 5a76e480c..2f3baee99 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.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class plugin extends SubCommand { public static String downloads, version; @@ -103,7 +103,7 @@ public class plugin extends SubCommand { } }; for (final String s : strings) { - PlayerFunctions.sendMessage(plr, s); + BukkitPlayerFunctions.sendMessage(plr, s); } } }); 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 aced4227a..a46acd270 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * A plot manager with a square grid layout, with square shaped plots @@ -109,38 +109,38 @@ public abstract class SquarePlotManager extends GridPlotManager { final boolean eastWest = (rx <= pathWidthLower) || (rx > end); 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 PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH)); final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; } if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) { - return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; } return null; } if (northSouth) { // 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 PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH)); final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; } if (plot.settings.getMerged(0)) { - return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; } return null; } 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 PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0)); final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; } if (plot.settings.getMerged(3)) { - return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; } return null; } @@ -149,7 +149,7 @@ public abstract class SquarePlotManager extends GridPlotManager { if (plot == null) { return id; } - return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index 9d3ac6d03..cf8e23d8e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -34,7 +34,7 @@ import org.bukkit.util.Vector; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -45,7 +45,7 @@ public class ForceFieldListener implements Listener { final Set players = new HashSet<>(); Player oPlayer; for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { - if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !PlayerFunctions.isInPlot(oPlayer) || !PlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { + if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !BukkitPlayerFunctions.isInPlot(oPlayer) || !BukkitPlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } UUID uuid = UUIDHandler.getUUID(oPlayer); @@ -59,7 +59,7 @@ public class ForceFieldListener implements Listener { private Player hasNearbyPermitted(final Player player, final Plot plot) { Player oPlayer; for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { - if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !PlayerFunctions.isInPlot(oPlayer) || !PlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { + if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !BukkitPlayerFunctions.isInPlot(oPlayer) || !BukkitPlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } UUID uuid = UUIDHandler.getUUID(oPlayer); @@ -96,10 +96,10 @@ public class ForceFieldListener implements Listener { @EventHandler public void onPlotEntry(final PlayerMoveEvent event) { final Player player = event.getPlayer(); - if (!PlayerFunctions.isInPlot(player)) { + if (!BukkitPlayerFunctions.isInPlot(player)) { return; } - final Plot plot = PlayerFunctions.getCurrentPlot(player); + final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) { if (!PlotListener.booleanFlag(plot, "forcefield", false)) { UUID uuid = UUIDHandler.getUUID(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index 33a6a1487..c44248d10 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -9,7 +9,7 @@ import org.bukkit.event.inventory.InventoryInteractEvent; import org.bukkit.inventory.Inventory; import com.intellectualcrafters.plot.object.InfoInventory; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * Created 2014-11-18 for PlotSquared @@ -36,7 +36,7 @@ public class InventoryListener implements Listener { case 4: case 5: case 6: - PlayerFunctions.sendMessage(player, "This is not implemented yet"); + BukkitPlayerFunctions.sendMessage(player, "This is not implemented yet"); break; default: break; 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 0dba37f39..0938277b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -102,7 +102,7 @@ import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -154,7 +154,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (Settings.TELEPORT_ON_LOGIN) { BukkitUtil.teleportPlayer(player, MainUtil.getPlotHomeDefault(plot)); - PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); + BukkitPlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); } plotEntry(player, plot); } @@ -187,7 +187,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi passed = false; } if (passed) { - PlayerFunctions.sendMessage(player, C.BORDER); + BukkitPlayerFunctions.sendMessage(player, C.BORDER); return; } } @@ -197,7 +197,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final UUID uuid = UUIDHandler.getUUID(player); if (plot.isDenied(uuid)) { if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; } @@ -263,7 +263,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.destroy.unowned")) { return; } - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned"); event.setCancelled(true); return; } @@ -277,7 +277,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { return; } - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other"); event.setCancelled(true); return; } @@ -287,7 +287,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road"); event.setCancelled(true); return; } @@ -344,7 +344,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (!isInPlot(loc)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; } @@ -352,7 +352,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } @@ -361,7 +361,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!plot.isAdded(uuid)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; } @@ -527,7 +527,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.interact.unowned")) { return; } - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned"); event.setCancelled(true); return; } @@ -540,7 +540,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { return; } - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other"); event.setCancelled(true); return; } @@ -550,7 +550,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road"); event.setCancelled(true); return; } @@ -634,7 +634,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = e.getPlayer(); if (!isInPlot(loc)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } @@ -642,7 +642,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } @@ -650,7 +650,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi UUID uuid = UUIDHandler.getUUID(p); if (!plot.isAdded(uuid)) if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -669,7 +669,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(q); if (plot.isDenied(event.getPlayer())) { - PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED); + BukkitPlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED); event.setCancelled(true); return; } else { @@ -701,7 +701,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(p, "plots.admin.build.road")) { return; } - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } else { @@ -710,7 +710,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { return; } - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } else if (!plot.isAdded(e.getPlayer())) { @@ -722,7 +722,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -766,7 +766,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(p, "plots.admin.build.road")) { return; } - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } else { @@ -775,7 +775,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { return; } - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } else if (!plot.isAdded(e.getPlayer())) { @@ -788,7 +788,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -805,7 +805,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = e.getPlayer(); if (!isInPlot(loc)) { if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } @@ -813,7 +813,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } @@ -823,7 +823,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -842,7 +842,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(l)) { if (!isInPlot(l)) { if (!BukkitMain.hasPermission(p, "plots.admin.destroy.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.road"); e.setCancelled(true); return; } @@ -850,7 +850,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.destroy.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); e.setCancelled(true); return; } @@ -860,7 +860,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(p, "plots.admin.destroy.other")) { if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.other"); e.setCancelled(true); return; } @@ -878,7 +878,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = e.getPlayer(); if (!isInPlot(l)) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); return; } @@ -886,7 +886,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); return; } @@ -906,7 +906,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); return; } @@ -926,7 +926,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final PlotWorld pW = getPlotWorld(l.getWorld()); if (!isInPlot(l)) { if (!BukkitMain.hasPermission(p, "plots.admin.vehicle.break.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); e.setCancelled(true); return; } @@ -934,7 +934,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.vehicle.break.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); e.setCancelled(true); return; } @@ -946,7 +946,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(p, "plots.admin.vehicle.break.other")) { if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); e.setCancelled(true); return; } @@ -981,7 +981,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!isInPlot(l)) { if (!BukkitMain.hasPermission(p, "plots.admin.pve.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.road"); e.setCancelled(true); return; } @@ -989,7 +989,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.pve.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.unowned"); e.setCancelled(true); return; } @@ -1013,7 +1013,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(p, "plots.admin.pve.other")) { if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.other"); e.setCancelled(true); return; } @@ -1034,7 +1034,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = e.getPlayer(); if (!isInPlot(l)) { if (!BukkitMain.hasPermission(p, "plots.admin.projectile.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.road"); e.setHatching(false); return; } @@ -1042,14 +1042,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.projectile.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.unowned"); e.setHatching(false); return; } } else if (!plot.isAdded(p)) { if (!BukkitMain.hasPermission(p, "plots.admin.projectile.other")) { if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); e.setHatching(false); return; } @@ -1077,7 +1077,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.build.unowned")) { return; } - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } @@ -1088,7 +1088,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!BukkitMain.hasPermission(player, "plots.admin.build.other")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; } @@ -1097,7 +1097,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) { if (isPlotArea(loc)) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; } 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 d1d642b60..5f7c23ff0 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 @@ -14,7 +14,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents_1_8 extends PlotListener implements Listener { @@ -25,14 +25,14 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { final Player p = e.getPlayer(); if (!isInPlot(l)) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); } } else { final Plot plot = MainUtil.getPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); } } else { @@ -40,7 +40,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { if (!plot.isAdded(uuid)) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); + BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); } } 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 183ff5d6e..0ff8ee142 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -54,7 +54,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -108,12 +108,12 @@ public class PlotPlusListener extends PlotListener implements Listener { event.setCancelled(true); final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { - PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); return; } UUID uuid = UUIDHandler.getUUID(player); if (!plot.isAdded(uuid)) { - PlayerFunctions.sendMessage(player, C.NO_PLOT_PERMS); + BukkitPlayerFunctions.sendMessage(player, C.NO_PLOT_PERMS); return; } final Set plotPlayers = new HashSet<>(); @@ -135,7 +135,7 @@ public class PlotPlusListener extends PlotListener implements Listener { } for (final Player p : plotPlayers) { p.playEffect(p.getLocation(), Effect.RECORD_PLAY, meta.getMaterial()); - PlayerFunctions.sendMessage(p, C.RECORD_PLAY.s().replaceAll("%player", player.getName()).replaceAll("%name", meta.toString())); + BukkitPlayerFunctions.sendMessage(p, C.RECORD_PLAY.s().replaceAll("%player", player.getName()).replaceAll("%name", meta.toString())); } } @@ -215,7 +215,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } if (player.isOnline()) { - PlayerFunctions.sendMessage(player, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + BukkitPlayerFunctions.sendMessage(player, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } } @@ -258,7 +258,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } if (player.isOnline()) { - PlayerFunctions.sendMessage(player, C.NOTIFY_LEAVE.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + BukkitPlayerFunctions.sendMessage(player, C.NOTIFY_LEAVE.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } } 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 a9e85a832..ba8da2423 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -50,7 +50,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.LocalSession; @@ -149,16 +149,16 @@ public class WorldEditListener implements Listener { 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"); + BukkitPlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Both points"); return; } if (!mask.test(pos1)) { e.setCancelled(true); - PlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Position 1"); + BukkitPlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Position 1"); } if (!mask.test(pos2)) { e.setCancelled(true); - PlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Position 2"); + BukkitPlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Position 2"); } } } 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 b313f4d8d..33731488c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -25,7 +25,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 e7794a636..974a58b0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -23,7 +23,7 @@ import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ExpireManager { 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 d08a764f5..344a28fd0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SendChunk; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java new file mode 100644 index 000000000..b59e39b85 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -0,0 +1,191 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// 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.util.bukkit; + +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.BukkitPlayer; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; + +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.bukkit.util.ChatPaginator; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * Functions involving players, plots and locations. + */ +public class BukkitPlayerFunctions { + /** + * Clear a plot. Use null player if no player is present + * @param player + * @param world + * @param plot + * @param isDelete + */ + public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { + final long start = System.currentTimeMillis(); + Runnable whenDone = new Runnable() { + @Override + public void run() { + if ((player != null) && player.isOnline()) { + MainUtil.sendMessage(new BukkitPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); + } + } + }; + if (!MainUtil.clearAsPlayer(plot, isDelete, whenDone)) { + MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); + } + } + + /** + * Merges all plots in the arraylist (with cost) + * + * @param plr + * @param world + * @param plotIds + * + * @return + */ + public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) { + final double cost = plotIds.size() * plotworld.MERGE_PRICE; + if (cost > 0d) { + final Economy economy = PlotSquared.economy; + if (economy.getBalance(plr) < cost) { + MainUtil.sendMessage(new BukkitPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); + return false; + } + economy.withdrawPlayer(plr, cost); + MainUtil.sendMessage(new BukkitPlayer(plr), C.REMOVED_BALANCE, cost + ""); + } + } + return MainUtil.mergePlots(world, plotIds, true); + } + + public static String getPlayerName(final UUID uuid) { + if (uuid == null) { + return "unknown"; + } + final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); + if (!plr.hasPlayedBefore()) { + return "unknown"; + } + return plr.getName(); + } + + /** + * @param player player + * + * @return + */ + public static boolean isInPlot(final Player player) { + return getCurrentPlot(player) != null; + } + + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { + final Plot plot1 = PlotSquared.getPlots(world).get(pos1); + final Plot plot2 = PlotSquared.getPlots(world).get(pos2); + if (plot1 != null) { + pos1 = MainUtil.getBottomPlot(plot1).id; + } + if (plot2 != null) { + pos2 = MainUtil.getTopPlot(world, plot2).id; + } + final ArrayList myplots = new ArrayList<>(); + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + myplots.add(new PlotId(x, y)); + } + } + return myplots; + } + + /** + * Returns the plot a player is currently in. + * + * @param player + * + * @return + */ + public static Plot getCurrentPlot(final Player player) { + if (!PlotSquared.isPlotWorld(player.getWorld().getName())) { + return null; + } + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(player)); + final String world = player.getWorld().getName(); + if (id == null) { + return null; + } + if (PlotSquared.getPlots(world).containsKey(id)) { + return PlotSquared.getPlots(world).get(id); + } + return new Plot(id, null, new ArrayList(), new ArrayList(), world); + } + + /** + * Get the plots for a player + * + * @param plr + * + * @return + */ + public static Set getPlayerPlots(final String world, final Player plr) { + final Set p = PlotSquared.getPlots(world, plr.getName()); + if (p == null) { + return new HashSet<>(); + } + return p; + } + + /** + * Get the number of plots for a player + * + * @param plr + * + * @return + */ + public static int getPlayerPlotCount(final String world, final Player plr) { + final UUID uuid = UUIDHandler.getUUID(plr); + int count = 0; + for (final Plot plot : PlotSquared.getPlots(world).values()) { + if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { + count++; + } + } + return count; + } +} From 081da3502434c700df1cf061b3696a9c2454f6d4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 22:25:01 +1100 Subject: [PATCH 050/124] . --- .../plot/util/bukkit/PlayerFunctions.java | 191 ------------------ 1 file changed, 191 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java deleted file mode 100644 index a5e7b82e4..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PlayerFunctions.java +++ /dev/null @@ -1,191 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.util.bukkit; - -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.BukkitPlayer; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; - -import net.milkbowl.vault.economy.Economy; - -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.ChatPaginator; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -/** - * Functions involving players, plots and locations. - */ -public class PlayerFunctions { - /** - * Clear a plot. Use null player if no player is present - * @param player - * @param world - * @param plot - * @param isDelete - */ - public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { - final long start = System.currentTimeMillis(); - Runnable whenDone = new Runnable() { - @Override - public void run() { - if ((player != null) && player.isOnline()) { - MainUtil.sendMessage(new BukkitPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); - } - } - }; - if (!MainUtil.clearAsPlayer(plot, isDelete, whenDone)) { - MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); - } - } - - /** - * Merges all plots in the arraylist (with cost) - * - * @param plr - * @param world - * @param plotIds - * - * @return - */ - public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) { - final double cost = plotIds.size() * plotworld.MERGE_PRICE; - if (cost > 0d) { - final Economy economy = PlotSquared.economy; - if (economy.getBalance(plr) < cost) { - MainUtil.sendMessage(new BukkitPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); - return false; - } - economy.withdrawPlayer(plr, cost); - MainUtil.sendMessage(new BukkitPlayer(plr), C.REMOVED_BALANCE, cost + ""); - } - } - return MainUtil.mergePlots(world, plotIds, true); - } - - public static String getPlayerName(final UUID uuid) { - if (uuid == null) { - return "unknown"; - } - final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if (!plr.hasPlayedBefore()) { - return "unknown"; - } - return plr.getName(); - } - - /** - * @param player player - * - * @return - */ - public static boolean isInPlot(final Player player) { - return getCurrentPlot(player) != null; - } - - public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { - final Plot plot1 = PlotSquared.getPlots(world).get(pos1); - final Plot plot2 = PlotSquared.getPlots(world).get(pos2); - if (plot1 != null) { - pos1 = MainUtil.getBottomPlot(plot1).id; - } - if (plot2 != null) { - pos2 = MainUtil.getTopPlot(world, plot2).id; - } - final ArrayList myplots = new ArrayList<>(); - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - myplots.add(new PlotId(x, y)); - } - } - return myplots; - } - - /** - * Returns the plot a player is currently in. - * - * @param player - * - * @return - */ - public static Plot getCurrentPlot(final Player player) { - if (!PlotSquared.isPlotWorld(player.getWorld().getName())) { - return null; - } - final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(player)); - final String world = player.getWorld().getName(); - if (id == null) { - return null; - } - if (PlotSquared.getPlots(world).containsKey(id)) { - return PlotSquared.getPlots(world).get(id); - } - return new Plot(id, null, new ArrayList(), new ArrayList(), world); - } - - /** - * Get the plots for a player - * - * @param plr - * - * @return - */ - public static Set getPlayerPlots(final String world, final Player plr) { - final Set p = PlotSquared.getPlots(world, plr.getName()); - if (p == null) { - return new HashSet<>(); - } - return p; - } - - /** - * Get the number of plots for a player - * - * @param plr - * - * @return - */ - public static int getPlayerPlotCount(final String world, final Player plr) { - final UUID uuid = UUIDHandler.getUUID(plr); - int count = 0; - for (final Plot plot : PlotSquared.getPlots(world).values()) { - if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { - count++; - } - } - return count; - } -} From 4aeb5f459f317676bbe64a023951e420a1267515 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 22:37:34 +1100 Subject: [PATCH 051/124] more stuff --- .../intellectualcrafters/plot/BukkitMain.java | 5 +- .../plot/generator/SquarePlotManager.java | 67 ++++++++++--------- .../util/bukkit/BukkitPlayerFunctions.java | 13 ++++ 3 files changed, 51 insertions(+), 34 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 9a218daab..e93ae098f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.listeners.*; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -19,7 +20,9 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.*; import com.sk89q.worldedit.bukkit.WorldEditPlugin; + import net.milkbowl.vault.economy.Economy; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -76,7 +79,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (Settings.USE_PLOTME_ALIAS) { player.performCommand(message.replace("/plotme", "plots")); } else { - BukkitPlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME); + MainUtil.sendMessage(new BukkitPlayer(player), C.NOT_USING_PLOTME); } event.setCancelled(true); } 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 a46acd270..610fbcf67 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -1,28 +1,29 @@ package com.intellectualcrafters.plot.generator; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.MainUtil; /** * A plot manager with a square grid layout, with square shaped plots */ public abstract class SquarePlotManager extends GridPlotManager { @Override - public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whendone) { - final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); - ChunkManager.regenerateRegion(pos1, pos2, whendone); + public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { + final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); + AChunkManager.manager.regenerateRegion(pos1, pos2, whenDone); return true; } @@ -33,15 +34,12 @@ public abstract class SquarePlotManager extends GridPlotManager { final int pz = plotid.y; final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; - return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z); + return new Location(plotworld.worldname, x, 256, z); } @Override - public PlotId getPlotIdAbs(final PlotWorld plotworld, final Location loc) { + public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, int y, int z) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); - // get x,z loc - int x = loc.getBlockX(); - int z = loc.getBlockZ(); // get plot size final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; // get size of path on bottom part, and top part of plot @@ -78,10 +76,8 @@ public abstract class SquarePlotManager extends GridPlotManager { } @Override - public PlotId getPlotId(final PlotWorld plotworld, final Location loc) { + public PlotId getPlotId(final PlotWorld plotworld, int x, int y, int z) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); - int x = loc.getBlockX(); - int z = loc.getBlockZ(); if (plotworld == null) { return null; } @@ -109,47 +105,49 @@ public abstract class SquarePlotManager extends GridPlotManager { final boolean eastWest = (rx <= pathWidthLower) || (rx > end); if (northSouth && eastWest) { // This means you are in the intersection - final PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH)); - final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); + Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z + dpw.ROAD_WIDTH); + final PlotId id = MainUtil.getPlotAbs(loc); + final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id); if (plot == null) { return null; } if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) { - return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return MainUtil.getBottomPlot(plot).id; } return null; } if (northSouth) { - // You are on a road running West to East (yeah, I named the var - // poorly) - final PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH)); - final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); + // You are on a road running West to East (yeah, I named the var poorly) + Location loc = new Location(plotworld.worldname, x, y, z + dpw.ROAD_WIDTH); + final PlotId id = MainUtil.getPlotAbs(loc); + final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id); if (plot == null) { return null; } if (plot.settings.getMerged(0)) { - return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return MainUtil.getBottomPlot(plot).id; } return null; } if (eastWest) { // This is the road separating an Eastern and Western plot - final PlotId id = BukkitPlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0)); - final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); + Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z); + final PlotId id = MainUtil.getPlotAbs(loc); + final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id); if (plot == null) { return null; } if (plot.settings.getMerged(3)) { - return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return MainUtil.getBottomPlot(plot).id; } return null; } final PlotId id = new PlotId(dx + 1, dz + 1); - final Plot plot = PlotSquared.getPlots(loc.getWorld()).get(id); + final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id); if (plot == null) { return id; } - return BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot).id; + return MainUtil.getBottomPlot(plot).id; } /** @@ -162,20 +160,23 @@ public abstract class SquarePlotManager extends GridPlotManager { final int pz = plotid.y; final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; - return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z); + return new Location(plotworld.worldname, x, 1, z); } /** * Set a plot biome */ @Override - public boolean setBiome(final World world, final Plot plot, final Biome biome) { - final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getBlockX() - 1; - final int topX = MainUtil.getPlotTopLoc(world, plot.id).getBlockX() + 1; - final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getBlockZ() - 1; - final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getBlockZ() + 1; + public boolean setBiome(final String world, final Plot plot, final Biome biome) { + final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getX() - 1; + final int topX = MainUtil.getPlotTopLoc(world, plot.id).getX() + 1; + final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getZ() - 1; + final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getZ() + 1; final Block block = world.getBlockAt(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 1, 1)); final Biome current = block.getBiome(); + + + if (biome.equals(current)) { return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index b59e39b85..c18c41b31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -48,6 +48,19 @@ import java.util.UUID; * Functions involving players, plots and locations. */ public class BukkitPlayerFunctions { + + /* + * =========== NOTICE ================ + * - We will try to move as many functions as we can out of this class and into the MainUtil class + */ + + + + + + + + /** * Clear a plot. Use null player if no player is present * @param player From c5260471c5321c715b7dc327a5437d03beef432d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 03:17:34 +1100 Subject: [PATCH 052/124] pm --- .../plot/generator/ClassicPlotManager.java | 183 ++++++++++-------- .../plot/generator/SquarePlotManager.java | 42 ++-- .../plot/object/PlotManager.java | 2 +- .../plot/util/BlockManager.java | 6 + .../plot/util/bukkit/BukkitUtil.java | 9 + 5 files changed, 137 insertions(+), 105 deletions(-) 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 9aa9bd496..54ef71500 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -2,14 +2,12 @@ package com.intellectualcrafters.plot.generator; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; - +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; /** @@ -17,33 +15,97 @@ import com.intellectualcrafters.plot.util.MainUtil; */ public abstract class ClassicPlotManager extends SquarePlotManager { @Override - public boolean setComponent(final World world, final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) { + public boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) { switch (component) { case "floor": { - setFloor(world, plotworld, plotid, blocks); + setFloor(plotworld, plotid, blocks); return true; } case "wall": { - setWallFilling(world, plotworld, plotid, blocks); + setWallFilling(plotworld, plotid, blocks); return true; } case "border": { - setWall(world, plotworld, plotid, blocks); + setWall(plotworld, plotid, blocks); return true; } } return false; } - public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { + public boolean setFloor(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); - final Location pos2 = MainUtil.getPlotTopLoc(world, plotid); - MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks); + final Location pos2 = MainUtil.getPlotTopLoc(plotworld.worldname, plotid); + int size = (pos2.getX() - pos1.getX() + 1) * (pos2.getZ() - pos1.getZ() + 1); + + pos1.setY(dpw.PLOT_HEIGHT); + pos2.setY(dpw.PLOT_HEIGHT + 1); + + MainUtil.setCuboid(plotworld.worldname, pos1, pos2, blocks); return true; } - public boolean setWallFilling(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { + public boolean setWallFilling(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { + final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; + if (dpw.ROAD_WIDTH == 0) { + return false; + } + final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); + final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid); + int x, z; + z = bottom.getZ(); + int length = top.getX() - bottom.getX(); + int size = (length) * 4 * (dpw.WALL_HEIGHT - 1); + final int[] xl = new int[size]; + final int[] yl = new int[size]; + final int[] zl = new int[size]; + final PlotBlock[] bl = new PlotBlock[size]; + int i = 0; + for (x = bottom.getX(); x < (top.getX() + 1); x++) { + for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; + } + } + x = top.getX() + 1; + for (z = bottom.getZ(); z < (top.getZ() + 1); z++) { + for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; + } + } + z = top.getZ() + 1; + for (x = top.getX() + 1; x > (bottom.getX() - 1); x--) { + for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; + } + } + x = bottom.getX(); + for (z = top.getZ() + 1; z > (bottom.getZ() - 1); z--) { + for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; + } + } + BlockManager.setBlocks(plotworld.worldname, x, y, z, blocks); + return true; + } + + public boolean setWall(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; if (dpw.ROAD_WIDTH == 0) { return false; @@ -51,55 +113,20 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); final Location top = MainUtil.getPlotTopLoc(w, plotid); int x, z; - z = bottom.getBlockZ(); - for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) { - for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - MainUtil.setBlock(w, x, y, z, blocks); - } - } - x = top.getBlockX() + 1; - for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) { - for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - MainUtil.setBlock(w, x, y, z, blocks); - } - } - z = top.getBlockZ() + 1; - for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) { - for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - MainUtil.setBlock(w, x, y, z, blocks); - } - } - x = bottom.getBlockX(); - for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) { - for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { - MainUtil.setBlock(w, x, y, z, blocks); - } - } - return true; - } - - public boolean setWall(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { - final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - if (dpw.ROAD_WIDTH == 0) { - return false; - } - final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); - final Location top = MainUtil.getPlotTopLoc(w, plotid); - int x, z; - z = bottom.getBlockZ(); - for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) { + z = bottom.getZ(); + for (x = bottom.getX(); x < (top.getX() + 1); x++) { MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } - x = top.getBlockX() + 1; - for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) { + x = top.getX() + 1; + for (z = bottom.getZ(); z < (top.getZ() + 1); z++) { MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } - z = top.getBlockZ() + 1; - for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) { + z = top.getZ() + 1; + for (x = top.getX() + 1; x > (bottom.getX() - 1); x--) { MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } - x = bottom.getBlockX(); - for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) { + x = bottom.getX(); + for (z = top.getZ() + 1; z > (bottom.getZ() - 1); z--) { MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); } return true; @@ -114,10 +141,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sx = pos2.getBlockX() + 1; + final int sx = pos2.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; - final int sz = pos1.getBlockZ() - 1; - final int ez = pos2.getBlockZ() + 2; + final int sz = pos1.getZ() - 1; + final int ez = pos2.getZ() + 2; MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0)); MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0)); MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); @@ -134,10 +161,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sz = pos2.getBlockZ() + 1; + final int sz = pos2.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - final int sx = pos1.getBlockX() - 1; - final int ex = pos2.getBlockX() + 2; + final int sx = pos1.getX() - 1; + final int ex = pos2.getX() + 2; MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0)); MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); @@ -153,9 +180,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World w = Bukkit.getWorld(plot.world); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sx = pos2.getBlockX() + 1; + final int sx = pos2.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; - final int sz = pos2.getBlockZ() + 1; + final int sz = pos2.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; MainUtil.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0)); @@ -169,10 +196,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sx = pos2.getBlockX() + 1; + final int sx = pos2.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; - final int sz = pos1.getBlockZ(); - final int ez = pos2.getBlockZ() + 1; + final int sz = pos1.getZ(); + final int ez = pos2.getZ() + 1; MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); @@ -185,10 +212,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); - final int sz = pos2.getBlockZ() + 1; + final int sz = pos2.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - final int sx = pos1.getBlockX(); - final int ex = pos2.getBlockX() + 1; + final int sx = pos1.getX(); + final int ex = pos2.getX() + 1; MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); @@ -200,9 +227,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final World world = Bukkit.getWorld(plot.world); final Location loc = getPlotTopLocAbs(dpw, plot.id); - final int sx = loc.getBlockX() + 1; + final int sx = loc.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; - final int sz = loc.getBlockZ() + 1; + final int sz = loc.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; MainUtil.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); MainUtil.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); @@ -214,7 +241,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { * Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED) */ @Override - public boolean finishPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds) { + public boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList plotIds) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final PlotId pos1 = plotIds.get(0); final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; @@ -225,7 +252,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } @Override - public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds) { + public boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds) { final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; for (final PlotId id : plotIds) { @@ -237,17 +264,17 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } @Override - public boolean startPlotMerge(final World world, final PlotWorld plotworld, final ArrayList plotIds) { + public boolean startPlotMerge(final PlotWorld plotworld, final ArrayList plotIds) { return true; } @Override - public boolean startPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds) { + public boolean startPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds) { return true; } @Override - public boolean claimPlot(final World world, final PlotWorld plotworld, final Plot plot) { + public boolean claimPlot(final PlotWorld plotworld, final Plot plot) { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; if (claim.equals(unclaim)) { @@ -257,7 +284,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } @Override - public boolean unclaimPlot(final World world, final PlotWorld plotworld, final Plot plot) { + public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot) { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; if (claim != unclaim) { @@ -278,6 +305,6 @@ public abstract class ClassicPlotManager extends SquarePlotManager { public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location bot = MainUtil.getPlotBottomLoc(plotworld.worldname, plot.id); - return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getBlockX(), dpw.ROAD_HEIGHT + 1, bot.getBlockZ() - 1); + return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getX(), dpw.ROAD_HEIGHT + 1, bot.getZ() - 1); } } 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 610fbcf67..87b838295 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -1,19 +1,14 @@ package com.intellectualcrafters.plot.generator; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.MainUtil; /** * A plot manager with a square grid layout, with square shaped plots @@ -167,30 +162,25 @@ public abstract class SquarePlotManager extends GridPlotManager { * Set a plot biome */ @Override - public boolean setBiome(final String world, final Plot plot, final Biome biome) { - final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getX() - 1; - final int topX = MainUtil.getPlotTopLoc(world, plot.id).getX() + 1; - final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getZ() - 1; - final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getZ() + 1; - final Block block = world.getBlockAt(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 1, 1)); - final Biome current = block.getBiome(); - - - - if (biome.equals(current)) { - return false; - } + public boolean setBiome(final Plot plot, final int biome) { + final int bottomX = MainUtil.getPlotBottomLoc(plot.world, plot.id).getX() - 1; + final int topX = MainUtil.getPlotTopLoc(plot.world, plot.id).getX() + 1; + final int bottomZ = MainUtil.getPlotBottomLoc(plot.world, plot.id).getZ() - 1; + final int topZ = MainUtil.getPlotTopLoc(plot.world, plot.id).getZ() + 1; + int size = (topX - bottomX + 1) * (topZ - bottomZ + 1); + int[] xb = new int[size]; + int[] zb = new int[size]; + int[] biomes = new int[size]; + int index = 0; for (int x = bottomX; x <= topX; x++) { for (int z = bottomZ; z <= topZ; z++) { - final Block blk = world.getBlockAt(x, 0, z); - final Biome c = blk.getBiome(); - if (c.equals(biome)) { - x += 15; - continue; - } - blk.setBiome(biome); + xb[index] = x; + zb[index] = z; + biomes[index] = biome; + index++; } } + BlockManager.setBiomes(plot.world, xb, zb, biomes); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index b2a18c279..17667fe95 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -58,7 +58,7 @@ public abstract class PlotManager { public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks); - public abstract boolean setBiome(final Plot plot, final Biome biome); + public abstract boolean setBiome(final Plot plot, final int biome); /* * PLOT MERGING (return false if your generator does not support plot diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 0bb395119..48066c706 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -32,6 +32,12 @@ public abstract class BlockManager { public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines); + public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final int[] biome); + + public static void setBiomes(final String worldname, final int[] x, final int z[], final int[] biome) { + manager.functionSetBiomes(worldname, x, z, biome); + } + public static void setBlocks(final String worldname, final int[] x, final int y[], final int z[], final PlotBlock[][] blocks) { final int[] id = new int[blocks.length]; final byte[] data = new byte[blocks.length]; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 6190060b6..27bb49b19 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -152,4 +152,13 @@ public class BukkitUtil extends BlockManager { public static int getViewDistance() { return Bukkit.getViewDistance(); } + + @Override + public void functionSetBiomes(String worldname, int[] x, int[] z, int[] biome) { + World world = getWorld(worldname); + Biome[] biomes = Biome.values(); + for (int i = 0; i < x.length; i++) { + world.setBiome(x[i], z[i], biomes[biome[i]]); + } + } } From 41a7ff1a3229cca411444f94613dc6904fc574ca Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 12:19:19 +1100 Subject: [PATCH 053/124] cpm --- .../plot/generator/ClassicPlotManager.java | 108 ++++++++++-------- 1 file changed, 62 insertions(+), 46 deletions(-) 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 54ef71500..e33986100 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -37,11 +37,8 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(plotworld.worldname, plotid); - int size = (pos2.getX() - pos1.getX() + 1) * (pos2.getZ() - pos1.getZ() + 1); - pos1.setY(dpw.PLOT_HEIGHT); pos2.setY(dpw.PLOT_HEIGHT + 1); - MainUtil.setCuboid(plotworld.worldname, pos1, pos2, blocks); return true; } @@ -56,7 +53,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { int x, z; z = bottom.getZ(); int length = top.getX() - bottom.getX(); - int size = (length) * 4 * (dpw.WALL_HEIGHT - 1); + int size = (length) * 4 * (dpw.WALL_HEIGHT); final int[] xl = new int[size]; final int[] yl = new int[size]; final int[] zl = new int[size]; @@ -101,7 +98,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { i++; } } - BlockManager.setBlocks(plotworld.worldname, x, y, z, blocks); + BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, blocks); return true; } @@ -111,24 +108,49 @@ public abstract class ClassicPlotManager extends SquarePlotManager { return false; } final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); - final Location top = MainUtil.getPlotTopLoc(w, plotid); + final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid); + int length = top.getX() - bottom.getX(); + int size = (length) * 4; + final int[] xl = new int[size]; + final int[] yl = new int[size]; + final int[] zl = new int[size]; + final PlotBlock[] bl = new PlotBlock[size]; int x, z; z = bottom.getZ(); + int i = 0; + int y = dpw.WALL_HEIGHT + 1; for (x = bottom.getX(); x < (top.getX() + 1); x++) { - MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; } x = top.getX() + 1; for (z = bottom.getZ(); z < (top.getZ() + 1); z++) { - MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; } z = top.getZ() + 1; for (x = top.getX() + 1; x > (bottom.getX() - 1); x--) { - MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; } x = bottom.getX(); for (z = top.getZ() + 1; z > (bottom.getZ() - 1); z--) { - MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks); + xl[i] = x; + zl[i] = z; + yl[i] = y; + bl[i] = blocks[BlockManager.random(blocks.length)]; + i++; } + BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, blocks); return true; } @@ -138,102 +160,96 @@ public abstract class ClassicPlotManager extends SquarePlotManager { @Override public boolean createRoadEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final int sx = pos2.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos1.getZ() - 1; final int ez = pos2.getZ() + 2; - MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); - MainUtil.setCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - MainUtil.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); - MainUtil.setCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, ex, 1, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @Override public boolean createRoadSouth(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final int sz = pos2.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int sx = pos1.getX() - 1; final int ex = pos2.getX() + 2; - MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); - MainUtil.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); - MainUtil.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING); - MainUtil.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK); - MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), new Location(plotworld.worldname, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, ez), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @Override public boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final World w = Bukkit.getWorld(plot.world); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final int sx = pos2.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos2.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - MainUtil.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), new Location(plotworld.worldname, ex, 1, ez), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @Override public boolean removeRoadEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final int sx = pos2.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = pos1.getZ(); final int ez = pos2.getZ() + 1; - MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); - MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); + MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } @Override public boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final World w = Bukkit.getWorld(plot.world); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final int sz = pos2.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int sx = pos1.getX(); final int ex = pos2.getX() + 1; - MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); - MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); + MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } @Override public boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; - final World world = Bukkit.getWorld(plot.world); final Location loc = getPlotTopLocAbs(dpw, plot.id); final int sx = loc.getX() + 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int sz = loc.getZ() + 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1; - MainUtil.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - MainUtil.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); - MainUtil.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(plotworld.worldname, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); + MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); return true; } @@ -246,7 +262,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final PlotId pos1 = plotIds.get(0); final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; if (block.id != 0) { - setWall(world, plotworld, pos1, new PlotBlock[] { ((ClassicPlotWorld) plotworld).WALL_BLOCK }); + setWall(plotworld, pos1, new PlotBlock[] { ((ClassicPlotWorld) plotworld).WALL_BLOCK }); } return true; } @@ -257,7 +273,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; for (final PlotId id : plotIds) { if (block.equals(unclaim)) { - setWall(world, plotworld, id, new PlotBlock[] { block }); + setWall(plotworld, id, new PlotBlock[] { block }); } } return true; @@ -278,7 +294,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; if (claim.equals(unclaim)) { - setWall(world, plotworld, plot.id, new PlotBlock[] { claim }); + setWall(plotworld, plot.id, new PlotBlock[] { claim }); } return true; } @@ -288,7 +304,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; if (claim != unclaim) { - setWall(world, plotworld, plot.id, new PlotBlock[] { unclaim }); + setWall(plotworld, plot.id, new PlotBlock[] { unclaim }); } return true; } From fa5f6fd573241c3ae89978f6f401523de7253b48 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 12:59:28 +1100 Subject: [PATCH 054/124] hpm --- .../plot/generator/HybridPlotManager.java | 237 +++++++----------- .../plot/util/bukkit/PWE.java | 4 +- 2 files changed, 87 insertions(+), 154 deletions(-) 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 b101631f5..4b5aa26ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -26,7 +26,6 @@ import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.Chunk; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; @@ -36,6 +35,7 @@ import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; @@ -43,6 +43,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -53,35 +54,34 @@ public class HybridPlotManager extends ClassicPlotManager { private int task; public static boolean checkModified(final Plot plot, int requiredChanges) { - final World world = Bukkit.getWorld(plot.world); - final Location bottom = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location top = MainUtil.getPlotTopLoc(world, plot.id); - final int botx = bottom.getBlockX(); - final int botz = bottom.getBlockZ(); - final int topx = top.getBlockX(); - final int topz = top.getBlockZ(); - final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getPlotWorld(world); + final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); + final int botx = bottom.getX(); + final int botz = bottom.getZ(); + final int topx = top.getX(); + final int topz = top.getZ(); + final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getPlotWorld(plot.world); final PlotBlock[] air = new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) }; - int changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK); + int changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK); if (changes == -1) { return true; } requiredChanges -= changes; - changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT + 1, hpw.PLOT_HEIGHT + 1, botz, topz, air); + changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 1, hpw.PLOT_HEIGHT + 1, botz, topz, air); if (changes == -1) { return true; } requiredChanges -= changes; - changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT + 2, world.getMaxHeight() - 1, botz, topz, air); + changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 2, BukkitUtil.getMaxHeight(plot.world) - 1, botz, topz, air); if (changes == -1) { return true; } requiredChanges -= changes; - changes = checkModified(requiredChanges, world, botx, topx, 1, hpw.PLOT_HEIGHT - 1, botz, topz, hpw.MAIN_BLOCK); + changes = checkModified(requiredChanges, plot.world, botx, topx, 1, hpw.PLOT_HEIGHT - 1, botz, topz, hpw.MAIN_BLOCK); return changes == -1; } - public static int checkModified(final int threshhold, final World world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) { + public static int checkModified(final int threshhold, final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) { int count = 0; for (int y = y1; y <= y2; y++) { for (int x = x1; x <= x2; x++) { @@ -108,15 +108,15 @@ public class HybridPlotManager extends ClassicPlotManager { } public boolean setupRoadSchematic(final Plot plot) { - final World world = Bukkit.getWorld(plot.world); + final String world = plot.world; final Location bot = MainUtil.getPlotBottomLoc(world, plot.id); final Location top = MainUtil.getPlotTopLoc(world, plot.id); final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); - final int sx = (bot.getBlockX() - plotworld.ROAD_WIDTH) + 1; - final int sz = bot.getBlockZ() + 1; + final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1; + final int sz = bot.getZ() + 1; final int sy = plotworld.ROAD_HEIGHT; - final int ex = bot.getBlockX(); - final int ez = top.getBlockZ(); + final int ex = bot.getX(); + final int ez = top.getZ(); final int ey = get_ey(world, sx, ex, sz, ez, sy); final Location pos1 = new Location(world, sx, sy, sz); final Location pos2 = new Location(world, ex, ey, ez); @@ -145,7 +145,7 @@ public class HybridPlotManager extends ClassicPlotManager { for (int z = sz; z <= ez; z++) { for (int y = sy; y < maxY; y++) { if (y > ey) { - final Block block = world.getBlockAt(new Location(world, x, y, z)); + final Block block = world.getBlockAt(x, y, z); if (block.getTypeId() != 0) { ey = y; } @@ -297,13 +297,13 @@ public class HybridPlotManager extends ClassicPlotManager { } @Override - public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList plotIds) { + public boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds) { final HybridPlotWorld hpw = (HybridPlotWorld) plotworld; if (hpw.ROAD_SCHEMATIC_ENABLED) { for (final PlotId id : plotIds) { final Location bottom = getPlotBottomLocAbs(plotworld, id); - final int sx = bottom.getBlockX() - hpw.PATH_WIDTH_LOWER; - final int sz = bottom.getBlockZ() - hpw.PATH_WIDTH_LOWER; + final int sx = bottom.getX() - hpw.PATH_WIDTH_LOWER; + final int sz = bottom.getZ() - hpw.PATH_WIDTH_LOWER; final int sy = hpw.ROAD_HEIGHT; for (final ChunkLoc loc : hpw.G_SCH.keySet()) { final HashMap blocks = hpw.G_SCH.get(loc); @@ -347,7 +347,8 @@ public class HybridPlotManager extends ClassicPlotManager { * to have 512x512 sized plots */ @Override - public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { + public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { + final String world = plotworld.worldname; MainUtil.runners.put(plot, 1); final Plugin plugin = PlotSquared.getMain(); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @@ -369,34 +370,34 @@ public class HybridPlotManager extends ClassicPlotManager { wall = dpw.CLAIMED_WALL_BLOCK; } final PlotBlock wall_filling = dpw.WALL_FILLING; - final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, 1, pos1.getBlockZ())); + final Block block = world.getBlockAt(new Location(world, pos1.getX() - 1, 1, pos1.getZ())); if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) { setWallFilling(world, dpw, plot.id, new PlotBlock[] { wall_filling }); } Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, dpw.WALL_HEIGHT + 1, pos1.getBlockZ())); + final Block block = world.getBlockAt(new Location(world, pos1.getX() - 1, dpw.WALL_HEIGHT + 1, pos1.getZ())); if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) { setWall(world, dpw, plot.id, new PlotBlock[] { wall }); } Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - if ((pos2.getBlockX() - pos1.getBlockX()) < 48) { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + if ((pos2.getX() - pos1.getX()) < 48) { + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, world.getMaxHeight() + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); } }, 5L); } @@ -405,44 +406,44 @@ public class HybridPlotManager extends ClassicPlotManager { }, 5L); return; } - final int startX = (pos1.getBlockX() / 16) * 16; - final int startZ = (pos1.getBlockZ() / 16) * 16; - final int chunkX = 16 + pos2.getBlockX(); - final int chunkZ = 16 + pos2.getBlockZ(); + final int startX = (pos1.getX() / 16) * 16; + final int startZ = (pos1.getZ() / 16) * 16; + final int chunkX = 16 + pos2.getX(); + final int chunkZ = 16 + pos2.getZ(); final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id); final Location l2 = MainUtil.getPlotTopLoc(world, plot.id); - final int plotMinX = l1.getBlockX() + 1; - final int plotMinZ = l1.getBlockZ() + 1; - final int plotMaxX = l2.getBlockX(); - final int plotMaxZ = l2.getBlockZ(); + final int plotMinX = l1.getX() + 1; + final int plotMinZ = l1.getZ() + 1; + final int plotMaxX = l2.getX(); + final int plotMaxZ = l2.getZ(); Location mn = null; Location mx = null; for (int i = startX; i < chunkX; i += 16) { for (int j = startZ; j < chunkZ; j += 16) { - final Plot plot1 = MainUtil.getCurrentPlot(new Location(world, i, 0, j)); + final Plot plot1 = MainUtil.getPlot(new Location(world, i, 0, j)); if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) { break; } - final Plot plot2 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j)); + final Plot plot2 = MainUtil.getPlot(new Location(world, i + 15, 0, j)); if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) { break; } - final Plot plot3 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + final Plot plot3 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15)); if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) { break; } - final Plot plot4 = MainUtil.getCurrentPlot(new Location(world, i, 0, j + 15)); + final Plot plot4 = MainUtil.getPlot(new Location(world, i, 0, j + 15)); if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) { break; } - final Plot plot5 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + final Plot plot5 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15)); if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) { break; } if (mn == null) { mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ)); mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); - } else if ((mx.getBlockZ() < (j + 15)) || (mx.getBlockX() < (i + 15))) { + } else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) { mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); } world.regenerateChunk(i / 16, j / 16); @@ -451,19 +452,19 @@ public class HybridPlotManager extends ClassicPlotManager { final Location max = mx; final Location min = mn; if (min == null) { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, world.getMaxHeight() + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); } }, 5L); } @@ -472,34 +473,34 @@ public class HybridPlotManager extends ClassicPlotManager { }, 5L); return; } else { - if (min.getBlockX() < plotMinX) { + if (min.getX() < plotMinX) { min.setX(plotMinX); } - if (min.getBlockZ() < plotMinZ) { + if (min.getZ() < plotMinZ) { min.setZ(plotMinZ); } - if (max.getBlockX() > plotMaxX) { + if (max.getX() > plotMaxX) { max.setX(plotMaxX); } - if (max.getBlockZ() > plotMaxZ) { + if (max.getZ() > plotMaxZ) { max.setZ(plotMaxZ); } Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); } }, 1L); } @@ -511,19 +512,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); } }, 1L); } @@ -535,19 +536,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); } }, 1L); } @@ -559,19 +560,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); } }, 1L); } @@ -583,19 +584,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); } }, 1L); } @@ -607,19 +608,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboid(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); } }, 1L); } @@ -631,19 +632,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + MainUtil.setCuboid(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); } }, 1L); } @@ -655,19 +656,19 @@ public class HybridPlotManager extends ClassicPlotManager { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboid(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); TaskManager.runTask(whenDone); } }, 1L); @@ -684,70 +685,4 @@ public class HybridPlotManager extends ClassicPlotManager { }, 20L); return true; } - - @Override - public PlotId getPlotIdAbs(PlotWorld plotworld, int x, int y, int z) { - // TODO Auto-generated method stub - return null; - } - - @Override - public PlotId getPlotId(PlotWorld plotworld, int x, int y, int z) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean clearPlot(PlotWorld plotworld, Plot plot, boolean isDelete, Runnable whenDone) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean claimPlot(PlotWorld plotworld, Plot plot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean unclaimPlot(PlotWorld plotworld, Plot plot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean setComponent(PlotWorld plotworld, PlotId plotid, String component, PlotBlock[] blocks) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean setBiome(Plot plot, Biome biome) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean startPlotMerge(PlotWorld plotworld, ArrayList plotIds) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean startPlotUnlink(PlotWorld plotworld, ArrayList plotIds) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean finishPlotMerge(PlotWorld plotworld, ArrayList plotIds) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean finishPlotUnlink(PlotWorld plotworld, ArrayList plotIds) { - // TODO Auto-generated method stub - return false; - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index f3ba0dd30..a7fe97869 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -77,15 +77,13 @@ public class PWE { } } if (force ^ (noMask(s) && !p.hasPermission("plots.worldedit.bypass"))) { + // FIXME unchecked casting final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); 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) { e.printStackTrace(); - // throw new - // PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, - // "WorldEdit == Null?"); } } From 9ea4c8fe20eab309b6eddecae5e42a390c70399f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 13:49:25 +1100 Subject: [PATCH 055/124] hu --- .../plot/generator/HybridPlotManager.java | 244 ++++++------------ .../plot/generator/HybridUtils.java | 168 ++++++++++++ .../plot/util/BlockManager.java | 4 +- .../plot/util/MainUtil.java | 4 + .../plot/util/bukkit/BukkitUtil.java | 12 +- 5 files changed, 261 insertions(+), 171 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java 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 4b5aa26ad..dce6340fc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -24,13 +24,6 @@ import java.io.File; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.plugin.Plugin; - import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -40,6 +33,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; @@ -138,8 +132,7 @@ public class HybridPlotManager extends ClassicPlotManager { return true; } - public int get_ey(final World world, final int sx, final int ex, final int sz, final int ez, final int sy) { - final int maxY = world.getMaxHeight(); + public int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy) { int ey = sy; for (int x = sx; x <= ex; x++) { for (int z = sz; z <= ez; z++) { @@ -156,7 +149,7 @@ public class HybridPlotManager extends ClassicPlotManager { return ey; } - public void regenerateChunkChunk(final World world, final ChunkLoc loc) { + public void regenerateChunkChunk(final String world, final ChunkLoc loc) { final int sx = loc.x << 5; final int sz = loc.z << 5; for (int x = sx; x < (sx + 32); x++) { @@ -176,7 +169,7 @@ public class HybridPlotManager extends ClassicPlotManager { SetBlockManager.setBlockManager.update(chunks2); } - public boolean scheduleRoadUpdate(final World world) { + public boolean scheduleRoadUpdate(final String world) { if (HybridPlotManager.UPDATE) { return false; } @@ -209,93 +202,6 @@ public class HybridPlotManager extends ClassicPlotManager { return true; } - public boolean regenerateRoad(final Chunk chunk) { - final World world = chunk.getWorld(); - final int x = chunk.getX() << 4; - final int z = chunk.getZ() << 4; - final int ex = x + 15; - final int ez = z + 15; - final Location bot = new Location(world, x, 0, z); - final Location top = new Location(world, ex, 0, ez); - final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); - if (!plotworld.ROAD_SCHEMATIC_ENABLED) { - return false; - } - final PlotId id1 = getPlotId(plotworld, bot); - final PlotId id2 = getPlotId(plotworld, top); - boolean toCheck = false; - if ((id1 == null) || (id2 == null) || (id1 != id2)) { - final boolean result = chunk.load(false); - if (result) { - while (!chunk.isLoaded()) { - chunk.load(false); - } - if (id1 != null) { - final Plot p1 = MainUtil.getPlot(world, id1); - if ((p1 != null) && p1.hasOwner() && p1.settings.isMerged()) { - toCheck = true; - } - } - if ((id2 != null) && !toCheck) { - final Plot p2 = MainUtil.getPlot(world, id2); - if ((p2 != null) && p2.hasOwner() && p2.settings.isMerged()) { - toCheck = true; - } - } - final int size = plotworld.SIZE; - for (int X = 0; X < 16; X++) { - for (int Z = 0; Z < 16; Z++) { - short absX = (short) ((x + X) % size); - short absZ = (short) ((z + Z) % size); - if (absX < 0) { - absX += size; - } - if (absZ < 0) { - absZ += size; - } - final boolean gx = absX > plotworld.PATH_WIDTH_LOWER; - final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; - final boolean lx = absX < plotworld.PATH_WIDTH_UPPER; - final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; - boolean condition; - if (toCheck) { - final Location l = new Location(world, x + X, 1, z + Z); - condition = getPlotId(plotworld, l) == null; - } else { - condition = (!gx || !gz || !lx || !lz); - } - if (condition) { - final int sy = plotworld.ROAD_HEIGHT; - final ChunkLoc loc = new ChunkLoc(absX, absZ); - final HashMap blocks = plotworld.G_SCH.get(loc); - for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT); y++) { - MainUtil.setBlock(world, x + X, sy + y, z + Z, 0, (byte) 0); - } - if (blocks != null) { - final HashMap datas = plotworld.G_SCH_DATA.get(loc); - if (datas == null) { - for (final Short y : blocks.keySet()) { - MainUtil.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0); - } - } else { - for (final Short y : blocks.keySet()) { - Byte data = datas.get(y); - if (data == null) { - data = 0; - } - MainUtil.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), data); - } - } - } - } - } - } - return true; - } - } - return false; - } - @Override public boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds) { final HybridPlotWorld hpw = (HybridPlotWorld) plotworld; @@ -351,7 +257,7 @@ public class HybridPlotManager extends ClassicPlotManager { final String world = plotworld.worldname; MainUtil.runners.put(plot, 1); final Plugin plugin = PlotSquared.getMain(); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.runners.remove(plot); @@ -374,27 +280,27 @@ public class HybridPlotManager extends ClassicPlotManager { if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) { setWallFilling(world, dpw, plot.id, new PlotBlock[] { wall_filling }); } - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { final Block block = world.getBlockAt(new Location(world, pos1.getX() - 1, dpw.WALL_HEIGHT + 1, pos1.getZ())); if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) { setWall(world, dpw, plot.id, new PlotBlock[] { wall }); } - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { if ((pos2.getX() - pos1.getX()) < 48) { MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, world.getMaxHeight() + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); @@ -453,15 +359,15 @@ public class HybridPlotManager extends ClassicPlotManager { final Location min = mn; if (min == null) { MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, world.getMaxHeight() + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); @@ -485,204 +391,204 @@ public class HybridPlotManager extends ClassicPlotManager { if (max.getZ() > plotMaxZ) { max.setZ(plotMaxZ); } - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 21L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + }, 21); + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } }, 25L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } }, 29L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } }, 33L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } }, 37L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 41L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + }, 41); + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 45L); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + }, 45); + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); TaskManager.runTask(whenDone); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 1L); + }, 1); } - }, 49L); + }, 49); } } - }, 20L); + }, 20); } - }, 20L); + }, 20); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java new file mode 100644 index 000000000..c47cc2977 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -0,0 +1,168 @@ +package com.intellectualcrafters.plot.generator; + +import java.io.File; +import java.util.HashMap; + +import com.intellectualcrafters.jnbt.CompoundTag; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; + +public abstract class HybridUtils { + + public boolean checkModified(final Plot plot, int requiredChanges) { + final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); + final int botx = bottom.getX(); + final int botz = bottom.getZ(); + final int topx = top.getX(); + final int topz = top.getZ(); + final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getPlotWorld(plot.world); + final PlotBlock[] air = new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) }; + int changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK); + if (changes == -1) { + return true; + } + requiredChanges -= changes; + changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 1, hpw.PLOT_HEIGHT + 1, botz, topz, air); + if (changes == -1) { + return true; + } + requiredChanges -= changes; + changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 2, BukkitUtil.getMaxHeight(plot.world) - 1, botz, topz, air); + if (changes == -1) { + return true; + } + requiredChanges -= changes; + changes = checkModified(requiredChanges, plot.world, botx, topx, 1, hpw.PLOT_HEIGHT - 1, botz, topz, hpw.MAIN_BLOCK); + return changes == -1; + } + + public abstract int checkModified(final int threshhold, final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks); + + public boolean setupRoadSchematic(final Plot plot) { + final String world = plot.world; + final Location bot = MainUtil.getPlotBottomLoc(world, plot.id); + final Location top = MainUtil.getPlotTopLoc(world, plot.id); + final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); + final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1; + final int sz = bot.getZ() + 1; + final int sy = plotworld.ROAD_HEIGHT; + final int ex = bot.getX(); + final int ez = top.getZ(); + final int ey = get_ey(world, sx, ex, sz, ez, sy); + final Location pos1 = new Location(world, sx, sy, sz); + final Location pos2 = new Location(world, ex, ey, ez); + final int bx = sx; + final int bz = sz - plotworld.ROAD_WIDTH; + final int by = sy; + final int tx = ex; + final int tz = sz - 1; + final int ty = get_ey(world, bx, tx, bz, tz, by); + final Location pos3 = new Location(world, bx, by, bz); + final Location pos4 = new Location(world, tx, ty, tz); + final CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2); + final CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4); + final String dir = PlotSquared.IMP.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"); + plotworld.ROAD_SCHEMATIC_ENABLED = true; + plotworld.setupSchematics(); + return true; + } + + public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy); + + public abstract void regenerateChunkChunk(final String world, final ChunkLoc loc); + + public abstract boolean scheduleRoadUpdate(final String world); + + public boolean regenerateRoad(String world, final ChunkLoc chunk) { + final int x = chunk.x << 4; + final int z = chunk.z << 4; + final int ex = x + 15; + final int ez = z + 15; + final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); + if (!plotworld.ROAD_SCHEMATIC_ENABLED) { + return false; + } + PlotManager manager = PlotSquared.getPlotManager(world); + final PlotId id1 = manager.getPlotId(plotworld, x, 0, z); + final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez); + boolean toCheck = false; + if ((id1 == null) || (id2 == null) || (id1 != id2)) { + final boolean result = BukkitUtil.loadChunk(world, chunk); + if (result) { + if (id1 != null) { + final Plot p1 = MainUtil.getPlot(world, id1); + if ((p1 != null) && p1.hasOwner() && p1.settings.isMerged()) { + toCheck = true; + } + } + if ((id2 != null) && !toCheck) { + final Plot p2 = MainUtil.getPlot(world, id2); + if ((p2 != null) && p2.hasOwner() && p2.settings.isMerged()) { + toCheck = true; + } + } + final int size = plotworld.SIZE; + for (int X = 0; X < 16; X++) { + for (int Z = 0; Z < 16; Z++) { + short absX = (short) ((x + X) % size); + short absZ = (short) ((z + Z) % size); + if (absX < 0) { + absX += size; + } + if (absZ < 0) { + absZ += size; + } + final boolean gx = absX > plotworld.PATH_WIDTH_LOWER; + final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; + final boolean lx = absX < plotworld.PATH_WIDTH_UPPER; + final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; + boolean condition; + if (toCheck) { + condition = manager.getPlotId(plotworld, x + X, 1, z + Z) == null; + } else { + condition = (!gx || !gz || !lx || !lz); + } + if (condition) { + final int sy = plotworld.ROAD_HEIGHT; + final ChunkLoc loc = new ChunkLoc(absX, absZ); + final HashMap blocks = plotworld.G_SCH.get(loc); + for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT); y++) { + BlockManager.manager.functionSetBlock(world, x + X, sy + y, z + Z, 0, (byte) 0); + } + if (blocks != null) { + final HashMap datas = plotworld.G_SCH_DATA.get(loc); + if (datas == null) { + for (final Short y : blocks.keySet()) { + BlockManager.manager.functionSetBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0); + } + } else { + for (final Short y : blocks.keySet()) { + Byte data = datas.get(y); + if (data == null) { + data = 0; + } + BlockManager.manager.functionSetBlock(world, x + X, sy + y, z + Z, blocks.get(y), data); + } + } + } + } + } + } + return true; + } + } + return false; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 48066c706..8263868c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -4,7 +4,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class BlockManager { - private static BlockManager manager = new BukkitUtil(); + public static BlockManager manager = new BukkitUtil(); private static long state = 1; public static long nextLong() { @@ -32,6 +32,8 @@ public abstract class BlockManager { public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines); + public abstract void functionSetBlock(String worldname, int x, int y, int z, int id, byte data); + public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final int[] biome); public static void setBiomes(final String worldname, final int[] x, final int z[], final int[] biome) { 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 344a28fd0..577758b33 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -961,4 +961,8 @@ public class MainUtil { } return getPlot(loc.getWorld(), id); } + + public static void setBlock(String world, int i, int j, int k, int l, byte b) { + BlockManager.setBl + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 27bb49b19..a8dfe151e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -15,6 +15,7 @@ import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.BlockManager; @@ -24,6 +25,10 @@ public class BukkitUtil extends BlockManager { private static String lastString = null; private static World lastWorld = null; + public static boolean loadChunk(String world, ChunkLoc loc) { + return getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); + } + public static Biome getBiome(final Location loc) { return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()); } @@ -33,7 +38,7 @@ public class BukkitUtil extends BlockManager { } public static World getWorld(final String string) { - if (lastString == string) { + if (string == lastString) { return lastWorld; } World world = worlds.get(string); @@ -161,4 +166,9 @@ public class BukkitUtil extends BlockManager { world.setBiome(x[i], z[i], biomes[biome[i]]); } } + + @Override + public void functionSetBlock(String worldname, int x, int y, int z, int id, byte data) { + BukkitUtil.setBlock(getWorld(worldname), x, y, z, id, data); + } } From cf7c46ed5d5732e0726c8ab149151639f12e3a5b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 14:43:08 +1100 Subject: [PATCH 056/124] gen stuff --- .../plot/generator/BukkitHybridUtils.java | 131 +++++++++ .../plot/generator/HybridPlotManager.java | 257 ++---------------- .../plot/generator/HybridUtils.java | 2 + .../plot/util/bukkit/BukkitUtil.java | 4 + 4 files changed, 162 insertions(+), 232 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java new file mode 100644 index 000000000..12d78baa0 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -0,0 +1,131 @@ +package com.intellectualcrafters.plot.generator; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.plugin.Plugin; + +import com.intellectualcrafters.plot.BukkitMain; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; + +public class BukkitHybridUtils extends HybridUtils { + + @Override + public int checkModified(int threshhold, String worldname, int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) { + World world = BukkitUtil.getWorld(worldname); + int count = 0; + for (int y = y1; y <= y2; y++) { + for (int x = x1; x <= x2; x++) { + for (int z = z1; z <= z2; z++) { + final Block block = world.getBlockAt(x, y, z); + final int id = block.getTypeId(); + boolean same = false; + for (final PlotBlock p : blocks) { + if (id == p.id) { + same = true; + break; + } + } + if (!same) { + count++; + if (count > threshhold) { + return -1; + } + } + } + } + } + return count; + } + + @Override + public int get_ey(String worldname, int sx, int ex, int sz, int ez, int sy) { + World world = BukkitUtil.getWorld(worldname); + int maxY = world.getMaxHeight(); + int ey = sy; + for (int x = sx; x <= ex; x++) { + for (int z = sz; z <= ez; z++) { + for (int y = sy; y < maxY; y++) { + if (y > ey) { + final Block block = world.getBlockAt(x, y, z); + if (block.getTypeId() != 0) { + ey = y; + } + } + } + } + } + return ey; + } + + @Override + public void regenerateChunkChunk(String worldname, ChunkLoc loc) { + World world = BukkitUtil.getWorld(worldname); + final int sx = loc.x << 5; + final int sz = loc.z << 5; + for (int x = sx; x < (sx + 32); x++) { + for (int z = sz; z < (sz + 32); z++) { + final Chunk chunk = world.getChunkAt(x, z); + chunk.load(false); + } + } + final ArrayList chunks2 = new ArrayList<>(); + for (int x = sx; x < (sx + 32); x++) { + for (int z = sz; z < (sz + 32); z++) { + final Chunk chunk = world.getChunkAt(x, z); + chunks2.add(chunk); + regenerateRoad(worldname, new ChunkLoc(x,z)); + } + } + SetBlockManager.setBlockManager.update(chunks2); + } + + private static boolean UPDATE = false; + private int task; + + @Override + public boolean scheduleRoadUpdate(final String world) { + if (BukkitHybridUtils.UPDATE) { + return false; + } + final List chunks = AChunkManager.manager.getChunkChunks(world); + final Plugin plugin = (Plugin) BukkitMain.THIS; + this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { + @Override + public void run() { + if (chunks.size() == 0) { + BukkitHybridUtils.UPDATE = false; + PlotSquared.log(C.PREFIX.s() + "Finished road conversion"); + Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task); + return; + } else { + try { + final ChunkLoc loc = chunks.get(0); + PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)"); + PlotSquared.log("Remaining regions: " + chunks.size()); + regenerateChunkChunk(world, loc); + chunks.remove(0); + } catch (final Exception e) { + final ChunkLoc loc = chunks.get(0); + PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); + PlotSquared.log("&d - Potentially skipping 256 chunks"); + PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); + } + } + } + }, 20, 20); + return true; + } + +} 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 dce6340fc..098a8cc3c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -44,207 +44,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager { - private static boolean UPDATE = false; - private int task; - - public static boolean checkModified(final Plot plot, int requiredChanges) { - final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); - final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); - final int botx = bottom.getX(); - final int botz = bottom.getZ(); - final int topx = top.getX(); - final int topz = top.getZ(); - final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getPlotWorld(plot.world); - final PlotBlock[] air = new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) }; - int changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK); - if (changes == -1) { - return true; - } - requiredChanges -= changes; - changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 1, hpw.PLOT_HEIGHT + 1, botz, topz, air); - if (changes == -1) { - return true; - } - requiredChanges -= changes; - changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 2, BukkitUtil.getMaxHeight(plot.world) - 1, botz, topz, air); - if (changes == -1) { - return true; - } - requiredChanges -= changes; - changes = checkModified(requiredChanges, plot.world, botx, topx, 1, hpw.PLOT_HEIGHT - 1, botz, topz, hpw.MAIN_BLOCK); - return changes == -1; - } - - public static int checkModified(final int threshhold, final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) { - int count = 0; - for (int y = y1; y <= y2; y++) { - for (int x = x1; x <= x2; x++) { - for (int z = z1; z <= z2; z++) { - final Block block = world.getBlockAt(x, y, z); - final int id = block.getTypeId(); - boolean same = false; - for (final PlotBlock p : blocks) { - if (id == p.id) { - same = true; - break; - } - } - if (!same) { - count++; - if (count > threshhold) { - return -1; - } - } - } - } - } - return count; - } - - public boolean setupRoadSchematic(final Plot plot) { - final String world = plot.world; - final Location bot = MainUtil.getPlotBottomLoc(world, plot.id); - final Location top = MainUtil.getPlotTopLoc(world, plot.id); - final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); - final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1; - final int sz = bot.getZ() + 1; - final int sy = plotworld.ROAD_HEIGHT; - final int ex = bot.getX(); - final int ez = top.getZ(); - final int ey = get_ey(world, sx, ex, sz, ez, sy); - final Location pos1 = new Location(world, sx, sy, sz); - final Location pos2 = new Location(world, ex, ey, ez); - final int bx = sx; - final int bz = sz - plotworld.ROAD_WIDTH; - final int by = sy; - final int tx = ex; - final int tz = sz - 1; - final int ty = get_ey(world, bx, tx, bz, tz, by); - final Location pos3 = new Location(world, bx, by, bz); - final Location pos4 = new Location(world, tx, ty, tz); - final CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2); - final CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4); - final String dir = PlotSquared.IMP.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"); - plotworld.ROAD_SCHEMATIC_ENABLED = true; - plotworld.setupSchematics(); - return true; - } - - public int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy) { - int ey = sy; - for (int x = sx; x <= ex; x++) { - for (int z = sz; z <= ez; z++) { - for (int y = sy; y < maxY; y++) { - if (y > ey) { - final Block block = world.getBlockAt(x, y, z); - if (block.getTypeId() != 0) { - ey = y; - } - } - } - } - } - return ey; - } - - public void regenerateChunkChunk(final String world, final ChunkLoc loc) { - final int sx = loc.x << 5; - final int sz = loc.z << 5; - for (int x = sx; x < (sx + 32); x++) { - for (int z = sz; z < (sz + 32); z++) { - final Chunk chunk = world.getChunkAt(x, z); - chunk.load(false); - } - } - final ArrayList chunks2 = new ArrayList<>(); - for (int x = sx; x < (sx + 32); x++) { - for (int z = sz; z < (sz + 32); z++) { - final Chunk chunk = world.getChunkAt(x, z); - chunks2.add(chunk); - regenerateRoad(chunk); - } - } - SetBlockManager.setBlockManager.update(chunks2); - } - - public boolean scheduleRoadUpdate(final String world) { - if (HybridPlotManager.UPDATE) { - return false; - } - final ArrayList chunks = ChunkManager.getChunkChunks(world); - 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; - PlotSquared.log(C.PREFIX.s() + "Finished road conversion"); - Bukkit.getScheduler().cancelTask(HybridPlotManager.this.task); - return; - } else { - try { - final ChunkLoc loc = chunks.get(0); - PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)"); - PlotSquared.log("Remaining regions: " + chunks.size()); - regenerateChunkChunk(world, loc); - chunks.remove(0); - } catch (final Exception e) { - final ChunkLoc loc = chunks.get(0); - PlotSquared.log("&c[ERROR]&7 Could not update '" + world.getName() + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); - PlotSquared.log("&d - Potentially skipping 256 chunks"); - PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); - } - } - } - }, 20, 20); - return true; - } - - @Override - public boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds) { - final HybridPlotWorld hpw = (HybridPlotWorld) plotworld; - if (hpw.ROAD_SCHEMATIC_ENABLED) { - for (final PlotId id : plotIds) { - final Location bottom = getPlotBottomLocAbs(plotworld, id); - final int sx = bottom.getX() - hpw.PATH_WIDTH_LOWER; - final int sz = bottom.getZ() - hpw.PATH_WIDTH_LOWER; - final int sy = hpw.ROAD_HEIGHT; - for (final ChunkLoc loc : hpw.G_SCH.keySet()) { - final HashMap blocks = hpw.G_SCH.get(loc); - final HashMap datas = hpw.G_SCH_DATA.get(loc); - if (datas == null) { - for (final Short y : blocks.keySet()) { - MainUtil.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0); - } - } else { - for (final Short y : blocks.keySet()) { - Byte data = datas.get(y); - if (data == null) { - data = 0; - } - MainUtil.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data); - } - } - } - } - } - final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; - if (block.id != 0) { - for (final PlotId id : plotIds) { - setWall(world, plotworld, id, new PlotBlock[] { ((ClassicPlotWorld) plotworld).WALL_BLOCK }); - final Plot plot = MainUtil.getPlot(world, id); - if (plot.hasOwner()) { - final String name = UUIDHandler.getName(plot.owner); - if (name != null) { - MainUtil.setSign(world, name, plot); - } - } - } - } - return true; - } /** * Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid @@ -256,13 +55,12 @@ public class HybridPlotManager extends ClassicPlotManager { public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { final String world = plotworld.worldname; MainUtil.runners.put(plot, 1); - final Plugin plugin = PlotSquared.getMain(); TaskManager.runTaskLater(new Runnable() { @Override public void run() { MainUtil.runners.remove(plot); } - }, 90L); + }, 90); final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld); final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id); @@ -276,17 +74,12 @@ public class HybridPlotManager extends ClassicPlotManager { wall = dpw.CLAIMED_WALL_BLOCK; } final PlotBlock wall_filling = dpw.WALL_FILLING; - final Block block = world.getBlockAt(new Location(world, pos1.getX() - 1, 1, pos1.getZ())); - if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) { - setWallFilling(world, dpw, plot.id, new PlotBlock[] { wall_filling }); - } + setWallFilling(dpw, plot.id, new PlotBlock[] { wall_filling }); + final int maxy = BukkitUtil.getMaxHeight(world); TaskManager.runTaskLater(new Runnable() { @Override public void run() { - final Block block = world.getBlockAt(new Location(world, pos1.getX() - 1, dpw.WALL_HEIGHT + 1, pos1.getZ())); - if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) { - setWall(world, dpw, plot.id, new PlotBlock[] { wall }); - } + setWall(dpw, plot.id, new PlotBlock[] { wall }); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -295,7 +88,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, world.getMaxHeight() + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -305,11 +98,11 @@ public class HybridPlotManager extends ClassicPlotManager { public void run() { MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); } - }, 5L); + }, 5); } - }, 5L); + }, 5); } - }, 5L); + }, 5); return; } final int startX = (pos1.getX() / 16) * 16; @@ -352,7 +145,7 @@ public class HybridPlotManager extends ClassicPlotManager { } else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) { mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); } - world.regenerateChunk(i / 16, j / 16); + BukkitUtil.regenerateChunk(world, i / 16, j / 16); } } final Location max = mx; @@ -362,7 +155,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, world.getMaxHeight() + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -372,11 +165,11 @@ public class HybridPlotManager extends ClassicPlotManager { public void run() { MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); } - }, 5L); + }, 5); } - }, 5L); + }, 5); } - }, 5L); + }, 5); return; } else { if (min.getX() < plotMinX) { @@ -398,7 +191,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -422,7 +215,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -438,7 +231,7 @@ public class HybridPlotManager extends ClassicPlotManager { } }, 1); } - }, 25L); + }, 25); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -446,7 +239,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -462,7 +255,7 @@ public class HybridPlotManager extends ClassicPlotManager { } }, 1); } - }, 29L); + }, 29); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -470,7 +263,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -486,7 +279,7 @@ public class HybridPlotManager extends ClassicPlotManager { } }, 1); } - }, 33L); + }, 33); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -494,7 +287,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -510,7 +303,7 @@ public class HybridPlotManager extends ClassicPlotManager { } }, 1); } - }, 37L); + }, 37); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -518,7 +311,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -542,7 +335,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -566,7 +359,7 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); TaskManager.runTaskLater(new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index c47cc2977..b26fb18dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -18,6 +18,8 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class HybridUtils { + public static HybridUtils manager = new BukkitHybridUtils(); + public boolean checkModified(final Plot plot, int requiredChanges) { final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index a8dfe151e..d2fb33be9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -116,6 +116,10 @@ public class BukkitUtil extends BlockManager { getWorld(world).refreshChunk(x, z); } + public static void regenerateChunk(final String world, final int x, final int z) { + getWorld(world).regenerateChunk(x, z); + } + public static PlotBlock getBlock(final Location loc) { final World world = getWorld(loc.getWorld()); final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); From 3bd9ab4dd320e9824d61ceaa4424817c292ff21c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 14:50:58 +1100 Subject: [PATCH 057/124] hgj fgh --- .../java/com/intellectualcrafters/plot/generator/HybridPop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 98cb4725b..a4cd724d5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -116,7 +116,7 @@ public class HybridPop extends BlockPopulator { } this.X = cx << 4; this.Z = cz << 4; - final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(w); + final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(w.getName()); final RegionWrapper plot = AChunkManager.CURRENT_PLOT_CLEAR; if (plot != null) { short sx = (short) ((this.X) % this.size); From 4cf92c4a0a78fe3650068e9ff7c522f28751f450 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:27:01 +1100 Subject: [PATCH 058/124] cache player --- .../intellectualcrafters/plot/BukkitMain.java | 54 +++++++++++-------- .../intellectualcrafters/plot/IPlotMain.java | 7 +-- .../plot/commands/Auto.java | 2 +- .../plot/commands/DebugClear.java | 2 +- .../plot/commands/MainCommand.java | 17 +++--- .../plot/commands/Reload.java | 1 + .../plot/commands/SubCommand.java | 6 +-- .../plot/commands/Trim.java | 2 +- .../plot/commands/WE_Anywhere.java | 2 +- .../plot/generator/AugmentedPopulator.java | 1 - .../plot/generator/BukkitHybridUtils.java | 1 - .../plot/generator/HybridPlotManager.java | 14 ----- .../plot/generator/SquarePlotManager.java | 1 - .../plot/listeners/InventoryListener.java | 4 +- .../plot/listeners/PlayerEvents.java | 8 +-- .../plot/listeners/PlayerEvents_1_8.java | 2 +- .../plot/listeners/PlotListener.java | 1 - .../plot/listeners/PlotPlusListener.java | 2 +- .../plot/listeners/WorldEditListener.java | 2 +- .../plot/object/BukkitPlayer.java | 1 + .../plot/object/PlotManager.java | 2 - .../plot/object/PlotPlayer.java | 3 -- .../plot/util/ClusterManager.java | 4 +- .../plot/util/ExpireManager.java | 5 +- .../plot/util/MainUtil.java | 6 --- .../plot/util/Permissions.java | 1 - .../util/bukkit/BukkitPlayerFunctions.java | 44 ++++++--------- .../plot/util/bukkit/BukkitUtil.java | 16 ++++++ .../plot/util/bukkit/ChunkManager.java | 3 +- .../plot/util/bukkit/PWE.java | 1 - 30 files changed, 98 insertions(+), 117 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index e93ae098f..aa8241d28 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -1,25 +1,7 @@ package com.intellectualcrafters.plot; -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.Settings; -import com.intellectualcrafters.plot.database.PlotMeConverter; -import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; -import com.intellectualcrafters.plot.events.PlotDeleteEvent; -import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.listeners.*; -import com.intellectualcrafters.plot.object.BukkitPlayer; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.ConsoleColors; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.*; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import java.io.File; +import java.util.Arrays; import net.milkbowl.vault.economy.Economy; @@ -39,8 +21,34 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.util.Arrays; +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.Settings; +import com.intellectualcrafters.plot.database.PlotMeConverter; +import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.listeners.ForceFieldListener; +import com.intellectualcrafters.plot.listeners.InventoryListener; +import com.intellectualcrafters.plot.listeners.PlayerEvents; +import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; +import com.intellectualcrafters.plot.listeners.PlotPlusListener; +import com.intellectualcrafters.plot.listeners.WorldEditListener; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.ConsoleColors; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.Metrics; +import com.intellectualcrafters.plot.util.bukkit.SendChunk; +import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; +import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; +import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS = null; @@ -79,7 +87,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (Settings.USE_PLOTME_ALIAS) { player.performCommand(message.replace("/plotme", "plots")); } else { - MainUtil.sendMessage(new BukkitPlayer(player), C.NOT_USING_PLOTME); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME); } event.setCancelled(true); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index f7f7250ec..1894c5d22 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -1,11 +1,12 @@ package com.intellectualcrafters.plot; +import java.io.File; + +import net.milkbowl.vault.economy.Economy; + import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.TaskManager; -import net.milkbowl.vault.economy.Economy; - -import java.io.File; public interface IPlotMain { public void log(String message); 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 1e3912f18..df81089b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -37,8 +37,8 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Auto extends SubCommand { public Auto() { 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 7514de024..b2aa400a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -32,8 +32,8 @@ import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugClear extends SubCommand { 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 85d2b3139..0d72e1e8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -20,20 +20,21 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; /** * PlotSquared command class 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 945b676f7..cf82c6376 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -25,6 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Reload extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index bcfe550a5..03d625b7d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -20,13 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; +import java.util.Arrays; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; -import java.util.ArrayList; -import java.util.Arrays; - /** * SubCommand class * 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 d665c91f6..612baa903 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -40,8 +40,8 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; public class Trim extends SubCommand { public static boolean TASK = false; 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 33f56eb09..b7688645f 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 @@ -24,8 +24,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.util.bukkit.PWE; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PWE; public class WE_Anywhere extends SubCommand { public WE_Anywhere() { 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 cd69cf2c6..e167c49ff 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -18,7 +18,6 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.AChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 12d78baa0..b788efd39 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -16,7 +16,6 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class BukkitHybridUtils extends HybridUtils { 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 098a8cc3c..90bf4e149 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -20,27 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.generator; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; - -import com.intellectualcrafters.jnbt.CompoundTag; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager { 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 87b838295..4ac024cac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -8,7 +8,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; /** * A plot manager with a square grid layout, with square shaped plots diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index c44248d10..15004e90f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -9,7 +9,7 @@ import org.bukkit.event.inventory.InventoryInteractEvent; import org.bukkit.inventory.Inventory; import com.intellectualcrafters.plot.object.InfoInventory; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.MainUtil; /** * Created 2014-11-18 for PlotSquared @@ -36,7 +36,7 @@ public class InventoryListener implements Listener { case 4: case 5: case 6: - BukkitPlayerFunctions.sendMessage(player, "This is not implemented yet"); + MainUtil.sendMessage(player, "This is not implemented yet"); break; default: break; 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 0938277b4..0d4d50273 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -97,12 +97,13 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -143,7 +144,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!player.hasPlayedBefore()) { player.saveData(); } - final String username = player.getName(); + PlotPlayer pp = BukkitUtil.getPlayer(player); + final String username = pp.getName(); final StringWrapper name = new StringWrapper(username); final UUID uuid = UUIDHandler.getUUID(player); UUIDHandler.add(name, uuid); @@ -154,7 +156,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (Settings.TELEPORT_ON_LOGIN) { BukkitUtil.teleportPlayer(player, MainUtil.getPlotHomeDefault(plot)); - BukkitPlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); + MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD); } plotEntry(player, plot); } 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 5f7c23ff0..5301f9cdd 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 @@ -13,8 +13,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents_1_8 extends PlotListener implements Listener { 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 d1754a687..0b8b089a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -20,7 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.listeners; -import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; 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 0ff8ee142..b695bf5dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -53,8 +53,8 @@ import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 ba8da2423..453f6b144 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -48,9 +48,9 @@ import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.LocalSession; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index f20bf2043..f69742be5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -13,6 +13,7 @@ public class BukkitPlayer implements PlotPlayer { UUID uuid; String name; + public BukkitPlayer(Player player, String name, UUID uuid) { this.player = player; this.name = name; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 17667fe95..62bd5aab5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -22,8 +22,6 @@ package com.intellectualcrafters.plot.object; import java.util.ArrayList; -import org.bukkit.block.Biome; - public abstract class PlotManager { /* * Plot locations (methods with Abs in them will not need to consider mega diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 2d0b7d62c..f5682afdf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -1,8 +1,5 @@ package com.intellectualcrafters.plot.object; -import com.intellectualcrafters.plot.BukkitMain; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; - import java.util.UUID; /** 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 33731488c..67cd05ef3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -16,7 +16,6 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; @@ -25,7 +24,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -262,7 +260,7 @@ public class ClusterManager { ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName()); final Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner); if (owner != null) { - MainUtil.sendMessage(new BukkitPlayer(owner), C.CLEARING_DONE); + MainUtil.sendMessage(BukkitUtil.getPlayer(owner), C.CLEARING_DONE); } } }, (interval * chunks.size()) + 20); 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 974a58b0c..4647058f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -19,11 +19,10 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; -import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ExpireManager { @@ -105,7 +104,7 @@ public class ExpireManager { for (final UUID helper : plot.helpers) { final Player player = UUIDHandler.uuidWrapper.getPlayer(helper); if (player != null) { - MainUtil.sendMessage(new BukkitPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString()); } } final PlotManager manager = PlotSquared.getPlotManager(world); 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 577758b33..fab915f6c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; @@ -43,7 +42,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SendChunk; /** @@ -961,8 +959,4 @@ public class MainUtil { } return getPlot(loc.getWorld(), id); } - - public static void setBlock(String world, int i, int j, int k, int l, byte b) { - BlockManager.setBl - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index 6bf280849..bbb3bc475 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -1,6 +1,5 @@ package com.intellectualcrafters.plot.util; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotPlayer; public class Permissions { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index c18c41b31..1b9d6b4a5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -20,30 +20,23 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.util.bukkit; -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.BukkitPlayer; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; - -import net.milkbowl.vault.economy.Economy; - -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.ChatPaginator; - import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; + /** * Functions involving players, plots and locations. */ @@ -54,13 +47,6 @@ public class BukkitPlayerFunctions { * - We will try to move as many functions as we can out of this class and into the MainUtil class */ - - - - - - - /** * Clear a plot. Use null player if no player is present * @param player @@ -74,7 +60,7 @@ public class BukkitPlayerFunctions { @Override public void run() { if ((player != null) && player.isOnline()) { - MainUtil.sendMessage(new BukkitPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); } } }; @@ -99,11 +85,11 @@ public class BukkitPlayerFunctions { if (cost > 0d) { final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < cost) { - MainUtil.sendMessage(new BukkitPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); + MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); return false; } economy.withdrawPlayer(plr, cost); - MainUtil.sendMessage(new BukkitPlayer(plr), C.REMOVED_BALANCE, cost + ""); + MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + ""); } } return MainUtil.mergePlots(world, plotIds, true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index d2fb33be9..ce762e986 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -15,9 +15,11 @@ import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; public class BukkitUtil extends BlockManager { @@ -25,6 +27,20 @@ public class BukkitUtil extends BlockManager { private static String lastString = null; private static World lastWorld = null; + private static HashMap players = new HashMap<>(); + private static Player lastPlayer = null; + private static PlotPlayer lastPlotPlayer = null; + + public static PlotPlayer getPlayer(Player player) { + if (player == lastPlayer) { + return lastPlotPlayer; + } + lastPlotPlayer = new BukkitPlayer(player); + players.put(lastPlotPlayer.getName(), lastPlotPlayer); + lastPlayer = player; + return lastPlotPlayer; + } + public static boolean loadChunk(String world, ChunkLoc loc) { return getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 109be47c9..331df271d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -45,7 +45,6 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -748,7 +747,7 @@ public class ChunkManager extends AChunkManager { if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - MainUtil.teleportPlayer(new BukkitPlayer(player), BukkitUtil.getLocation(entity), plot); + MainUtil.teleportPlayer(BukkitUtil.getPlayer(player), BukkitUtil.getLocation(entity), plot); PlotListener.plotExit(player, plot); } else { entity.remove(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index a7fe97869..6f61cf1ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.util.bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; From 6c2bce824c7a481c85c388070ea2b96c392917eb Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:32:01 +1100 Subject: [PATCH 059/124] messages --- .../plot/commands/Claim.java | 2 +- .../plot/commands/Cluster.java | 4 +- .../plot/commands/CreateRoadSchematic.java | 4 +- .../plot/commands/Database.java | 2 +- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugExec.java | 2 +- .../plot/commands/DebugRoadRegen.java | 2 +- .../plot/commands/Denied.java | 2 +- .../plot/commands/FlagCmd.java | 72 +++++++++---------- .../plot/commands/Info.java | 18 ++--- .../plot/commands/MainCommand.java | 10 +-- .../plot/listeners/PlayerEvents.java | 23 +++--- .../plot/listeners/PlotPlusListener.java | 8 +-- .../plot/util/bukkit/BukkitUtil.java | 8 +++ 14 files changed, 84 insertions(+), 75 deletions(-) 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 32a7f2435..1e2604998 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -57,7 +57,7 @@ public class Claim extends SubCommand { if (!event.isCancelled()) { MainUtil.createPlot(player, plot); MainUtil.setSign(player, plot); - BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } 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 4fbedab0c..e2377d85a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -320,7 +320,7 @@ public class Cluster extends SubCommand { DBFunc.setInvited(world, cluster, uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { - BukkitPlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLUSTER_INVITED, cluster.getName()); } } BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_USER); @@ -367,7 +367,7 @@ public class Cluster extends SubCommand { DBFunc.removeInvited(cluster, uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { - BukkitPlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLUSTER_REMOVED, cluster.getName()); } for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); 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 7542b0f11..8c30f8dfc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -38,7 +38,7 @@ public class CreateRoadSchematic extends SubCommand { @Override public boolean execute(final Player player, final String... args) { if (!BukkitPlayerFunctions.isInPlot(player)) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; } if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { @@ -48,7 +48,7 @@ public class CreateRoadSchematic extends SubCommand { final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); MainUtil.update(BukkitUtil.getLocation(entity)); - BukkitPlayerFunctions.sendMessage(player, "&6Saved new road schematic"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Saved new road schematic"); return true; } } 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 b29d9e030..b57efa460 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -141,7 +141,7 @@ public class Database extends SubCommand { if (player == null) { PlotSquared.log(msg); } else { - BukkitPlayerFunctions.sendMessage(player, msg); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), msg); } return true; } 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 92d8db244..b8552ff9d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -64,7 +64,7 @@ public class DebugClaimTest extends SubCommand { if (!event.isCancelled()) { MainUtil.createPlot(player, plot); MainUtil.setSign(player, plot); - BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 0b2d77319..3dc5767e7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -166,7 +166,7 @@ public class DebugExec extends SubCommand { } } } - BukkitPlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); return true; } } 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 8561f4610..f5f47d33a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -48,7 +48,7 @@ public class DebugRoadRegen extends SubCommand { if (result) { SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } - BukkitPlayerFunctions.sendMessage(player, "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return true; } } 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 397ffecb7..12c2730a5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -94,7 +94,7 @@ public class Denied extends SubCommand { if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { final Plot pl = BukkitPlayerFunctions.getCurrentPlot(player); if ((pl != null) && pl.id.equals(plot.id)) { - BukkitPlayerFunctions.sendMessage(player, C.YOU_BE_DENIED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); player.teleport(player.getWorld().getSpawnLocation()); } } 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 7baf99bdb..6c7ccc50c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -53,12 +53,12 @@ public class FlagCmd extends SubCommand { * plot flag list */ if (args.length == 0) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); if (plot == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; } if (!plot.hasOwner()) { @@ -66,88 +66,88 @@ public class FlagCmd extends SubCommand { return false; } if (!plot.hasRights(player) && !BukkitMain.hasPermission(player, "plots.set.flag.other")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag.other"); return false; } switch (args[0].toLowerCase()) { case "info": { if (!BukkitMain.hasPermission(player, "plots.set.flag")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.info"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.info"); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1]); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info "); return false; } // flag key - BukkitPlayerFunctions.sendMessage(player, C.FLAG_KEY, af.getKey()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_KEY, af.getKey()); // flag type - BukkitPlayerFunctions.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_TYPE, af.value.getClass().getSimpleName()); // Flag type description - BukkitPlayerFunctions.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); - BukkitPlayerFunctions.sendMessage(player, "&cNot implemented."); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_DESC, af.getValueDesc()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&cNot implemented."); } case "set": { if (!BukkitMain.hasPermission(player, "plots.set.flag")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag"); return false; } if (args.length < 3) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag set "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc()); return false; } final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed); final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED); return false; } - BukkitPlayerFunctions.sendMessage(player, C.FLAG_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "remove": { if (!BukkitMain.hasPermission(player, "plots.flag.remove")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.remove"); return false; } if ((args.length != 2) && (args.length != 3)) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove [values]"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag remove [values]"); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()); if (flag == null) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_IN_PLOT); return false; } if ((args.length == 3) && flag.getAbstractFlag().isList()) { @@ -157,36 +157,36 @@ public class FlagCmd extends SubCommand { } else { final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); if (!result) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_REMOVED); return false; } } - BukkitPlayerFunctions.sendMessage(player, C.FLAG_REMOVED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_REMOVED); PlotListener.plotEntry(player, plot); return true; } case "add": { if (!BukkitMain.hasPermission(player, "plots.flag.add")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.add"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.add"); return false; } if (args.length < 3) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag add "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc()); return false; } Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase()); @@ -197,21 +197,21 @@ public class FlagCmd extends SubCommand { } final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED); return false; } DBFunc.setFlags(plot.world, plot, plot.settings.flags); - BukkitPlayerFunctions.sendMessage(player, C.FLAG_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "list": { if (!BukkitMain.hasPermission(player, "plots.flag.list")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.list"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.list"); return false; } if (args.length != 1) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag list"); return false; } final HashMap> flags = new HashMap<>(); @@ -228,11 +228,11 @@ public class FlagCmd extends SubCommand { message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", "); prefix = "\n"; } - BukkitPlayerFunctions.sendMessage(player, message); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), message); return true; } } - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); return false; } } 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 15078754a..459e70ea2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -58,11 +58,11 @@ public class Info extends SubCommand { if (player != null) { world = player.getWorld(); if (!PlotSquared.isPlotWorld(world)) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT_WORLD); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT_WORLD); return false; } if (!BukkitPlayerFunctions.isInPlot(player)) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; } plot = BukkitPlayerFunctions.getCurrentPlot(player); @@ -73,7 +73,7 @@ public class Info extends SubCommand { } final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); if (plotworld == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_WORLD); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_WORLD); return false; } try { @@ -81,7 +81,7 @@ public class Info extends SubCommand { final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id); if (plot == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_PLOT_ID); return false; } world = Bukkit.getWorld(args[0]); @@ -91,7 +91,7 @@ public class Info extends SubCommand { args = new String[0]; } } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.INFO_SYNTAX_CONSOLE); return false; } } @@ -109,7 +109,7 @@ public class Info extends SubCommand { } // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { - BukkitPlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); return true; } String owner = "none"; @@ -123,13 +123,13 @@ public class Info extends SubCommand { if (args.length == 1) { info = getCaption(args[0].toLowerCase()); if (info == null) { - BukkitPlayerFunctions.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); return false; } } info = format(info, world, plot, player); - BukkitPlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER); - BukkitPlayerFunctions.sendMessage(player, info, false); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_HEADER); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), info, false); return true; } 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 0d72e1e8d..947a8fbd8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -53,7 +53,7 @@ public class MainCommand { }; public static boolean no_permission(final PlotPlayer player, final String permission) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, permission); return false; } @@ -121,7 +121,7 @@ public class MainCommand { builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands")); - return BukkitPlayerFunctions.sendMessage(player, builder.toString()); + return MainUtil.sendMessage(BukkitUtil.getPlayer(player), builder.toString()); } final String cat = args[1]; SubCommand.CommandCategory cato = null; @@ -137,7 +137,7 @@ public class MainCommand { for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } - return BukkitPlayerFunctions.sendMessage(player, builder.toString(), false); + return MainUtil.sendMessage(BukkitUtil.getPlayer(player), builder.toString(), false); } final StringBuilder help = new StringBuilder(); int page = 0; @@ -181,14 +181,14 @@ public class MainCommand { } } } - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_SUBCOMMAND); final String[] commands = new String[subCommands.size()]; for (int x = 0; x < subCommands.size(); x++) { commands[x] = subCommands.get(x).cmd; } /* Let's try to get a proper usage string */ final String command = new StringComparison(args[0], commands).getBestMatch(); - return BukkitPlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); + return MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.DID_YOU_MEAN, "/plot " + command); // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new // StringComparsion(args[0], commands).getBestMatch()); } 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 0d4d50273..1cb3e9cf2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -189,7 +189,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi passed = false; } if (passed) { - BukkitPlayerFunctions.sendMessage(player, C.BORDER); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.BORDER); return; } } @@ -199,7 +199,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final UUID uuid = UUIDHandler.getUUID(player); if (plot.isDenied(uuid)) { if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; } @@ -265,7 +265,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.destroy.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.unowned"); event.setCancelled(true); return; } @@ -279,7 +279,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.other"); event.setCancelled(true); return; } @@ -289,7 +289,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.road"); event.setCancelled(true); return; } @@ -529,7 +529,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.interact.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.unowned"); event.setCancelled(true); return; } @@ -542,7 +542,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.other"); event.setCancelled(true); return; } @@ -552,7 +552,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.road"); event.setCancelled(true); return; } @@ -746,6 +746,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Setup.setupMap.containsKey(event.getPlayer().getName())) { Setup.setupMap.remove(event.getPlayer().getName()); } + BukkitUtil.removePlayer(event.getPlayer().getName()); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { final Collection plots = PlotSquared.getPlots(event.getPlayer().getName()).values(); for (final Plot plot : plots) { @@ -1079,7 +1080,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.build.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.unowned"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } @@ -1090,7 +1091,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!BukkitMain.hasPermission(player, "plots.admin.build.other")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; } @@ -1099,7 +1100,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) { if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.road"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; } 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 b695bf5dd..d91fe2134 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -108,12 +108,12 @@ public class PlotPlusListener extends PlotListener implements Listener { event.setCancelled(true); final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return; } UUID uuid = UUIDHandler.getUUID(player); if (!plot.isAdded(uuid)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PLOT_PERMS); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PLOT_PERMS); return; } final Set plotPlayers = new HashSet<>(); @@ -215,7 +215,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } if (player.isOnline()) { - BukkitPlayerFunctions.sendMessage(player, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } } @@ -258,7 +258,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } if (player.isOnline()) { - BukkitPlayerFunctions.sendMessage(player, C.NOTIFY_LEAVE.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOTIFY_LEAVE.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index ce762e986..b8d708fb7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -31,6 +31,14 @@ public class BukkitUtil extends BlockManager { private static Player lastPlayer = null; private static PlotPlayer lastPlotPlayer = null; + public static void removePlayer(String plr) { + if (lastPlayer != null && lastPlayer.getName().equals(plr)) { + lastPlayer = null; + lastPlotPlayer = null; + } + players.remove(plr); + } + public static PlotPlayer getPlayer(Player player) { if (player == lastPlayer) { return lastPlotPlayer; From b14b7102b9c789729b44bfc78f45cdc1a7f9043f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:34:05 +1100 Subject: [PATCH 060/124] perms --- .../plot/commands/CommandPermission.java | 2 +- .../plot/commands/FlagCmd.java | 18 +++++++++--------- .../plot/commands/MainCommand.java | 2 +- .../plot/listeners/PlayerEvents.java | 17 +++++++++-------- .../plot/listeners/WorldEditListener.java | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) 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 7f84e6d75..3b6c827ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -47,6 +47,6 @@ public class CommandPermission { * @return true of player has the required permission node */ public boolean hasPermission(final PlotPlayer player) { - return BukkitMain.hasPermission(player, this.permission); + return Permissions.hasPermission(BukkitUtil.getPlayer(player), this.permission); } } 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 6c7ccc50c..1111822c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -65,13 +65,13 @@ public class FlagCmd extends SubCommand { sendMessage(player, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(player) && !BukkitMain.hasPermission(player, "plots.set.flag.other")) { + if (!plot.hasRights(player) && !Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag.other")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag.other"); return false; } switch (args[0].toLowerCase()) { case "info": { - if (!BukkitMain.hasPermission(player, "plots.set.flag")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.info"); return false; } @@ -94,7 +94,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&cNot implemented."); } case "set": { - if (!BukkitMain.hasPermission(player, "plots.set.flag")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag"); return false; } @@ -107,7 +107,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } - if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -128,7 +128,7 @@ public class FlagCmd extends SubCommand { return true; } case "remove": { - if (!BukkitMain.hasPermission(player, "plots.flag.remove")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.remove")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.remove"); return false; } @@ -141,7 +141,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } - if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -166,7 +166,7 @@ public class FlagCmd extends SubCommand { return true; } case "add": { - if (!BukkitMain.hasPermission(player, "plots.flag.add")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.add")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.add"); return false; } @@ -179,7 +179,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } - if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } @@ -206,7 +206,7 @@ public class FlagCmd extends SubCommand { return true; } case "list": { - if (!BukkitMain.hasPermission(player, "plots.flag.list")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.list")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.list"); 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 947a8fbd8..8be6cf67d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -110,7 +110,7 @@ public class MainCommand { } public boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { - if (!BukkitMain.hasPermission(player, PlotSquared.MAIN_PERMISSION)) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(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/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 1cb3e9cf2..128ec376e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -101,6 +101,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -198,7 +199,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (plot.denied.size() > 0) { final UUID uuid = UUIDHandler.getUUID(player); if (plot.isDenied(uuid)) { - if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.entry.denied")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; @@ -262,7 +263,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasOwner()) { - if (BukkitMain.hasPermission(player, "plots.admin.destroy.unowned")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.destroy.unowned")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.unowned"); @@ -526,7 +527,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (BukkitMain.hasPermission(player, "plots.admin.interact.unowned")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.unowned")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.unowned"); @@ -539,7 +540,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final UUID uuid = UUIDHandler.getUUID(player); if (!plot.isAdded(uuid)) { - if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.other")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.other"); @@ -548,7 +549,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (BukkitMain.hasPermission(player, "plots.admin.interact.road")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.road")) { return; } if (isPlotArea(loc)) { @@ -1077,7 +1078,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (BukkitMain.hasPermission(player, "plots.admin.build.unowned")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.unowned")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.unowned"); @@ -1090,7 +1091,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((place != null) && ((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - if (!BukkitMain.hasPermission(player, "plots.admin.build.other")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.other")) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; @@ -1098,7 +1099,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) { + if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.road")) { if (isPlotArea(loc)) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); 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 453f6b144..6eb7107c4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -85,7 +85,7 @@ public class WorldEditListener implements Listener { if (!world.equals(player.getWorld().getName())) { return; } - if (BukkitMain.hasPermission(player, "plots.worldedit.bypass")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.worldedit.bypass")) { return; } PWE.setNoMask(player); From 6487184d42f7af017a742ebd78a065ed01f7f21d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:35:19 +1100 Subject: [PATCH 061/124] . --- .../plot/listeners/PlayerEvents.java | 22 +++++++++---------- .../plot/listeners/PlotPlusListener.java | 18 +++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) 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 128ec376e..47ed05078 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -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(), block.getData()))) { return; } - if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.destroy.other")) { return; } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.other"); @@ -286,7 +286,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.road")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.destroy.road")) { return; } if (isPlotArea(loc)) { @@ -671,19 +671,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(q)) { final Plot plot = getCurrentPlot(q); - if (plot.isDenied(event.getPlayer())) { - BukkitPlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED); + if (plot.isDenied(player)) { + BukkitPlayerFunctions.sendMessage(player, C.YOU_BE_DENIED); event.setCancelled(true); return; } else { if (enteredPlot(f, t)) { - plotEntry(event.getPlayer(), plot); + plotEntry(player, plot); } } } else { if (leftPlot(f, t)) { final Plot plot = getCurrentPlot(event.getFrom()); - plotExit(event.getPlayer(), plot); + plotExit(player, plot); } } if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) { @@ -744,12 +744,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public static void onLeave(final PlayerQuitEvent event) { - if (Setup.setupMap.containsKey(event.getPlayer().getName())) { - Setup.setupMap.remove(event.getPlayer().getName()); + if (Setup.setupMap.containsKey(player.getName())) { + Setup.setupMap.remove(player.getName()); } - BukkitUtil.removePlayer(event.getPlayer().getName()); + BukkitUtil.removePlayer(player.getName()); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { - final Collection plots = PlotSquared.getPlots(event.getPlayer().getName()).values(); + final Collection plots = PlotSquared.getPlots(player.getName()).values(); for (final Plot plot : plots) { final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); final PlotManager manager = PlotSquared.getPlotManager(plot.world); @@ -1070,7 +1070,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin")) { + if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin")) { return; } final Player player = event.getPlayer(); 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 d91fe2134..c5181830c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -223,26 +223,26 @@ public class PlotPlusListener extends PlotListener implements Listener { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { - if (feedRunnable.containsKey(event.getPlayer().getName())) { - feedRunnable.remove(event.getPlayer().getName()); + if (feedRunnable.containsKey(player.getName())) { + feedRunnable.remove(player.getName()); } - if (healRunnable.containsKey(event.getPlayer().getName())) { - healRunnable.remove(event.getPlayer().getName()); + if (healRunnable.containsKey(player.getName())) { + healRunnable.remove(player.getName()); } } @EventHandler public void onPlotLeave(final PlayerLeavePlotEvent event) { - event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.RECORD_PLAY, 0); + event.getPlayer().playEffect(player.getLocation(), Effect.RECORD_PLAY, 0); final Plot plot = event.getPlot(); if (FlagManager.getPlotFlag(plot, "farewell") != null) { event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString())); } - if (feedRunnable.containsKey(event.getPlayer().getName())) { - feedRunnable.remove(event.getPlayer().getName()); + if (feedRunnable.containsKey(player.getName())) { + feedRunnable.remove(player.getName()); } - if (healRunnable.containsKey(event.getPlayer().getName())) { - healRunnable.remove(event.getPlayer().getName()); + if (healRunnable.containsKey(player.getName())) { + healRunnable.remove(player.getName()); } if (booleanFlag(plot, "notify-leave", false)) { if (plot.hasOwner()) { From 0c58c9da37349106a28c033096a84ccabb6e4d31 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:39:13 +1100 Subject: [PATCH 062/124] sad --- .../intellectualcrafters/plot/listeners/InventoryListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index 15004e90f..b7ca8cfb4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -36,7 +36,7 @@ public class InventoryListener implements Listener { case 4: case 5: case 6: - MainUtil.sendMessage(player, "This is not implemented yet"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "This is not implemented yet"); break; default: break; From 9a41a989def5ae8980e8875f6297eba355fd78c0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 16:48:49 +1100 Subject: [PATCH 063/124] main --- .../intellectualcrafters/plot/BukkitMain.java | 7 +- .../intellectualcrafters/plot/IPlotMain.java | 4 - .../plot/commands/BukkitCommand.java | 55 ++++++++++- .../plot/commands/CommandPermission.java | 3 +- .../plot/commands/MainCommand.java | 61 +++--------- .../plot/commands/SubCommand.java | 3 +- .../plot/listeners/InventoryListener.java | 1 + .../plot/util/MainUtil.java | 96 ++++++++++++++++--- 8 files changed, 158 insertions(+), 72 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index aa8241d28..00a0e3a88 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -21,6 +21,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +import com.intellectualcrafters.plot.commands.BukkitCommand; import com.intellectualcrafters.plot.commands.Buy; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.WE_Anywhere; @@ -36,6 +37,7 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; @@ -145,10 +147,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void registerCommands() { final MainCommand command = new MainCommand(); + final BukkitCommand bcmd = new BukkitCommand(); final PluginCommand plotCommand = getCommand("plots"); - plotCommand.setExecutor(command); + plotCommand.setExecutor(bcmd); plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot")); - plotCommand.setTabCompleter(command); + plotCommand.setTabCompleter(bcmd); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 1894c5d22..b00d4acad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -42,8 +42,4 @@ public interface IPlotMain { public void getGenerator(String world, String name); public boolean callRemovePlot(String world, PlotId id); - - public boolean hasPermission(final PlotPlayer player, final String permission); - - public void sendMessage(final PlotPlayer player, final String message); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java index 9c6415e89..e6e435896 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java @@ -1,19 +1,66 @@ package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.command.TabCommandExecutor; +import org.bukkit.command.TabCompleter; +import org.bukkit.entity.Player; + +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * Created 2015-02-20 for PlotSquared * * @author Citymonstret */ -public class BukkitCommand implements CommandExecutor { +public class BukkitCommand implements CommandExecutor, TabCompleter { @Override - public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { - MainCommand - return false; + public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) { + Player player = null; + if (commandSender instanceof Player) { + player = (Player) commandSender; + } + return MainCommand.onCommand(BukkitUtil.getPlayer(player), commandLabel, args); + } + + @Override + public List onTabComplete(final CommandSender commandSender, final Command command, final String s, final String[] strings) { + if (!(commandSender instanceof Player)) { + return null; + } + final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender); + if (strings.length < 1) { + if ((strings.length == 0) || "plots".startsWith(s)) { + return Arrays.asList("plots"); + } + } + if (strings.length > 1) { + return null; + } + if (!command.getLabel().equalsIgnoreCase("plots")) { + return null; + } + final List tabOptions = new ArrayList<>(); + final String arg = strings[0].toLowerCase(); + for (final SubCommand cmd : MainCommand.subCommands) { + if (cmd.permission.hasPermission(player)) { + if (cmd.cmd.startsWith(arg)) { + tabOptions.add(cmd.cmd); + } else if (cmd.alias.get(0).startsWith(arg)) { + tabOptions.add(cmd.alias.get(0)); + } + } + } + if (tabOptions.size() > 0) { + return tabOptions; + } + return null; } } 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 3b6c827ec..17329e82f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.Permissions; /** * Created by Citymonstret on 2014-08-03. @@ -47,6 +48,6 @@ public class CommandPermission { * @return true of player has the required permission node */ public boolean hasPermission(final PlotPlayer player) { - return Permissions.hasPermission(BukkitUtil.getPlayer(player), this.permission); + return Permissions.hasPermission(player, this.permission); } } 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 8be6cf67d..c40b3a3b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -24,15 +24,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; @@ -53,7 +50,7 @@ public class MainCommand { }; public static boolean no_permission(final PlotPlayer player, final String permission) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, permission); + MainUtil.sendMessage(player, C.NO_PERMISSION, permission); return false; } @@ -106,11 +103,11 @@ public class MainCommand { } private static String t(final String s) { - return ChatColor.translateAlternateColorCodes('&', s); + return MainUtil.colorise('&', s); } - public boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), PlotSquared.MAIN_PERMISSION)) { + public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { + if (!Permissions.hasPermission(player, PlotSquared.MAIN_PERMISSION)) { return no_permission(player, PlotSquared.MAIN_PERMISSION); } if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) { @@ -121,7 +118,7 @@ public class MainCommand { builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands")); - return MainUtil.sendMessage(BukkitUtil.getPlayer(player), builder.toString()); + return MainUtil.sendMessage(player, builder.toString()); } final String cat = args[1]; SubCommand.CommandCategory cato = null; @@ -137,7 +134,7 @@ public class MainCommand { for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } - return MainUtil.sendMessage(BukkitUtil.getPlayer(player), builder.toString(), false); + return MainUtil.sendMessage(player, builder.toString(), false); } final StringBuilder help = new StringBuilder(); int page = 0; @@ -163,7 +160,7 @@ public class MainCommand { for (final String string : helpMenu(player, cato, page)) { help.append(string).append("\n"); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', help.toString())); + player.sendMessage(MainUtil.colorise('&', help.toString())); // return PlayerFunctions.sendMessage(player, help.toString()); } else { for (final SubCommand command : subCommands) { @@ -174,58 +171,24 @@ public class MainCommand { if ((player != null) || !command.isPlayer) { return command.execute(player, arguments); } else { - return !BukkitPlayerFunctions.sendMessage(null, C.IS_CONSOLE); + return !MainUtil.sendMessage(null, C.IS_CONSOLE); } } else { return no_permission(player, command.permission.permission.toLowerCase()); } } } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_SUBCOMMAND); + MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND); final String[] commands = new String[subCommands.size()]; for (int x = 0; x < subCommands.size(); x++) { commands[x] = subCommands.get(x).cmd; } /* Let's try to get a proper usage string */ final String command = new StringComparison(args[0], commands).getBestMatch(); - return MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.DID_YOU_MEAN, "/plot " + command); + return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new // StringComparsion(args[0], commands).getBestMatch()); } return true; } - - @Override - public List onTabComplete(final CommandSender commandSender, final Command command, final String s, final String[] strings) { - if (!(commandSender instanceof Player)) { - return null; - } - final Player player = (Player) commandSender; - if (strings.length < 1) { - if ((strings.length == 0) || "plots".startsWith(s)) { - return Arrays.asList("plots"); - } - } - if (strings.length > 1) { - return null; - } - if (!command.getLabel().equalsIgnoreCase("plots")) { - return null; - } - final List tabOptions = new ArrayList<>(); - final String arg = strings[0].toLowerCase(); - for (final SubCommand cmd : subCommands) { - if (cmd.permission.hasPermission(player)) { - if (cmd.cmd.startsWith(arg)) { - tabOptions.add(cmd.cmd); - } else if (cmd.alias.get(0).startsWith(arg)) { - tabOptions.add(cmd.alias.get(0)); - } - } - } - if (tabOptions.size() > 0) { - return tabOptions; - } - return null; - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 03d625b7d..f2b83b4dc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -25,6 +25,7 @@ import java.util.Arrays; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** @@ -148,7 +149,7 @@ public abstract class SubCommand { * com.intellectualcrafters.plot.config.C, String...) */ public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { - BukkitPlayerFunctions.sendMessage(plr, c, args); + MainUtil.sendMessage(plr, c, args); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index b7ca8cfb4..8ec12926f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.Inventory; import com.intellectualcrafters.plot.object.InfoInventory; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * Created 2014-11-18 for PlotSquared 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 fab915f6c..14d23a3f1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -24,9 +24,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.UUID; -import org.bukkit.ChatColor; -import org.bukkit.util.ChatPaginator; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -61,8 +58,8 @@ public class MainUtil { final Plot bot = MainUtil.getBottomPlot(plot); // TODO -// boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot); - boolean result = true; + // boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot); + final boolean result = true; // TOOD ^ remove that if (!result) { @@ -794,18 +791,96 @@ public class MainUtil { public static boolean sendMessage(final PlotPlayer plr, final String msg) { return sendMessage(plr, msg, true); } - + + public static String colorise(final char alt, final String message) { + final char[] b = message.toCharArray(); + for (int i = 0; i < (b.length - 1); i++) { + if ((b[i] == alt) && ("0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[(i + 1)]) > -1)) { + b[i] = '§'; + b[(i + 1)] = Character.toLowerCase(b[(i + 1)]); + } + } + return new String(b); + } + public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) { if ((msg.length() > 0) && !msg.equals("")) { if (plr == null) { PlotSquared.log(C.PREFIX.s() + msg); } else { - sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); + sendMessageWrapped(plr, colorise('&', C.PREFIX.s() + msg)); } } return true; } + public static String[] wordWrap(final String rawString, final int lineLength) { + if (rawString == null) { + return new String[] { "" }; + } + if ((rawString.length() <= lineLength) && (!rawString.contains("\n"))) { + return new String[] { rawString }; + } + final char[] rawChars = (rawString + ' ').toCharArray(); + StringBuilder word = new StringBuilder(); + StringBuilder line = new StringBuilder(); + final ArrayList lines = new ArrayList(); + int lineColorChars = 0; + for (int i = 0; i < rawChars.length; i++) { + final char c = rawChars[i]; + if (c == '§') { + word.append('§' + (rawChars[(i + 1)])); + lineColorChars += 2; + i++; + } else if ((c == ' ') || (c == '\n')) { + if ((line.length() == 0) && (word.length() > lineLength)) { + for (final String partialWord : word.toString().split("(?<=\\G.{" + lineLength + "})")) { + lines.add(partialWord); + } + } else if (((line.length() + word.length()) - lineColorChars) == lineLength) { + line.append(word); + lines.add(line.toString()); + line = new StringBuilder(); + lineColorChars = 0; + } else if (((line.length() + 1 + word.length()) - lineColorChars) > lineLength) { + for (final String partialWord : word.toString().split("(?<=\\G.{" + lineLength + "})")) { + lines.add(line.toString()); + line = new StringBuilder(partialWord); + } + lineColorChars = 0; + } else { + if (line.length() > 0) { + line.append(' '); + } + line.append(word); + } + word = new StringBuilder(); + if (c == '\n') { + lines.add(line.toString()); + line = new StringBuilder(); + } + } else { + word.append(c); + } + } + if (line.length() > 0) { + lines.add(line.toString()); + } + if ((lines.get(0).length() == 0) || (lines.get(0).charAt(0) != '§')) { + lines.set(0, "§f" + lines.get(0)); + } + for (int i = 1; i < lines.size(); i++) { + final String pLine = lines.get(i - 1); + final String subLine = lines.get(i); + + final char color = pLine.charAt(pLine.lastIndexOf('§') + 1); + if ((subLine.length() == 0) || (subLine.charAt(0) != '§')) { + lines.set(i, '§' + (color) + subLine); + } + } + return lines.toArray(new String[lines.size()]); + } + /** * \\previous\\ * @@ -813,8 +888,8 @@ public class MainUtil { * @param msg Was used to wrap the chat client length (Packets out--) */ public static void sendMessageWrapped(final PlotPlayer plr, String msg) { - if (msg.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) { - final String[] ss = ChatPaginator.wordWrap(msg, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH); + if (msg.length() > 65) { + final String[] ss = wordWrap(msg, 65); final StringBuilder b = new StringBuilder(); for (final String p : ss) { b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n "); @@ -905,7 +980,6 @@ public class MainUtil { return new Plot(id, null, new ArrayList(), new ArrayList(), world); } - /** * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) * @param loc @@ -953,7 +1027,7 @@ public class MainUtil { } public static Plot getPlot(final Location loc) { - PlotId id = getPlotId(loc); + final PlotId id = getPlotId(loc); if (id == null) { return null; } From 28dcfaa8499fb8325d78a125dbcf41a3dcab3615 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 17:42:30 +1100 Subject: [PATCH 064/124] experimental permission caching --- .../plot/listeners/PlayerEvents_1_8.java | 2 ++ .../plot/object/BukkitPlayer.java | 32 +++++++++++++++++-- .../plot/util/MainUtil.java | 4 +-- .../plot/util/Permissions.java | 4 +-- 4 files changed, 36 insertions(+), 6 deletions(-) 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 5301f9cdd..104d670f9 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 @@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -23,6 +24,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); + PlotPlayer PlotPlayer = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(l)) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.road")) { BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index f69742be5..f07945649 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -1,5 +1,6 @@ package com.intellectualcrafters.plot.object; +import java.util.HashSet; import java.util.UUID; import org.bukkit.entity.Player; @@ -12,6 +13,9 @@ public class BukkitPlayer implements PlotPlayer { public final Player player; UUID uuid; String name; + private HashSet hasPerm; + private HashSet noPerm; + private int op = 0; public BukkitPlayer(Player player, String name, UUID uuid) { @@ -39,7 +43,19 @@ public class BukkitPlayer implements PlotPlayer { @Override public boolean hasPermission(String perm) { - return player.hasPermission(perm); + if (noPerm.contains(perm)) { + return false; + } + if (hasPerm.contains(perm)) { + return true; + } + boolean result = player.hasPermission(perm); + if (!result) { + noPerm.add(perm); + return false; + } + hasPerm.add(perm); + return true; } @Override @@ -55,7 +71,19 @@ public class BukkitPlayer implements PlotPlayer { @Override public boolean isOp() { - return this.player.isOp(); + if (this.op != 0) { + if (this.op == 1) { + return false; + } + return true; + } + boolean result = this.player.isOp(); + if (!result) { + this.op = 1; + return false; + } + this.op = 2; + return true; } @Override 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 14d23a3f1..6cc38eecc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -1022,8 +1022,8 @@ public class MainUtil { * @param p * @return */ - public static int getAllowedPlots(final PlotPlayer p) { - return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); + public static int getAllowedPlots(final PlotPlayer p, int current) { + return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS, current); } public static Plot getPlot(final Location loc) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index bbb3bc475..9b3514a29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -36,14 +36,14 @@ public class Permissions { return false; } - public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { + public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range, final int min) { if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) { return Byte.MAX_VALUE; } if (player.hasPermission(stub + ".*")) { return Byte.MAX_VALUE; } - for (int i = range; i > 0; i--) { + for (int i = min; i < range; i++) { if (player.hasPermission(stub + "." + i)) { return i; } From f3a0837a296c0019fed873ec978ae04683ecf758 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 17:47:12 +1100 Subject: [PATCH 065/124] lmksad --- .../plot/listeners/PlayerEvents.java | 127 +++++++++--------- .../plot/listeners/PlayerEvents_1_8.java | 15 +-- 2 files changed, 72 insertions(+), 70 deletions(-) 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 47ed05078..61fd47bee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -346,25 +346,26 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = (Player) e; final Location loc = BukkitUtil.getLocation(b.getLocation()); if (!isInPlot(loc)) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(p, "plots.admin.build.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + if (!Permissions.hasPermission(p, "plots.admin.build.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } } else { final UUID uuid = UUIDHandler.getUUID(p); if (!plot.isAdded(uuid)) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { + if (!Permissions.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; } @@ -636,24 +637,27 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(p, "plots.admin.build.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(p, "plots.admin.build.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } } else { UUID uuid = UUIDHandler.getUUID(p); - if (!plot.isAdded(uuid)) if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!plot.isAdded(uuid)) if (!Permissions.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -670,9 +674,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(q)) { if (isInPlot(q)) { final Plot plot = getCurrentPlot(q); - if (plot.isDenied(player)) { - BukkitPlayerFunctions.sendMessage(player, C.YOU_BE_DENIED); + BukkitUtil.sendMessage(player, C.YOU_BE_DENIED); event.setCancelled(true); return; } else { @@ -701,19 +704,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (BukkitMain.hasPermission(p, "plots.admin.build.road")) { + if (Permissions.hasPermission(p, "plots.admin.build.road")) { return; } - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { + if (Permissions.hasPermission(p, "plots.admin.build.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } else if (!plot.isAdded(e.getPlayer())) { @@ -721,11 +724,11 @@ 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 (BukkitMain.hasPermission(p, "plots.admin.build.other")) { + if (Permissions.hasPermission(p, "plots.admin.build.other")) { return; } if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -767,19 +770,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (BukkitMain.hasPermission(p, "plots.admin.build.road")) { + if (Permissions.hasPermission(p, "plots.admin.build.road")) { return; } - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { + if (Permissions.hasPermission(p, "plots.admin.build.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } else if (!plot.isAdded(e.getPlayer())) { @@ -788,11 +791,11 @@ 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 (BukkitMain.hasPermission(p, "plots.admin.build.other")) { + if (Permissions.hasPermission(p, "plots.admin.build.other")) { return; } if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -808,16 +811,16 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(loc)) { final Player p = e.getPlayer(); if (!isInPlot(loc)) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + if (!Permissions.hasPermission(p, "plots.admin.build.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.build.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + if (!Permissions.hasPermission(p, "plots.admin.build.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } @@ -825,9 +828,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) { return; } - if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { + if (!Permissions.hasPermission(p, "plots.admin.build.other")) { if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -845,16 +848,16 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location l = e.getEntity().getLocation(); if (isPlotWorld(l)) { if (!isInPlot(l)) { - if (!BukkitMain.hasPermission(p, "plots.admin.destroy.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.road"); + if (!Permissions.hasPermission(p, "plots.admin.destroy.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.destroy.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); + if (!Permissions.hasPermission(p, "plots.admin.destroy.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); e.setCancelled(true); return; } @@ -862,9 +865,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { return; } - if (!BukkitMain.hasPermission(p, "plots.admin.destroy.other")) { + if (!Permissions.hasPermission(p, "plots.admin.destroy.other")) { if (isPlotArea(l)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.other"); e.setCancelled(true); return; } @@ -881,16 +884,16 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { - if (!BukkitMain.hasPermission(p, "plots.admin.interact.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); + if (!Permissions.hasPermission(p, "plots.admin.interact.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); + if (!Permissions.hasPermission(p, "plots.admin.interact.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); return; } @@ -908,9 +911,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((entity instanceof RideableMinecart) && FlagManager.isPlotFlagTrue(plot, "vehicle-use")) { return; } - if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { + if (!Permissions.hasPermission(p, "plots.admin.interact.other")) { if (isPlotArea(l)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); return; } @@ -929,16 +932,16 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = (Player) d; final PlotWorld pW = getPlotWorld(l.getWorld()); if (!isInPlot(l)) { - if (!BukkitMain.hasPermission(p, "plots.admin.vehicle.break.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); + if (!Permissions.hasPermission(p, "plots.admin.vehicle.break.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.vehicle.break.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); + if (!Permissions.hasPermission(p, "plots.admin.vehicle.break.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); e.setCancelled(true); return; } @@ -948,9 +951,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) { return; } - if (!BukkitMain.hasPermission(p, "plots.admin.vehicle.break.other")) { + if (!Permissions.hasPermission(p, "plots.admin.vehicle.break.other")) { if (isPlotArea(l)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); e.setCancelled(true); return; } @@ -984,16 +987,16 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!isInPlot(l)) { - if (!BukkitMain.hasPermission(p, "plots.admin.pve.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.road"); + if (!Permissions.hasPermission(p, "plots.admin.pve.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.pve.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.unowned"); + if (!Permissions.hasPermission(p, "plots.admin.pve.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.unowned"); e.setCancelled(true); return; } @@ -1015,9 +1018,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((a instanceof Tameable) && ((Tameable) a).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-attack")) { return; } - if (!BukkitMain.hasPermission(p, "plots.admin.pve.other")) { + if (!Permissions.hasPermission(p, "plots.admin.pve.other")) { if (isPlotArea(l)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.other"); e.setCancelled(true); return; } @@ -1037,23 +1040,23 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { - if (!BukkitMain.hasPermission(p, "plots.admin.projectile.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.road"); + if (!Permissions.hasPermission(p, "plots.admin.projectile.road")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.road"); e.setHatching(false); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.projectile.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.unowned"); + if (!Permissions.hasPermission(p, "plots.admin.projectile.unowned")) { + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.unowned"); e.setHatching(false); return; } } else if (!plot.isAdded(p)) { - if (!BukkitMain.hasPermission(p, "plots.admin.projectile.other")) { + if (!Permissions.hasPermission(p, "plots.admin.projectile.other")) { if (isPlotArea(l)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); + BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); e.setHatching(false); return; } 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 104d670f9..e4abd498e 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 @@ -8,13 +8,12 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -26,23 +25,23 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { final Player p = e.getPlayer(); PlotPlayer PlotPlayer = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(l)) { - if (!BukkitMain.hasPermission(p, "plots.admin.interact.road")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); + if (!Permissions.hasPermission(PlotPlayer, "plots.admin.interact.road")) { + MainUtil.sendMessage(PlotPlayer, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); } } else { final Plot plot = MainUtil.getPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); + if (!Permissions.hasPermission(PlotPlayer, "plots.admin.interact.unowned")) { + MainUtil.sendMessage(PlotPlayer, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); } } else { UUID uuid = UUIDHandler.getUUID(p); if (!plot.isAdded(uuid)) { - if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { + if (!Permissions.hasPermission(PlotPlayer, "plots.admin.interact.other")) { if (isPlotArea(l)) { - BukkitPlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); + MainUtil.sendMessage(PlotPlayer, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); } } From dfb56986b32936c38d33f0157da8cafac10ae6fe Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 18:01:37 +1100 Subject: [PATCH 066/124] pe --- .../plot/listeners/PlayerEvents.java | 248 ++++++++++-------- 1 file changed, 132 insertions(+), 116 deletions(-) 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 61fd47bee..abb5739a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -190,17 +190,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi passed = false; } if (passed) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.BORDER); + PlotPlayer pp = BukkitUtil.getPlayer(player); + MainUtil.sendMessage(pp, C.BORDER); return; } } Plot plot = getCurrentPlot(t); if (plot != null) { if (plot.denied.size() > 0) { - final UUID uuid = UUIDHandler.getUUID(player); - if (plot.isDenied(uuid)) { - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.entry.denied")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.entry.denied"); + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (plot.isDenied(pp.getUUID())) { + if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; } @@ -263,34 +264,36 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasOwner()) { - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.destroy.unowned")) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) { return; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.unowned"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.unowned"); event.setCancelled(true); return; } - final UUID uuid = UUIDHandler.getUUID(player); - if (!plot.isAdded(uuid)) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (!plot.isAdded(pp.getUUID())) { final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Block block = event.getBlock(); if ((destroy != null) && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.destroy.other")) { + if (Permissions.hasPermission(pp, "plots.admin.destroy.other")) { return; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.other"); event.setCancelled(true); return; } return; } - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.destroy.road")) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) { return; } if (isPlotArea(loc)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.road"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road"); event.setCancelled(true); return; } @@ -347,25 +350,26 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (!isInPlot(loc)) { PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!Permissions.hasPermission(p, "plots.admin.build.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(p, "plots.admin.build.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } } else { - final UUID uuid = UUIDHandler.getUUID(p); - if (!plot.isAdded(uuid)) { - if (!Permissions.hasPermission(p, "plots.admin.build.other")) { + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!plot.isAdded(pp.getUUID())) { + if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { if (isPlotArea(loc)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; } @@ -528,10 +532,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.unowned")) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { return; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.unowned"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); event.setCancelled(true); return; } @@ -539,22 +544,23 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - final UUID uuid = UUIDHandler.getUUID(player); - if (!plot.isAdded(uuid)) { - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.other")) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (!plot.isAdded(pp.getUUID())) { + if (Permissions.hasPermission(pp, "plots.admin.interact.other")) { return; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); event.setCancelled(true); return; } return; } - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.interact.road")) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (Permissions.hasPermission(pp, "plots.admin.interact.road")) { return; } if (isPlotArea(loc)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.road"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); event.setCancelled(true); return; } @@ -628,7 +634,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - Player player = e.getPlayer(); if (player == null) { if (isPlotArea(loc)) { e.setCancelled(true); @@ -638,8 +643,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = e.getPlayer(); if (!isInPlot(loc)) { PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!Permissions.hasPermission(p, "plots.admin.build.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } @@ -647,17 +652,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!Permissions.hasPermission(p, "plots.admin.build.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } } else { UUID uuid = UUIDHandler.getUUID(p); PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!plot.isAdded(uuid)) if (!Permissions.hasPermission(p, "plots.admin.build.other")) { + if (!plot.isAdded(pp.getUUID())) if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { if (isPlotArea(loc)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -671,11 +676,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location f = BukkitUtil.getLocation(event.getFrom()); final Location t = BukkitUtil.getLocation(event.getTo()); final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ()); + Player player = event.getPlayer(); if (isPlotWorld(q)) { if (isInPlot(q)) { final Plot plot = getCurrentPlot(q); - if (plot.isDenied(player)) { - BukkitUtil.sendMessage(player, C.YOU_BE_DENIED); + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (plot.isDenied(pp.getUUID())) { + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); event.setCancelled(true); return; } else { @@ -685,7 +692,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { if (leftPlot(f, t)) { - final Plot plot = getCurrentPlot(event.getFrom()); + final Plot plot = getCurrentPlot(f); plotExit(player, plot); } } @@ -702,33 +709,33 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { - final Player p = e.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(loc)) { - if (Permissions.hasPermission(p, "plots.admin.build.road")) { + if (Permissions.hasPermission(pp, "plots.admin.build.road")) { return; } - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (Permissions.hasPermission(p, "plots.admin.build.unowned")) { + if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) { return; } - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; - } else if (!plot.isAdded(e.getPlayer())) { + } else if (!plot.isAdded(pp.getUUID())) { final Flag use = FlagManager.getPlotFlag(plot, "use"); if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { return; } - if (Permissions.hasPermission(p, "plots.admin.build.other")) { + if (Permissions.hasPermission(pp, "plots.admin.build.other")) { return; } if (isPlotArea(loc)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -747,12 +754,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public static void onLeave(final PlayerQuitEvent event) { - if (Setup.setupMap.containsKey(player.getName())) { - Setup.setupMap.remove(player.getName()); + String name = event.getPlayer().getName(); + if (Setup.setupMap.containsKey(name)) { + Setup.setupMap.remove(name); } - BukkitUtil.removePlayer(player.getName()); + BukkitUtil.removePlayer(name); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { - final Collection plots = PlotSquared.getPlots(player.getName()).values(); + final Collection plots = PlotSquared.getPlots(name).values(); for (final Plot plot : plots) { final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); final PlotManager manager = PlotSquared.getPlotManager(plot.world); @@ -769,33 +777,34 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(loc)) { - if (Permissions.hasPermission(p, "plots.admin.build.road")) { + if (Permissions.hasPermission(pp, "plots.admin.build.road")) { return; } - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (Permissions.hasPermission(p, "plots.admin.build.unowned")) { + if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) { return; } - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; - } else if (!plot.isAdded(e.getPlayer())) { + } else if (!plot.isAdded(pp.getUUID())) { final Flag use = FlagManager.getPlotFlag(plot, "use"); final Block block = e.getBlockClicked(); if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - if (Permissions.hasPermission(p, "plots.admin.build.other")) { + if (Permissions.hasPermission(pp, "plots.admin.build.other")) { return; } if (isPlotArea(loc)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -810,27 +819,28 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(loc)) { - if (!Permissions.hasPermission(p, "plots.admin.build.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); + if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(p, "plots.admin.build.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); + if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } - } else if (!plot.isAdded(p)) { + } else if (!plot.isAdded(pp.getUUID())) { if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) { return; } - if (!Permissions.hasPermission(p, "plots.admin.build.other")) { + if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { if (isPlotArea(loc)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; } @@ -845,29 +855,30 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Entity r = e.getRemover(); if (r instanceof Player) { final Player p = (Player) r; - final Location l = e.getEntity().getLocation(); + final Location l = BukkitUtil.getLocation(e.getEntity()); + PlotPlayer pp = BukkitUtil.getPlayer(p); if (isPlotWorld(l)) { if (!isInPlot(l)) { - if (!Permissions.hasPermission(p, "plots.admin.destroy.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.road"); + if (!Permissions.hasPermission(pp, "plots.admin.destroy.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(p, "plots.admin.destroy.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); + if (!Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.unowned"); e.setCancelled(true); return; } - } else if (!plot.isAdded(p)) { + } else if (!plot.isAdded(pp.getUUID())) { if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { return; } - if (!Permissions.hasPermission(p, "plots.admin.destroy.other")) { + if (!Permissions.hasPermission(pp, "plots.admin.destroy.other")) { if (isPlotArea(l)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.other"); e.setCancelled(true); return; } @@ -880,24 +891,25 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { - final Location l = e.getRightClicked().getLocation(); + final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { - if (!Permissions.hasPermission(p, "plots.admin.interact.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road"); + if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(p, "plots.admin.interact.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); + if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); return; } - } else if (!plot.isAdded(p)) { + } else if (!plot.isAdded(pp.getUUID())) { final Entity entity = e.getRightClicked(); if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-interact")) { return; @@ -911,9 +923,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((entity instanceof RideableMinecart) && FlagManager.isPlotFlagTrue(plot, "vehicle-use")) { return; } - if (!Permissions.hasPermission(p, "plots.admin.interact.other")) { + if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { if (isPlotArea(l)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); return; } @@ -925,35 +937,36 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onVehicleDestroy(final VehicleDestroyEvent e) { - final Location l = e.getVehicle().getLocation(); + final Location l = BukkitUtil.getLocation(e.getVehicle()); if (isPlotWorld(l)) { final Entity d = e.getAttacker(); if (d instanceof Player) { final Player p = (Player) d; - final PlotWorld pW = getPlotWorld(l.getWorld()); + final PlotWorld pW = PlotSquared.getPlotWorld(l.getWorld()); + PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { - if (!Permissions.hasPermission(p, "plots.admin.vehicle.break.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); + if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(p, "plots.admin.vehicle.break.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); + if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); e.setCancelled(true); return; } return; } - if (!plot.isAdded(p)) { + if (!plot.isAdded(pp.getUUID())) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) { return; } - if (!Permissions.hasPermission(p, "plots.admin.vehicle.break.other")) { + if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) { if (isPlotArea(l)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); e.setCancelled(true); return; } @@ -966,7 +979,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { - final Location l = e.getEntity().getLocation(); + final Location l = BukkitUtil.getLocation(e.getEntity()); final Entity d = e.getDamager(); final Entity a = e.getEntity(); if ((Settings.TELEPORT_DELAY != 0) && (TaskManager.TELEPORT_QUEUE.size() > 0) && (a instanceof Player)) { @@ -980,23 +993,25 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (d instanceof Player) { final Player p = (Player) d; final boolean aPlr = a instanceof Player; - final PlotWorld pW = getPlotWorld(l.getWorld()); + final PlotWorld pW = PlotSquared.getPlotWorld(l.getWorld()); if (!aPlr && pW.PVE && (!(a instanceof ItemFrame) && !(a.getType().getTypeId() == 30))) { return; } else if (aPlr && pW.PVP) { return; } if (!isInPlot(l)) { - if (!Permissions.hasPermission(p, "plots.admin.pve.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.road"); + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(pp, "plots.admin.pve.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.road"); e.setCancelled(true); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(p, "plots.admin.pve.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.unowned"); + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(pp, "plots.admin.pve.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.unowned"); e.setCancelled(true); return; } @@ -1007,8 +1022,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } assert plot != null; - UUID uuid = UUIDHandler.getUUID(p); - if (!plot.isAdded(uuid)) { + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!plot.isAdded(pp.getUUID())) { if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { return; } @@ -1018,9 +1033,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((a instanceof Tameable) && ((Tameable) a).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-attack")) { return; } - if (!Permissions.hasPermission(p, "plots.admin.pve.other")) { + if (!Permissions.hasPermission(pp, "plots.admin.pve.other")) { if (isPlotArea(l)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.pve.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.other"); e.setCancelled(true); return; } @@ -1039,24 +1054,25 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location l = BukkitUtil.getLocation(e.getEgg().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { - if (!Permissions.hasPermission(p, "plots.admin.projectile.road")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.road"); + if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.road"); e.setHatching(false); return; } } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(p, "plots.admin.projectile.unowned")) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.unowned"); + if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.unowned"); e.setHatching(false); return; } - } else if (!plot.isAdded(p)) { - if (!Permissions.hasPermission(p, "plots.admin.projectile.other")) { + } else if (!plot.isAdded(pp.getUUID())) { + if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) { if (isPlotArea(l)) { - BukkitUtil.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.other"); e.setHatching(false); return; } @@ -1073,38 +1089,38 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin")) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (Permissions.hasPermission(pp, "plots.admin")) { return; } - final Player player = event.getPlayer(); final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.unowned")) { + if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) { return; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.unowned"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } - if (!plot.isAdded(player)) { + if (!plot.isAdded(pp.getUUID())) { final Flag place = FlagManager.getPlotFlag(plot, "place"); final Block block = event.getBlock(); if ((place != null) && ((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.other")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.other"); + if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; } } return; } - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.admin.build.road")) { + if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { if (isPlotArea(loc)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.road"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; } From 7514d3c5db5beedff85bba5ccd26ae157906747d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 18:05:30 +1100 Subject: [PATCH 067/124] PWE --- .../plot/listeners/WorldEditListener.java | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) 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 6eb7107c4..034cad330 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -47,7 +47,9 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; @@ -110,7 +112,7 @@ public class WorldEditListener implements Listener { final Plot plot = MainUtil.getPlot(loc); if (plot != null) { if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { - PWE.setMask(p, loc, false); + PWE.setMask(BukkitUtil.getPlayer(p), loc, false); } } } @@ -118,7 +120,8 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent e) { final Player p = e.getPlayer(); - if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || BukkitMain.hasPermission(p, "plots.worldedit.bypass")) { + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || Permissions.hasPermission(pp, "plots.worldedit.bypass")) { return; } String cmd = e.getMessage().toLowerCase(); @@ -149,16 +152,16 @@ public class WorldEditListener implements Listener { final LocalSession session = PlotSquared.worldEdit.getSession(p); final Mask mask = session.getMask(); if (mask == null) { - BukkitPlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Both points"); + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Both points"); return; } if (!mask.test(pos1)) { e.setCancelled(true); - BukkitPlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Position 1"); + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 1"); } if (!mask.test(pos2)) { e.setCancelled(true); - BukkitPlayerFunctions.sendMessage(p, C.REQUIRE_SELECTION_IN_MASK, "Position 2"); + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 2"); } } } @@ -168,17 +171,18 @@ public class WorldEditListener implements Listener { public void onPlayerJoin(final PlayerJoinEvent e) { final Player p = e.getPlayer(); final Location l = p.getLocation(); - if (BukkitMain.hasPermission(p, "plots.worldedit.bypass")) { + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (isPlotWorld(l)) { - PWE.removeMask(p); + PWE.removeMask(pp); } return; } if (isPlotWorld(l)) { com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(l); - PWE.setMask(p, loc, false); + PWE.setMask(pp, loc, false); } else { - PWE.removeMask(p); + PWE.removeMask(pp); } } @@ -190,7 +194,8 @@ public class WorldEditListener implements Listener { } final Location f = e.getFrom(); final Player p = e.getPlayer(); - if (BukkitMain.hasPermission(p, "plots.worldedit.bypass")) { + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (!PWE.hasMask(p)) { return; } @@ -201,37 +206,39 @@ public class WorldEditListener implements Listener { final PlotId idF = MainUtil.getPlotId(locf); final PlotId idT = MainUtil.getPlotId(loct); if ((idT != null) && !(idF == idT)) { - PWE.setMask(p, loct, false); + PWE.setMask(pp, loct, false); } } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPortal(final PlayerPortalEvent e) { - if (BukkitMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + Player p = e.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { return; } - final Player p = e.getPlayer(); final Location t = e.getTo(); final Location f = e.getFrom(); if (t == null) { - PWE.removeMask(p); + PWE.removeMask(pp); return; } if (isPlotWorld(t)) { com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); - PWE.setMask(p, loct, false); + PWE.setMask(pp, loct, false); return; } if ((f != null) && isPlotWorld(f)) { - PWE.removeMask(p); + PWE.removeMask(pp); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent e) { final Player p = e.getPlayer(); - if (BukkitMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + PlotPlayer pp = BukkitUtil.getPlayer(p); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (!PWE.hasMask(p)) { return; } @@ -241,11 +248,11 @@ public class WorldEditListener implements Listener { final Location f = e.getFrom(); if (!PlotSquared.isPlotWorld(loct.getWorld())) { if (isPlotWorld(f)) { - PWE.removeMask(p); + PWE.removeMask(pp); } return; } - PWE.setMask(p, loct, false); + PWE.setMask(pp, loct, false); } } From e3f7db4906188b65a6a2a46da3bb64b529398f8e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 18:25:28 +1100 Subject: [PATCH 068/124] listeners --- .../plot/listeners/PlotPlusListener.java | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) 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 c5181830c..3f78b6433 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -52,7 +52,9 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -107,13 +109,14 @@ public class PlotPlusListener extends PlotListener implements Listener { } event.setCancelled(true); final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); + PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); + MainUtil.sendMessage(pp, C.NOT_IN_PLOT); return; } UUID uuid = UUIDHandler.getUUID(player); if (!plot.isAdded(uuid)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PLOT_PERMS); + MainUtil.sendMessage(pp, C.NO_PLOT_PERMS); return; } final Set plotPlayers = new HashSet<>(); @@ -135,7 +138,7 @@ public class PlotPlusListener extends PlotListener implements Listener { } for (final Player p : plotPlayers) { p.playEffect(p.getLocation(), Effect.RECORD_PLAY, meta.getMaterial()); - BukkitPlayerFunctions.sendMessage(p, C.RECORD_PLAY.s().replaceAll("%player", player.getName()).replaceAll("%name", meta.toString())); + MainUtil.sendMessage(pp, C.RECORD_PLAY.s().replaceAll("%player", player.getName()).replaceAll("%name", meta.toString())); } } @@ -208,14 +211,16 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } final Player trespasser = event.getPlayer(); - if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(trespasser))) { + PlotPlayer pt = BukkitUtil.getPlayer(trespasser); + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (pp.getUUID().equals(pt.getUUID())) { return; } - if (BukkitMain.hasPermission(trespasser, "plots.flag.notify-enter.bypass")) { + if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) { return; } if (player.isOnline()) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + MainUtil.sendMessage(pp, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } } @@ -223,26 +228,31 @@ public class PlotPlusListener extends PlotListener implements Listener { @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { - if (feedRunnable.containsKey(player.getName())) { - feedRunnable.remove(player.getName()); + Player player = event.getPlayer(); + String name = player.getName(); + if (feedRunnable.containsKey(name)) { + feedRunnable.remove(name); } - if (healRunnable.containsKey(player.getName())) { - healRunnable.remove(player.getName()); + if (healRunnable.containsKey(name)) { + healRunnable.remove(name); } } @EventHandler public void onPlotLeave(final PlayerLeavePlotEvent event) { - event.getPlayer().playEffect(player.getLocation(), Effect.RECORD_PLAY, 0); + Player leaver = event.getPlayer(); + leaver.playEffect(leaver.getLocation(), Effect.RECORD_PLAY, 0); final Plot plot = event.getPlot(); if (FlagManager.getPlotFlag(plot, "farewell") != null) { event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString())); } - if (feedRunnable.containsKey(player.getName())) { - feedRunnable.remove(player.getName()); + PlotPlayer pl = BukkitUtil.getPlayer(leaver); + String name = pl.getName(); + if (feedRunnable.containsKey(leaver)) { + feedRunnable.remove(leaver); } - if (healRunnable.containsKey(player.getName())) { - healRunnable.remove(player.getName()); + if (healRunnable.containsKey(leaver)) { + healRunnable.remove(leaver); } if (booleanFlag(plot, "notify-leave", false)) { if (plot.hasOwner()) { @@ -250,15 +260,15 @@ public class PlotPlusListener extends PlotListener implements Listener { if (player == null) { return; } - final Player trespasser = event.getPlayer(); - if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(trespasser))) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + if (pp.getUUID().equals(pl.getUUID())) { return; } - if (BukkitMain.hasPermission(trespasser, "plots.flag.notify-leave.bypass")) { + if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) { return; } if (player.isOnline()) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOTIFY_LEAVE.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + MainUtil.sendMessage(pp, C.NOTIFY_LEAVE.s().replace("%player", pl.getName()).replace("%plot", plot.getId().toString())); } } } From 83f7aa544d8895e726d2a7b6cfa7212ab09f8ab4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 18:30:55 +1100 Subject: [PATCH 069/124] cmds --- .../java/com/intellectualcrafters/plot/commands/Auto.java | 2 +- .../main/java/com/intellectualcrafters/plot/commands/Ban.java | 2 +- .../main/java/com/intellectualcrafters/plot/commands/Buy.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Claim.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Clear.java | 2 +- .../com/intellectualcrafters/plot/commands/Clipboard.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Cluster.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Comment.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Condense.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Copy.java | 2 +- .../plot/commands/CreateRoadSchematic.java | 2 +- .../java/com/intellectualcrafters/plot/commands/DEOP.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Database.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Debug.java | 2 +- .../intellectualcrafters/plot/commands/DebugClaimTest.java | 2 +- .../com/intellectualcrafters/plot/commands/DebugClear.java | 2 +- .../com/intellectualcrafters/plot/commands/DebugExec.java | 2 +- .../com/intellectualcrafters/plot/commands/DebugFixFlags.java | 2 +- .../com/intellectualcrafters/plot/commands/DebugLoadTest.java | 2 +- .../intellectualcrafters/plot/commands/DebugRoadRegen.java | 2 +- .../com/intellectualcrafters/plot/commands/DebugSaveTest.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Delete.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Denied.java | 2 +- .../java/com/intellectualcrafters/plot/commands/FlagCmd.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Help.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Helpers.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Home.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Inbox.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Info.java | 2 +- .../com/intellectualcrafters/plot/commands/Inventory.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Kick.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Merge.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Move.java | 2 +- .../intellectualcrafters/plot/commands/MusicSubcommand.java | 2 +- .../main/java/com/intellectualcrafters/plot/commands/OP.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Paste.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Purge.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Rate.java | 2 +- .../com/intellectualcrafters/plot/commands/RegenAllRoads.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Reload.java | 2 +- .../com/intellectualcrafters/plot/commands/Schematic.java | 2 +- .../main/java/com/intellectualcrafters/plot/commands/Set.java | 2 +- .../java/com/intellectualcrafters/plot/commands/SetOwner.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Setup.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Swap.java | 2 +- .../main/java/com/intellectualcrafters/plot/commands/TP.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Target.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Template.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Trim.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Trusted.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Unban.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Unclaim.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Unlink.java | 4 ++-- .../java/com/intellectualcrafters/plot/commands/Visit.java | 2 +- .../com/intellectualcrafters/plot/commands/WE_Anywhere.java | 3 ++- .../java/com/intellectualcrafters/plot/commands/list.java | 2 +- .../java/com/intellectualcrafters/plot/commands/plugin.java | 2 +- 57 files changed, 59 insertions(+), 58 deletions(-) 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 df81089b7..db3cf7333 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -76,7 +76,7 @@ public class Auto extends SubCommand { // TODO auto claim a mega plot with schematic @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { World world; int size_x = 1; int size_z = 1; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java index b8ea0de8c..77b14d668 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java @@ -17,7 +17,7 @@ public class Ban extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } 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 a757c88b1..d416a13df 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -46,7 +46,7 @@ public class Buy extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!PlotSquared.useEconomy) { return sendMessage(plr, C.ECON_DISABLED); } 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 1e2604998..cc53a7017 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -83,7 +83,7 @@ public class Claim extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { String schematic = ""; if (args.length >= 1) { schematic = args[0]; 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 ef54fc659..d74c1f50e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -38,7 +38,7 @@ public class Clear extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { // Is console if (args.length < 2) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java index 4cb00e79b..7dea2cae8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java @@ -32,7 +32,7 @@ public class Clipboard extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!currentSelection.containsKey(plr.getName())) { return sendMessage(plr, C.NO_CLIPBOARD); } 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 e2377d85a..bc66f6e7c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -51,7 +51,7 @@ public class Cluster extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome if (args.length == 0) { // return arguments 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 a1272e78a..b84ba14ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -39,7 +39,7 @@ public class Comment extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } 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 5b61ac92b..4e3d2b5e7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -46,7 +46,7 @@ public class Condense extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; 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 951e55ceb..bee9fc59b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -35,7 +35,7 @@ public class Copy extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); 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 8c30f8dfc..2c52265ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -36,7 +36,7 @@ public class CreateRoadSchematic extends SubCommand { } @Override - public boolean execute(final Player player, final String... args) { + public boolean execute(final PlotPlayer player, final String... args) { if (!BukkitPlayerFunctions.isInPlot(player)) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java index bd055260b..3c8136c0e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java @@ -17,7 +17,7 @@ public class DEOP extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } 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 b57efa460..5170c15e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -71,7 +71,7 @@ public class Database extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { return sendMessage(plr, "/plot database [sqlite/mysql]"); } 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 65716a4d4..e58249162 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -37,7 +37,7 @@ public class Debug extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { final StringBuilder msg = new StringBuilder(); for (final C c : C.values()) { 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 b8552ff9d..e4532c5c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -73,7 +73,7 @@ public class DebugClaimTest extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { if (args.length < 3) { return !BukkitPlayerFunctions.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}"); 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 b2aa400a2..6126d374a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -42,7 +42,7 @@ public class DebugClear extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { // Is console if (args.length < 2) { 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 3dc5767e7..bfcf6e597 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -50,7 +50,7 @@ public class DebugExec extends SubCommand { } @Override - public boolean execute(final Player player, final String... args) { + public boolean execute(final PlotPlayer player, final String... args) { final List allowed_params = Arrays.asList(new String[] { "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check" }); if (args.length > 0) { final String arg = args[0].toLowerCase(); 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 156b96f32..f2ce2ad51 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -42,7 +42,7 @@ public class DebugFixFlags extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { BukkitPlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java index d45698f46..7a9e7a673 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -37,7 +37,7 @@ public class DebugLoadTest extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { try { final Field fPlots = PlotSquared.class.getDeclaredField("plots"); 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 f5f47d33a..2085f7702 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -38,7 +38,7 @@ public class DebugRoadRegen extends SubCommand { } @Override - public boolean execute(final Player player, final String... args) { + public boolean execute(final PlotPlayer player, final String... args) { if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } 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 a1d956532..9b9c49bc7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -38,7 +38,7 @@ public class DebugSaveTest extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { final ArrayList plots = new ArrayList(); plots.addAll(PlotSquared.getPlots()); 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 b27c20dc2..50c603058 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -39,7 +39,7 @@ public class Delete extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { return !sendMessage(plr, C.NOT_IN_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 12c2730a5..f24c010e2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -40,7 +40,7 @@ public class Denied extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { BukkitPlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); 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 1111822c6..a67c73fe0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -44,7 +44,7 @@ public class FlagCmd extends SubCommand { } @Override - public boolean execute(final Player player, final String... args) { + public boolean execute(final PlotPlayer player, final String... args) { /* * plot flag set fly true * plot flag remove fly diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java index e8dac809a..1f6879a41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java @@ -15,7 +15,7 @@ public class Help extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { 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 64a8d5c2f..7f545edff 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -39,7 +39,7 @@ public class Helpers extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { BukkitPlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); 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 832007503..4578173a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -46,7 +46,7 @@ public class Home extends SubCommand { } @Override - public boolean execute(final Player plr, String... args) { + public boolean execute(final PlotPlayer plr, String... args) { final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]); if (plots.length == 1) { PlotSquared.teleportPlayer(plr, plr.getLocation(), plots[0]); 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 4fb2cc82c..b0be4d72c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -43,7 +43,7 @@ public class Inbox extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { boolean report = false; if (args.length == 1) { if (args[0].equalsIgnoreCase("reports")) { 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 459e70ea2..d0d6f6734 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -52,7 +52,7 @@ public class Info extends SubCommand { } @Override - public boolean execute(final Player player, String... args) { + public boolean execute(final PlotPlayer player, String... args) { World world; Plot plot; if (player != null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java index 119c75766..21bde1b6a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java @@ -35,7 +35,7 @@ public class Inventory extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { final ArrayList cmds = new ArrayList<>(); for (final SubCommand cmd : MainCommand.subCommands) { if (cmd.permission.hasPermission(plr)) { 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 7be8d38dd..ffb5d1ba4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -36,7 +36,7 @@ public class Kick extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { BukkitPlayerFunctions.sendMessage(plr, "You're not in a plot."); return false; 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 de582fdf9..eb4d94d4a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -74,7 +74,7 @@ public class Merge extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return true; 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 485e59fe7..d2e3303cd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -38,7 +38,7 @@ public class Move extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { BukkitPlayerFunctions.sendMessage(plr, "MUST BE EXECUTED BY PLAYER"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index a261ef6ed..eb16571f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -39,7 +39,7 @@ public class MusicSubcommand extends SubCommand { } @Override - public boolean execute(final Player player, final String... args) { + public boolean execute(final PlotPlayer player, final String... args) { if (!BukkitPlayerFunctions.isInPlot(player)) { sendMessage(player, C.NOT_IN_PLOT); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java index 4dd26c6df..0eae5aa07 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java @@ -17,7 +17,7 @@ public class OP extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } 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 7d165a62f..14f740509 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -35,7 +35,7 @@ public class Paste extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); 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 14baa41c5..a0998e0b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -53,7 +53,7 @@ public class Purge extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index adf401365..eeed3d23f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -39,7 +39,7 @@ public class Rate extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { sendMessage(plr, C.RATING_NOT_VALID); return true; 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 b93c3cfeb..8dfade597 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -39,7 +39,7 @@ public class RegenAllRoads extends SubCommand { } @Override - public boolean execute(final Player player, final String... args) { + public boolean execute(final PlotPlayer player, final String... args) { if (player != null) { sendMessage(player, C.NOT_CONSOLE); 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 cf82c6376..54b8159fe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -34,7 +34,7 @@ public class Reload extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { try { // The following won't affect world generation, as that has to be // loaded during startup unfortunately. 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 61920af69..f3893f799 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -55,7 +55,7 @@ public class Schematic extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); return true; 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 3e142d6d0..af1a7751b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -64,7 +64,7 @@ public class Set extends SubCommand { @SuppressWarnings("deprecation") @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index ddfe50082..ea00c912b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -51,7 +51,7 @@ public class SetOwner extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || (plot.owner == null)) { BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_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 64344c33e..826e8fd98 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -84,7 +84,7 @@ public class Setup extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { // going through setup final String name = plr.getName(); if (!setupMap.containsKey(name)) { 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 5a71ea0a5..fb3955a3e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -44,7 +44,7 @@ public class Swap extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { BukkitPlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); 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 5dace5842..fe2220419 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -41,7 +41,7 @@ public class TP extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { BukkitPlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); return false; 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 957aa2f92..22ce9cd21 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -35,7 +35,7 @@ public class Target extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!PlotSquared.isPlotWorld(plr.getWorld())) { BukkitPlayerFunctions.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 55068666f..99817ab8e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -40,7 +40,7 @@ public class Template extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length != 2) { BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); 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 612baa903..c81645695 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -61,7 +61,7 @@ public class Trim extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; 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 c91a0df17..0caafc005 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -40,7 +40,7 @@ public class Trusted extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java index e36dc937b..ee7cd9210 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java @@ -17,7 +17,7 @@ public class Unban extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); } 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 ea0fe0d55..aa0f11999 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -40,7 +40,7 @@ public class Unclaim extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { return !sendMessage(plr, C.NOT_IN_PLOT); } 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 0f3159866..91b4ac28c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -50,7 +50,7 @@ public class Unlink extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } @@ -69,7 +69,7 @@ public class Unlink extends SubCommand { try { MainUtil.update(plr.getLocation()); } catch (final Exception e) { - // execute(final Player plr, final String... args) { + // execute(final PlotPlayer plr, final String... args) { try { PlotSquared.log("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); } catch (final Exception ex) { 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 46bf43db5..ab06001db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -47,7 +47,7 @@ public class Visit extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { return sendMessage(plr, C.NEED_USER); } 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 b7688645f..c0f6f582a 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 @@ -24,6 +24,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.PWE; @@ -33,7 +34,7 @@ public class WE_Anywhere extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (PlotSquared.worldEdit == null) { BukkitPlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); return false; 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 a614872c7..694fee96c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -56,7 +56,7 @@ public class list extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { final StringBuilder builder = new StringBuilder(); builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); 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 2f3baee99..4136ab8ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -89,7 +89,7 @@ public class plugin extends SubCommand { } @Override - public boolean execute(final Player plr, final String... args) { + public boolean execute(final PlotPlayer plr, final String... args) { Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { @Override public void run() { From cf1ebdb6c8bd7e58d8797785e093756e2a9a32fe Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 22:24:46 +1100 Subject: [PATCH 070/124] ksdajl --- .../plot/commands/Auto.java | 32 +-- .../plot/commands/Ban.java | 2 +- .../plot/commands/Buy.java | 2 +- .../plot/commands/Claim.java | 2 +- .../plot/commands/Clear.java | 2 +- .../plot/commands/Clipboard.java | 2 +- .../plot/commands/Cluster.java | 192 +++++++++--------- .../plot/commands/Comment.java | 2 +- .../plot/commands/Condense.java | 46 ++--- .../plot/commands/Copy.java | 8 +- .../plot/commands/DEOP.java | 2 +- .../plot/commands/Database.java | 2 +- .../plot/commands/Debug.java | 4 +- .../plot/commands/DebugClaimTest.java | 24 +-- .../plot/commands/DebugClear.java | 8 +- .../plot/commands/DebugExec.java | 48 ++--- .../plot/commands/DebugFixFlags.java | 10 +- .../plot/commands/DebugLoadTest.java | 2 +- .../plot/commands/DebugSaveTest.java | 2 +- .../plot/commands/Delete.java | 4 +- .../plot/commands/Denied.java | 26 +-- .../plot/commands/Helpers.java | 26 +-- .../plot/commands/Home.java | 8 +- .../plot/commands/Inbox.java | 30 +-- .../plot/commands/Info.java | 2 +- .../plot/commands/Kick.java | 12 +- .../plot/commands/Merge.java | 22 +- .../plot/commands/Move.java | 12 +- .../plot/commands/OP.java | 2 +- .../plot/commands/Paste.java | 8 +- .../plot/commands/Purge.java | 30 +-- .../plot/commands/Reload.java | 2 +- .../plot/commands/Schematic.java | 46 ++--- .../plot/commands/Set.java | 62 +++--- .../plot/commands/SetOwner.java | 12 +- .../plot/commands/Setup.java | 20 +- .../plot/commands/Swap.java | 26 +-- .../plot/commands/TP.java | 6 +- .../plot/commands/Target.java | 8 +- .../plot/commands/Template.java | 8 +- .../plot/commands/Trim.java | 14 +- .../plot/commands/Trusted.java | 26 +-- .../plot/commands/Unban.java | 2 +- .../plot/commands/Unclaim.java | 6 +- .../plot/commands/Unlink.java | 6 +- .../plot/commands/WE_Anywhere.java | 8 +- .../plot/commands/list.java | 16 +- .../plot/commands/plugin.java | 2 +- 48 files changed, 422 insertions(+), 422 deletions(-) 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 db3cf7333..ec9a4c593 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; @@ -77,31 +78,30 @@ public class Auto extends SubCommand { // TODO auto claim a mega plot with schematic @Override public boolean execute(final PlotPlayer plr, final String... args) { - World world; + String world; int size_x = 1; int size_z = 1; String schematic = ""; if (PlotSquared.getPlotWorlds().size() == 1) { - world = Bukkit.getWorld(PlotSquared.getPlotWorlds().iterator().next()); + world = PlotSquared.getPlotWorlds().iterator().next(); } else { - if (PlotSquared.isPlotWorld(plr.getWorld().getName())) { - world = plr.getWorld(); - } else { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + world = plr.getLocation().getWorld(); + if (!PlotSquared.isPlotWorld(world)) { + MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } } if (args.length > 0) { - if (BukkitMain.hasPermission(plr, "plots.auto.mega")) { + if (Permissions.hasPermission(plr, "plots.auto.mega")) { try { final String[] split = args[0].split(","); size_x = Integer.parseInt(split[0]); size_z = Integer.parseInt(split[1]); if ((size_x < 1) || (size_z < 1)) { - BukkitPlayerFunctions.sendMessage(plr, "&cError: size<=0"); + MainUtil.sendMessage(plr, "&cError: size<=0"); } if ((size_x > 4) || (size_z > 4)) { - BukkitPlayerFunctions.sendMessage(plr, "&cError: size>4"); + MainUtil.sendMessage(plr, "&cError: size>4"); } if (args.length > 1) { schematic = args[1]; @@ -121,15 +121,15 @@ public class Auto extends SubCommand { } } if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) { - BukkitPlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); + MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); return false; } final int diff = BukkitPlayerFunctions.getPlayerPlotCount(world, plr) - BukkitPlayerFunctions.getAllowedPlots(plr); if ((diff + (size_x * size_z)) > 0) { if (diff < 0) { - BukkitPlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); + MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); } else { - BukkitPlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); + MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } return false; } @@ -153,8 +153,8 @@ public class Auto extends SubCommand { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return true; } - if (!BukkitMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); + if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { + MainUtil.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return true; } // } @@ -170,7 +170,7 @@ public class Auto extends SubCommand { final PlotCluster cluster = ClusterManager.getCluster(loc); // Must be standing in a cluster if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } final PlotId bot = cluster.getP1(); @@ -190,7 +190,7 @@ public class Auto extends SubCommand { id = getNextPlot(id, 1); } // no free plots - BukkitPlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS); + MainUtil.sendMessage(plr, C.NO_FREE_PLOTS); return false; } boolean br = false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java index 77b14d668..4a3486b5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java @@ -19,7 +19,7 @@ public class Ban extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { - return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); } if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); 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 d416a13df..d474eacd2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -108,7 +108,7 @@ public class Buy extends SubCommand { } plot.owner = UUIDHandler.getUUID(plr); DBFunc.setOwner(plot, plot.owner); - BukkitPlayerFunctions.sendMessage(plr, C.CLAIMED); + MainUtil.sendMessage(plr, C.CLAIMED); return true; } } 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 cc53a7017..15ed083de 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -115,7 +115,7 @@ public class Claim extends SubCommand { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); } - if (!BukkitMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { + if (!Permissions.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 d74c1f50e..e259a8517 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -71,7 +71,7 @@ public class Clear extends SubCommand { if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.clear")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.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/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java index 7dea2cae8..1db72f37d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java @@ -42,7 +42,7 @@ public class Clipboard extends SubCommand { final int total = selection.getBlocks().length; String message = C.CLIPBOARD_INFO.s(); message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + ""); - BukkitPlayerFunctions.sendMessage(plr, message); + MainUtil.sendMessage(plr, message); return true; } } 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 bc66f6e7c..259f546e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -55,62 +55,62 @@ public class Cluster extends SubCommand { // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome if (args.length == 0) { // return arguments - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); + MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); return false; } final String sub = args[0].toLowerCase(); switch (sub) { case "l": case "list": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.list")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.list"); + if (!Permissions.hasPermission(plr, "plots.cluster.list")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.list"); return false; } if (args.length != 1) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list"); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list"); return false; } final HashSet clusters = ClusterManager.getClusters(plr.getWorld()); - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); + MainUtil.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); for (final PlotCluster cluster : clusters) { // Ignore unmanaged clusters final String name = "'" + cluster.getName() + "' : " + cluster.toString(); if (UUIDHandler.getUUID(plr).equals(cluster.owner)) { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name); + MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name); } else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name); + MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name); } else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name); + MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name); } else { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString()); + MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString()); } } return true; } case "c": case "create": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.create")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create"); + if (!Permissions.hasPermission(plr, "plots.cluster.create")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create"); return false; } if (args.length != 4) { final PlotId id = ClusterManager.estimatePlotId(plr.getLocation()); - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create "); - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create "); + MainUtil.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id); return false; } // check pos1 / pos2 final PlotId pos1 = MainUtil.parseId(args[2]); final PlotId pos2 = MainUtil.parseId(args[3]); if ((pos1 == null) || (pos2 == null)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } // check if name is taken final String name = args[1]; for (final PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) { if (name.equals(cluster.getName())) { - BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); + MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } } @@ -118,7 +118,7 @@ public class Cluster extends SubCommand { final PlotClusterId id = new PlotClusterId(pos1, pos2); final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); if ((intersects.size() > 0) || (pos2.x < pos1.x) || (pos2.y < pos1.y)) { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + ""); + MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + ""); return false; } // create cluster @@ -142,37 +142,37 @@ public class Cluster extends SubCommand { PlotSquared.config.createSection("worlds." + world); PlotSquared.loadWorld(plr.getWorld()); } - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED); + MainUtil.sendMessage(plr, C.CLUSTER_ADDED); return true; } case "disband": case "del": case "delete": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.delete")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); + if (!Permissions.hasPermission(plr, "plots.cluster.delete")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); return false; } if ((args.length != 1) && (args.length != 2)) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { - if (!BukkitMain.hasPermission(plr, "plots.cluster.delete.other")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); + if (!Permissions.hasPermission(plr, "plots.cluster.delete.other")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); return false; } } @@ -205,35 +205,35 @@ public class Cluster extends SubCommand { ClusterManager.last = null; ClusterManager.clusters.get(cluster.world).remove(cluster); ClusterManager.regenCluster(cluster); - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_DELETED); + MainUtil.sendMessage(plr, C.CLUSTER_DELETED); return true; } case "res": case "resize": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.resize")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize"); + if (!Permissions.hasPermission(plr, "plots.cluster.resize")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize"); return false; } if (args.length != 3) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster resize "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster resize "); return false; } // check pos1 / pos2 final PlotId pos1 = MainUtil.parseId(args[1]); final PlotId pos2 = MainUtil.parseId(args[2]); if ((pos1 == null) || (pos2 == null)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } // check if in cluster final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!BukkitMain.hasPermission(plr, "plots.cluster.resize.other")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other"); + if (!Permissions.hasPermission(plr, "plots.cluster.resize.other")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other"); return false; } } @@ -241,76 +241,76 @@ public class Cluster extends SubCommand { final PlotClusterId id = new PlotClusterId(pos1, pos2); final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); if (intersects.size() > 1) { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + ""); + MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + ""); return false; } // resize cluster DBFunc.resizeCluster(cluster, id); - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_RESIZED); + MainUtil.sendMessage(plr, C.CLUSTER_RESIZED); return true; } case "reg": case "regenerate": case "regen": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.delete")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen"); + if (!Permissions.hasPermission(plr, "plots.cluster.delete")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen"); return false; } if ((args.length != 1) && (args.length != 2)) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]"); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { - if (!BukkitMain.hasPermission(plr, "plots.cluster.regen.other")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen.other"); + if (!Permissions.hasPermission(plr, "plots.cluster.regen.other")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen.other"); return false; } } ClusterManager.regenCluster(cluster); - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_REGENERATED); + MainUtil.sendMessage(plr, C.CLUSTER_REGENERATED); return true; } case "add": case "inv": case "invite": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.invite")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite"); + if (!Permissions.hasPermission(plr, "plots.cluster.invite")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite"); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster invite "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster invite "); return false; } // check if in cluster final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!BukkitMain.hasPermission(plr, "plots.cluster.invite.other")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other"); + if (!Permissions.hasPermission(plr, "plots.cluster.invite.other")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other"); return false; } } // check uuid final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!cluster.hasRights(uuid)) { @@ -323,40 +323,40 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLUSTER_INVITED, cluster.getName()); } } - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_USER); + MainUtil.sendMessage(plr, C.CLUSTER_ADDED_USER); return true; } case "k": case "remove": case "kick": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.kick")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick"); + if (!Permissions.hasPermission(plr, "plots.cluster.kick")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick"); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick "); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!BukkitMain.hasPermission(plr, "plots.cluster.kick.other")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); + if (!Permissions.hasPermission(plr, "plots.cluster.kick.other")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); return false; } } // check uuid final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } // Can't kick if the player is yourself, the owner, or not added to the cluster if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.hasRights(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName()); + MainUtil.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName()); return false; } if (cluster.helpers.contains(uuid)) { @@ -376,40 +376,40 @@ public class Cluster extends SubCommand { DBFunc.delete(world, plot); } } - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_KICKED_USER); + MainUtil.sendMessage(plr, C.CLUSTER_KICKED_USER); return true; } case "quit": case "leave": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.leave")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); + if (!Permissions.hasPermission(plr, "plots.cluster.leave")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); return false; } if ((args.length != 1) && (args.length != 2)) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } final UUID uuid = UUIDHandler.getUUID(plr); if (!cluster.hasRights(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED); + MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED); return false; } if (uuid.equals(cluster.owner)) { - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_CANNOT_LEAVE); + MainUtil.sendMessage(plr, C.CLUSTER_CANNOT_LEAVE); return false; } if (cluster.helpers.contains(uuid)) { @@ -418,7 +418,7 @@ public class Cluster extends SubCommand { } cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); + MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { @@ -431,84 +431,84 @@ public class Cluster extends SubCommand { case "admin": case "helper": case "helpers": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.helpers")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.helpers"); + if (!Permissions.hasPermission(plr, "plots.cluster.helpers")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.helpers"); return false; } if (args.length != 3) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } final UUID uuid = UUIDHandler.getUUID(args[2]); if (uuid == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (args[1].toLowerCase().equals("add")) { cluster.helpers.add(uuid); - return BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_HELPER); + return MainUtil.sendMessage(plr, C.CLUSTER_ADDED_HELPER); } if (args[1].toLowerCase().equals("remove")) { cluster.helpers.remove(uuid); - return BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); + return MainUtil.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); } - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); return false; } case "spawn": case "home": case "tp": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.tp")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp"); + if (!Permissions.hasPermission(plr, "plots.cluster.tp")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp"); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp "); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } final UUID uuid = UUIDHandler.getUUID(plr); if (!cluster.hasRights(uuid)) { - if (!BukkitMain.hasPermission(plr, "plots.cluster.tp.other")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); + if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); return false; } } plr.teleport(ClusterManager.getHome(cluster)); - return BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_TELEPORTING); + return MainUtil.sendMessage(plr, C.CLUSTER_TELEPORTING); } case "i": case "info": case "show": case "information": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.info")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); + if (!Permissions.hasPermission(plr, "plots.cluster.info")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); return false; } if ((args.length != 1) && (args.length != 2)) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); return false; } PlotCluster cluster; if (args.length == 2) { cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; } } else { cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } } @@ -526,28 +526,28 @@ public class Cluster extends SubCommand { message = message.replaceAll("%name%", name); message = message.replaceAll("%size%", size); message = message.replaceAll("%rights%", rights); - BukkitPlayerFunctions.sendMessage(plr, message); + MainUtil.sendMessage(plr, message); return true; } case "sh": case "setspawn": case "sethome": { - if (!BukkitMain.hasPermission(plr, "plots.cluster.sethome")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); + if (!Permissions.hasPermission(plr, "plots.cluster.sethome")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); return false; } if ((args.length != 1) && (args.length != 2)) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); return false; } final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); if (cluster == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { - if (!BukkitMain.hasPermission(plr, "plots.cluster.sethome.other")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other"); + if (!Permissions.hasPermission(plr, "plots.cluster.sethome.other")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other"); return false; } } @@ -557,10 +557,10 @@ public class Cluster extends SubCommand { final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); cluster.settings.setPosition(blockloc); DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); - return BukkitPlayerFunctions.sendMessage(plr, C.POSITION_SET); + return MainUtil.sendMessage(plr, C.POSITION_SET); } } - BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); + MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); return false; } } 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 b84ba14ad..bbf31876c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -49,7 +49,7 @@ public class Comment extends SubCommand { } final List recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone"); if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) { - if (BukkitMain.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) { + if (Permissions.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 4e3d2b5e7..14b37aa94 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -48,35 +48,35 @@ public class Condense extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { - BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); + MainUtil.sendMessage(plr, (C.NOT_CONSOLE)); return false; } if ((args.length != 2) && (args.length != 3)) { - BukkitPlayerFunctions.sendMessage(plr, "/plot condense [radius]"); + MainUtil.sendMessage(plr, "/plot condense [radius]"); return false; } final String worldname = args[0]; final World world = Bukkit.getWorld(worldname); if ((world == null) || !PlotSquared.isPlotWorld(worldname)) { - BukkitPlayerFunctions.sendMessage(plr, "INVALID WORLD"); + MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } switch (args[1].toLowerCase()) { case "start": { if (args.length == 2) { - BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " start "); + MainUtil.sendMessage(plr, "/plot condense " + worldname + " start "); return false; } if (TASK) { - BukkitPlayerFunctions.sendMessage(plr, "TASK ALREADY STARTED"); + MainUtil.sendMessage(plr, "TASK ALREADY STARTED"); return false; } if (args.length == 2) { - BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " start "); + MainUtil.sendMessage(plr, "/plot condense " + worldname + " start "); return false; } if (!StringUtils.isNumeric(args[2])) { - BukkitPlayerFunctions.sendMessage(plr, "INVALID RADIUS"); + MainUtil.sendMessage(plr, "INVALID RADIUS"); return false; } final int radius = Integer.parseInt(args[2]); @@ -84,7 +84,7 @@ public class Condense extends SubCommand { final int size = plots.size(); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { - BukkitPlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); + MainUtil.sendMessage(plr, "RADIUS TOO SMALL"); return false; } final List to_move = new ArrayList<>(getPlots(plots, radius)); @@ -143,25 +143,25 @@ public class Condense extends SubCommand { } }); TASK = true; - BukkitPlayerFunctions.sendMessage(plr, "TASK STARTED..."); + MainUtil.sendMessage(plr, "TASK STARTED..."); return true; } case "stop": { if (!TASK) { - BukkitPlayerFunctions.sendMessage(plr, "TASK ALREADY STOPPED"); + MainUtil.sendMessage(plr, "TASK ALREADY STOPPED"); return false; } TASK = false; - BukkitPlayerFunctions.sendMessage(plr, "TASK STOPPED"); + MainUtil.sendMessage(plr, "TASK STOPPED"); return true; } case "info": { if (args.length == 2) { - BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " info "); + MainUtil.sendMessage(plr, "/plot condense " + worldname + " info "); return false; } if (!StringUtils.isNumeric(args[2])) { - BukkitPlayerFunctions.sendMessage(plr, "INVALID RADIUS"); + MainUtil.sendMessage(plr, "INVALID RADIUS"); return false; } final int radius = Integer.parseInt(args[2]); @@ -169,23 +169,23 @@ public class Condense extends SubCommand { final int size = plots.size(); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); if (radius < minimum_radius) { - BukkitPlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL"); + MainUtil.sendMessage(plr, "RADIUS TOO SMALL"); return false; } final int max_move = getPlots(plots, minimum_radius).size(); final int user_move = getPlots(plots, radius).size(); - BukkitPlayerFunctions.sendMessage(plr, "=== DEFAULT EVAL ==="); - BukkitPlayerFunctions.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius); - BukkitPlayerFunctions.sendMessage(plr, "MAXIMUM MOVES: " + max_move); - BukkitPlayerFunctions.sendMessage(plr, "=== INPUT EVAL ==="); - BukkitPlayerFunctions.sendMessage(plr, "INPUT RADIUS: " + radius); - BukkitPlayerFunctions.sendMessage(plr, "ESTIMATED MOVES: " + user_move); - BukkitPlayerFunctions.sendMessage(plr, "ESTIMATED TIME: " + "No idea, times will drastically change based on the system performance and load"); - BukkitPlayerFunctions.sendMessage(plr, "&e - Radius is measured in plot width"); + MainUtil.sendMessage(plr, "=== DEFAULT EVAL ==="); + MainUtil.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius); + MainUtil.sendMessage(plr, "MAXIMUM MOVES: " + max_move); + MainUtil.sendMessage(plr, "=== INPUT EVAL ==="); + MainUtil.sendMessage(plr, "INPUT RADIUS: " + radius); + MainUtil.sendMessage(plr, "ESTIMATED MOVES: " + user_move); + MainUtil.sendMessage(plr, "ESTIMATED TIME: " + "No idea, times will drastically change based on the system performance and load"); + MainUtil.sendMessage(plr, "&e - Radius is measured in plot width"); return true; } } - BukkitPlayerFunctions.sendMessage(plr, "/plot condense " + worldname + " [radius]"); + MainUtil.sendMessage(plr, "/plot condense " + worldname + " [radius]"); return false; } 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 bee9fc59b..f80941c19 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -37,17 +37,17 @@ public class Copy extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.copy")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.copy")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } assert plot != null; if (plot.settings.isMerged()) { - BukkitPlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); + MainUtil.sendMessage(plr, C.UNLINK_REQUIRED); return false; } final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java index 3c8136c0e..0e73c7b85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java @@ -19,7 +19,7 @@ public class DEOP extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { - return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); } if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 5170c15e3..888fe4824 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -36,7 +36,7 @@ public class Database extends SubCommand { } else { final Player p = UUIDHandler.uuidWrapper.getPlayer(uuid); if ((p != null) && p.isOnline()) { - return BukkitPlayerFunctions.sendMessage(p, msg); + return MainUtil.sendMessage(p, msg); } else { return sendMessageU(null, 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 e58249162..f1ebda2bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -43,7 +43,7 @@ public class Debug extends SubCommand { for (final C c : C.values()) { msg.append(c.s()).append("\n"); } - BukkitPlayerFunctions.sendMessage(plr, msg.toString()); + MainUtil.sendMessage(plr, msg.toString()); return true; } StringBuilder information; @@ -84,7 +84,7 @@ public class Debug extends SubCommand { information.append(getLine(line, "View all captions", "/plot debug msg")); } { - BukkitPlayerFunctions.sendMessage(plr, information.toString()); + MainUtil.sendMessage(plr, information.toString()); } return true; } 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 e4532c5c7..8ade9b77b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -76,11 +76,11 @@ public class DebugClaimTest extends SubCommand { public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { if (args.length < 3) { - return !BukkitPlayerFunctions.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}"); + return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}"); } final World world = Bukkit.getWorld(args[0]); if ((world == null) || !PlotSquared.isPlotWorld(world)) { - return !BukkitPlayerFunctions.sendMessage(null, "&cInvalid plot world!"); + return !MainUtil.sendMessage(null, "&cInvalid plot world!"); } PlotId min, max; try { @@ -89,10 +89,10 @@ public class DebugClaimTest extends SubCommand { min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1])); max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1])); } catch (final Exception e) { - return !BukkitPlayerFunctions.sendMessage(null, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area."); + return !MainUtil.sendMessage(null, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area."); } - BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while..."); - BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)"); + MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while..."); + MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)"); final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final ArrayList plots = new ArrayList<>(); @@ -100,7 +100,7 @@ public class DebugClaimTest extends SubCommand { final Plot plot = MainUtil.getPlot(world, id); final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id); if (contains) { - BukkitPlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id); + MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id); continue; } final Location loc = manager.getSignLoc(world, plotworld, plot); @@ -132,30 +132,30 @@ public class DebugClaimTest extends SubCommand { uuid = UUIDHandler.getUUID(line); } if (uuid != null) { - BukkitPlayerFunctions.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); + MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); plot.owner = uuid; plot.hasChanged = true; plots.add(plot); } else { - BukkitPlayerFunctions.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line); + MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line); } } } } } if (plots.size() > 0) { - BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!"); + MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!"); DBFunc.createPlots(plots); DBFunc.createAllSettingsAndHelpers(plots); for (final Plot plot : plots) { PlotSquared.updatePlot(plot); } - BukkitPlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); + MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); } else { - BukkitPlayerFunctions.sendMessage(null, "No plots were found for the given search."); + MainUtil.sendMessage(null, "No plots were found for the given search."); } } else { - BukkitPlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused."); + MainUtil.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused."); } return true; } 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 6126d374a..9501f06b1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -64,7 +64,7 @@ public class DebugClear extends SubCommand { final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); if (MainUtil.runners.containsKey(plot)) { - BukkitPlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); + MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); return false; } MainUtil.runners.put(plot, 1); @@ -89,7 +89,7 @@ public class DebugClear extends SubCommand { if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.debugclear")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; @@ -97,7 +97,7 @@ public class DebugClear extends SubCommand { final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); if (MainUtil.runners.containsKey(plot)) { - BukkitPlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); + MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); return false; } MainUtil.runners.put(plot, 1); @@ -105,7 +105,7 @@ public class DebugClear extends SubCommand { @Override public void run() { MainUtil.runners.remove(plot); - BukkitPlayerFunctions.sendMessage(plr, "&aDone!"); + MainUtil.sendMessage(plr, "&aDone!"); } }); // sign 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 bfcf6e597..f92a01ffa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -59,77 +59,77 @@ public class DebugExec extends SubCommand { if (ExpireManager.task != -1) { Bukkit.getScheduler().cancelTask(ExpireManager.task); } else { - return BukkitPlayerFunctions.sendMessage(null, "Task already halted"); + return MainUtil.sendMessage(null, "Task already halted"); } ExpireManager.task = -1; - return BukkitPlayerFunctions.sendMessage(null, "Cancelled task."); + return MainUtil.sendMessage(null, "Cancelled task."); } case "start-expire": { if (ExpireManager.task == -1) { ExpireManager.runTask(); } else { - return BukkitPlayerFunctions.sendMessage(null, "Plot expiry task already started"); + return MainUtil.sendMessage(null, "Plot expiry task already started"); } - return BukkitPlayerFunctions.sendMessage(null, "Started plot expiry task"); + return MainUtil.sendMessage(null, "Started plot expiry task"); } case "update-expired": { if (args.length > 1) { final World world = Bukkit.getWorld(args[1]); if (world == null) { - return BukkitPlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + return MainUtil.sendMessage(null, "Invalid world: " + args[1]); } - BukkitPlayerFunctions.sendMessage(null, "Updating expired plot list"); + MainUtil.sendMessage(null, "Updating expired plot list"); ExpireManager.updateExpired(args[1]); return true; } - return BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired "); + return MainUtil.sendMessage(null, "Use /plot debugexec update-expired "); } case "show-expired": { if (args.length > 1) { final World world = Bukkit.getWorld(args[1]); if ((world == null) || !ExpireManager.expiredPlots.containsKey(args[1])) { - return BukkitPlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + return MainUtil.sendMessage(null, "Invalid world: " + args[1]); } - BukkitPlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):"); + MainUtil.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):"); for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { final Plot plot = entry.getKey(); final Long stamp = entry.getValue(); - BukkitPlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); + MainUtil.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); } return true; } - return BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired "); + return MainUtil.sendMessage(null, "Use /plot debugexec show-expired "); } case "seen": { if (args.length != 2) { - return BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec seen "); + return MainUtil.sendMessage(null, "Use /plot debugexec seen "); } final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { - return BukkitPlayerFunctions.sendMessage(null, "player not found: " + args[1]); + return MainUtil.sendMessage(null, "player not found: " + args[1]); } final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); if ((op == null) || !op.hasPlayedBefore()) { - return BukkitPlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]); + return MainUtil.sendMessage(null, "player hasn't connected before: " + args[1]); } final Timestamp stamp = new Timestamp(op.getLastPlayed()); final Date date = new Date(stamp.getTime()); - BukkitPlayerFunctions.sendMessage(null, "PLAYER: " + args[1]); - BukkitPlayerFunctions.sendMessage(null, "UUID: " + uuid); - BukkitPlayerFunctions.sendMessage(null, "Object: " + date.toGMTString()); - BukkitPlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString()); - BukkitPlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString()); + MainUtil.sendMessage(null, "PLAYER: " + args[1]); + MainUtil.sendMessage(null, "UUID: " + uuid); + MainUtil.sendMessage(null, "Object: " + date.toGMTString()); + MainUtil.sendMessage(null, "GMT: " + date.toGMTString()); + MainUtil.sendMessage(null, "Local: " + date.toLocaleString()); return true; } case "trim-check": { if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check "); - BukkitPlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim"); - return BukkitPlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run"); + MainUtil.sendMessage(null, "Use /plot debugexec trim-check "); + MainUtil.sendMessage(null, "&7 - Generates a list of regions to trim"); + return MainUtil.sendMessage(null, "&7 - Run after plot expiry has run"); } final World world = Bukkit.getWorld(args[1]); if ((world == null) || !PlotSquared.isPlotWorld(args[1])) { - return BukkitPlayerFunctions.sendMessage(null, "Invalid world: " + args[1]); + return MainUtil.sendMessage(null, "Invalid world: " + args[1]); } final ArrayList empty = new ArrayList<>(); final boolean result = Trim.getTrimRegions(empty, world, new Runnable() { @@ -160,7 +160,7 @@ public class DebugExec extends SubCommand { } }); if (!result) { - BukkitPlayerFunctions.sendMessage(null, "Trim task already started!"); + MainUtil.sendMessage(null, "Trim task already started!"); } return result; } 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 f2ce2ad51..59cd7a75d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -44,19 +44,19 @@ public class DebugFixFlags extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); + MainUtil.sendMessage(plr, C.NOT_CONSOLE); return false; } if (args.length != 1) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags "); return false; } final World world = Bukkit.getWorld(args[0]); if ((world == null) || !PlotSquared.isPlotWorld(world)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); return false; } - BukkitPlayerFunctions.sendMessage(plr, "&8--- &6Starting task &8 ---"); + MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---"); for (final Plot plot : PlotSquared.getPlots(world).values()) { final Set flags = plot.settings.flags; final ArrayList toRemove = new ArrayList(); @@ -73,7 +73,7 @@ public class DebugFixFlags extends SubCommand { DBFunc.setFlags(plot.world, plot, plot.settings.flags); } } - BukkitPlayerFunctions.sendMessage(plr, "&aDone!"); + MainUtil.sendMessage(plr, "&aDone!"); return true; } } 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 7a9e7a673..36aa892b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -49,7 +49,7 @@ public class DebugLoadTest extends SubCommand { PlotSquared.log("&3===END OF STACKTRACE==="); } } else { - BukkitPlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.."); + MainUtil.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.."); } return true; } 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 9b9c49bc7..797532c52 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -45,7 +45,7 @@ public class DebugSaveTest extends SubCommand { DBFunc.createPlots(plots); DBFunc.createAllSettingsAndHelpers(plots); } else { - BukkitPlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused"); + MainUtil.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused"); } return true; } 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 50c603058..4d8ff392c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -47,7 +47,7 @@ public class Delete extends SubCommand { if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !BukkitMain.hasPermission(plr, "plots.admin.command.delete")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; @@ -65,7 +65,7 @@ public class Delete extends SubCommand { plot.clear(plr, true); DBFunc.delete(plr.getWorld().getName(), plot); } else { - BukkitPlayerFunctions.sendMessage(plr, "Plot deletion has been denied."); + MainUtil.sendMessage(plr, "Plot deletion has been denied."); } return true; } 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 f24c010e2..6557770da 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -42,20 +42,20 @@ public class Denied extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { - BukkitPlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); + MainUtil.sendMessage(plr, C.DENIED_NEED_ARGUMENT); return true; } if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.denied")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } if (args[0].equalsIgnoreCase("add")) { @@ -66,12 +66,12 @@ public class Denied extends SubCommand { uuid = UUIDHandler.getUUID(args[1]); } if (uuid == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!plot.denied.contains(uuid)) { if (plot.owner.equals(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); + MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } if (plot.trusted.contains(uuid)) { @@ -87,7 +87,7 @@ public class Denied extends SubCommand { final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { - BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); + MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); @@ -98,18 +98,18 @@ public class Denied extends SubCommand { player.teleport(player.getWorld().getSpawnLocation()); } } - BukkitPlayerFunctions.sendMessage(plr, C.DENIED_ADDED); + MainUtil.sendMessage(plr, C.DENIED_ADDED); return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { final UUID uuid = DBFunc.everyone; if (!plot.denied.contains(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); return true; } plot.removeDenied(uuid); DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); - BukkitPlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); + MainUtil.sendMessage(plr, C.DENIED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); @@ -117,9 +117,9 @@ public class Denied extends SubCommand { DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); - BukkitPlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); + MainUtil.sendMessage(plr, C.DENIED_REMOVED); } else { - BukkitPlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); + MainUtil.sendMessage(plr, C.DENIED_NEED_ARGUMENT); return true; } return true; 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 7f545edff..06462e1ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -41,20 +41,20 @@ public class Helpers extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { - BukkitPlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); + MainUtil.sendMessage(plr, C.HELPER_NEED_ARGUMENT); return true; } if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.helpers")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } if (args[0].equalsIgnoreCase("add")) { @@ -65,12 +65,12 @@ public class Helpers extends SubCommand { uuid = UUIDHandler.getUUID(args[1]); } if (uuid == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!plot.helpers.contains(uuid)) { if (plot.owner.equals(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); + MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } if (plot.trusted.contains(uuid)) { @@ -86,21 +86,21 @@ public class Helpers extends SubCommand { final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { - BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); + MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } - BukkitPlayerFunctions.sendMessage(plr, C.HELPER_ADDED); + MainUtil.sendMessage(plr, C.HELPER_ADDED); return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { final UUID uuid = DBFunc.everyone; if (!plot.helpers.contains(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); return true; } plot.removeHelper(uuid); DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); - BukkitPlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); + MainUtil.sendMessage(plr, C.HELPER_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); @@ -108,9 +108,9 @@ public class Helpers extends SubCommand { DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); - BukkitPlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); + MainUtil.sendMessage(plr, C.HELPER_REMOVED); } else { - BukkitPlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); + MainUtil.sendMessage(plr, C.HELPER_NEED_ARGUMENT); return true; } 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 4578173a2..5e377e0a9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -67,20 +67,20 @@ public class Home extends SubCommand { return true; } } - BukkitPlayerFunctions.sendMessage(plr, C.NOT_YOUR_PLOT); + MainUtil.sendMessage(plr, C.NOT_YOUR_PLOT); return false; } - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); + MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER); return true; } if ((id > (plots.length)) || (id < 1)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); + MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER); return false; } teleportPlayer(plr, plots[id - 1]); return true; } else { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOTS); + MainUtil.sendMessage(plr, C.NO_PLOTS); return true; } } 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 b0be4d72c..5b9eb91fd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -51,17 +51,17 @@ public class Inbox extends SubCommand { } } if (!BukkitPlayerFunctions.isInPlot(plr) && !report) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot != null) && !plot.hasOwner()) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } Integer tier; final UUID uuid = UUIDHandler.getUUID(plr); - if (BukkitMain.hasPermission(plr, "plots.comment.admin")) { + if (Permissions.hasPermission(plr, "plots.comment.admin")) { tier = 0; } else if ((plot != null) && plot.owner.equals(uuid)) { tier = 1; @@ -80,7 +80,7 @@ public class Inbox extends SubCommand { if (tier <= 0) { tier = 0; } else { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); return false; } break; @@ -88,7 +88,7 @@ public class Inbox extends SubCommand { if (tier <= 1) { tier = 1; } else { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner"); + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner"); return false; } break; @@ -96,7 +96,7 @@ public class Inbox extends SubCommand { if (tier <= 2) { tier = 2; } else { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper"); + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper"); return false; } break; @@ -104,7 +104,7 @@ public class Inbox extends SubCommand { if (tier <= 3) { tier = 3; } else { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted"); + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted"); return false; } break; @@ -112,7 +112,7 @@ public class Inbox extends SubCommand { if (tier <= 4) { tier = 4; } else { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone"); + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone"); return false; } break; @@ -120,12 +120,12 @@ public class Inbox extends SubCommand { if (tier <= 0) { tier = -1; } else { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); return false; } break; default: - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4)); + MainUtil.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4)); return false; } } else { @@ -149,7 +149,7 @@ public class Inbox extends SubCommand { if (args.length == 2) { final String[] split = args[1].toLowerCase().split(":"); if (!split[0].equals("clear")) { - BukkitPlayerFunctions.sendMessage(plr, "&c/plot inbox [tier] [clear][:#]"); + MainUtil.sendMessage(plr, "&c/plot inbox [tier] [clear][:#]"); return; } if (split.length > 1) { @@ -158,10 +158,10 @@ public class Inbox extends SubCommand { final PlotComment comment = comments.get(index - 1); DBFunc.removeComment(world, plot, comment); plot.settings.removeComment(comment); - BukkitPlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment"); + MainUtil.sendMessage(plr, C.COMMENT_REMOVED, "1 comment"); return; } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]"); + MainUtil.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]"); return; } } @@ -169,7 +169,7 @@ public class Inbox extends SubCommand { DBFunc.removeComment(world, plot, comment); } plot.settings.removeComments(comments); - BukkitPlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); + MainUtil.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); } else { final List recipients = Arrays.asList("A", "O", "H", "T", "E"); int count = 1; @@ -183,7 +183,7 @@ public class Inbox extends SubCommand { if (comments.size() == 0) { message.append("&cNo messages."); } - BukkitPlayerFunctions.sendMessage(plr, message.toString()); + MainUtil.sendMessage(plr, message.toString()); } } }); 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 d0d6f6734..483e1d1ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -68,7 +68,7 @@ public class Info extends SubCommand { plot = BukkitPlayerFunctions.getCurrentPlot(player); } else { if (args.length < 2) { - BukkitPlayerFunctions.sendMessage(null, C.INFO_SYNTAX_CONSOLE); + MainUtil.sendMessage(null, C.INFO_SYNTAX_CONSOLE); return false; } final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); 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 ffb5d1ba4..1538a4682 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -38,25 +38,25 @@ public class Kick extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, "You're not in a plot."); + MainUtil.sendMessage(plr, "You're not in a plot."); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.kick")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if (args.length != 1) { - BukkitPlayerFunctions.sendMessage(plr, "&c/plot kick "); + MainUtil.sendMessage(plr, "&c/plot kick "); return false; } if (Bukkit.getPlayer(args[0]) == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } final Player player = Bukkit.getPlayer(args[0]); if (!player.getWorld().equals(plr.getWorld()) || !BukkitPlayerFunctions.isInPlot(player) || (BukkitPlayerFunctions.getCurrentPlot(player) == null) || !BukkitPlayerFunctions.getCurrentPlot(player).equals(plot)) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); + MainUtil.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); return false; } player.teleport(player.getWorld().getSpawnLocation()); 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 eb4d94d4a..338f8d925 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -76,22 +76,22 @@ public class Merge extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - final boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge"); + final boolean admin = Permissions.hasPermission(plr, "plots.admin.command.merge"); if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if (args.length < 1) { - BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); - BukkitPlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); + MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); + MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); return false; } int direction = -1; @@ -102,8 +102,8 @@ public class Merge extends SubCommand { } } if (direction == -1) { - BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); - BukkitPlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); + MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); + MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); return false; } final World world = plr.getWorld(); @@ -138,7 +138,7 @@ public class Merge extends SubCommand { for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); + MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; } } @@ -160,10 +160,10 @@ public class Merge extends SubCommand { Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { event.setCancelled(true); - BukkitPlayerFunctions.sendMessage(plr, "&cMerge has been cancelled"); + MainUtil.sendMessage(plr, "&cMerge has been cancelled"); return false; } - BukkitPlayerFunctions.sendMessage(plr, "&cPlots have been merged"); + MainUtil.sendMessage(plr, "&cPlots have been merged"); MainUtil.mergePlots(world, plots, true); MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot); MainUtil.update(plr.getLocation()); 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 d2e3303cd..f934ae66c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -40,32 +40,32 @@ public class Move extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { - BukkitPlayerFunctions.sendMessage(plr, "MUST BE EXECUTED BY PLAYER"); + MainUtil.sendMessage(plr, "MUST BE EXECUTED BY PLAYER"); } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(plr, "/plot move "); + MainUtil.sendMessage(plr, "/plot move "); return false; } final World world = plr.getWorld(); final PlotId plot1 = MainUtil.parseId(args[0]); final PlotId plot2 = MainUtil.parseId(args[1]); if ((plot1 == null) || (plot2 == null)) { - BukkitPlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move "); + MainUtil.sendMessage(plr, "INVALID PLOT ID\n/plot move "); return false; } if (plot1 == plot2) { - BukkitPlayerFunctions.sendMessage(plr, "DUPLICATE ID"); + MainUtil.sendMessage(plr, "DUPLICATE ID"); return false; } if (MainUtil.move(world, plot1, plot2, new Runnable() { @Override public void run() { - BukkitPlayerFunctions.sendMessage(plr, "MOVE SUCCESS"); + MainUtil.sendMessage(plr, "MOVE SUCCESS"); } })) { return true; } else { - BukkitPlayerFunctions.sendMessage(plr, "MOVE FAILED"); + MainUtil.sendMessage(plr, "MOVE FAILED"); return false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java index 0eae5aa07..98808c3f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java @@ -19,7 +19,7 @@ public class OP extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { - return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); } if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); 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 14f740509..a1a5b0d45 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -37,16 +37,16 @@ public class Paste extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.paste")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.paste")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { - BukkitPlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); + MainUtil.sendMessage(plr, C.UNLINK_REQUIRED); return false; } assert plot != null; 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 a0998e0b8..d10d6da63 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -55,47 +55,47 @@ public class Purge extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { - BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); + MainUtil.sendMessage(plr, (C.NOT_CONSOLE)); return false; } if (args.length == 1) { final String arg = args[0].toLowerCase(); final PlotId id = getId(arg); if (id != null) { - BukkitPlayerFunctions.sendMessage(plr, "/plot purge x;z &l"); + MainUtil.sendMessage(plr, "/plot purge x;z &l"); return false; } final UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - BukkitPlayerFunctions.sendMessage(plr, "/plot purge " + args[0] + " &l"); + MainUtil.sendMessage(plr, "/plot purge " + args[0] + " &l"); return false; } if (arg.equals("player")) { - BukkitPlayerFunctions.sendMessage(plr, "/plot purge &l "); + MainUtil.sendMessage(plr, "/plot purge &l "); return false; } if (arg.equals("unowned")) { - BukkitPlayerFunctions.sendMessage(plr, "/plot purge unowned &l"); + MainUtil.sendMessage(plr, "/plot purge unowned &l"); return false; } if (arg.equals("unknown")) { - BukkitPlayerFunctions.sendMessage(plr, "/plot purge unknown &l"); + MainUtil.sendMessage(plr, "/plot purge unknown &l"); return false; } if (arg.equals("all")) { - BukkitPlayerFunctions.sendMessage(plr, "/plot purge all &l"); + MainUtil.sendMessage(plr, "/plot purge all &l"); return false; } - BukkitPlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); + MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); + MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } final World world = Bukkit.getWorld(args[1]); if ((world == null) || !PlotSquared.isPlotWorld(world)) { - BukkitPlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD); + MainUtil.sendMessage(null, C.NOT_VALID_PLOT_WORLD); return false; } final String worldname = world.getName(); @@ -123,7 +123,7 @@ public class Purge extends SubCommand { if (arg.equals("all")) { final Set ids = PlotSquared.getPlots(world).keySet(); if (ids.size() == 0) { - return BukkitPlayerFunctions.sendMessage(null, "&cNo plots found"); + return MainUtil.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); @@ -140,7 +140,7 @@ public class Purge extends SubCommand { } } if (ids.size() == 0) { - return BukkitPlayerFunctions.sendMessage(null, "&cNo plots found"); + return MainUtil.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); @@ -154,17 +154,17 @@ public class Purge extends SubCommand { } } if (ids.size() == 0) { - return BukkitPlayerFunctions.sendMessage(null, "&cNo plots found"); + return MainUtil.sendMessage(null, "&cNo plots found"); } DBFunc.purge(worldname, ids); return finishPurge(ids.size()); } - BukkitPlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX); + MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } private boolean finishPurge(final int amount) { - BukkitPlayerFunctions.sendMessage(null, C.PURGE_SUCCESS, amount + ""); + MainUtil.sendMessage(null, C.PURGE_SUCCESS, amount + ""); 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 54b8159fe..8cb995e33 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -47,7 +47,7 @@ public class Reload extends SubCommand { } MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(plr, C.RELOAD_FAILED); + MainUtil.sendMessage(plr, C.RELOAD_FAILED); } return true; } 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 f3893f799..1c6b2c3e6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -69,8 +69,8 @@ public class Schematic extends SubCommand { PlotSquared.log(C.IS_CONSOLE); return false; } - if (!BukkitMain.hasPermission(plr, "plots.schematic.paste")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); + if (!Permissions.hasPermission(plr, "plots.schematic.paste")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); return false; } if (args.length < 2) { @@ -82,7 +82,7 @@ public class Schematic extends SubCommand { break; } if (this.running) { - BukkitPlayerFunctions.sendMessage(plr, "&cTask is already running."); + MainUtil.sendMessage(plr, "&cTask is already running."); return false; } final String file2 = args[1]; @@ -150,8 +150,8 @@ public class Schematic extends SubCommand { PlotSquared.log(C.IS_CONSOLE); return false; } - if (!BukkitMain.hasPermission(plr, "plots.schematic.test")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); + if (!Permissions.hasPermission(plr, "plots.schematic.test")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); return false; } if (args.length < 2) { @@ -177,20 +177,20 @@ public class Schematic extends SubCommand { case "saveall": case "exportall": if (plr != null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); + MainUtil.sendMessage(plr, C.NOT_CONSOLE); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall "); + MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall "); return false; } final HashMap plotmap = PlotSquared.getPlots(args[1]); if ((plotmap == null) || (plotmap.size() == 0)) { - BukkitPlayerFunctions.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall "); + MainUtil.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall "); return false; } if (this.running) { - BukkitPlayerFunctions.sendMessage(null, "&cTask is already running."); + MainUtil.sendMessage(null, "&cTask is already running."); return false; } PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); @@ -216,17 +216,17 @@ public class Schematic extends SubCommand { final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { - BukkitPlayerFunctions.sendMessage(null, "&7 - Skipped plot &c" + plot.id); + MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); } else { Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { @Override public void run() { - BukkitPlayerFunctions.sendMessage(null, "&6ID: " + plot.id); + MainUtil.sendMessage(null, "&6ID: " + plot.id); final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + worldname + "," + owner + ".schematic"); if (!result) { - BukkitPlayerFunctions.sendMessage(null, "&7 - Failed to save &c" + plot.id); + MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id); } else { - BukkitPlayerFunctions.sendMessage(null, "&7 - &aExport success: " + plot.id); + MainUtil.sendMessage(null, "&7 - &aExport success: " + plot.id); } } }); @@ -237,12 +237,12 @@ public class Schematic extends SubCommand { break; case "export": case "save": - if (!BukkitMain.hasPermission(plr, "plots.schematic.save")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); + if (!Permissions.hasPermission(plr, "plots.schematic.save")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); return false; } if (this.running) { - BukkitPlayerFunctions.sendMessage(plr, "&cTask is already running."); + MainUtil.sendMessage(plr, "&cTask is already running."); return false; } final String world; @@ -266,16 +266,16 @@ public class Schematic extends SubCommand { final String[] split = args[2].split(";"); final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) { - BukkitPlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); + MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } p2 = PlotSquared.getPlots(world).get(i); } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); + MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } } else { - BukkitPlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); + MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save "); return false; } } @@ -297,17 +297,17 @@ public class Schematic extends SubCommand { final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { - BukkitPlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); + MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); } else { Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { @Override public void run() { - BukkitPlayerFunctions.sendMessage(plr, "&6ID: " + plot.id); + MainUtil.sendMessage(plr, "&6ID: " + plot.id); final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + world + "," + owner.trim() + ".schematic"); if (!result) { - BukkitPlayerFunctions.sendMessage(plr, "&7 - Failed to save &c" + plot.id); + MainUtil.sendMessage(plr, "&7 - Failed to save &c" + plot.id); } else { - BukkitPlayerFunctions.sendMessage(plr, "&7 - &aExport success: " + plot.id); + MainUtil.sendMessage(plr, "&7 - &aExport success: " + plot.id); } } }); 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 af1a7751b..db9a20f61 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -66,7 +66,7 @@ public class Set extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); @@ -74,12 +74,12 @@ public class Set extends SubCommand { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(plr) && !BukkitMain.hasPermission(plr, "plots.admin.command.set")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (!plot.hasRights(plr) && !Permissions.hasPermission(plr, "plots.admin.command.set")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if (args.length < 1) { - BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); + MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); return false; } for (int i = 0; i < aliases.length; i++) { @@ -90,8 +90,8 @@ public class Set extends SubCommand { } /* TODO: Implement option */ // final boolean advanced_permissions = true; - if (!BukkitMain.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); + if (!Permissions.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); return false; } if (args[0].equalsIgnoreCase("flag")) { @@ -104,7 +104,7 @@ public class Set extends SubCommand { message += "," + StringUtils.join(PlotSquared.worldGuardListener.str_flags, "&c, &6"); } } - BukkitPlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); + MainUtil.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } AbstractFlag af; @@ -114,11 +114,11 @@ public class Set extends SubCommand { af = new AbstractFlag(args[1].toLowerCase()); } if (!FlagManager.getFlags().contains(af) && ((PlotSquared.worldGuardListener == null) || !PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); + MainUtil.sendMessage(plr, C.NOT_VALID_FLAG); return false; } - if (!BukkitMain.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION); + if (!Permissions.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) { + MainUtil.sendMessage(plr, C.NO_PERMISSION); return false; } if (args.length == 2) { @@ -129,15 +129,15 @@ public class Set extends SubCommand { return false; } } - BukkitPlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.FLAG_NOT_IN_PLOT); return false; } final boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase()); if (!result) { - BukkitPlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED); + MainUtil.sendMessage(plr, C.FLAG_NOT_REMOVED); return false; } - BukkitPlayerFunctions.sendMessage(plr, C.FLAG_REMOVED); + MainUtil.sendMessage(plr, C.FLAG_REMOVED); PlotListener.plotEntry(plr, plot); return true; } @@ -145,7 +145,7 @@ public class Set extends SubCommand { final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed_value = af.parseValueRaw(value); if (parsed_value == null) { - BukkitPlayerFunctions.sendMessage(plr, af.getValueDesc()); + MainUtil.sendMessage(plr, af.getValueDesc()); return false; } if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotSquared.worldGuardListener != null)) { @@ -155,14 +155,14 @@ public class Set extends SubCommand { final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed_value); final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - BukkitPlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED); + MainUtil.sendMessage(plr, C.FLAG_NOT_ADDED); return false; } - BukkitPlayerFunctions.sendMessage(plr, C.FLAG_ADDED); + MainUtil.sendMessage(plr, C.FLAG_ADDED); PlotListener.plotEntry(plr, plot); return true; } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(plr, "&c" + e.getMessage()); + MainUtil.sendMessage(plr, "&c" + e.getMessage()); return false; } } @@ -173,7 +173,7 @@ public class Set extends SubCommand { DBFunc.setPosition(plr.getWorld().getName(), plot, ""); return true; } - return BukkitPlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT); + return MainUtil.sendMessage(plr, C.HOME_ARGUMENT); } //set to current location final World world = plr.getWorld(); @@ -183,35 +183,35 @@ public class Set extends SubCommand { final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); plot.settings.setPosition(blockloc); DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); - return BukkitPlayerFunctions.sendMessage(plr, C.POSITION_SET); + return MainUtil.sendMessage(plr, C.POSITION_SET); } if (args[0].equalsIgnoreCase("alias")) { if (args.length < 2) { - BukkitPlayerFunctions.sendMessage(plr, C.MISSING_ALIAS); + MainUtil.sendMessage(plr, C.MISSING_ALIAS); return false; } final String alias = args[1]; if (alias.length() >= 50) { - BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_TOO_LONG); + MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG); return false; } for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) { if (p.settings.getAlias().equalsIgnoreCase(alias)) { - BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); + MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } if (UUIDHandler.nameExists(new StringWrapper(alias))) { - BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); + MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } } DBFunc.setAlias(plr.getWorld().getName(), plot, alias); - BukkitPlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); + MainUtil.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); return true; } if (args[0].equalsIgnoreCase("biome")) { if (args.length < 2) { - BukkitPlayerFunctions.sendMessage(plr, C.NEED_BIOME); + MainUtil.sendMessage(plr, C.NEED_BIOME); return true; } if (args[1].length() < 2) { @@ -228,11 +228,11 @@ public class Set extends SubCommand { * } */ if (biome == null) { - BukkitPlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); + MainUtil.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); return true; } MainUtil.setBiome(plr.getWorld(), plot, biome); - BukkitPlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); + MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); return true; } // Get components @@ -243,7 +243,7 @@ public class Set extends SubCommand { for (final String component : components) { if (component.equalsIgnoreCase(args[0])) { if (args.length < 2) { - BukkitPlayerFunctions.sendMessage(plr, C.NEED_BLOCK); + MainUtil.sendMessage(plr, C.NEED_BLOCK); return true; } PlotBlock[] blocks; @@ -253,12 +253,12 @@ public class Set extends SubCommand { try { blocks = new PlotBlock[] { new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0) }; } catch (final Exception e2) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK); + MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); return false; } } manager.setComponent(world, plotworld, plot.id, component, blocks); - BukkitPlayerFunctions.sendMessage(plr, C.GENERATING_COMPONENT); + MainUtil.sendMessage(plr, C.GENERATING_COMPONENT); return true; } } @@ -280,7 +280,7 @@ public class Set extends SubCommand { return true; } } - BukkitPlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); + MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index ea00c912b..bb5a39748 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -54,15 +54,15 @@ public class SetOwner extends SubCommand { public boolean execute(final PlotPlayer plr, final String... args) { final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || (plot.owner == null)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } if (args.length < 1) { - BukkitPlayerFunctions.sendMessage(plr, C.NEED_USER); + MainUtil.sendMessage(plr, C.NEED_USER); return false; } - if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.setowner")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); + if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } final World world = plr.getWorld(); @@ -73,7 +73,7 @@ public class SetOwner extends SubCommand { final Plot current = PlotSquared.getPlots(world).get(id); final UUID uuid = getUUID(args[0]); if (uuid == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } current.owner = uuid; @@ -84,7 +84,7 @@ public class SetOwner extends SubCommand { } } MainUtil.setSign(world, args[0], plot); - BukkitPlayerFunctions.sendMessage(plr, C.SET_OWNER); + MainUtil.sendMessage(plr, C.SET_OWNER); return true; } } 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 826e8fd98..7ec97a7ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -93,13 +93,13 @@ public class Setup extends SubCommand { updateGenerators(); final String prefix = "\n&8 - &7"; sendMessage(plr, C.SETUP_INIT); - BukkitPlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + MainUtil.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); return false; } if (args.length == 1) { if (args[0].equalsIgnoreCase("cancel")) { setupMap.remove(plr.getName()); - BukkitPlayerFunctions.sendMessage(plr, "&aCancelled setup"); + MainUtil.sendMessage(plr, "&aCancelled setup"); return false; } if (args[0].equalsIgnoreCase("back")) { @@ -120,14 +120,14 @@ public class Setup extends SubCommand { case 0: { // choose generator if ((args.length != 1) || !this.generators.containsKey(args[0])) { final String prefix = "\n&8 - &7"; - BukkitPlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); sendMessage(plr, C.SETUP_INIT); return false; } object.generator = args[0]; object.current++; final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : ""; - BukkitPlayerFunctions.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); + MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); break; } case 1: { // choose world type @@ -138,7 +138,7 @@ public class Setup extends SubCommand { types = Arrays.asList(new String[] { "default", "augmented" }); } if ((args.length != 1) || !types.contains(args[0].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); + MainUtil.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); return false; } object.type = types.indexOf(args[0].toLowerCase()); @@ -150,7 +150,7 @@ public class Setup extends SubCommand { final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); } else { - BukkitPlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); } object.current++; break; @@ -158,7 +158,7 @@ public class Setup extends SubCommand { case 2: { // Choose terrain final List terrain = Arrays.asList(new String[] { "none", "ore", "all" }); if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + MainUtil.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); return false; } object.terrain = terrain.indexOf(args[0].toLowerCase()); @@ -172,7 +172,7 @@ public class Setup extends SubCommand { } case 3: { // world setup if (object.setup_index == object.step.length) { - BukkitPlayerFunctions.sendMessage(plr, "&6What do you want your world to be called?"); + MainUtil.sendMessage(plr, "&6What do you want your world to be called?"); object.setup_index = 0; object.current++; return true; @@ -202,11 +202,11 @@ public class Setup extends SubCommand { } case 4: { if (args.length != 1) { - BukkitPlayerFunctions.sendMessage(plr, "&cYou need to choose a world name!"); + MainUtil.sendMessage(plr, "&cYou need to choose a world name!"); return false; } if (Bukkit.getWorld(args[0]) != null) { - BukkitPlayerFunctions.sendMessage(plr, "&cThat world name is already taken!"); + MainUtil.sendMessage(plr, "&cThat world name is already taken!"); } object.world = args[0]; setupMap.remove(plr.getName()); 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 fb3955a3e..7d7b2d500 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -46,21 +46,21 @@ public class Swap extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { - BukkitPlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); - BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); + MainUtil.sendMessage(plr, C.NEED_PLOT_ID); + MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.swap")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } if ((plot != null) && plot.settings.isMerged()) { - BukkitPlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); + MainUtil.sendMessage(plr, C.UNLINK_REQUIRED); return false; } final String id = args[0]; @@ -69,26 +69,26 @@ public class Swap extends SubCommand { try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotSquared.getPlots(world).get(plotid); - if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.swap")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); + if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { + MainUtil.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); return false; } } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); - BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } assert plot != null; if (plot.id.equals(plotid)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); - BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } PlotSelection.swap(world, plot.id, plotid); // TODO Requires testing!! DBFunc.dbManager.swapPlots(plot, MainUtil.getPlot(world, plotid)); // TODO Requires testing!! - BukkitPlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS); + MainUtil.sendMessage(plr, C.SWAP_SUCCESS); MainUtil.update(plr.getLocation()); return true; } 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 fe2220419..4a2ca07c0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -43,7 +43,7 @@ public class TP extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { - BukkitPlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID); + MainUtil.sendMessage(plr, C.NEED_PLOT_ID); return false; } final String id = args[0]; @@ -55,7 +55,7 @@ public class TP extends SubCommand { } } if (!PlotSquared.isPlotWorld(world)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } Plot temp; @@ -68,7 +68,7 @@ public class TP extends SubCommand { PlotSquared.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid)); return true; } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); } return false; } 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 22ce9cd21..9efb7ff59 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -37,21 +37,21 @@ public class Target extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (!PlotSquared.isPlotWorld(plr.getWorld())) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } if (args.length == 1) { final PlotId id = MainUtil.parseId(args[1]); if (id == null) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } final Location loc = MainUtil.getPlotHome(plr.getWorld(), id); plr.setCompassTarget(loc); - BukkitPlayerFunctions.sendMessage(plr, C.COMPASS_TARGET); + MainUtil.sendMessage(plr, C.COMPASS_TARGET); return true; } - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot target "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot target "); 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 99817ab8e..e33c84e16 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -42,23 +42,23 @@ public class Template extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); return false; } final World world = Bukkit.getWorld(args[1]); final PlotWorld plotworld = PlotSquared.getPlotWorld(args[1]); if ((world == null) || (plotworld == null)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); return false; } switch (args[0].toLowerCase()) { case "import": { // TODO import template - BukkitPlayerFunctions.sendMessage(plr, "TODO"); + MainUtil.sendMessage(plr, "TODO"); return true; } case "export": { - BukkitPlayerFunctions.sendMessage(plr, "TODO"); + MainUtil.sendMessage(plr, "TODO"); } } // TODO allow world settings (including schematics to be packed into a single file) 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 c81645695..c1221f633 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -63,35 +63,35 @@ public class Trim extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { - BukkitPlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); + MainUtil.sendMessage(plr, (C.NOT_CONSOLE)); return false; } if (args.length == 1) { final String arg = args[0].toLowerCase(); final PlotId id = getId(arg); if (id != null) { - BukkitPlayerFunctions.sendMessage(plr, "/plot trim x;z &l"); + MainUtil.sendMessage(plr, "/plot trim x;z &l"); return false; } if (arg.equals("all")) { - BukkitPlayerFunctions.sendMessage(plr, "/plot trim all &l"); + MainUtil.sendMessage(plr, "/plot trim all &l"); return false; } - BukkitPlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); + MainUtil.sendMessage(plr, C.TRIM_SYNTAX); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); + MainUtil.sendMessage(plr, C.TRIM_SYNTAX); return false; } final String arg = args[0].toLowerCase(); if (!arg.equals("all")) { - BukkitPlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX); + MainUtil.sendMessage(plr, C.TRIM_SYNTAX); return false; } final World world = Bukkit.getWorld(args[1]); if ((world == null) || (PlotSquared.getPlotWorld(world) == null)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD); + MainUtil.sendMessage(plr, C.NOT_VALID_WORLD); return false; } if (Trim.TASK) { 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 0caafc005..5e6015e85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -42,20 +42,20 @@ public class Trusted extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { - BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); + MainUtil.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; } if (!BukkitPlayerFunctions.isInPlot(plr)) { - BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); + MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - BukkitPlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); + MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.trusted")) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } if (args[0].equalsIgnoreCase("add")) { @@ -66,12 +66,12 @@ public class Trusted extends SubCommand { uuid = UUIDHandler.getUUID(args[1]); } if (uuid == null) { - BukkitPlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } if (!plot.trusted.contains(uuid)) { if (plot.owner.equals(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); + MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } if (plot.helpers.contains(uuid)) { @@ -87,21 +87,21 @@ public class Trusted extends SubCommand { final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { - BukkitPlayerFunctions.sendMessage(plr, C.ALREADY_ADDED); + MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } - BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); + MainUtil.sendMessage(plr, C.TRUSTED_ADDED); return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { final UUID uuid = DBFunc.everyone; if (!plot.trusted.contains(uuid)) { - BukkitPlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); + MainUtil.sendMessage(plr, C.T_WAS_NOT_ADDED); return true; } plot.removeTrusted(uuid); DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); - BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); + MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); @@ -109,9 +109,9 @@ public class Trusted extends SubCommand { DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); - BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); + MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); } else { - BukkitPlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); + MainUtil.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; } return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java index ee7cd9210..0b3d11c39 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java @@ -19,7 +19,7 @@ public class Unban extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { - return BukkitPlayerFunctions.sendMessage(plr, "&cUsage: &c" + this.usage); + return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); } if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); 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 aa0f11999..2f5dac440 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -48,7 +48,7 @@ public class Unclaim extends SubCommand { if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !BukkitMain.hasPermission(plr, "plots.admin.command.unclaim")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; @@ -69,9 +69,9 @@ public class Unclaim extends SubCommand { DBFunc.delete(worldname, plot); // TODO set wall block } else { - BukkitPlayerFunctions.sendMessage(plr, "Plot removal has been denied."); + MainUtil.sendMessage(plr, "Plot removal has been denied."); } - BukkitPlayerFunctions.sendMessage(plr, C.UNCLAIM_SUCCESS); + MainUtil.sendMessage(plr, C.UNCLAIM_SUCCESS); return true; } } 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 91b4ac28c..4ca93039a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -55,7 +55,7 @@ public class Unlink extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !BukkitMain.hasPermission(plr, "plots.admin.command.unlink")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } if (BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { @@ -63,7 +63,7 @@ public class Unlink extends SubCommand { } final World world = plr.getWorld(); if (!unlinkPlot(world, plot)) { - BukkitPlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled"); + MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); return false; } try { @@ -76,7 +76,7 @@ public class Unlink extends SubCommand { ex.printStackTrace(); } } - BukkitPlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!"); + MainUtil.sendMessage(plr, "&6Plots unlinked successfully!"); 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 c0f6f582a..778587e36 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 @@ -36,15 +36,15 @@ public class WE_Anywhere extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (PlotSquared.worldEdit == null) { - BukkitPlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); + MainUtil.sendMessage(plr, "&cWorldEdit is not enabled on this server"); return false; } - if (BukkitMain.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { + if (Permissions.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { PWE.removeMask(plr); - BukkitPlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask"); + MainUtil.sendMessage(plr, "&6Cleared your WorldEdit mask"); } else { PWE.setMask(plr, plr.getLocation(), true); - BukkitPlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask"); + MainUtil.sendMessage(plr, "&6Updated your WorldEdit mask"); } return true; } 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 694fee96c..dc430cf71 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -65,7 +65,7 @@ public class list extends SubCommand { } else { builder.append(getArgumentList(new String[] { "all" })); } - BukkitPlayerFunctions.sendMessage(plr, builder.toString()); + MainUtil.sendMessage(plr, builder.toString()); return true; } if (args[0].equalsIgnoreCase("forsale") && (plr != null)) { @@ -83,11 +83,11 @@ public class list extends SubCommand { } } if (idx == 0) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOTS); + MainUtil.sendMessage(plr, C.NO_PLOTS); return true; } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "Includes").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots")); - BukkitPlayerFunctions.sendMessage(plr, string.toString()); + MainUtil.sendMessage(plr, string.toString()); return true; } if (args[0].equalsIgnoreCase("mine") && (plr != null)) { @@ -99,11 +99,11 @@ public class list extends SubCommand { idx++; } if (idx == 0) { - BukkitPlayerFunctions.sendMessage(plr, C.NO_PLOTS); + MainUtil.sendMessage(plr, C.NO_PLOTS); return true; } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "You have").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots")); - BukkitPlayerFunctions.sendMessage(plr, string.toString()); + MainUtil.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("shared") && (plr != null)) { final StringBuilder string = new StringBuilder(); @@ -114,7 +114,7 @@ public class list extends SubCommand { } } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There are").replaceAll("%num%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots")); - BukkitPlayerFunctions.sendMessage(plr, string.toString()); + MainUtil.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("all")) { // Current page @@ -152,7 +152,7 @@ public class list extends SubCommand { 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%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots")); - BukkitPlayerFunctions.sendMessage(plr, string.toString()); + MainUtil.sendMessage(plr, string.toString()); return true; } else if (args[0].equalsIgnoreCase("world") && (plr != null)) { final StringBuilder string = new StringBuilder(); @@ -162,7 +162,7 @@ public class list extends SubCommand { 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 is").replaceAll("%num%", plots.values().size() + "").replaceAll("%plot%", plots.values().size() == 1 ? "plot" : "plots")); - BukkitPlayerFunctions.sendMessage(plr, string.toString()); + MainUtil.sendMessage(plr, string.toString()); return true; } else { // execute(plr); 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 4136ab8ac..ea9a73018 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -103,7 +103,7 @@ public class plugin extends SubCommand { } }; for (final String s : strings) { - BukkitPlayerFunctions.sendMessage(plr, s); + MainUtil.sendMessage(plr, s); } } }); From b904cdd51bc85ca2cb4a6f15be3c5e392f9b934a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 22:38:44 +1100 Subject: [PATCH 071/124] AUto --- .../intellectualcrafters/plot/BukkitMain.java | 1 - .../intellectualcrafters/plot/IPlotMain.java | 1 - .../plot/commands/Auto.java | 27 ++++++++----------- .../plot/commands/Ban.java | 4 +-- .../plot/commands/BukkitCommand.java | 1 - .../plot/commands/Buy.java | 4 +-- .../plot/commands/Claim.java | 8 +++--- .../plot/commands/Clear.java | 3 +-- .../plot/commands/Clipboard.java | 5 ++-- .../plot/commands/Cluster.java | 3 +-- .../plot/commands/CommandPermission.java | 1 - .../plot/commands/Comment.java | 3 +-- .../plot/commands/Condense.java | 3 +-- .../plot/commands/Copy.java | 4 +-- .../plot/commands/CreateRoadSchematic.java | 3 +-- .../plot/commands/DEOP.java | 4 +-- .../plot/commands/Database.java | 3 ++- .../plot/commands/Debug.java | 3 +-- .../plot/commands/DebugClaimTest.java | 1 + .../plot/commands/DebugClear.java | 3 +-- .../plot/commands/DebugExec.java | 4 +-- .../plot/commands/DebugFixFlags.java | 4 +-- .../plot/commands/DebugLoadTest.java | 5 ++-- .../plot/commands/DebugRoadRegen.java | 4 +-- .../plot/commands/DebugSaveTest.java | 5 ++-- .../plot/commands/Delete.java | 5 ++-- .../plot/commands/Denied.java | 3 ++- .../plot/commands/FlagCmd.java | 4 +-- .../plot/commands/Help.java | 2 +- .../plot/commands/Helpers.java | 4 +-- .../plot/commands/Home.java | 3 ++- .../plot/commands/Inbox.java | 4 +-- .../plot/commands/Info.java | 1 + .../plot/commands/Inventory.java | 3 ++- .../plot/commands/Kick.java | 3 ++- .../plot/commands/MainCommand.java | 2 -- .../plot/commands/Merge.java | 3 +-- .../plot/commands/Move.java | 3 +-- .../plot/commands/MusicSubcommand.java | 2 +- .../plot/commands/OP.java | 4 +-- .../plot/commands/Paste.java | 4 +-- .../plot/commands/Purge.java | 4 +-- .../plot/commands/Rate.java | 3 +-- .../plot/commands/RegenAllRoads.java | 2 +- .../plot/commands/Reload.java | 4 +-- .../plot/commands/Schematic.java | 3 +-- .../plot/commands/Set.java | 3 +-- .../plot/commands/SetOwner.java | 3 +-- .../plot/commands/Setup.java | 4 +-- .../plot/commands/SubCommand.java | 1 - .../plot/commands/Swap.java | 3 +-- .../plot/commands/TP.java | 2 +- .../plot/commands/Target.java | 3 +-- .../plot/commands/Template.java | 4 +-- .../plot/commands/Trim.java | 3 +-- .../plot/commands/Trusted.java | 4 +-- .../plot/commands/Unban.java | 4 +-- .../plot/commands/Unclaim.java | 4 +-- .../plot/commands/Unlink.java | 2 +- .../plot/commands/Visit.java | 3 +-- .../plot/commands/WE_Anywhere.java | 5 +--- .../plot/commands/list.java | 4 +-- .../plot/commands/plugin.java | 4 +-- .../plot/listeners/PlayerEvents.java | 2 -- .../plot/listeners/PlotPlusListener.java | 2 -- .../plot/listeners/WorldEditListener.java | 2 -- .../plot/object/BukkitPlayer.java | 11 +++----- .../plot/util/MainUtil.java | 24 +++++++++++++++-- .../util/bukkit/BukkitPlayerFunctions.java | 18 ------------- 69 files changed, 121 insertions(+), 167 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 00a0e3a88..fee316dac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -37,7 +37,6 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index b00d4acad..dba352914 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -5,7 +5,6 @@ import java.io.File; import net.milkbowl.vault.economy.Economy; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.TaskManager; public interface IPlotMain { 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 ec9a4c593..4f0280435 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -22,15 +22,10 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; - -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.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotId; @@ -38,8 +33,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.Permissions; public class Auto extends SubCommand { public Auto() { @@ -124,7 +118,8 @@ public class Auto extends SubCommand { MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); return false; } - final int diff = BukkitPlayerFunctions.getPlayerPlotCount(world, plr) - BukkitPlayerFunctions.getAllowedPlots(plr); + int currentPlots = MainUtil.getPlayerPlotCount(world, plr); + final int diff = currentPlots - MainUtil.getAllowedPlots(plr, currentPlots); if ((diff + (size_x * size_z)) > 0) { if (diff < 0) { MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); @@ -133,17 +128,17 @@ public class Auto extends SubCommand { } return false; } - final PlotWorld pWorld = PlotSquared.getPlotWorld(world.getName()); + final PlotWorld pWorld = PlotSquared.getPlotWorld(world); if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY) { double cost = pWorld.PLOT_PRICE; cost = (size_x * size_z) * cost; if (cost > 0d) { final Economy economy = PlotSquared.economy; - if (economy.getBalance(plr) < cost) { + if (economy.getBalance(plr.getName()) < cost) { sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); return true; } - economy.withdrawPlayer(plr, cost); + economy.withdrawPlayer(plr.getName(), cost); sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } @@ -159,11 +154,11 @@ public class Auto extends SubCommand { } // } } - final String worldname = world.getName(); + final String worldname = world; final PlotWorld plotworld = PlotSquared.getPlotWorld(worldname); if (plotworld.TYPE == 2) { - final Location loc = BukkitUtil.getLocation(plr); - final Plot plot = MainUtil.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(new Location(worldname, loc.getX(), loc.getY(), loc.getZ())); if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } @@ -225,7 +220,7 @@ public class Auto extends SubCommand { Claim.claimPlot(plr, plot, teleport, true); } } - if (!MainUtil.mergePlots(plr, worldname, BukkitPlayerFunctions.getPlotSelectionIds(start, end))) { + if (!MainUtil.mergePlots(worldname, MainUtil.getPlotSelectionIds(start, end), true)) { return false; } br = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java index 4a3486b5b..9f7d93a7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java @@ -1,9 +1,9 @@ package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java index e6e435896..852bfeaa2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java @@ -7,7 +7,6 @@ import java.util.List; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCommandExecutor; import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; 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 d474eacd2..ec0db781d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -22,9 +22,6 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; -import org.bukkit.World; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -32,6 +29,7 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; 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 15ed083de..baa6c6712 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -23,14 +23,12 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; @@ -44,11 +42,11 @@ public class Claim extends SubCommand { super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true); } - public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final boolean auto) { + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final boolean auto) { return claimPlot(player, plot, teleport, "", auto); } - public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) { + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) { if (plot.hasOwner() || plot.settings.isMerged()) { return false; } 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 e259a8517..5462e624e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -21,13 +21,12 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java index 1db72f37d..8768a627b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java @@ -20,11 +20,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; public class Clipboard extends SubCommand { public Clipboard() { 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 259f546e8..144e63cd8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -29,7 +29,6 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -39,10 +38,10 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Cluster extends SubCommand { 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 17329e82f..5bc566019 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -20,7 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.Permissions; 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 bbf31876c..25d876563 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -24,13 +24,12 @@ import java.util.Arrays; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Comment extends SubCommand { 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 14b37aa94..506b6cd28 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -29,14 +29,13 @@ import java.util.Set; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Condense extends SubCommand { public static boolean TASK = false; 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 f80941c19..a800e0002 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -20,11 +20,9 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 2c52265ca..5577f5b7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -20,13 +20,12 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java index 0e73c7b85..e79c15abf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java @@ -1,9 +1,9 @@ package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** 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 888fe4824..3ffbd9f09 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -13,9 +13,10 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 f1ebda2bf..54ae8c264 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -22,14 +22,13 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.Lag; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.RUtils; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Debug extends SubCommand { public Debug() { 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 8ade9b77b..3afb20e24 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -39,6 +39,7 @@ import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; 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 9501f06b1..2c6506e87 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -23,14 +23,13 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; 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 f92a01ffa..f0729e205 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -35,13 +35,13 @@ import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.ExpireManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugExec extends SubCommand { 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 59cd7a75d..ed770bd18 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -25,7 +25,6 @@ import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -34,7 +33,8 @@ import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; public class DebugFixFlags extends SubCommand { public DebugFixFlags() { 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 36aa892b2..3edf91893 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -22,11 +22,10 @@ package com.intellectualcrafters.plot.commands; import java.lang.reflect.Field; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; /** * @author Citymonstret 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 2085f7702..e08655e7c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -23,13 +23,13 @@ package com.intellectualcrafters.plot.commands; import java.util.Arrays; import org.bukkit.Chunk; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class DebugRoadRegen extends SubCommand { 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 797532c52..3391feb85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -22,12 +22,11 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; /** * @author Citymonstret 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 4d8ff392c..b198851e2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -22,14 +22,13 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; -import org.bukkit.entity.Player; - -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 6557770da..2afce81f4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -25,11 +25,12 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 a67c73fe0..6565b6b8f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -25,9 +25,7 @@ import java.util.Arrays; import java.util.HashMap; import org.apache.commons.lang.StringUtils; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; @@ -36,6 +34,8 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class FlagCmd extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java index 1f6879a41..978afa09b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java @@ -7,7 +7,7 @@ */ package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.object.PlotPlayer; public class Help extends SubCommand { public Help() { 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 06462e1ca..c82ab5e19 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -23,13 +23,13 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 5e377e0a9..3aaf74b5c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -25,7 +25,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 5b9eb91fd..0919f5f99 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -26,14 +26,14 @@ import java.util.List; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 483e1d1ca..ee8de8f56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.InfoInventory; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java index 21bde1b6a..e816e5e14 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java @@ -25,10 +25,11 @@ import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import com.intellectualcrafters.plot.object.PlotPlayer; + public class Inventory extends SubCommand { public Inventory() { super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO, true); 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 1538a4682..5db8c76aa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -23,9 +23,10 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 c40b3a3b2..70abef5fb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -24,14 +24,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * PlotSquared command class 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 338f8d925..e8311c8ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -27,14 +27,13 @@ import net.milkbowl.vault.economy.Economy; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; 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 f934ae66c..e7b76d167 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -21,11 +21,10 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * Created 2014-08-01 for PlotSquared diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index eb16571f5..8cc68c9fe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -24,13 +24,13 @@ import java.util.Arrays; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class MusicSubcommand extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java index 98808c3f9..b953d97bd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java @@ -1,9 +1,9 @@ package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** 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 a1a5b0d45..2ad66e890 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -20,11 +20,9 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 d10d6da63..50057bc14 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -27,14 +27,14 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({ "javadoc" }) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index eeed3d23f..59f3e21d8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -20,11 +20,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 8dfade597..f482ab200 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -24,13 +24,13 @@ import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; public class RegenAllRoads extends SubCommand { 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 8cb995e33..22ef1b96c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -20,13 +20,11 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Reload extends SubCommand { public Reload() { 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 1c6b2c3e6..6563a38ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -26,16 +26,15 @@ import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.jnbt.CompoundTag; -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; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; 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 db9a20f61..191e62968 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -29,9 +29,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Biome; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; @@ -44,6 +42,7 @@ import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; 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 bb5a39748..0b999315b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -24,14 +24,13 @@ import java.util.ArrayList; import java.util.UUID; import org.bukkit.World; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 7ec97a7ee..47c439242 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -31,7 +31,6 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.WorldCreator; -import org.bukkit.entity.Player; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; @@ -41,7 +40,8 @@ import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; public class Setup extends SubCommand { public final static Map setupMap = new HashMap<>(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index f2b83b4dc..f5ca65fe3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -26,7 +26,6 @@ import java.util.Arrays; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * SubCommand class 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 7d7b2d500..b2435bce1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -21,14 +21,13 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.World; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 4a2ca07c0..097d61e50 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -29,8 +29,8 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * @author Citymonstret 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 9efb7ff59..a0c676b44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -21,13 +21,12 @@ package com.intellectualcrafters.plot.commands; import org.bukkit.Location; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Target extends SubCommand { public Target() { 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 e33c84e16..3c408382d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -27,12 +27,12 @@ import java.util.zip.GZIPOutputStream; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.MainUtil; public class Template extends SubCommand { public Template() { 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 c1221f633..509143a05 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -31,16 +31,15 @@ import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; public class Trim extends SubCommand { 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 5e6015e85..5dff8fe4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -23,13 +23,13 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java index 0b3d11c39..8da5ab61f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java @@ -1,9 +1,9 @@ package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** 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 2f5dac440..54490d600 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -23,14 +23,14 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; import org.bukkit.World; -import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 4ca93039a..452426514 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -26,7 +26,6 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -34,6 +33,7 @@ import com.intellectualcrafters.plot.events.PlotUnlinkEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; 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 ab06001db..2d997d34e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -24,11 +24,10 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Visit extends SubCommand { 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 778587e36..69cd4fbd9 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 @@ -20,12 +20,9 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; public class WE_Anywhere extends SubCommand { 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 dc430cf71..5d8981f90 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.UUID; import org.bukkit.ChatColor; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -32,8 +31,9 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 ea9a73018..fad1bb18e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -27,11 +27,11 @@ import java.net.URLConnection; import java.util.ArrayList; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; public class plugin extends SubCommand { public static String downloads, version; 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 abb5739a1..4488f27b1 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,6 @@ import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.WorldInitEvent; import org.bukkit.generator.ChunkGenerator; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.commands.Setup; import com.intellectualcrafters.plot.config.C; @@ -103,7 +102,6 @@ import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 3f78b6433..66d243986 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,6 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; @@ -55,7 +54,6 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 034cad330..3cbe411b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -39,7 +39,6 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -50,7 +49,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index f07945649..5d494de28 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -17,13 +17,10 @@ public class BukkitPlayer implements PlotPlayer { private HashSet noPerm; private int op = 0; - - public BukkitPlayer(Player player, String name, UUID uuid) { - this.player = player; - this.name = name; - this.uuid = uuid; - } - + /** + * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. + * @param player + */ public BukkitPlayer(Player player) { this.player = player; } 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 6cc38eecc..5743f110b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -54,6 +54,24 @@ public class MainUtil { public static HashMap lastPlot = new HashMap<>(); public static HashMap worldBorder = new HashMap<>(); + /** + * Get the number of plots for a player + * + * @param plr + * + * @return + */ + public static int getPlayerPlotCount(final String world, final PlotPlayer plr) { + final UUID uuid = plr.getUUID(); + int count = 0; + for (final Plot plot : PlotSquared.getPlots(world).values()) { + if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { + count++; + } + } + return count; + } + public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) { final Plot bot = MainUtil.getBottomPlot(plot); @@ -189,8 +207,10 @@ public class MainUtil { final PlotId pos2 = plotIds.get(plotIds.size() - 1); final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + + // FIXME call event + manager.startPlotMerge(plotworld, plotIds); - final boolean result = false; for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { final boolean lx = x < pos2.x; @@ -234,7 +254,7 @@ public class MainUtil { } } manager.finishPlotMerge(plotworld, plotIds); - return result; + return true; } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 1b9d6b4a5..24641c2cd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -169,22 +169,4 @@ public class BukkitPlayerFunctions { } return p; } - - /** - * Get the number of plots for a player - * - * @param plr - * - * @return - */ - public static int getPlayerPlotCount(final String world, final Player plr) { - final UUID uuid = UUIDHandler.getUUID(plr); - int count = 0; - for (final Plot plot : PlotSquared.getPlots(world).values()) { - if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { - count++; - } - } - return count; - } } From 50c80ba5c40eea7ae1f3efa299dc4581f91ab97b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 22:46:33 +1100 Subject: [PATCH 072/124] color --- .../intellectualcrafters/plot/PlotSquared.java | 17 ++++++++--------- .../intellectualcrafters/plot/commands/Ban.java | 7 ++++--- .../com/intellectualcrafters/plot/config/C.java | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index b9742a59b..732961cce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -20,7 +20,6 @@ import java.util.UUID; import net.milkbowl.vault.economy.Economy; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.commands.Cluster; @@ -761,10 +760,10 @@ public class PlotSquared { 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(style.getString("color.1")); - C.COLOR_2 = ChatColor.getByChar(style.getString("color.2")); - C.COLOR_3 = ChatColor.getByChar(style.getString("color.3")); - C.COLOR_4 = ChatColor.getByChar(style.getString("color.4")); + C.COLOR_1 = "\u00A7" + (style.getString("color.1")); + C.COLOR_2 = "\u00A7" + (style.getString("color.2")); + C.COLOR_3 = "\u00A7" + (style.getString("color.3")); + C.COLOR_4 = "\u00A7" + (style.getString("color.4")); if (Settings.DEBUG) { final Map settings = new HashMap<>(); settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS); @@ -786,10 +785,10 @@ public class PlotSquared { private static void setupStyle() { style.set("version", VERSION); 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()); + o.put("color.1", C.COLOR_1.substring(1)); + o.put("color.2", C.COLOR_2.substring(1)); + o.put("color.3", C.COLOR_3.substring(1)); + o.put("color.4", C.COLOR_4.substring(1)); for (final Entry node : o.entrySet()) { if (!style.contains(node.getKey())) { style.set(node.getKey(), node.getValue()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java index 9f7d93a7e..b4092996b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java @@ -21,13 +21,14 @@ public class Ban extends SubCommand { if (args.length < 1) { return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); } - if (!BukkitPlayerFunctions.isInPlot(plr)) { + Plot plot = MainUtil.getPlot(plr.getLocation()); + if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); - if (!plot.hasRights(plr)) { + if (!plot.isAdded(plr.getUUID())) { return sendMessage(plr, C.NO_PLOT_PERMS); } + return plr.performCommand("plot denied add " + args[0]); } } 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 ac5be71dd..479355b21 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -444,7 +444,7 @@ public enum C { * @see com.intellectualsites.translation.TranslationLanguage */ protected final static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use"); - public static ChatColor COLOR_1 = ChatColor.GOLD, COLOR_2 = ChatColor.GRAY, COLOR_3 = ChatColor.DARK_GRAY, COLOR_4 = ChatColor.DARK_AQUA; + public static String COLOR_1 = "\u00A76", COLOR_2 = "\u00A77", COLOR_3 = "\u00A78", COLOR_4 = "\u00A73"; /** * The TranslationManager * From 1eb0ba47b48f755f68846b4a287e0b300589f2df Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 23:01:15 +1100 Subject: [PATCH 073/124] cmd --- .../plot/commands/Ban.java | 34 ------------------- .../plot/commands/Buy.java | 8 +++-- .../plot/commands/Claim.java | 2 +- .../plot/commands/Clear.java | 2 +- .../plot/commands/Comment.java | 2 +- .../plot/commands/Copy.java | 2 +- .../plot/commands/CreateRoadSchematic.java | 2 +- .../plot/commands/DEOP.java | 2 +- .../plot/commands/DebugClear.java | 2 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/Denied.java | 4 +-- .../plot/commands/FlagCmd.java | 2 +- .../plot/commands/Helpers.java | 2 +- .../plot/commands/Inbox.java | 2 +- .../plot/commands/Info.java | 2 +- .../plot/commands/Kick.java | 4 +-- .../plot/commands/Merge.java | 2 +- .../plot/commands/MusicSubcommand.java | 2 +- .../plot/commands/OP.java | 2 +- .../plot/commands/Paste.java | 2 +- .../plot/commands/Rate.java | 2 +- .../plot/commands/Schematic.java | 6 ++-- .../plot/commands/Set.java | 2 +- .../plot/commands/SetOwner.java | 2 +- .../plot/commands/Swap.java | 2 +- .../plot/commands/Trusted.java | 2 +- .../plot/commands/Unban.java | 2 +- .../plot/commands/Unclaim.java | 2 +- .../plot/commands/Unlink.java | 2 +- .../plot/listeners/ForceFieldListener.java | 2 +- 30 files changed, 37 insertions(+), 69 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java deleted file mode 100644 index b4092996b..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.intellectualcrafters.plot.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; - -/** - * Created 2014-11-09 for PlotSquared - * - * @author Citymonstret - */ -public class Ban extends SubCommand { - public Ban() { - super(Command.BAN, "Alias for /plot denied add", "/plot ban [player]", CommandCategory.ACTIONS, true); - } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length < 1) { - return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); - } - Plot plot = MainUtil.getPlot(plr.getLocation()); - if (plot == null) { - return sendMessage(plr, C.NOT_IN_PLOT); - } - if (!plot.isAdded(plr.getUUID())) { - return sendMessage(plr, C.NO_PLOT_PERMS); - } - - return plr.performCommand("plot denied add " + args[0]); - } -} 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 ec0db781d..d6ed4426f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -27,6 +27,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -45,10 +46,11 @@ public class Buy extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!PlotSquared.useEconomy) { + if (PlotSquared.economy == null) { return sendMessage(plr, C.ECON_DISABLED); } - final World world = plr.getWorld(); + Location loc = plr.getLocation(); + final String world = loc.getWorld(); if (!PlotSquared.isPlotWorld(world)) { return sendMessage(plr, C.NOT_IN_PLOT_WORLD); } @@ -62,7 +64,7 @@ public class Buy extends SubCommand { return sendMessage(plr, C.NOT_VALID_PLOT_ID); } } else { - plot = BukkitPlayerFunctions.getCurrentPlot(plr); + plot = MainUtil.getPlot(loc); } if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); 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 baa6c6712..58385f02c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -92,7 +92,7 @@ public class Claim extends SubCommand { if (BukkitPlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= BukkitPlayerFunctions.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (plot.hasOwner()) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } 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 5462e624e..d245d642a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -66,7 +66,7 @@ public class Clear extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } 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 25d876563..a04e250de 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -42,7 +42,7 @@ public class Comment extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!plot.hasOwner()) { return sendMessage(plr, C.NOT_IN_PLOT); } 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 a800e0002..2a13db78a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -38,7 +38,7 @@ public class Copy extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.copy")) { MainUtil.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 5577f5b7e..4591cdce2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -43,7 +43,7 @@ public class CreateRoadSchematic extends SubCommand { if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); + final Plot plot = MainUtil.getPlot(loc); final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); MainUtil.update(BukkitUtil.getLocation(entity)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java index e79c15abf..f85c18882 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java @@ -24,7 +24,7 @@ public class DEOP extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!plot.hasRights(plr)) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 2c6506e87..b1d7b316d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -84,7 +84,7 @@ public class DebugClear extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr) || !(PlotSquared.getPlotWorld(plr.getWorld()) instanceof SquarePlotWorld)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } 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 b198851e2..d16999d8a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -42,7 +42,7 @@ public class Delete extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return !sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } 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 2afce81f4..3a29cc28b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -50,7 +50,7 @@ public class Denied extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; @@ -93,7 +93,7 @@ public class Denied extends SubCommand { } final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { - final Plot pl = BukkitPlayerFunctions.getCurrentPlot(player); + final Plot pl = MainUtil.getPlot(loc); if ((pl != null) && pl.id.equals(plot.id)) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); player.teleport(player.getWorld().getSpawnLocation()); 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 6565b6b8f..5b8aaa150 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -56,7 +56,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); return false; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); 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 c82ab5e19..78c89d84f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -48,7 +48,7 @@ public class Helpers extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; 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 0919f5f99..2fd8c6803 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -54,7 +54,7 @@ public class Inbox extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if ((plot != null) && !plot.hasOwner()) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; 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 ee8de8f56..baa4e0559 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -66,7 +66,7 @@ public class Info extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; } - plot = BukkitPlayerFunctions.getCurrentPlot(player); + plot = MainUtil.getPlot(loc); } else { if (args.length < 2) { MainUtil.sendMessage(null, C.INFO_SYNTAX_CONSOLE); 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 5db8c76aa..6a3129b5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -42,7 +42,7 @@ public class Kick extends SubCommand { MainUtil.sendMessage(plr, "You're not in a plot."); return false; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; @@ -56,7 +56,7 @@ public class Kick extends SubCommand { return false; } final Player player = Bukkit.getPlayer(args[0]); - if (!player.getWorld().equals(plr.getWorld()) || !BukkitPlayerFunctions.isInPlot(player) || (BukkitPlayerFunctions.getCurrentPlot(player) == null) || !BukkitPlayerFunctions.getCurrentPlot(player).equals(plot)) { + if (!player.getWorld().equals(plr.getWorld()) || !BukkitPlayerFunctions.isInPlot(player) || (MainUtil.getPlot(loc) == null) || !MainUtil.getPlot(loc).equals(plot)) { MainUtil.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); return false; } 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 e8311c8ae..b413fbef9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -78,7 +78,7 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 8cc68c9fe..78b7526ed 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -44,7 +44,7 @@ public class MusicSubcommand extends SubCommand { sendMessage(player, C.NOT_IN_PLOT); return true; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); + final Plot plot = MainUtil.getPlot(loc); if (!plot.hasRights(player)) { sendMessage(player, C.NO_PLOT_PERMS); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java index b953d97bd..23e7aba06 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java @@ -24,7 +24,7 @@ public class OP extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!plot.hasRights(plr)) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 2ad66e890..70fcd2188 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -38,7 +38,7 @@ public class Paste extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.paste")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 59f3e21d8..440a54ab8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -47,7 +47,7 @@ public class Rate extends SubCommand { sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!plot.hasOwner()) { sendMessage(plr, C.RATING_NOT_OWNED); return true; 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 6563a38ea..5134a8b8a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -98,7 +98,7 @@ public class Schematic extends SubCommand { } final int x; final int z; - final Plot plot2 = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot2 = MainUtil.getPlot(loc); final Dimension dem = schematic.getSchematicDimension(); final Location bot = MainUtil.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1); final int length2 = MainUtil.getPlotWidth(plr.getWorld(), plot2.id); @@ -165,7 +165,7 @@ public class Schematic extends SubCommand { } final int l1 = schematic.getSchematicDimension().getX(); final int l2 = schematic.getSchematicDimension().getZ(); - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); final int length = MainUtil.getPlotWidth(plr.getWorld(), plot.id); if ((l1 < length) || (l2 < length)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); @@ -251,7 +251,7 @@ public class Schematic extends SubCommand { sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot myplot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot myplot = MainUtil.getPlot(loc); if (!myplot.hasRights(plr)) { sendMessage(plr, C.NO_PLOT_PERMS); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 191e62968..7dccdbaef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -68,7 +68,7 @@ public class Set extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!plot.hasOwner()) { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 0b999315b..8c25d99b6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -51,7 +51,7 @@ public class SetOwner extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || (plot.owner == null)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; 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 b2435bce1..fe199a973 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -53,7 +53,7 @@ public class Swap extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; 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 5dff8fe4e..92ae320c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -49,7 +49,7 @@ public class Trusted extends SubCommand { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return true; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java index 8da5ab61f..183792a60 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java @@ -24,7 +24,7 @@ public class Unban extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!plot.hasRights(plr)) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 54490d600..7c4a9413b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -44,7 +44,7 @@ public class Unclaim extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return !sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } 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 452426514..fb0d40673 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -54,7 +54,7 @@ public class Unlink extends SubCommand { if (!BukkitPlayerFunctions.isInPlot(plr)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr); + final Plot plot = MainUtil.getPlot(loc); if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index cf8e23d8e..508586a8c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -99,7 +99,7 @@ public class ForceFieldListener implements Listener { if (!BukkitPlayerFunctions.isInPlot(player)) { return; } - final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); + final Plot plot = MainUtil.getPlot(loc); if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) { if (!PlotListener.booleanFlag(plot, "forcefield", false)) { UUID uuid = UUIDHandler.getUUID(player); From 406ae58391fac100a51e876710a10fc97bb43e72 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 23:09:20 +1100 Subject: [PATCH 074/124] econ --- .../com/intellectualcrafters/plot/PlotSquared.java | 2 +- .../com/intellectualcrafters/plot/commands/Auto.java | 2 +- .../com/intellectualcrafters/plot/commands/Buy.java | 7 ++++--- .../com/intellectualcrafters/plot/commands/Claim.java | 2 +- .../com/intellectualcrafters/plot/commands/Merge.java | 2 +- .../intellectualcrafters/plot/object/PlotWorld.java | 2 +- .../intellectualcrafters/plot/util/EconHandler.java | 10 ++++++++++ .../plot/util/bukkit/BukkitPlayerFunctions.java | 2 +- 8 files changed, 20 insertions(+), 9 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 732961cce..3b1a61ee7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -381,6 +381,7 @@ public class PlotSquared { THIS = this; IMP = imp_class; VERSION = IMP.getVersion(); + economy = IMP.getEconomy(); C.setupTranslations(); C.saveTranslations(); if (getJavaVersion() < 1.7) { @@ -428,7 +429,6 @@ public class PlotSquared { if (Settings.AUTO_CLEAR) { ExpireManager.runTask(); } - economy = IMP.getEconomy(); } public void disable() { 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 4f0280435..0f30da926 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -138,7 +138,7 @@ public class Auto extends SubCommand { sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); return true; } - economy.withdrawPlayer(plr.getName(), cost); + EconHandler.withdrawPlayer(plr.getName(), cost); sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } 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 d6ed4426f..5d0841bb2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -92,12 +93,12 @@ public class Buy extends SubCommand { price += plotworld.PLOT_PRICE * size; initPrice += plotworld.SELL_PRICE * size; } - if (price > 0d) { + if (PlotSquared.economy != null && price > 0d) { final Economy economy = PlotSquared.economy; - if (economy.getBalance(plr) < price) { + if (EconHandler.getBalance(plr) < price) { return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price); } - economy.withdrawPlayer(plr, price); + EconHandler.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner); 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 58385f02c..e9f74ba69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -104,7 +104,7 @@ public class Claim extends SubCommand { if (economy.getBalance(plr) < cost) { return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); } - economy.withdrawPlayer(plr, cost); + EconHandler.withdrawPlayer(plr, cost); sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } 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 b413fbef9..4f8941dfb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -151,7 +151,7 @@ public class Merge extends SubCommand { sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + ""); return false; } - economy.withdrawPlayer(plr, cost); + EconHandler.withdrawPlayer(plr, cost); sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } 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 cf6ffd07e..af9070eec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -115,7 +115,7 @@ public abstract class PlotWorld { this.SCHEMATIC_FILE = config.getString("schematic.file"); this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim"); this.SCHEMATICS = config.getStringList("schematic.schematics"); - this.USE_ECONOMY = config.getBoolean("economy.use"); + this.USE_ECONOMY = config.getBoolean("economy.use") && PlotSquared.economy != null; this.PLOT_PRICE = config.getDouble("economy.prices.claim"); this.MERGE_PRICE = config.getDouble("economy.prices.merge"); this.SELL_PRICE = config.getDouble("economy.prices.sell"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index bae9074f9..8cca6b826 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -1,5 +1,15 @@ package com.intellectualcrafters.plot.util; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.PlotPlayer; + public class EconHandler { // TODO economy shit + public static double getBalance(PlotPlayer player) { + return PlotSquared.economy.getBalance(player.getName()); + } + + public static void withdrawPlayer(PlotPlayer player, double amount) { + EconHandler.withdrawPlayer(player.getName(), amount); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 24641c2cd..1f6f2d31d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -88,7 +88,7 @@ public class BukkitPlayerFunctions { MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); return false; } - economy.withdrawPlayer(plr, cost); + EconHandler.withdrawPlayer(plr, cost); MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + ""); } } From dc025839f5cc62a707e2587cf5e21db5ffa7e354 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 23:52:50 +1100 Subject: [PATCH 075/124] UUID --- .../intellectualcrafters/plot/BukkitMain.java | 2 +- .../plot/commands/Auto.java | 3 +- .../plot/commands/Buy.java | 13 +++--- .../plot/commands/Clear.java | 2 +- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugClear.java | 2 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/Info.java | 4 +- .../plot/commands/Merge.java | 6 +-- .../plot/commands/Paste.java | 2 +- .../plot/commands/SetOwner.java | 4 +- .../plot/commands/Unclaim.java | 2 +- .../plot/commands/Unlink.java | 6 +-- .../plot/listeners/WorldEditListener.java | 6 +-- .../plot/object/BukkitOfflinePlayer.java | 38 +++++++++++++++++ .../plot/object/BukkitPlayer.java | 2 +- .../plot/object/InfoInventory.java | 3 +- .../plot/object/OfflinePlotPlayer.java | 18 ++++++++ .../plot/object/Plot.java | 2 +- .../plot/util/ClusterManager.java | 5 ++- .../plot/util/EconHandler.java | 6 ++- .../plot/util/ExpireManager.java | 16 +++---- .../util/bukkit/BukkitPlayerFunctions.java | 9 ++-- .../plot/util/bukkit/BukkitUtil.java | 5 +-- .../plot/util/bukkit/PWE.java | 18 ++------ .../plot/util/bukkit/UUIDHandler.java | 42 ++++++++++++------- .../plot/uuid/DefaultUUIDWrapper.java | 22 ++++------ .../plot/uuid/OfflineUUIDWrapper.java | 24 +++++------ .../plot/uuid/UUIDWrapper.java | 12 +++--- 29 files changed, 167 insertions(+), 111 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index fee316dac..9ca66e3e7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -57,7 +57,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @EventHandler public static void worldLoad(final WorldLoadEvent event) { - UUIDHandler.cacheAll(); + UUIDHandler.cacheAll(event.getWorld().getName()); } public static boolean checkVersion(final int major, final int minor, final int minor2) { 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 0f30da926..e16129fcf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; @@ -138,7 +139,7 @@ public class Auto extends SubCommand { sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); return true; } - EconHandler.withdrawPlayer(plr.getName(), cost); + EconHandler.withdrawPlayer(plr, cost); sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } 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 5d0841bb2..0191f73c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -70,13 +70,14 @@ public class Buy extends SubCommand { if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - if (BukkitPlayerFunctions.getPlayerPlotCount(world, plr) >= BukkitPlayerFunctions.getAllowedPlots(plr)) { + int currentPlots = MainUtil.getPlayerPlotCount(world, plr); + if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } if (!plot.hasOwner()) { return sendMessage(plr, C.PLOT_UNOWNED); } - if (plot.owner.equals(UUIDHandler.getUUID(plr))) { + if (plot.owner.equals(plr.getUUID())) { return sendMessage(plr, C.CANNOT_BUY_OWN); } final Flag flag = FlagManager.getPlotFlag(plot, "price"); @@ -86,8 +87,8 @@ public class Buy extends SubCommand { double initPrice = (double) flag.getValue(); double price = initPrice; final PlotId id = plot.id; - final PlotId id2 = BukkitPlayerFunctions.getTopPlot(world, plot).id; - final int size = BukkitPlayerFunctions.getPlotSelectionIds(id, id2).size(); + final PlotId id2 = MainUtil.getTopPlot(world, plot).id; + final int size = MainUtil.getPlotSelectionIds(id, id2).size(); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (plotworld.USE_ECONOMY) { price += plotworld.PLOT_PRICE * size; @@ -100,14 +101,14 @@ public class Buy extends SubCommand { } EconHandler.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); - economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); + EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner); if (owner != null) { sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); } FlagManager.removePlotFlag(plot, "price"); } - plot.owner = UUIDHandler.getUUID(plr); + plot.owner = plr.getUUID(); DBFunc.setOwner(plot, plot.owner); MainUtil.sendMessage(plr, C.CLAIMED); return true; 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 d245d642a..447b3e464 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -67,7 +67,7 @@ public class Clear extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = MainUtil.getPlot(loc); - if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { 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 3afb20e24..699a1ad8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -97,7 +97,7 @@ public class DebugClaimTest extends SubCommand { final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final ArrayList plots = new ArrayList<>(); - for (final PlotId id : BukkitPlayerFunctions.getPlotSelectionIds(min, max)) { + for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) { final Plot plot = MainUtil.getPlot(world, id); final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id); if (contains) { 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 b1d7b316d..3f817236a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -85,7 +85,7 @@ public class DebugClear extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = MainUtil.getPlot(loc); - if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { 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 d16999d8a..c6f06ae7c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -43,7 +43,7 @@ public class Delete extends SubCommand { return !sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = MainUtil.getPlot(loc); - if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { 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 baa4e0559..f1bb0b464 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -163,8 +163,8 @@ public class Info extends SubCommand { private String format(String info, final World world, final Plot plot, final Player player) { final PlotId id = plot.id; - final PlotId id2 = BukkitPlayerFunctions.getTopPlot(world, plot).id; - final int num = BukkitPlayerFunctions.getPlotSelectionIds(id, id2).size(); + final PlotId id2 = MainUtil.getTopPlot(world, plot).id; + final int num = MainUtil.getPlotSelectionIds(id, id2).size(); final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; final String biome = getBiomeAt(plot).toString(); final String helpers = getPlayerList(plot.helpers); 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 4f8941dfb..37f872431 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -107,7 +107,7 @@ public class Merge extends SubCommand { } final World world = plr.getWorld(); PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id; - PlotId top = BukkitPlayerFunctions.getTopPlot(world, plot).id; + PlotId top = MainUtil.getTopPlot(world, plot).id; ArrayList plots; switch (direction) { case 0: // north = -y @@ -129,8 +129,8 @@ public class Merge extends SubCommand { final PlotId topId = plots.get(plots.size() - 1); final PlotId bot1 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, botId)).id; final PlotId bot2 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, topId)).id; - final PlotId top1 = BukkitPlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, topId)).id; - final PlotId top2 = BukkitPlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, botId)).id; + final PlotId top1 = MainUtil.getTopPlot(world, MainUtil.getPlot(world, topId)).id; + final PlotId top2 = MainUtil.getTopPlot(world, MainUtil.getPlot(world, botId)).id; bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y)); top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y)); plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, bot, top); 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 70fcd2188..d347b2d56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -43,7 +43,7 @@ public class Paste extends SubCommand { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } - if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { MainUtil.sendMessage(plr, C.UNLINK_REQUIRED); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 8c25d99b6..6712f851a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -66,8 +66,8 @@ public class SetOwner extends SubCommand { } final World world = plr.getWorld(); final PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id; - final PlotId top = BukkitPlayerFunctions.getTopPlot(world, plot).id; - final ArrayList plots = BukkitPlayerFunctions.getPlotSelectionIds(bot, top); + final PlotId top = MainUtil.getTopPlot(world, plot).id; + final ArrayList plots = MainUtil.getPlotSelectionIds(bot, top); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); final UUID uuid = getUUID(args[0]); 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 7c4a9413b..839fb5f08 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -45,7 +45,7 @@ public class Unclaim extends SubCommand { return !sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = MainUtil.getPlot(loc); - if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) { 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 fb0d40673..2b5cb847f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -58,7 +58,7 @@ public class Unlink extends SubCommand { if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } - if (BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_IMPOSSIBLE); } final World world = plr.getWorld(); @@ -82,8 +82,8 @@ public class Unlink extends SubCommand { public static boolean unlinkPlot(final World world, final Plot plot) { final PlotId pos1 = BukkitPlayerFunctions.getBottomPlot(world, plot).id; - final PlotId pos2 = BukkitPlayerFunctions.getTopPlot(world, plot).id; - final ArrayList ids = BukkitPlayerFunctions.getPlotSelectionIds(pos1, pos2); + final PlotId pos2 = MainUtil.getTopPlot(world, plot).id; + final ArrayList ids = MainUtil.getPlotSelectionIds(pos1, pos2); final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { 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 3cbe411b4..4aa9d4f4b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -78,14 +78,14 @@ public class WorldEditListener implements Listener { if ((plot == null) || (plot.owner == null)) { return; } - final Player player = UUIDHandler.uuidWrapper.getPlayer(plot.owner); + final PlotPlayer player = UUIDHandler.getPlayer(plot.owner); if (player == null) { return; } - if (!world.equals(player.getWorld().getName())) { + if (!world.equals(player.getLocation().getWorld())) { return; } - if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.worldedit.bypass")) { + if (Permissions.hasPermission(player, "plots.worldedit.bypass")) { return; } PWE.setNoMask(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java new file mode 100644 index 000000000..c09e291be --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java @@ -0,0 +1,38 @@ +package com.intellectualcrafters.plot.object; + +import java.util.UUID; + +import org.bukkit.OfflinePlayer; + +public class BukkitOfflinePlayer implements OfflinePlotPlayer { + + public final OfflinePlayer player; + + /** + * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. + * @param player + */ + public BukkitOfflinePlayer(OfflinePlayer player) { + this.player = player; + } + + @Override + public UUID getUUID() { + return player.getUniqueId(); + } + + @Override + public long getLastPlayed() { + return player.getLastPlayed(); + } + + @Override + public boolean isOnline() { + return player.isOnline(); + } + + @Override + public String getName() { + return player.getName(); + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 5d494de28..5c75a4ebf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -33,7 +33,7 @@ public class BukkitPlayer implements PlotPlayer { @Override public UUID getUUID() { if (this.uuid == null) { - this.uuid = UUIDHandler.getUUID(this.player); + this.uuid = UUIDHandler.getUUID(this); } return this.uuid; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index 040b5877f..d1da24fb4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -13,6 +13,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -50,7 +51,7 @@ public class InfoInventory implements InventoryHolder { } public InfoInventory build() { - UUID uuid = UUIDHandler.getUUID(player); + UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(player)); final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers"); final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java new file mode 100644 index 000000000..41d3865fe --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java @@ -0,0 +1,18 @@ +package com.intellectualcrafters.plot.object; + +import java.util.UUID; + +/** + * Created 2015-02-20 for PlotSquared + * + * @author Citymonstret + */ +public interface OfflinePlotPlayer { + public UUID getUUID(); + + public long getLastPlayed(); + + public boolean isOnline(); + + public String getName(); +} 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 40cfec017..a11eef6f0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -147,7 +147,7 @@ public class Plot implements Cloneable { * @return true if the player is added as a helper or is the owner */ public boolean isAdded(final UUID uuid) { - return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone))); + return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone))); } /** 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 67cd05ef3..4a9c77f8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -22,6 +22,7 @@ import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; @@ -258,9 +259,9 @@ public class ClusterManager { @Override public void run() { ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName()); - final Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner); + final PlotPlayer owner = UUIDHandler.getPlayer(cluster.owner); if (owner != null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(owner), C.CLEARING_DONE); + MainUtil.sendMessage(owner, C.CLEARING_DONE); } } }, (interval * chunks.size()) + 20); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index 8cca6b826..63cc1600e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -10,6 +10,10 @@ public class EconHandler { } public static void withdrawPlayer(PlotPlayer player, double amount) { - EconHandler.withdrawPlayer(player.getName(), amount); + PlotSquared.economy.withdrawPlayer(player.getName(), amount); + } + + public static void depositPlayer(PlotPlayer player, double amount) { + PlotSquared.economy.depositPlayer(player.getName(), amount); } } 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 4647058f6..945680cd8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -19,8 +19,10 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -86,7 +88,7 @@ public class ExpireManager { } final Plot plot = plots.iterator().next(); if (plot.owner != null) { - if (UUIDHandler.uuidWrapper.getPlayer(plot.owner) != null) { + if (UUIDHandler.getPlayer(plot.owner) != null) { expiredPlots.get(world).remove(plot); return; } @@ -102,9 +104,9 @@ public class ExpireManager { return; } for (final UUID helper : plot.helpers) { - final Player player = UUIDHandler.uuidWrapper.getPlayer(helper); + final PlotPlayer player = UUIDHandler.getPlayer(helper); if (player != null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString()); + MainUtil.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString()); } } final PlotManager manager = PlotSquared.getPlotManager(world); @@ -165,13 +167,13 @@ public class ExpireManager { if (keep.contains(uuid)) { continue; } - final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + final PlotPlayer player = UUIDHandler.getPlayer(uuid); if (player != null) { keep.add(uuid); continue; } - final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if ((op == null) || !op.hasPlayedBefore()) { + final BukkitOfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); + if ((op == null) || op.getLastPlayed() == 0) { continue; } long last = op.getLastPlayed(); @@ -184,7 +186,7 @@ public class ExpireManager { if (BukkitMain.checkVersion(1, 7, 5)) { foldername = "playerdata"; try { - filename = op.getUniqueId() + ".dat"; + filename = op.getUUID() + ".dat"; } catch (final Throwable e) { filename = uuid.toString() + ".dat"; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 1f6f2d31d..67c08488c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -35,6 +35,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; /** @@ -88,7 +89,7 @@ public class BukkitPlayerFunctions { MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); return false; } - EconHandler.withdrawPlayer(plr, cost); + EconHandler.withdrawPlayer(BukkitUtil.getPlayer(plr), cost); MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + ""); } } @@ -99,11 +100,11 @@ public class BukkitPlayerFunctions { if (uuid == null) { return "unknown"; } - final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if (!plr.hasPlayedBefore()) { + final String name = UUIDHandler.getName(uuid); + if (name == null) { return "unknown"; } - return plr.getName(); + return name; } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index b8d708fb7..14ed0e05d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -27,7 +27,6 @@ public class BukkitUtil extends BlockManager { private static String lastString = null; private static World lastWorld = null; - private static HashMap players = new HashMap<>(); private static Player lastPlayer = null; private static PlotPlayer lastPlotPlayer = null; @@ -36,7 +35,7 @@ public class BukkitUtil extends BlockManager { lastPlayer = null; lastPlotPlayer = null; } - players.remove(plr); + UUIDHandler.players.remove(plr); } public static PlotPlayer getPlayer(Player player) { @@ -44,7 +43,7 @@ public class BukkitUtil extends BlockManager { return lastPlotPlayer; } lastPlotPlayer = new BukkitPlayer(player); - players.put(lastPlotPlayer.getName(), lastPlotPlayer); + UUIDHandler.players.put(lastPlotPlayer.getName(), lastPlotPlayer); lastPlayer = player; return lastPlotPlayer; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index 6f61cf1ce..c398a4fc6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -86,13 +86,8 @@ public class PWE { } } - public static boolean hasMask(final Player p) { - LocalSession s; - if (PlotSquared.worldEdit == null) { - s = WorldEdit.getInstance().getSession(p.getName()); - } else { - s = PlotSquared.worldEdit.getSession(p); - } + public static boolean hasMask(final PlotPlayer p) { + LocalSession s = WorldEdit.getInstance().getSession(p.getName()); return !noMask(s); } @@ -101,14 +96,9 @@ public class PWE { } @SuppressWarnings("deprecation") - public static void setNoMask(final Player p) { + public static void setNoMask(final PlotPlayer p) { try { - LocalSession s; - if (PlotSquared.worldEdit == null) { - s = WorldEdit.getInstance().getSession(p.getName()); - } else { - s = PlotSquared.worldEdit.getSession(p); - } + LocalSession s = WorldEdit.getInstance().getSession(p.getName()); final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index 98f5076ef..a57033c51 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -6,16 +6,14 @@ import java.util.HashMap; import java.util.HashSet; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; @@ -24,6 +22,8 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; public class UUIDHandler { public static boolean CACHED = false; public static UUIDWrapper uuidWrapper = null; + public static HashMap players = new HashMap<>(); + /** * Map containing names and UUIDs * @@ -77,14 +77,14 @@ public class UUIDHandler { return uuidMap.containsKey(name); } - public static void cacheAll() { + public static void cacheAll(String world) { if (CACHED) { return; } PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching"); UUIDHandler.CACHED = true; final HashSet worlds = new HashSet<>(); - worlds.add(Bukkit.getWorlds().get(0).getName()); + worlds.add(world); worlds.add("world"); final HashSet uuids = new HashSet<>(); final HashSet names = new HashSet<>(); @@ -125,7 +125,7 @@ public class UUIDHandler { final UUIDWrapper wrapper = new DefaultUUIDWrapper(); for (UUID uuid : uuids) { try { - final OfflinePlayer player = wrapper.getOfflinePlayer(uuid); + final BukkitOfflinePlayer player = wrapper.getOfflinePlayer(uuid); uuid = UUIDHandler.uuidWrapper.getUUID(player); final StringWrapper name = new StringWrapper(player.getName()); add(name, uuid); @@ -134,8 +134,7 @@ public class UUIDHandler { } } for (final String name : names) { - final OfflinePlayer player = Bukkit.getOfflinePlayer(name); - final UUID uuid = UUIDHandler.uuidWrapper.getUUID(player); + final UUID uuid = uuidWrapper.getUUID(name); final StringWrapper nameWrap = new StringWrapper(name); add(nameWrap, uuid); } @@ -144,11 +143,11 @@ public class UUIDHandler { PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); } - public static UUID getUUID(final Player player) { + public static UUID getUUID(final PlotPlayer player) { return UUIDHandler.uuidWrapper.getUUID(player); } - public static UUID getUUID(final OfflinePlayer player) { + public static UUID getUUID(final BukkitOfflinePlayer player) { return UUIDHandler.uuidWrapper.getUUID(player); } @@ -157,7 +156,7 @@ public class UUIDHandler { return null; } // check online - final Player player = uuidWrapper.getPlayer(uuid); + final PlotPlayer player = UUIDHandler.getPlayer(uuid); if (player != null) { return player.getName(); } @@ -169,16 +168,27 @@ public class UUIDHandler { return null; } + public static PlotPlayer getPlayer(UUID uuid) { + for (PlotPlayer player : players.values()) { + if (player.getUUID().equals(uuid)) { + return player; + } + } + return null; + } + + public static PlotPlayer getPlayer(String name) { + return players.get(name); + } + public static UUID getUUID(final String name) { if ((name == null) || (name.length() == 0)) { return null; } // check online - final Player player = Bukkit.getPlayer(name); + final PlotPlayer player = getPlayer(name); if (player != null) { - final UUID uuid = UUIDHandler.uuidWrapper.getUUID(player); - add(new StringWrapper(name), uuid); - return uuid; + return player.getUUID(); } // check cache final StringWrapper wrap = new StringWrapper(name); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java index f251dd4d1..ca0427ae9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java @@ -3,28 +3,24 @@ package com.intellectualcrafters.plot.uuid; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.BukkitPlayer;; public class DefaultUUIDWrapper extends UUIDWrapper { @Override - public UUID getUUID(final Player player) { - return player.getUniqueId(); + public UUID getUUID(final PlotPlayer player) { + return ((BukkitPlayer) player).player.getUniqueId(); } @Override - public UUID getUUID(final OfflinePlayer player) { - return player.getUniqueId(); + public UUID getUUID(final BukkitOfflinePlayer player) { + return player.getUUID(); } @Override - public OfflinePlayer getOfflinePlayer(final UUID uuid) { - return Bukkit.getOfflinePlayer(uuid); - } - - @Override - public Player getPlayer(final UUID uuid) { - return Bukkit.getPlayer(uuid); + public BukkitOfflinePlayer getOfflinePlayer(final UUID uuid) { + return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid)); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java index 1957cc0a4..0d7b6e167 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java @@ -11,6 +11,8 @@ import org.bukkit.entity.Player; import com.google.common.base.Charsets; import com.google.common.collect.BiMap; +import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -29,17 +31,21 @@ public class OfflineUUIDWrapper extends UUIDWrapper { } @Override - public UUID getUUID(final Player player) { + public UUID getUUID(final PlotPlayer player) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); } @Override + public UUID getUUID(final BukkitOfflinePlayer player) { + return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); + } + public UUID getUUID(final OfflinePlayer player) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); } @Override - public OfflinePlayer getOfflinePlayer(final UUID uuid) { + public BukkitOfflinePlayer getOfflinePlayer(final UUID uuid) { final BiMap map = UUIDHandler.getUuidMap().inverse(); String name; try { @@ -50,12 +56,12 @@ public class OfflineUUIDWrapper extends UUIDWrapper { if (name != null) { final OfflinePlayer op = Bukkit.getOfflinePlayer(name); if (op.hasPlayedBefore()) { - return op; + return new BukkitOfflinePlayer(op); } } for (final OfflinePlayer player : Bukkit.getOfflinePlayers()) { if (getUUID(player).equals(uuid)) { - return player; + return new BukkitOfflinePlayer(player); } } return null; @@ -81,16 +87,6 @@ public class OfflineUUIDWrapper extends UUIDWrapper { } } - @Override - public Player getPlayer(final UUID uuid) { - for (final Player player : getOnlinePlayers()) { - if (getUUID(player).equals(uuid)) { - return player; - } - } - return null; - } - @Override public UUID getUUID(final String name) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java index 09b3fa649..33b5623a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java @@ -2,17 +2,15 @@ package com.intellectualcrafters.plot.uuid; import java.util.UUID; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; +import com.intellectualcrafters.plot.object.PlotPlayer; public abstract class UUIDWrapper { - public abstract UUID getUUID(Player player); + public abstract UUID getUUID(PlotPlayer player); - public abstract UUID getUUID(OfflinePlayer player); + public abstract UUID getUUID(BukkitOfflinePlayer player); public abstract UUID getUUID(String name); - public abstract OfflinePlayer getOfflinePlayer(UUID uuid); - - public abstract Player getPlayer(UUID uuid); + public abstract BukkitOfflinePlayer getOfflinePlayer(UUID uuid); } From ec1a026e8c8bc1254ca61982b19141c5414dc880 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 00:06:59 +1100 Subject: [PATCH 076/124] ff --- .../plot/listeners/ForceFieldListener.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index 508586a8c..abb608087 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -24,7 +24,6 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -33,8 +32,12 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.util.Vector; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -48,7 +51,7 @@ public class ForceFieldListener implements Listener { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !BukkitPlayerFunctions.isInPlot(oPlayer) || !BukkitPlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } - UUID uuid = UUIDHandler.getUUID(oPlayer); + UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer)); if (!plot.isAdded(uuid)) { players.add(oPlayer); } @@ -62,7 +65,7 @@ public class ForceFieldListener implements Listener { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !BukkitPlayerFunctions.isInPlot(oPlayer) || !BukkitPlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } - UUID uuid = UUIDHandler.getUUID(oPlayer); + UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer)); if (plot.isAdded(uuid)) { return oPlayer; } @@ -71,8 +74,8 @@ public class ForceFieldListener implements Listener { } public Vector calculateVelocity(final Player p, final Player e) { - final Location playerLocation = p.getLocation(); - final Location oPlayerLocation = e.getLocation(); + final org.bukkit.Location playerLocation = p.getLocation(); + final org.bukkit.Location oPlayerLocation = e.getLocation(); final double playerX = playerLocation.getX(), playerY = playerLocation.getY(), playerZ = playerLocation.getZ(), oPlayerX = oPlayerLocation.getX(), oPlayerY = oPlayerLocation.getY(), oPlayerZ = oPlayerLocation.getZ(); double x = 0d, y = 0d, z = 0d; if (playerX < oPlayerX) { @@ -96,13 +99,15 @@ public class ForceFieldListener implements Listener { @EventHandler public void onPlotEntry(final PlayerMoveEvent event) { final Player player = event.getPlayer(); - if (!BukkitPlayerFunctions.isInPlot(player)) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + Location loc = pp.getLocation(); + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { return; } - final Plot plot = MainUtil.getPlot(loc); if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) { if (!PlotListener.booleanFlag(plot, "forcefield", false)) { - UUID uuid = UUIDHandler.getUUID(player); + UUID uuid = pp.getUUID(); if (plot.isAdded(uuid)) { final Set players = getNearbyPlayers(player, plot); for (final Player oPlayer : players) { From 97df6d80b57c76fa56a97e5f15bf37afa8685bd1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 00:28:26 +1100 Subject: [PATCH 077/124] dsald --- .../plot/listeners/PlayerEvents_1_8.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 e4abd498e..70060112f 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 @@ -23,25 +23,25 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); - PlotPlayer PlotPlayer = BukkitUtil.getPlayer(e.getPlayer()); + PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(l)) { - if (!Permissions.hasPermission(PlotPlayer, "plots.admin.interact.road")) { - MainUtil.sendMessage(PlotPlayer, C.NO_PERMISSION, "plots.admin.interact.road"); + if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); } } else { final Plot plot = MainUtil.getPlot(l); if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(PlotPlayer, "plots.admin.interact.unowned")) { - MainUtil.sendMessage(PlotPlayer, C.NO_PERMISSION, "plots.admin.interact.unowned"); + if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); } } else { - UUID uuid = UUIDHandler.getUUID(p); + UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid)) { - if (!Permissions.hasPermission(PlotPlayer, "plots.admin.interact.other")) { + if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { if (isPlotArea(l)) { - MainUtil.sendMessage(PlotPlayer, C.NO_PERMISSION, "plots.admin.interact.other"); + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); } } From 48e9bc1adf6ac94259b5507261b64b4f22430284 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 00:32:37 +1100 Subject: [PATCH 078/124] PPL --- .../plot/listeners/PlayerEvents.java | 3 +-- .../plot/listeners/PlotPlusListener.java | 26 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) 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 4488f27b1..717c66c97 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -146,7 +146,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi PlotPlayer pp = BukkitUtil.getPlayer(player); final String username = pp.getName(); final StringWrapper name = new StringWrapper(username); - final UUID uuid = UUIDHandler.getUUID(player); + final UUID uuid = pp.getUUID(); UUIDHandler.add(name, uuid); final Location loc = BukkitUtil.getLocation(player.getLocation()); final Plot plot = MainUtil.getPlot(loc); @@ -656,7 +656,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } else { - UUID uuid = UUIDHandler.getUUID(p); PlotPlayer pp = BukkitUtil.getPlayer(p); if (!plot.isAdded(pp.getUUID())) if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { if (isPlotArea(loc)) { 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 66d243986..1d6546d20 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -112,7 +112,7 @@ public class PlotPlusListener extends PlotListener implements Listener { MainUtil.sendMessage(pp, C.NOT_IN_PLOT); return; } - UUID uuid = UUIDHandler.getUUID(player); + UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid)) { MainUtil.sendMessage(pp, C.NO_PLOT_PERMS); return; @@ -173,11 +173,12 @@ public class PlotPlusListener extends PlotListener implements Listener { @EventHandler public void onItemPickup(final PlayerPickupItemEvent event) { final Player player = event.getPlayer(); - final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); + PlotPlayer pp = BukkitUtil.getPlayer(player); + final Plot plot = MainUtil.getPlot(pp.getLocation()); if (plot == null) { return; } - UUID uuid = UUIDHandler.getUUID(player); + UUID uuid = pp.getUUID(); if (plot.isAdded(uuid) && booleanFlag(plot, "drop-protection", false)) { event.setCancelled(true); } @@ -186,11 +187,12 @@ public class PlotPlusListener extends PlotListener implements Listener { @EventHandler public void onItemDrop(final PlayerDropItemEvent event) { final Player player = event.getPlayer(); - final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); + PlotPlayer pp = BukkitUtil.getPlayer(player); + final Plot plot = MainUtil.getPlot(pp.getLocation()); if (plot == null) { return; } - UUID uuid = UUIDHandler.getUUID(player); + UUID uuid = pp.getUUID(); if (plot.isAdded(uuid) && booleanFlag(plot, "item-drop", false)) { event.setCancelled(true); } @@ -204,20 +206,19 @@ public class PlotPlusListener extends PlotListener implements Listener { } if (booleanFlag(plot, "notify-enter", false)) { if (plot.hasOwner()) { - final Player player = UUIDHandler.uuidWrapper.getPlayer(plot.getOwner()); - if (player == null) { + final PlotPlayer pp = UUIDHandler.getPlayer(plot.getOwner()); + if (pp == null) { return; } final Player trespasser = event.getPlayer(); PlotPlayer pt = BukkitUtil.getPlayer(trespasser); - PlotPlayer pp = BukkitUtil.getPlayer(player); if (pp.getUUID().equals(pt.getUUID())) { return; } if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) { return; } - if (player.isOnline()) { + if (pp.isOnline()) { MainUtil.sendMessage(pp, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } @@ -254,18 +255,17 @@ public class PlotPlusListener extends PlotListener implements Listener { } if (booleanFlag(plot, "notify-leave", false)) { if (plot.hasOwner()) { - final Player player = UUIDHandler.uuidWrapper.getPlayer(plot.getOwner()); - if (player == null) { + final PlotPlayer pp = UUIDHandler.getPlayer(plot.getOwner()); + if (pp == null) { return; } - PlotPlayer pp = BukkitUtil.getPlayer(player); if (pp.getUUID().equals(pl.getUUID())) { return; } if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) { return; } - if (player.isOnline()) { + if (pp.isOnline()) { MainUtil.sendMessage(pp, C.NOTIFY_LEAVE.s().replace("%player", pl.getName()).replace("%plot", plot.getId().toString())); } } From 7bd99afa25ec7ac4a28ad2223b140c14400a6c21 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 00:36:57 +1100 Subject: [PATCH 079/124] WEL --- .../plot/listeners/WorldEditListener.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 4aa9d4f4b..4741b631b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -106,10 +106,11 @@ public class WorldEditListener implements Listener { if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) { return; } - com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(b.getLocation()); + PlotPlayer pp = BukkitUtil.getPlayer(p); + com.intellectualcrafters.plot.object.Location loc = pp.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot != null) { - if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { + if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(pp.getUUID()))) { PWE.setMask(BukkitUtil.getPlayer(p), loc, false); } } @@ -127,8 +128,8 @@ public class WorldEditListener implements Listener { cmd = cmd.substring(0, cmd.indexOf(" ")); } if (this.restrictedcmds.contains(cmd)) { - final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(p)); - if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { + final Plot plot = MainUtil.getPlot(pp.getLocation()); + if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(pp.getUUID()))) { e.setCancelled(true); } return; @@ -194,7 +195,7 @@ public class WorldEditListener implements Listener { final Player p = e.getPlayer(); PlotPlayer pp = BukkitUtil.getPlayer(p); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - if (!PWE.hasMask(p)) { + if (!PWE.hasMask(pp)) { return; } } @@ -237,7 +238,7 @@ public class WorldEditListener implements Listener { final Player p = e.getPlayer(); PlotPlayer pp = BukkitUtil.getPlayer(p); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - if (!PWE.hasMask(p)) { + if (!PWE.hasMask(pp)) { return; } } From 670c0979c96e208ceb183ca6fc2d06ee91a30415 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 00:58:01 +1100 Subject: [PATCH 080/124] buy --- .../java/com/intellectualcrafters/plot/commands/Buy.java | 2 +- .../plot/listeners/InventoryListener.java | 3 --- .../java/com/intellectualcrafters/plot/util/EconHandler.java | 5 +++++ 3 files changed, 6 insertions(+), 4 deletions(-) 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 0191f73c9..3cf112d76 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -102,7 +102,7 @@ public class Buy extends SubCommand { EconHandler.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); - final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner); + PlotPlayer owner = UUIDHandler.getPlayer(plot.owner); if (owner != null) { sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index 8ec12926f..70649c1ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -14,10 +14,8 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * Created 2014-11-18 for PlotSquared - * * @author Citymonstret */ -@SuppressWarnings("unused") public class InventoryListener implements Listener { @EventHandler public void onInventoryAction(final InventoryInteractEvent event) { @@ -31,7 +29,6 @@ public class InventoryListener implements Listener { final Inventory inventory = event.getInventory(); final Player player = (Player) event.getWhoClicked(); if (inventory.getHolder() instanceof InfoInventory) { - // TODO: Do stuff switch (event.getSlot()) { case 3: case 4: diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index 63cc1600e..38e581168 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer; public class EconHandler { @@ -16,4 +17,8 @@ public class EconHandler { public static void depositPlayer(PlotPlayer player, double amount) { PlotSquared.economy.depositPlayer(player.getName(), amount); } + + public static void depositPlayer(OfflinePlotPlayer player, double amount) { + PlotSquared.economy.depositPlayer(player.getName(), amount); + } } From 694dd0432e1fbb4748de78730d476f63b3d66698 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 00:58:59 +1100 Subject: [PATCH 081/124] We should redo the command alias things --- .../plot/commands/DEOP.java | 33 ------------------- .../plot/commands/OP.java | 33 ------------------- 2 files changed, 66 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java deleted file mode 100644 index f85c18882..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellectualcrafters.plot.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; - -/** - * Created 2014-11-09 for PlotSquared - * - * @author Citymonstret - */ -public class DEOP extends SubCommand { - public DEOP() { - super(Command.DEOP, "Alias for /plot trusted remove", "/plot deop [player]", CommandCategory.ACTIONS, true); - } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length < 1) { - return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); - } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - return sendMessage(plr, C.NOT_IN_PLOT); - } - final Plot plot = MainUtil.getPlot(loc); - if (!plot.hasRights(plr)) { - return sendMessage(plr, C.NO_PLOT_PERMS); - } - return plr.performCommand("plot trusted remove " + args[0]); - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java deleted file mode 100644 index 23e7aba06..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellectualcrafters.plot.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; - -/** - * Created 2014-11-09 for PlotSquared - * - * @author Citymonstret - */ -public class OP extends SubCommand { - public OP() { - super(Command.OP, "Alias for /plot trusted add", "/plot op [player]", CommandCategory.ACTIONS, true); - } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length < 1) { - return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); - } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - return sendMessage(plr, C.NOT_IN_PLOT); - } - final Plot plot = MainUtil.getPlot(loc); - if (!plot.hasRights(plr)) { - return sendMessage(plr, C.NO_PLOT_PERMS); - } - return plr.performCommand("plot trusted add " + args[0]); - } -} From d7d012a39d024eb3e8814877172ce0bbed79f621 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 01:13:34 +1100 Subject: [PATCH 082/124] tp --- .../plot/commands/Claim.java | 18 +++++++++++------- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/Home.java | 4 ++-- .../intellectualcrafters/plot/commands/TP.java | 4 ++-- .../plot/commands/Visit.java | 4 ++-- 5 files changed, 18 insertions(+), 14 deletions(-) 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 e9f74ba69..49fbe1e03 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -50,14 +50,18 @@ public class Claim extends SubCommand { if (plot.hasOwner() || plot.settings.isMerged()) { return false; } - final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); - Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - MainUtil.createPlot(player, plot); - MainUtil.setSign(player, plot); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED); + // FIXME claim plot event +// final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); +// Bukkit.getPluginManager().callEvent(event); +// boolean result = event.isCancelled(); + boolean result = true; + + if (!result) { + MainUtil.createPlot(player.getUUID(), plot); + MainUtil.setSign(player.getName(), plot); + MainUtil.sendMessage(player, C.CLAIMED); if (teleport) { - PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); + MainUtil.teleportPlayer(player, player.getLocation(), plot); } final World world = plot.world; final PlotWorld plotworld = PlotSquared.getPlotWorld(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 699a1ad8d..a09fe55e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -67,7 +67,7 @@ public class DebugClaimTest extends SubCommand { MainUtil.setSign(player, plot); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED); if (teleport) { - PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); + MainUtil.teleportPlayer(player, player.getLocation(), plot); } } return event.isCancelled(); 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 3aaf74b5c..d9d922c04 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -50,7 +50,7 @@ public class Home extends SubCommand { public boolean execute(final PlotPlayer plr, String... args) { final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]); if (plots.length == 1) { - PlotSquared.teleportPlayer(plr, plr.getLocation(), plots[0]); + MainUtil.teleportPlayer(plr, plr.getLocation(), plots[0]); return true; } else if (plots.length > 1) { if (args.length < 1) { @@ -87,6 +87,6 @@ public class Home extends SubCommand { } public void teleportPlayer(final Player player, final Plot plot) { - PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); + MainUtil.teleportPlayer(player, player.getLocation(), plot); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java index 097d61e50..7755edf82 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -60,12 +60,12 @@ public class TP extends SubCommand { } Plot temp; if ((temp = isAlias(world, id)) != null) { - PlotSquared.teleportPlayer(plr, plr.getLocation(), temp); + MainUtil.teleportPlayer(plr, plr.getLocation(), temp); return true; } try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); - PlotSquared.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid)); + MainUtil.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid)); return true; } catch (final Exception e) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); 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 2d997d34e..2e2d82df6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -60,7 +60,7 @@ public class Visit extends SubCommand { return sendMessage(plr, C.FOUND_NO_PLOTS); } if (args.length < 2) { - PlotSquared.teleportPlayer(plr, plr.getLocation(), plots.get(0)); + MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); return true; } int i; @@ -72,7 +72,7 @@ public class Visit extends SubCommand { if ((i < 0) || (i >= plots.size())) { return sendMessage(plr, C.NOT_VALID_NUMBER); } - PlotSquared.teleportPlayer(plr, plr.getLocation(), plots.get(i)); + MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(i)); return true; } } From 54ad7fefcec09a3a23d6814d842677e401f0ef81 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 01:17:31 +1100 Subject: [PATCH 083/124] claim --- .../plot/commands/Buy.java | 1 - .../plot/commands/Claim.java | 32 +++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) 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 3cf112d76..4d3d070bb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -95,7 +95,6 @@ public class Buy extends SubCommand { initPrice += plotworld.SELL_PRICE * size; } if (PlotSquared.economy != null && price > 0d) { - final Economy economy = PlotSquared.economy; if (EconHandler.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 49fbe1e03..61d56b65c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -22,15 +22,16 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; @@ -60,12 +61,13 @@ public class Claim extends SubCommand { MainUtil.createPlot(player.getUUID(), plot); MainUtil.setSign(player.getName(), plot); MainUtil.sendMessage(player, C.CLAIMED); + Location loc = player.getLocation(); if (teleport) { - MainUtil.teleportPlayer(player, player.getLocation(), plot); + MainUtil.teleportPlayer(player, loc, plot); } - final World world = plot.world; + final String world = plot.world; final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id); + final Plot plot2 = PlotSquared.getPlots(world).get(plot.id); if (plotworld.SCHEMATIC_ON_CLAIM) { SchematicHandler.Schematic sch; if (schematic.equals("")) { @@ -76,12 +78,12 @@ public class Claim extends SubCommand { sch = SchematicHandler.getSchematic(plotworld.SCHEMATIC_FILE); } } - SchematicHandler.paste(BukkitUtil.getLocation(entity), sch, plot2, 0, 0); + SchematicHandler.paste(player.getLocation(), sch, plot2, 0, 0); } - PlotSquared.getPlotManager(plot.world).claimPlot(world, plotworld, plot); - MainUtil.update(BukkitUtil.getLocation(entity)); + PlotSquared.getPlotManager(world).claimPlot(plotworld, plot); + MainUtil.update(loc); } - return event.isCancelled(); + return !result; } @Override @@ -90,22 +92,24 @@ public class Claim extends SubCommand { if (args.length >= 1) { schematic = args[0]; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { + Location loc = plr.getLocation(); + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - if (BukkitPlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= BukkitPlayerFunctions.getAllowedPlots(plr)) { + int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr); + if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } - final Plot plot = MainUtil.getPlot(loc); if (plot.hasOwner()) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } final PlotWorld world = PlotSquared.getPlotWorld(plot.world); - if (PlotSquared.useEconomy && world.USE_ECONOMY) { + if (PlotSquared.economy != null && world.USE_ECONOMY) { final double cost = world.PLOT_PRICE; if (cost > 0d) { final Economy economy = PlotSquared.economy; - if (economy.getBalance(plr) < cost) { + if (EconHandler.getBalance(plr) < cost) { return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); } EconHandler.withdrawPlayer(plr, cost); From 2b0006b7f9850876d7372583475c0579df576fb0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 16:52:19 +1100 Subject: [PATCH 084/124] lkjdasklsad --- .../plot/commands/Clear.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 447b3e464..80021a350 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -20,14 +20,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -51,11 +51,11 @@ public class Clear extends SubCommand { if (!PlotSquared.isPlotWorld(world)) { PlotSquared.log("Invalid plot world: " + world); } else { - final Plot plot = MainUtil.getPlot(Bukkit.getWorld(world), id); + final Plot plot = MainUtil.getPlot(world, id); if (plot == null) { PlotSquared.log("Could not find plot " + args[0] + " in world " + world); } else { - plot.clear(null, false); + MainUtil.clear(world, plot, true, null); PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); } } @@ -63,17 +63,19 @@ public class Clear extends SubCommand { } return true; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { + Location loc = plr.getLocation(); + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = MainUtil.getPlot(loc); - if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(loc.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; + boolean result = MainUtil.clearAsPlayer(plot, isDelete, whenDone); plot.clear(plr, false); // sign // wall From 2e7b5e794fd2d86d8da933f517519ba18a95515a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 16:58:00 +1100 Subject: [PATCH 085/124] clear --- .../plot/commands/Clear.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 80021a350..67ba4cf7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -68,17 +68,25 @@ public class Clear extends SubCommand { if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - if (!MainUtil.getTopPlot(loc.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(loc.getWorld(), plot))) { + if (!MainUtil.getTopPlot(loc.getWorld(), plot).equals(MainUtil.getBottomPlot( plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - boolean result = MainUtil.clearAsPlayer(plot, isDelete, whenDone); - plot.clear(plr, false); + final long start = System.currentTimeMillis(); + boolean result = MainUtil.clearAsPlayer(plot, false, new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); + } + }); + if (!result) { + MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); + } // sign // wall - return true; + return result; } } From e572428e458927f07906d5999ef17c88249564c4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:05:35 +1100 Subject: [PATCH 086/124] cluster --- .../plot/commands/Clear.java | 1 - .../plot/commands/Clipboard.java | 47 ------------- .../plot/commands/Cluster.java | 68 ++++++++----------- .../plot/generator/AugmentedPopulator.java | 13 ++++ 4 files changed, 42 insertions(+), 87 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java 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 67ba4cf7e..ad26f8197 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -28,7 +28,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Clear extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java deleted file mode 100644 index 8768a627b..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java +++ /dev/null @@ -1,47 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; - -public class Clipboard extends SubCommand { - public Clipboard() { - super(Command.CLIPBOARD, "View information about your current copy", "clipboard", CommandCategory.INFO, true); - } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (!currentSelection.containsKey(plr.getName())) { - return sendMessage(plr, C.NO_CLIPBOARD); - } - final PlotSelection selection = currentSelection.get(plr.getName()); - final PlotId plotId = selection.getPlot().getId(); - final int width = selection.getWidth(); - final int total = selection.getBlocks().length; - String message = C.CLIPBOARD_INFO.s(); - message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + ""); - MainUtil.sendMessage(plr, message); - return true; - } -} 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 144e63cd8..de28e714f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -25,15 +25,12 @@ import java.util.HashSet; import java.util.Iterator; import java.util.UUID; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.generator.BlockPopulator; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; @@ -42,6 +39,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Cluster extends SubCommand { @@ -69,7 +67,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list"); return false; } - final HashSet clusters = ClusterManager.getClusters(plr.getWorld()); + final HashSet clusters = ClusterManager.getClusters(plr.getLocation().getWorld()); MainUtil.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); for (final PlotCluster cluster : clusters) { // Ignore unmanaged clusters @@ -107,7 +105,7 @@ public class Cluster extends SubCommand { } // check if name is taken final String name = args[1]; - for (final PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) { + for (final PlotCluster cluster : ClusterManager.getClusters(plr.getLocation().getWorld())) { if (name.equals(cluster.getName())) { MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; @@ -115,13 +113,13 @@ public class Cluster extends SubCommand { } //check if overlap final PlotClusterId id = new PlotClusterId(pos1, pos2); - final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); + final HashSet intersects = ClusterManager.getIntersects(plr.getLocation().getWorld(), id); if ((intersects.size() > 0) || (pos2.x < pos1.x) || (pos2.y < pos1.y)) { MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + ""); return false; } // create cluster - final String world = plr.getWorld().getName(); + final String world = plr.getLocation().getWorld(); final PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr)); cluster.settings.setAlias(name); DBFunc.createCluster(world, cluster); @@ -130,7 +128,7 @@ public class Cluster extends SubCommand { } ClusterManager.clusters.get(world).add(cluster); // Add any existing plots to the current cluster - for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { + for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster current = ClusterManager.getCluster(plot); if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { cluster.invited.add(plot.owner); @@ -139,7 +137,7 @@ public class Cluster extends SubCommand { } if (!PlotSquared.isPlotWorld(world)) { PlotSquared.config.createSection("worlds." + world); - PlotSquared.loadWorld(plr.getWorld()); + PlotSquared.loadWorld(world, null); } MainUtil.sendMessage(plr, C.CLUSTER_ADDED); return true; @@ -157,7 +155,7 @@ public class Cluster extends SubCommand { } PlotCluster cluster; if (args.length == 2) { - cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + cluster = ClusterManager.getCluster(plr.getLocation().getWorld(), args[1]); if (cluster == null) { MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; @@ -175,10 +173,10 @@ public class Cluster extends SubCommand { return false; } } - final PlotWorld plotworld = PlotSquared.getPlotWorld(plr.getWorld()); + final PlotWorld plotworld = PlotSquared.getPlotWorld(plr.getLocation().getWorld()); if (plotworld.TYPE == 2) { final ArrayList toRemove = new ArrayList<>(); - for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) { + for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster other = ClusterManager.getCluster(plot); if (cluster.equals(other)) { toRemove.add(plot); @@ -190,14 +188,7 @@ public class Cluster extends SubCommand { } DBFunc.delete(cluster); if (plotworld.TYPE == 2) { - for (final Iterator iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) { - final BlockPopulator populator = iterator.next(); - if (populator instanceof AugmentedPopulator) { - if (((AugmentedPopulator) populator).cluster.equals(cluster)) { - iterator.remove(); - } - } - } + AugmentedPopulator.removePopulator(plr.getLocation().getWorld(), cluster); } for (final String set : ClusterManager.clusters.keySet()) { } @@ -238,7 +229,7 @@ public class Cluster extends SubCommand { } //check if overlap final PlotClusterId id = new PlotClusterId(pos1, pos2); - final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); + final HashSet intersects = ClusterManager.getIntersects(plr.getLocation().getWorld(), id); if (intersects.size() > 1) { MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + ""); return false; @@ -261,7 +252,7 @@ public class Cluster extends SubCommand { } PlotCluster cluster; if (args.length == 2) { - cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + cluster = ClusterManager.getCluster(plr.getLocation().getWorld(), args[1]); if (cluster == null) { MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; @@ -315,11 +306,11 @@ public class Cluster extends SubCommand { if (!cluster.hasRights(uuid)) { // add the user if not added cluster.invited.add(uuid); - final String world = plr.getWorld().getName(); + final String world = plr.getLocation().getWorld(); DBFunc.setInvited(world, cluster, uuid); - final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + PlotPlayer player = UUIDHandler.getPlayer(uuid); if (player != null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLUSTER_INVITED, cluster.getName()); + MainUtil.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); } } MainUtil.sendMessage(plr, C.CLUSTER_ADDED_USER); @@ -364,14 +355,14 @@ public class Cluster extends SubCommand { } cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); - final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + PlotPlayer player = UUIDHandler.getPlayer(uuid); if (player != null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLUSTER_REMOVED, cluster.getName()); + MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } - for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { + for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { - final String world = plr.getWorld().getName(); + final String world = plr.getLocation().getWorld(); DBFunc.delete(world, plot); } } @@ -390,7 +381,7 @@ public class Cluster extends SubCommand { } PlotCluster cluster; if (args.length == 2) { - cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + cluster = ClusterManager.getCluster(plr.getLocation().getWorld(), args[1]); if (cluster == null) { MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; @@ -418,10 +409,10 @@ public class Cluster extends SubCommand { cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); - for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { + for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { - final String world = plr.getWorld().getName(); + final String world = plr.getLocation().getWorld(); DBFunc.delete(world, plot); } } @@ -470,7 +461,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp "); return false; } - final PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation().getWorld(), args[1]); if (cluster == null) { MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; @@ -499,7 +490,7 @@ public class Cluster extends SubCommand { } PlotCluster cluster; if (args.length == 2) { - cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + cluster = ClusterManager.getCluster(plr.getLocation().getWorld(), args[1]); if (cluster == null) { MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]); return false; @@ -551,11 +542,10 @@ public class Cluster extends SubCommand { } } final Location base = ClusterManager.getClusterBottom(cluster); - base.setY(0); - final Location relative = plr.getLocation().subtract(base); - final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); + final Location relative = plr.getLocation().subtract(base.getX(), 0, base.getZ()); + final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ()); cluster.settings.setPosition(blockloc); - DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); + DBFunc.setPosition(cluster, relative.getX() + "," + relative.getY() + "," + relative.getZ()); return MainUtil.sendMessage(plr, C.POSITION_SET); } } 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 e167c49ff..766274c7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.generator; import java.util.Arrays; +import java.util.Iterator; import java.util.Random; import org.bukkit.Bukkit; @@ -36,6 +37,18 @@ public class AugmentedPopulator extends BlockPopulator { private final int tx; private final int tz; + public static void removePopulator(String worldname, PlotCluster cluster) { + World world = Bukkit.getWorld(worldname); + for (final Iterator iterator = world.getPopulators().iterator(); iterator.hasNext();) { + final BlockPopulator populator = iterator.next(); + if (populator instanceof AugmentedPopulator) { + if (((AugmentedPopulator) populator).cluster.equals(cluster)) { + iterator.remove(); + } + } + } + } + public BlockWrapper get(final int X, final int Z, final int i, final int j, final short[][] r, final boolean c) { final int y = (i << 4) + (j >> 8); final int a = (j - ((y & 0xF) << 8)); From 029fbd7f00b909607519a494da872e52aeac1bbe Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:06:45 +1100 Subject: [PATCH 087/124] comment --- .../intellectualcrafters/plot/commands/Comment.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 a04e250de..4ed631d4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -27,9 +27,12 @@ import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Comment extends SubCommand { @@ -39,10 +42,11 @@ public class Comment extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { + Location loc = plr.getLocation(); + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = MainUtil.getPlot(loc); if (!plot.hasOwner()) { return sendMessage(plr, C.NOT_IN_PLOT); } @@ -52,7 +56,7 @@ public class Comment extends SubCommand { 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); - DBFunc.setComment(plr.getWorld().getName(), plot, comment); + DBFunc.setComment(loc.getWorld(), plot, comment); return sendMessage(plr, C.COMMENT_ADDED); } else { return sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase()); From e1bc18b00916db177ef84f2dfe475f249f052b10 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:06:59 +1100 Subject: [PATCH 088/124] imports --- .../main/java/com/intellectualcrafters/plot/commands/Buy.java | 3 --- .../java/com/intellectualcrafters/plot/commands/Claim.java | 2 -- .../java/com/intellectualcrafters/plot/commands/Cluster.java | 1 - .../java/com/intellectualcrafters/plot/commands/Comment.java | 1 - .../com/intellectualcrafters/plot/commands/DebugClaimTest.java | 1 - .../java/com/intellectualcrafters/plot/commands/FlagCmd.java | 1 - .../com/intellectualcrafters/plot/commands/MainCommand.java | 1 + .../java/com/intellectualcrafters/plot/commands/Merge.java | 1 + .../intellectualcrafters/plot/commands/MusicSubcommand.java | 1 + .../main/java/com/intellectualcrafters/plot/commands/Rate.java | 1 + .../java/com/intellectualcrafters/plot/commands/Visit.java | 1 + 11 files changed, 5 insertions(+), 9 deletions(-) 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 4d3d070bb..e0bb598f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import net.milkbowl.vault.economy.Economy; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -34,7 +32,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 61d56b65c..b22686649 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -24,7 +24,6 @@ import net.milkbowl.vault.economy.Economy; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -33,7 +32,6 @@ import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; /** * @author Citymonstret 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 de28e714f..a52b5a10e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.UUID; import com.intellectualcrafters.plot.PlotSquared; 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 4ed631d4e..fb87864d3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Comment extends SubCommand { public Comment() { 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 a09fe55e3..6e566703e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -43,7 +43,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 5b8aaa150..dc6e91e3f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -36,7 +36,6 @@ import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class FlagCmd extends SubCommand { public FlagCmd() { 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 70abef5fb..f0c4a0297 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.awt.datatransfer.Clipboard; import java.util.ArrayList; import java.util.Arrays; import java.util.List; 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 37f872431..b994c744f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -35,6 +35,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 78b7526ed..0e6be05d3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class MusicSubcommand extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 440a54ab8..d1dcbee17 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 2e2d82df6..692fa7637 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -28,6 +28,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Visit extends SubCommand { From d9b6204da338948d05c10fbed2c51a107250970d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:09:20 +1100 Subject: [PATCH 089/124] condense --- .../plot/commands/Condense.java | 16 +++++++--------- .../plot/util/bukkit/BukkitUtil.java | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) 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 506b6cd28..4017d85ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -27,8 +27,6 @@ import java.util.List; import java.util.Set; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.World; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -36,6 +34,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Condense extends SubCommand { public static boolean TASK = false; @@ -55,8 +54,7 @@ public class Condense extends SubCommand { return false; } final String worldname = args[0]; - final World world = Bukkit.getWorld(worldname); - if ((world == null) || !PlotSquared.isPlotWorld(worldname)) { + if (!BukkitUtil.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) { MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } @@ -90,13 +88,13 @@ public class Condense extends SubCommand { final List free = new ArrayList<>(); PlotId start = new PlotId(0, 0); while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) { - final Plot plot = MainUtil.getPlot(world, start); + final Plot plot = MainUtil.getPlot(worldname, start); if (!plot.hasOwner()) { free.add(plot.id); } start = Auto.getNextPlot(start, 1); } - MainUtil.move(world, to_move.get(0), free.get(0), new Runnable() { + MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() { @Override public void run() { if (!TASK) { @@ -107,7 +105,7 @@ public class Condense extends SubCommand { free.remove(0); int index = 0; for (final PlotId id : to_move) { - final Plot plot = MainUtil.getPlot(world, id); + final Plot plot = MainUtil.getPlot(worldname, id); if (plot.hasOwner()) { break; } @@ -118,7 +116,7 @@ public class Condense extends SubCommand { } index = 0; for (final PlotId id : free) { - final Plot plot = MainUtil.getPlot(world, id); + final Plot plot = MainUtil.getPlot(worldname, id); if (!plot.hasOwner()) { break; } @@ -138,7 +136,7 @@ public class Condense extends SubCommand { return; } sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0)); - MainUtil.move(world, to_move.get(0), free.get(0), this); + MainUtil.move(worldname, to_move.get(0), free.get(0), this); } }); TASK = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 14ed0e05d..44067676e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -38,6 +38,10 @@ public class BukkitUtil extends BlockManager { UUIDHandler.players.remove(plr); } + public static boolean isWorld(String world) { + return getWorld(world) != null; + } + public static PlotPlayer getPlayer(Player player) { if (player == lastPlayer) { return lastPlotPlayer; From 3852df4fd2ce5d7bed984957b0cc89f602364758 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:10:22 +1100 Subject: [PATCH 090/124] copy --- .../plot/commands/Copy.java | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java deleted file mode 100644 index 2a13db78a..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ /dev/null @@ -1,60 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; - -public class Copy extends SubCommand { - public Copy() { - super(Command.COPY, "Copy a plot", "copy", CommandCategory.ACTIONS, true); - } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return false; - } - final Plot plot = MainUtil.getPlot(loc); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.copy")) { - MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); - return false; - } - assert plot != null; - if (plot.settings.isMerged()) { - MainUtil.sendMessage(plr, C.UNLINK_REQUIRED); - return false; - } - final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); - final PlotSelection selection = new PlotSelection(size, plr.getWorld(), plot); - if (PlotSelection.currentSelection.containsKey(plr.getName())) { - PlotSelection.currentSelection.remove(plr.getName()); - } - PlotSelection.currentSelection.put(plr.getName(), selection); - sendMessage(plr, C.CLIPBOARD_SET); - return true; - } -} From bb5eb5576182e60b4d8a367f727f30fcc78c4836 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:13:52 +1100 Subject: [PATCH 091/124] hybrid --- .../plot/commands/CreateRoadSchematic.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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 4591cdce2..42ef8e481 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -22,8 +22,11 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -36,18 +39,17 @@ public class CreateRoadSchematic extends SubCommand { @Override public boolean execute(final PlotPlayer player, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(player)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); - return false; + Location loc = player.getLocation(); + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return sendMessage(player, C.NOT_IN_PLOT); } - if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { + if (!(PlotSquared.getPlotWorld(loc.getWorld()) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - final Plot plot = MainUtil.getPlot(loc); - final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); - manager.setupRoadSchematic(plot); - MainUtil.update(BukkitUtil.getLocation(entity)); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Saved new road schematic"); + HybridUtils.manager.setupRoadSchematic(plot); + MainUtil.update(loc); + MainUtil.sendMessage(player, "&6Saved new road schematic"); return true; } } From 8ccee322c6d1d5b3e1a34987c3bd4d649d411286 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:14:37 +1100 Subject: [PATCH 092/124] DB --- .../plot/commands/CreateRoadSchematic.java | 3 --- .../com/intellectualcrafters/plot/commands/Database.java | 8 +++----- 2 files changed, 3 insertions(+), 8 deletions(-) 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 42ef8e481..3818d7dbe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -22,15 +22,12 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.generator.BukkitHybridUtils; -import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class CreateRoadSchematic extends SubCommand { public CreateRoadSchematic() { 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 3ffbd9f09..5f0300bcb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -7,8 +7,6 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.UUID; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLManager; @@ -35,7 +33,7 @@ public class Database extends SubCommand { if (uuid == null) { PlotSquared.log(msg); } else { - final Player p = UUIDHandler.uuidWrapper.getPlayer(uuid); + final PlotPlayer p = UUIDHandler.getPlayer(uuid); if ((p != null) && p.isOnline()) { return MainUtil.sendMessage(p, msg); } else { @@ -138,11 +136,11 @@ public class Database extends SubCommand { return false; } - private boolean sendMessage(final Player player, final String msg) { + private boolean sendMessage(final PlotPlayer player, final String msg) { if (player == null) { PlotSquared.log(msg); } else { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), msg); + MainUtil.sendMessage(player, msg); } return true; } From 66e72759496f48e8eecd0783ec6ae5d998bac0a8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:18:45 +1100 Subject: [PATCH 093/124] RUTils --- .../plot/commands/Debug.java | 10 +----- .../plot/util/RUtils.java | 34 ------------------- 2 files changed, 1 insertion(+), 43 deletions(-) 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 54ae8c264..fdf095049 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -29,6 +29,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.Lag; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.RUtils; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Debug extends SubCommand { public Debug() { @@ -66,15 +67,6 @@ public class Debug extends SubCommand { information.append(getSection(section, "PlotWorld")); information.append(getLine(line, "Plot Worlds", worlds)); information.append(getLine(line, "Owned Plots", PlotSquared.getPlots().size())); - // information.append(getLine(line, "PlotWorld Size", - // PlotHelper.getWorldFolderSize() + "MB")); - for (final String worldname : PlotSquared.getPlotWorlds()) { - final World world = Bukkit.getWorld(worldname); - information.append(getLine(line, "World: " + world.getName() + " size", MainUtil.getWorldFolderSize(world))); - information.append(getLine(line, " - Entities", MainUtil.getEntities(world))); - information.append(getLine(line, " - Loaded Tile Entities", MainUtil.getTileEntities(world))); - information.append(getLine(line, " - Loaded Chunks", MainUtil.getLoadedChunks(world))); - } information.append(getSection(section, "RAM")); information.append(getLine(line, "Free Ram", RUtils.getFreeRam() + "MB")); information.append(getLine(line, "Total Ram", RUtils.getTotalRam() + "MB")); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java index 4277c4c1b..8ec02fae4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java @@ -20,9 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.util; -import org.bukkit.Location; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -78,37 +75,6 @@ public class RUtils { return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m).replaceAll("%hours%", s_h); } - /** - * Force textures on the client - * - * @param p texture to force - */ - public void forceTexture(final Player p) { - p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); - } - - public Direction getDirection(final Location l) { - final double d = ((l.getYaw() * 4.0F) / 360.0F) + 0.5D; - final int i = (int) d; - final int x = d < i ? i - 1 : i; - switch (x) { - case 0: - return Direction.SOUTH; - case 1: - return Direction.EAST; - case 2: - return Direction.NORTH; - case 3: - return Direction.WEST; - default: - return null; - } - } - - public boolean compareDirections(final Location l1, final Location l2) { - return getDirection(l1) == getDirection(l2); - } - enum Direction { SOUTH(0), EAST(1), From bfd4a77c6633fd9d32de520bc4002efcb0e724e2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:30:58 +1100 Subject: [PATCH 094/124] DCT --- .../plot/commands/Condense.java | 3 +- .../plot/commands/Debug.java | 3 + .../plot/commands/DebugClaimTest.java | 98 +++++++++---------- .../plot/generator/HybridUtils.java | 3 +- .../plot/util/AChunkManager.java | 2 + .../plot/util/BlockManager.java | 5 + .../plot/util/bukkit/BukkitUtil.java | 19 +++- .../plot/util/bukkit/ChunkManager.java | 5 + 8 files changed, 79 insertions(+), 59 deletions(-) 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 4017d85ec..e91a1cc1a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -54,7 +55,7 @@ public class Condense extends SubCommand { return false; } final String worldname = args[0]; - if (!BukkitUtil.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) { + if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) { MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } 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 fdf095049..d0b81aa3c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -59,6 +59,9 @@ public class Debug extends SubCommand { for (final String world : PlotSquared.getPlotWorlds()) { worlds.append(world).append(" "); } + + // FIXME not sure if we actually need any of this debug info as we should just do a timings report which is more detailed anyway + information.append(header); information.append(getSection(section, "Lag / TPS")); information.append(getLine(line, "Ticks Per Second", Lag.getTPS())); 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 6e566703e..ec1acc4d5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -23,26 +23,23 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; - import com.google.common.collect.BiMap; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -54,22 +51,24 @@ public class DebugClaimTest extends SubCommand { } @SuppressWarnings("unused") - public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) { + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) { return claimPlot(player, plot, teleport, ""); } - public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) { - final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true); - Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - MainUtil.createPlot(player, plot); - MainUtil.setSign(player, plot); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED); + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) { + // FIXME call claim event + // boolean result = event result + boolean result = true; + + if (!result) { + MainUtil.createPlot(player.getUUID(), plot); + MainUtil.setSign(player.getName(), plot); + MainUtil.sendMessage(player, C.CLAIMED); if (teleport) { MainUtil.teleportPlayer(player, player.getLocation(), plot); } } - return event.isCancelled(); + return result; } @Override @@ -78,8 +77,8 @@ public class DebugClaimTest extends SubCommand { if (args.length < 3) { return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}"); } - final World world = Bukkit.getWorld(args[0]); - if ((world == null) || !PlotSquared.isPlotWorld(world)) { + String world = args[0]; + if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) { return !MainUtil.sendMessage(null, "&cInvalid plot world!"); } PlotId min, max; @@ -103,42 +102,37 @@ public class DebugClaimTest extends SubCommand { MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id); continue; } - final Location loc = manager.getSignLoc(world, plotworld, plot); - final Chunk chunk = world.getChunkAt(loc); - if (!chunk.isLoaded()) { - final boolean result = chunk.load(false); - if (!result) { - continue; - } + final Location loc = manager.getSignLoc(plotworld, plot); + ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); + boolean result = AChunkManager.manager.loadChunk(world, chunk); + if (!result) { + continue; } - final Block block = world.getBlockAt(loc); - if (block != null) { - if (block.getState() instanceof Sign) { - final Sign sign = (Sign) block.getState(); - String line = sign.getLine(2); - if ((line != null) && (line.length() > 2)) { - line = line.substring(2); - final BiMap map = UUIDHandler.getUuidMap(); - UUID uuid = (map.get(new StringWrapper(line))); - if (uuid == null) { - for (final StringWrapper string : map.keySet()) { - if (string.value.toLowerCase().startsWith(line.toLowerCase())) { - uuid = map.get(string); - break; - } + String[] lines = BlockManager.manager.getSign(loc); + if (lines != null) { + String line = lines[2]; + if ((line != null) && (line.length() > 2)) { + line = line.substring(2); + final BiMap map = UUIDHandler.getUuidMap(); + UUID uuid = (map.get(new StringWrapper(line))); + if (uuid == null) { + for (final StringWrapper string : map.keySet()) { + if (string.value.toLowerCase().startsWith(line.toLowerCase())) { + uuid = map.get(string); + break; } } - if (uuid == null) { - uuid = UUIDHandler.getUUID(line); - } - if (uuid != null) { - MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); - plot.owner = uuid; - plot.hasChanged = true; - plots.add(plot); - } else { - MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line); - } + } + if (uuid == null) { + uuid = UUIDHandler.getUUID(line); + } + if (uuid != null) { + MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); + plot.owner = uuid; + plot.hasChanged = true; + plots.add(plot); + } else { + MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line); } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index b26fb18dd..e206b7439 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; @@ -101,7 +102,7 @@ public abstract class HybridUtils { final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez); boolean toCheck = false; if ((id1 == null) || (id2 == null) || (id1 != id2)) { - final boolean result = BukkitUtil.loadChunk(world, chunk); + final boolean result = AChunkManager.manager.loadChunk(world, chunk); if (result) { if (id1 != null) { final Plot p1 = MainUtil.getPlot(world, id1); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java index 23e0b8dd2..04471e9a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -20,6 +20,8 @@ public abstract class AChunkManager { return new ChunkLoc(x, z); } + public abstract boolean loadChunk(String world, ChunkLoc loc); + public abstract List getChunkChunks(String world); public abstract void deleteRegionFile(final String world, final ChunkLoc loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 8263868c3..df962c79a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -1,5 +1,6 @@ package com.intellectualcrafters.plot.util; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -28,6 +29,10 @@ public abstract class BlockManager { return (int) r; } + public abstract String[] getSign(Location loc); + + public abstract boolean isWorld(String world); + public abstract void functionSetBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data); public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 44067676e..8a028c753 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -38,7 +38,8 @@ public class BukkitUtil extends BlockManager { UUIDHandler.players.remove(plr); } - public static boolean isWorld(String world) { + @Override + public boolean isWorld(String world) { return getWorld(world) != null; } @@ -52,10 +53,6 @@ public class BukkitUtil extends BlockManager { return lastPlotPlayer; } - public static boolean loadChunk(String world, ChunkLoc loc) { - return getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); - } - public static Biome getBiome(final Location loc) { return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()); } @@ -202,4 +199,16 @@ public class BukkitUtil extends BlockManager { public void functionSetBlock(String worldname, int x, int y, int z, int id, byte data) { BukkitUtil.setBlock(getWorld(worldname), x, y, z, id, data); } + + @Override + public String[] getSign(Location loc) { + Block block = getWorld(loc.getWorld()).getBlockAt(loc.getX(), loc.getY(), loc.getZ()); + if (block != null) { + if (block.getState() instanceof Sign) { + final Sign sign = (Sign) block.getState(); + return sign.getLines(); + } + } + return null; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 331df271d..5bfb6c591 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -755,4 +755,9 @@ public class ChunkManager extends AChunkManager { } } } + + @Override + public boolean loadChunk(String world, ChunkLoc loc) { + return BukkitUtil.getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); + } } From 528581b63bf37230acc7108d0ccfb9423451ac66 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:37:44 +1100 Subject: [PATCH 095/124] debugclear --- .../plot/commands/Buy.java | 2 +- .../plot/commands/Clear.java | 2 +- .../plot/commands/DebugClaimTest.java | 5 +--- .../plot/commands/DebugClear.java | 29 +++++++++---------- .../plot/util/MainUtil.java | 16 +++++----- .../util/bukkit/BukkitPlayerFunctions.java | 2 +- 6 files changed, 25 insertions(+), 31 deletions(-) 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 e0bb598f2..218876b4c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -84,7 +84,7 @@ public class Buy extends SubCommand { double initPrice = (double) flag.getValue(); double price = initPrice; final PlotId id = plot.id; - final PlotId id2 = MainUtil.getTopPlot(world, plot).id; + final PlotId id2 = MainUtil.getTopPlot(plot).id; final int size = MainUtil.getPlotSelectionIds(id, id2).size(); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (plotworld.USE_ECONOMY) { 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 ad26f8197..2afd14432 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -67,7 +67,7 @@ public class Clear extends SubCommand { if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - if (!MainUtil.getTopPlot(loc.getWorld(), plot).equals(MainUtil.getBottomPlot( plot))) { + if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot( plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { 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 ec1acc4d5..387f53702 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -27,7 +27,6 @@ import com.google.common.collect.BiMap; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -39,7 +38,6 @@ import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -50,12 +48,11 @@ public class DebugClaimTest extends SubCommand { super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false); } - @SuppressWarnings("unused") public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) { return claimPlot(player, plot, teleport, ""); } - public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) { + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic) { // FIXME call claim event // boolean result = event result boolean result = true; 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 3f817236a..c142e72e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -20,17 +20,15 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -55,19 +53,18 @@ public class DebugClear extends SubCommand { if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) { PlotSquared.log("Invalid plot world: " + world); } else { - final Plot plot = MainUtil.getPlot(Bukkit.getWorld(world), id); + final Plot plot = MainUtil.getPlot(world, id); if (plot == null) { PlotSquared.log("Could not find plot " + args[0] + " in world " + world); } else { - final World bukkitWorld = Bukkit.getWorld(world); - final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); - final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); + final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); if (MainUtil.runners.containsKey(plot)) { MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); return false; } MainUtil.runners.put(plot, 1); - ChunkManager.regenerateRegion(pos1, pos2, new Runnable() { + ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { MainUtil.runners.remove(plot); @@ -81,26 +78,26 @@ public class DebugClear extends SubCommand { } return true; } - if (!BukkitPlayerFunctions.isInPlot(plr) || !(PlotSquared.getPlotWorld(plr.getWorld()) instanceof SquarePlotWorld)) { + Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null || !(PlotSquared.getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) { return sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = MainUtil.getPlot(loc); - if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; - final World bukkitWorld = plr.getWorld(); - final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); - final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id); + final Location pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1); + final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id); if (MainUtil.runners.containsKey(plot)) { MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); return false; } MainUtil.runners.put(plot, 1); - ChunkManager.regenerateRegion(pos1, pos2, new Runnable() { + ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { MainUtil.runners.remove(plot); 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 5743f110b..53414359c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -333,7 +333,7 @@ public class MainUtil { } count++; final PlotId bot = getBottomPlot(plot).id; - final PlotId top = getTopPlot(world, plot).id; + final PlotId top = getTopPlot(plot).id; plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); if (ownsPlots(world, plots, uuid, 0)) { final boolean result = mergePlots(world, plots, true); @@ -379,7 +379,7 @@ public class MainUtil { if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) { return false; } - final PlotId top = getTopPlot(world, myplot).id; + final PlotId top = getTopPlot(myplot).id; if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) { return false; } @@ -724,7 +724,7 @@ public class MainUtil { public static Location getPlotTopLoc(final String world, PlotId id) { final Plot plot = PlotSquared.getPlots(world).get(id); if (plot != null) { - id = getTopPlot(world, plot).id; + id = getTopPlot(plot).id; } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); @@ -773,7 +773,7 @@ public class MainUtil { return false; } final Plot pos1 = getBottomPlot(currentPlot); - final Plot pos2 = getTopPlot(world, currentPlot); + final Plot pos2 = getTopPlot(currentPlot); final PlotId size = MainUtil.getSize(world, currentPlot); if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { return false; @@ -967,12 +967,12 @@ public class MainUtil { return plot; } - public static Plot getTopPlot(final String world, final Plot plot) { + public static Plot getTopPlot(final Plot plot) { if (plot.settings.getMerged(2)) { - return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); + return getTopPlot(PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1))); } if (plot.settings.getMerged(1)) { - return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); + return getTopPlot(PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y))); } return plot; } @@ -982,7 +982,7 @@ public class MainUtil { if (!settings.isMerged()) { return new PlotId(1, 1); } - final Plot top = getTopPlot(world, plot); + final Plot top = getTopPlot(plot); final Plot bot = getBottomPlot(plot); return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 67c08488c..8dde1d571 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -123,7 +123,7 @@ public class BukkitPlayerFunctions { pos1 = MainUtil.getBottomPlot(plot1).id; } if (plot2 != null) { - pos2 = MainUtil.getTopPlot(world, plot2).id; + pos2 = MainUtil.getTopPlot(plot2).id; } final ArrayList myplots = new ArrayList<>(); for (int x = pos1.x; x <= pos2.x; x++) { From ab012ddc0e24ec8fdb3f9fbefa2b53101f5495a6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:42:52 +1100 Subject: [PATCH 096/124] debugexec --- .../plot/commands/DebugExec.java | 30 ++++++++++--------- .../plot/commands/Trim.java | 5 ++-- .../plot/util/ExpireManager.java | 2 -- 3 files changed, 19 insertions(+), 18 deletions(-) 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 f0729e205..ea27418db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -31,15 +31,15 @@ import java.util.List; import java.util.Map.Entry; import java.util.UUID; -import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.World; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -74,8 +74,8 @@ public class DebugExec extends SubCommand { } case "update-expired": { if (args.length > 1) { - final World world = Bukkit.getWorld(args[1]); - if (world == null) { + final String world = args[1]; + if (!BlockManager.manager.isWorld(world)) { return MainUtil.sendMessage(null, "Invalid world: " + args[1]); } MainUtil.sendMessage(null, "Updating expired plot list"); @@ -86,10 +86,13 @@ public class DebugExec extends SubCommand { } case "show-expired": { if (args.length > 1) { - final World world = Bukkit.getWorld(args[1]); - if ((world == null) || !ExpireManager.expiredPlots.containsKey(args[1])) { + final String world = args[1]; + if (!BlockManager.manager.isWorld(world)) { return MainUtil.sendMessage(null, "Invalid world: " + args[1]); } + if (!ExpireManager.expiredPlots.containsKey(args[1])) { + return MainUtil.sendMessage(null, "No task for world: " + args[1]); + } MainUtil.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):"); for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { final Plot plot = entry.getKey(); @@ -108,8 +111,8 @@ public class DebugExec extends SubCommand { if (uuid == null) { return MainUtil.sendMessage(null, "player not found: " + args[1]); } - final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if ((op == null) || !op.hasPlayedBefore()) { + BukkitOfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); + if ((op == null) || op.getLastPlayed() == 0) { return MainUtil.sendMessage(null, "player hasn't connected before: " + args[1]); } final Timestamp stamp = new Timestamp(op.getLastPlayed()); @@ -127,8 +130,8 @@ public class DebugExec extends SubCommand { MainUtil.sendMessage(null, "&7 - Generates a list of regions to trim"); return MainUtil.sendMessage(null, "&7 - Run after plot expiry has run"); } - final World world = Bukkit.getWorld(args[1]); - if ((world == null) || !PlotSquared.isPlotWorld(args[1])) { + final String world = args[1]; + if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(args[1])) { return MainUtil.sendMessage(null, "Invalid world: " + args[1]); } final ArrayList empty = new ArrayList<>(); @@ -143,9 +146,8 @@ public class DebugExec extends SubCommand { PrintWriter writer; try { writer = new PrintWriter(file); - final String worldname = world.getName(); for (final ChunkLoc loc : empty) { - writer.println(worldname + "/region/r." + loc.x + "." + loc.z + ".mca"); + writer.println(world + "/region/r." + loc.x + "." + loc.z + ".mca"); } writer.close(); Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'"); @@ -166,7 +168,7 @@ public class DebugExec extends SubCommand { } } } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); + MainUtil.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); return true; } } 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 509143a05..b5c455783 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; @@ -162,7 +163,7 @@ public class Trim extends SubCommand { return true; } - public static boolean getTrimRegions(final ArrayList empty, final World world, final Runnable whenDone) { + public static boolean getTrimRegions(final ArrayList empty, final String world, final Runnable whenDone) { if (Trim.TASK) { return false; } @@ -170,7 +171,7 @@ public class Trim extends SubCommand { sendMessage("Collecting region data..."); final ArrayList plots = new ArrayList<>(); plots.addAll(PlotSquared.getPlots(world).values()); - final HashSet chunks = new HashSet<>(ChunkManager.getChunkChunks(world)); + final HashSet chunks = new HashSet<>(AChunkManager.manager.getChunkChunks(world)); sendMessage(" - MCA #: " + chunks.size()); sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)"); sendMessage(" - TIME ESTIMATE: " + (chunks.size() / 1200) + " minutes"); 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 945680cd8..a7026c09f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -10,7 +10,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; @@ -24,7 +23,6 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ExpireManager { From b9e2abce9f6a2d268efedc0b0ecc72acdd62b9da Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:47:15 +1100 Subject: [PATCH 097/124] debug road regen --- .../plot/commands/Condense.java | 1 - .../plot/commands/Debug.java | 4 ---- .../plot/commands/DebugClear.java | 1 - .../plot/commands/DebugExec.java | 2 +- .../plot/commands/DebugFixFlags.java | 8 +++---- .../plot/commands/DebugRoadRegen.java | 22 +++++++++---------- .../plot/listeners/PlayerEvents_1_8.java | 1 - .../plot/util/ClusterManager.java | 1 - .../plot/util/RUtils.java | 1 - .../util/bukkit/BukkitPlayerFunctions.java | 1 - .../plot/util/bukkit/BukkitUtil.java | 1 - .../plot/util/bukkit/PWE.java | 2 -- .../plot/uuid/DefaultUUIDWrapper.java | 3 ++- 13 files changed, 16 insertions(+), 32 deletions(-) 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 e91a1cc1a..eb47b126f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -35,7 +35,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Condense extends SubCommand { public static boolean TASK = false; 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 d0b81aa3c..8c9ed5e36 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -20,16 +20,12 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.Bukkit; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.Lag; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.RUtils; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Debug extends SubCommand { public Debug() { 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 c142e72e8..a741fb0ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -29,7 +29,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; 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 ea27418db..66358b578 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.UUID; +import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import com.intellectualcrafters.plot.PlotSquared; @@ -38,7 +39,6 @@ import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.MainUtil; 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 ed770bd18..d37f12a7d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -23,9 +23,6 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -34,6 +31,7 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; public class DebugFixFlags extends SubCommand { @@ -51,8 +49,8 @@ public class DebugFixFlags extends SubCommand { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags "); return false; } - final World world = Bukkit.getWorld(args[0]); - if ((world == null) || !PlotSquared.isPlotWorld(world)) { + final String world = args[0]; + if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index e08655e7c..e15ce7ce9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -20,17 +20,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.Arrays; - -import org.bukkit.Chunk; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class DebugRoadRegen extends SubCommand { public DebugRoadRegen() { @@ -39,16 +36,17 @@ public class DebugRoadRegen extends SubCommand { @Override public boolean execute(final PlotPlayer player, final String... args) { - if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { + Location loc = player.getLocation(); + String world = loc.getWorld(); + if (!(PlotSquared.getPlotWorld(world) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); - final Chunk chunk = BukkitUtil.getLocation(entity).getChunk(); - final boolean result = manager.regenerateRoad(chunk); + ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); + boolean result = HybridUtils.manager.regenerateRoad(world, chunk); if (result) { - SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); + MainUtil.update(loc); } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); + MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return 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 70060112f..9c52f184f 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 @@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents_1_8 extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) 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 4a9c77f8d..42634a86c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -9,7 +9,6 @@ import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotSquared; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java index 8ec02fae4..3c2803a98 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java @@ -21,7 +21,6 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.Settings; /** * Random utilities diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 8dde1d571..7e789a4bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -27,7 +27,6 @@ import java.util.UUID; import net.milkbowl.vault.economy.Economy; -import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 8a028c753..842cfd920 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -16,7 +16,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.BukkitPlayer; -import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotPlayer; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index c398a4fc6..e9b68b1a9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.util.bukkit; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java index ca0427ae9..f3d6a78b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java @@ -3,9 +3,10 @@ package com.intellectualcrafters.plot.uuid; import java.util.UUID; import org.bukkit.Bukkit; + import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.BukkitPlayer;; public class DefaultUUIDWrapper extends UUIDWrapper { @Override From b2b4d827e87a92cbb3b8fe4b32e736f11d499a6d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:50:33 +1100 Subject: [PATCH 098/124] delete --- .../plot/commands/Delete.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) 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 c6f06ae7c..66c222d58 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -25,10 +25,13 @@ import net.milkbowl.vault.economy.Economy; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -39,11 +42,12 @@ public class Delete extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { + Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = MainUtil.getPlot(loc); - if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { @@ -51,18 +55,31 @@ public class Delete extends SubCommand { } assert plot != null; final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world); - if (PlotSquared.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + if (PlotSquared.economy != null && 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 = PlotSquared.economy; - economy.depositPlayer(plr, c); + EconHandler.depositPlayer(plr, c); sendMessage(plr, C.ADDED_BALANCE, c + ""); } } - final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true); + if (MainUtil.runners.containsKey(plot)) { + MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); + return false; + } + final boolean result = PlotSquared.removePlot(loc.getWorld(), plot.id, true); + final long start = System.currentTimeMillis(); if (result) { - plot.clear(plr, true); - DBFunc.delete(plr.getWorld().getName(), plot); + boolean result2 = MainUtil.clearAsPlayer(plot, false, new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); + } + }); + if (!result2) { + MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); + } + DBFunc.delete(loc.getWorld(), plot); } else { MainUtil.sendMessage(plr, "Plot deletion has been denied."); } From e41676544d2ec5d1e67f3b560c6edec028050da8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:52:03 +1100 Subject: [PATCH 099/124] loc --- .../plot/commands/Delete.java | 4 ---- .../plot/commands/Denied.java | 20 ++++++++++--------- .../plot/commands/FlagCmd.java | 2 ++ .../plot/commands/Helpers.java | 10 +++++----- .../plot/commands/Inbox.java | 2 +- .../plot/commands/Schematic.java | 2 +- .../plot/commands/Set.java | 6 +++--- .../plot/commands/Trusted.java | 10 +++++----- .../plot/commands/Unclaim.java | 2 +- 9 files changed, 29 insertions(+), 29 deletions(-) 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 66c222d58..ae5772426 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import net.milkbowl.vault.economy.Economy; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -32,7 +30,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Delete extends SubCommand { @@ -58,7 +55,6 @@ public class Delete extends SubCommand { if (PlotSquared.economy != null && 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 = PlotSquared.economy; EconHandler.depositPlayer(plr, c); sendMessage(plr, C.ADDED_BALANCE, c + ""); } 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 3a29cc28b..bfca432bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -28,9 +28,11 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -46,11 +48,11 @@ public class Denied extends SubCommand { MainUtil.sendMessage(plr, C.DENIED_NEED_ARGUMENT); return true; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return true; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; @@ -77,14 +79,14 @@ public class Denied extends SubCommand { } if (plot.trusted.contains(uuid)) { plot.trusted.remove(uuid); - DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); + DBFunc.removeTrusted(loc.getWorld(), plot, uuid); } if (plot.helpers.contains(uuid)) { plot.helpers.remove(uuid); - DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); + DBFunc.removeHelper(loc.getWorld(), plot, uuid); } plot.addDenied(uuid); - DBFunc.setDenied(plr.getWorld().getName(), plot, uuid); + DBFunc.setDenied(loc.getWorld(), plot, uuid); final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { @@ -109,13 +111,13 @@ public class Denied extends SubCommand { return true; } plot.removeDenied(uuid); - DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); + DBFunc.removeDenied(loc.getWorld(), plot, uuid); MainUtil.sendMessage(plr, C.DENIED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeDenied(uuid); - DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); + DBFunc.removeDenied(loc.getWorld(), plot, uuid); final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); MainUtil.sendMessage(plr, C.DENIED_REMOVED); 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 dc6e91e3f..bc8af3d98 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.listeners.PlotListener; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -55,6 +56,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); return false; } + Location loc = player.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); 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 78c89d84f..9dbcfc490 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -75,14 +75,14 @@ public class Helpers extends SubCommand { } if (plot.trusted.contains(uuid)) { plot.trusted.remove(uuid); - DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); + DBFunc.removeTrusted(loc.getWorld(), plot, uuid); } if (plot.denied.contains(uuid)) { plot.denied.remove(uuid); - DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); + DBFunc.removeDenied(loc.getWorld(), plot, uuid); } plot.addHelper(uuid); - DBFunc.setHelper(plr.getWorld().getName(), plot, uuid); + DBFunc.setHelper(loc.getWorld(), plot, uuid); final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { @@ -99,13 +99,13 @@ public class Helpers extends SubCommand { return true; } plot.removeHelper(uuid); - DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); + DBFunc.removeHelper(loc.getWorld(), plot, uuid); MainUtil.sendMessage(plr, C.HELPER_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeHelper(uuid); - DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); + DBFunc.removeHelper(loc.getWorld(), plot, uuid); final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); MainUtil.sendMessage(plr, C.HELPER_REMOVED); 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 2fd8c6803..41064de4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -131,7 +131,7 @@ public class Inbox extends SubCommand { } else { below = true; } - final String world = plr.getWorld().getName(); + final String world = loc.getWorld(); final int tier2 = tier; Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { @Override 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 5134a8b8a..0c4fca7d6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -257,7 +257,7 @@ public class Schematic extends SubCommand { return false; } p2 = myplot; - world = plr.getWorld().getName(); + world = loc.getWorld(); } else { if (args.length == 3) { try { 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 7dccdbaef..3b5732eb3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -169,7 +169,7 @@ public class Set extends SubCommand { if (args.length > 1) { if (args[1].equalsIgnoreCase("none")) { plot.settings.setPosition(null); - DBFunc.setPosition(plr.getWorld().getName(), plot, ""); + DBFunc.setPosition(loc.getWorld(), plot, ""); return true; } return MainUtil.sendMessage(plr, C.HOME_ARGUMENT); @@ -181,7 +181,7 @@ public class Set extends SubCommand { final Location relative = plr.getLocation().subtract(base); final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); plot.settings.setPosition(blockloc); - DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); + DBFunc.setPosition(loc.getWorld(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); return MainUtil.sendMessage(plr, C.POSITION_SET); } if (args[0].equalsIgnoreCase("alias")) { @@ -204,7 +204,7 @@ public class Set extends SubCommand { return false; } } - DBFunc.setAlias(plr.getWorld().getName(), plot, alias); + DBFunc.setAlias(loc.getWorld(), plot, alias); MainUtil.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); return true; } 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 92ae320c3..e32a18db8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -76,14 +76,14 @@ public class Trusted extends SubCommand { } if (plot.helpers.contains(uuid)) { plot.helpers.remove(uuid); - DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid); + DBFunc.removeHelper(loc.getWorld(), plot, uuid); } if (plot.denied.contains(uuid)) { plot.denied.remove(uuid); - DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid); + DBFunc.removeDenied(loc.getWorld(), plot, uuid); } plot.addTrusted(uuid); - DBFunc.setTrusted(plr.getWorld().getName(), plot, uuid); + DBFunc.setTrusted(loc.getWorld(), plot, uuid); final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); } else { @@ -100,13 +100,13 @@ public class Trusted extends SubCommand { return true; } plot.removeTrusted(uuid); - DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); + DBFunc.removeTrusted(loc.getWorld(), plot, uuid); MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeTrusted(uuid); - DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid); + DBFunc.removeTrusted(loc.getWorld(), plot, uuid); final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false); Bukkit.getPluginManager().callEvent(event); MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); 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 839fb5f08..ea46acab5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -61,7 +61,7 @@ public class Unclaim extends SubCommand { sendMessage(plr, C.ADDED_BALANCE, c + ""); } } - final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true); + final boolean result = PlotSquared.removePlot(loc.getWorld(), plot.id, true); if (result) { final World world = plr.getWorld(); final String worldname = world.getName(); From 46e2b1344ecb368061df1c54b8e32b3c32bbc79f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:56:46 +1100 Subject: [PATCH 100/124] Denied --- .../intellectualcrafters/plot/commands/Denied.java | 14 ++++++-------- .../plot/util/BlockManager.java | 2 ++ .../plot/util/bukkit/BukkitUtil.java | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) 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 bfca432bf..e10febc96 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -31,12 +31,12 @@ import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings("deprecation") public class Denied extends SubCommand { public Denied() { super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS, true); @@ -87,18 +87,17 @@ public class Denied extends SubCommand { } plot.addDenied(uuid); DBFunc.setDenied(loc.getWorld(), plot, uuid); - final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true); - Bukkit.getPluginManager().callEvent(event); + //FIXME PlayerPlotDeniedEvent } else { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } - final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + final PlotPlayer player = UUIDHandler.getPlayer(uuid); if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { final Plot pl = MainUtil.getPlot(loc); if ((pl != null) && pl.id.equals(plot.id)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); - player.teleport(player.getWorld().getSpawnLocation()); + MainUtil.sendMessage(player, C.YOU_BE_DENIED); + player.teleport(BlockManager.manager.getSpawn(loc.getWorld())); } } MainUtil.sendMessage(plr, C.DENIED_ADDED); @@ -118,8 +117,7 @@ public class Denied extends SubCommand { final UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeDenied(uuid); DBFunc.removeDenied(loc.getWorld(), plot, uuid); - final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false); - Bukkit.getPluginManager().callEvent(event); + // FIXME PlayerPlotDeniedEvent MainUtil.sendMessage(plr, C.DENIED_REMOVED); } else { MainUtil.sendMessage(plr, C.DENIED_NEED_ARGUMENT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index df962c79a..272e25422 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -29,6 +29,8 @@ public abstract class BlockManager { return (int) r; } + public abstract Location getSpawn(String world); + public abstract String[] getSign(Location loc); public abstract boolean isWorld(String world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 842cfd920..c3bb572d9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -210,4 +210,10 @@ public class BukkitUtil extends BlockManager { } return null; } + + @Override + public Location getSpawn(String world) { + org.bukkit.Location temp = getWorld(world).getSpawnLocation(); + return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ()); + } } From 9eb1b0f6f5a9112ce462a8ed7486cb8422ad3e69 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:59:29 +1100 Subject: [PATCH 101/124] flag cmd --- .../plot/commands/FlagCmd.java | 91 ++++++++++--------- .../plot/listeners/PlotListener.java | 6 ++ 2 files changed, 52 insertions(+), 45 deletions(-) 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 bc8af3d98..4c34cbd96 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; public class FlagCmd extends SubCommand { public FlagCmd() { @@ -53,102 +54,102 @@ public class FlagCmd extends SubCommand { * plot flag list */ if (args.length == 0) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); return false; } Location loc = player.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); + MainUtil.sendMessage(player, C.NOT_IN_PLOT); return false; } if (!plot.hasOwner()) { sendMessage(player, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(player) && !Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag.other")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag.other"); + if (!plot.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.set.flag.other")) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other"); return false; } switch (args[0].toLowerCase()) { case "info": { - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.info"); + if (!Permissions.hasPermission(player, "plots.set.flag")) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.info"); return false; } if (args.length != 2) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info "); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1]); if (af == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info "); + MainUtil.sendMessage(player, C.NOT_VALID_FLAG); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); return false; } // flag key - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_KEY, af.getKey()); + MainUtil.sendMessage(player, C.FLAG_KEY, af.getKey()); // flag type - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_TYPE, af.value.getClass().getSimpleName()); + MainUtil.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName()); // Flag type description - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_DESC, af.getValueDesc()); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&cNot implemented."); + MainUtil.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); + MainUtil.sendMessage(player, "&cNot implemented."); } case "set": { - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag"); + if (!Permissions.hasPermission(player, "plots.set.flag")) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); return false; } if (args.length < 3) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag set "); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); + MainUtil.sendMessage(player, C.NOT_VALID_FLAG); return false; } - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc()); + MainUtil.sendMessage(player, "&c" + af.getValueDesc()); return false; } final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed); final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED); + MainUtil.sendMessage(player, C.FLAG_NOT_ADDED); return false; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_ADDED); + MainUtil.sendMessage(player, C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "remove": { - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.remove")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.remove"); + if (!Permissions.hasPermission(player, "plots.flag.remove")) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove"); return false; } if ((args.length != 2) && (args.length != 3)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag remove [values]"); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove [values]"); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); + MainUtil.sendMessage(player, C.NOT_VALID_FLAG); return false; } - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()); if (flag == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_IN_PLOT); + MainUtil.sendMessage(player, C.FLAG_NOT_IN_PLOT); return false; } if ((args.length == 3) && flag.getAbstractFlag().isList()) { @@ -158,36 +159,36 @@ public class FlagCmd extends SubCommand { } else { final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); if (!result) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_REMOVED); + MainUtil.sendMessage(player, C.FLAG_NOT_REMOVED); return false; } } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_REMOVED); + MainUtil.sendMessage(player, C.FLAG_REMOVED); PlotListener.plotEntry(player, plot); return true; } case "add": { - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.add")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.add"); + if (!Permissions.hasPermission(player, "plots.flag.add")) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.add"); return false; } if (args.length < 3) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag add "); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); + MainUtil.sendMessage(player, C.NOT_VALID_FLAG); return false; } - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.set.flag." + args[1].toLowerCase())) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc()); + MainUtil.sendMessage(player, "&c" + af.getValueDesc()); return false; } Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase()); @@ -198,21 +199,21 @@ public class FlagCmd extends SubCommand { } final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED); + MainUtil.sendMessage(player, C.FLAG_NOT_ADDED); return false; } DBFunc.setFlags(plot.world, plot, plot.settings.flags); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_ADDED); + MainUtil.sendMessage(player, C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "list": { - if (!Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.flag.list")) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.list"); + if (!Permissions.hasPermission(player, "plots.flag.list")) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.list"); return false; } if (args.length != 1) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag list"); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list"); return false; } final HashMap> flags = new HashMap<>(); @@ -229,11 +230,11 @@ public class FlagCmd extends SubCommand { message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", "); prefix = "\n"; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), message); + MainUtil.sendMessage(player, message); return true; } } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); return false; } } 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 0b8b089a6..99646b975 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -36,9 +36,11 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.util.ClusterManager; @@ -149,6 +151,10 @@ public class PlotListener { } } + public static void plotEntry(final PlotPlayer player, final Plot plot) { + plotEntry(((BukkitPlayer) player).player, plot); + } + public static void plotEntry(final Player player, final Plot plot) { if (plot.hasOwner()) { final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode"); From ef9e1dd1acd4067f6159e06ad0f552cd540d64ae Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:03:25 +1100 Subject: [PATCH 102/124] inplot --- .../plot/commands/Helpers.java | 9 +-- .../plot/commands/Inbox.java | 9 +-- .../plot/commands/Info.java | 9 +-- .../plot/commands/Kick.java | 9 +-- .../plot/commands/Merge.java | 9 +-- .../plot/commands/MusicSubcommand.java | 9 +-- .../plot/commands/Paste.java | 67 ------------------- .../plot/commands/Rate.java | 9 +-- .../plot/commands/Schematic.java | 9 +-- .../plot/commands/Set.java | 8 +-- .../plot/commands/Swap.java | 9 +-- .../plot/commands/Trusted.java | 9 +-- .../plot/commands/Unban.java | 33 --------- .../plot/commands/Unclaim.java | 6 +- .../plot/commands/Unlink.java | 8 ++- .../plot/commands/WE_Anywhere.java | 1 + 16 files changed, 64 insertions(+), 149 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java 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 9dbcfc490..df4a5d532 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -27,6 +27,7 @@ import org.bukkit.Bukkit; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -44,11 +45,11 @@ public class Helpers extends SubCommand { MainUtil.sendMessage(plr, C.HELPER_NEED_ARGUMENT); return true; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return true; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; 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 41064de4e..b64e26082 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -30,6 +30,7 @@ import org.bukkit.Bukkit; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -50,11 +51,11 @@ public class Inbox extends SubCommand { report = true; } } - if (!BukkitPlayerFunctions.isInPlot(plr) && !report) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return false; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null && !report) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if ((plot != null) && !plot.hasOwner()) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; 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 f1bb0b464..c7dd552ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -57,14 +57,15 @@ public class Info extends SubCommand { World world; Plot plot; if (player != null) { - world = player.getWorld(); + Location loc = player.getLocation(); + String world = loc.getWorld(); if (!PlotSquared.isPlotWorld(world)) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT_WORLD); return false; } - if (!BukkitPlayerFunctions.isInPlot(player)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); - return false; + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); } plot = MainUtil.getPlot(loc); } else { 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 6a3129b5b..5c7850a95 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -24,6 +24,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -38,11 +39,11 @@ public class Kick extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, "You're not in a plot."); - return false; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; 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 b994c744f..a824c664e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -31,6 +31,7 @@ import org.bukkit.World; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlotMergeEvent; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -75,11 +76,11 @@ public class Merge extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return true; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 0e6be05d3..9d9e839b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -29,6 +29,7 @@ import org.bukkit.inventory.meta.ItemMeta; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.listeners.PlotPlusListener; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -41,11 +42,11 @@ public class MusicSubcommand extends SubCommand { @Override public boolean execute(final PlotPlayer player, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(player)) { - sendMessage(player, C.NOT_IN_PLOT); - return true; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if (!plot.hasRights(player)) { sendMessage(player, C.NO_PLOT_PERMS); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java deleted file mode 100644 index d347b2d56..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ /dev/null @@ -1,67 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// 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.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; - -public class Paste extends SubCommand { - public Paste() { - super(Command.PASTE, "Paste a plot", "paste", CommandCategory.ACTIONS, true); - } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return false; - } - final Plot plot = MainUtil.getPlot(loc); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.paste")) { - MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); - return false; - } - if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { - MainUtil.sendMessage(plr, C.UNLINK_REQUIRED); - return false; - } - assert plot != null; - final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX()); - if (PlotSelection.currentSelection.containsKey(plr.getName())) { - final PlotSelection selection = PlotSelection.currentSelection.get(plr.getName()); - if (size != selection.getWidth()) { - sendMessage(plr, C.PASTE_FAILED, "The size of the current plot is not the same as the paste"); - return false; - } - selection.paste(plr.getWorld(), plot); - sendMessage(plr, C.PASTED); - } else { - sendMessage(plr, C.NO_CLIPBOARD); - return false; - } - PlotSelection.currentSelection.remove(plr.getName()); - return true; - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index d1dcbee17..435dc061e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -44,11 +45,11 @@ public class Rate extends SubCommand { sendMessage(plr, C.RATING_NOT_VALID); return true; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - sendMessage(plr, C.NOT_IN_PLOT); - return true; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if (!plot.hasOwner()) { sendMessage(plr, C.RATING_NOT_OWNED); return true; 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 0c4fca7d6..a219479ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -36,6 +36,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; @@ -247,11 +248,11 @@ public class Schematic extends SubCommand { final String world; final Plot p2; if (plr != null) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { - sendMessage(plr, C.NOT_IN_PLOT); - return false; + Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); } - final Plot myplot = MainUtil.getPlot(loc); if (!myplot.hasRights(plr)) { sendMessage(plr, C.NO_PLOT_PERMS); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 3b5732eb3..1a302f0b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -64,11 +64,11 @@ public class Set extends SubCommand { @SuppressWarnings("deprecation") @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return false; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if (!plot.hasOwner()) { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; 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 fe199a973..fe50a2b6f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -25,6 +25,7 @@ import org.bukkit.World; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -49,11 +50,11 @@ public class Swap extends SubCommand { MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return false; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; 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 e32a18db8..629e5765f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -27,6 +27,7 @@ import org.bukkit.Bukkit; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -45,11 +46,11 @@ public class Trusted extends SubCommand { MainUtil.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); - return true; - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if ((plot == null) || !plot.hasOwner()) { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java deleted file mode 100644 index 183792a60..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellectualcrafters.plot.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; - -/** - * Created 2014-11-09 for PlotSquared - * - * @author Citymonstret - */ -public class Unban extends SubCommand { - public Unban() { - super(Command.UNBAN, "Alias for /plot denied remove", "/plot unban [player]", CommandCategory.ACTIONS, true); - } - - @Override - public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length < 1) { - return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage); - } - if (!BukkitPlayerFunctions.isInPlot(plr)) { - return sendMessage(plr, C.NOT_IN_PLOT); - } - final Plot plot = MainUtil.getPlot(loc); - if (!plot.hasRights(plr)) { - return sendMessage(plr, C.NO_PLOT_PERMS); - } - return plr.performCommand("plot denied remove " + args[0]); - } -} 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 ea46acab5..3ee36d6a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -27,6 +27,7 @@ import org.bukkit.World; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; @@ -41,10 +42,11 @@ public class Unclaim extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { + Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - final Plot plot = MainUtil.getPlot(loc); if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } 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 2b5cb847f..0fc40c6c4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotUnlinkEvent; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; @@ -51,10 +52,11 @@ public class Unlink extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!BukkitPlayerFunctions.isInPlot(plr)) { - return sendMessage(plr, C.NOT_IN_PLOT); - } + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } 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 69cd4fbd9..83054b54a 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,6 +23,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.PWE; public class WE_Anywhere extends SubCommand { From 1f76b5c551e05c0c36a6d73ff5d494fe861b707e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:07:02 +1100 Subject: [PATCH 103/124] home --- .../intellectualcrafters/plot/PlotSquared.java | 18 ++++++++++++++++++ .../plot/commands/Helpers.java | 7 +++---- .../plot/commands/Home.java | 8 +++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 3b1a61ee7..4d13d0f3f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -46,6 +46,7 @@ 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.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ExpireManager; @@ -176,6 +177,23 @@ public class PlotSquared { return new HashMap<>(); } + public static Set getPlots(final PlotPlayer player) { + final UUID uuid = player.getUUID(); + final ArrayList myplots = new ArrayList<>(); + for (final String world : plots.keySet()) { + if (isPlotWorld(world)) { + for (final Plot plot : plots.get(world).values()) { + if (plot.hasOwner()) { + if (plot.getOwner().equals(uuid)) { + myplots.add(plot); + } + } + } + } + } + return new HashSet<>(myplots); + } + public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) { if (callEvent) { if (!IMP.callRemovePlot(world, id)) { 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 df4a5d532..0d303b7c5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -84,8 +85,7 @@ public class Helpers extends SubCommand { } plot.addHelper(uuid); DBFunc.setHelper(loc.getWorld(), plot, uuid); - final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); - Bukkit.getPluginManager().callEvent(event); + // FIXME PlayerPlotHelperEvent } else { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; @@ -107,8 +107,7 @@ public class Helpers extends SubCommand { final UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeHelper(uuid); DBFunc.removeHelper(loc.getWorld(), plot, uuid); - final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false); - Bukkit.getPluginManager().callEvent(event); + // FIXME PlayerPlotHelperEvent MainUtil.sendMessage(plr, C.HELPER_REMOVED); } else { MainUtil.sendMessage(plr, C.HELPER_NEED_ARGUMENT); 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 d9d922c04..e09b0e419 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; @@ -64,7 +62,7 @@ public class Home extends SubCommand { if ((temp = isAlias(args[0])) != null) { if (temp.hasOwner()) { if (temp.getOwner().equals(UUIDHandler.getUUID(plr))) { - teleportPlayer(plr, temp); + MainUtil.teleportPlayer(plr, plr.getLocation(), temp); return true; } } @@ -78,7 +76,7 @@ public class Home extends SubCommand { MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER); return false; } - teleportPlayer(plr, plots[id - 1]); + MainUtil.teleportPlayer(plr, plr.getLocation(), plots[id - 1]); return true; } else { MainUtil.sendMessage(plr, C.NO_PLOTS); @@ -86,7 +84,7 @@ public class Home extends SubCommand { } } - public void teleportPlayer(final Player player, final Plot plot) { + public void teleportPlayer(final PlotPlayer player, final Plot plot) { MainUtil.teleportPlayer(player, player.getLocation(), plot); } } From 625f1698cdc08e82137f0b8f01522e5d34f8efc8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:07:29 +1100 Subject: [PATCH 104/124] inbox --- .../java/com/intellectualcrafters/plot/commands/Inbox.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 b64e26082..03ecb900d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -25,8 +25,6 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -35,6 +33,8 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -134,7 +134,7 @@ public class Inbox extends SubCommand { } final String world = loc.getWorld(); final int tier2 = tier; - Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { ArrayList comments = null; From 5f5d794c669d1aaa176bdb34e68f24b693e343ea Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:13:27 +1100 Subject: [PATCH 105/124] info --- .../plot/commands/Denied.java | 5 -- .../plot/commands/Helpers.java | 4 -- .../plot/commands/Inbox.java | 2 - .../plot/commands/Info.java | 53 ++++++++----------- .../plot/commands/MusicSubcommand.java | 1 - .../plot/commands/Rate.java | 1 - .../plot/commands/Set.java | 1 - .../plot/commands/Swap.java | 1 - .../plot/commands/Trusted.java | 1 - .../plot/object/InfoInventory.java | 4 +- .../plot/object/PlotSettings.java | 5 +- .../plot/util/BlockManager.java | 2 + .../plot/util/bukkit/BukkitUtil.java | 5 +- 13 files changed, 31 insertions(+), 54 deletions(-) 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 e10febc96..923b22deb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -22,19 +22,14 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Denied extends SubCommand { 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 0d303b7c5..1640b2e18 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -22,17 +22,13 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Helpers extends SubCommand { 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 03ecb900d..77bedefaf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; @@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Inbox extends SubCommand { 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 c7dd552ce..a58797282 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -24,23 +24,19 @@ import java.util.ArrayList; import java.util.UUID; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.InfoInventory; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -54,20 +50,19 @@ public class Info extends SubCommand { @Override public boolean execute(final PlotPlayer player, String... args) { - World world; Plot plot; + String world; if (player != null) { Location loc = player.getLocation(); - String world = loc.getWorld(); + world = loc.getWorld(); if (!PlotSquared.isPlotWorld(world)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT_WORLD); + MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD); return false; } - final Plot plot = MainUtil.getPlot(loc); - if (plot == null) { - return !sendMessage(plr, C.NOT_IN_PLOT); - } plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(player, C.NOT_IN_PLOT); + } } else { if (args.length < 2) { MainUtil.sendMessage(null, C.INFO_SYNTAX_CONSOLE); @@ -75,25 +70,25 @@ public class Info extends SubCommand { } final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); if (plotworld == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_WORLD); + MainUtil.sendMessage(player, C.NOT_VALID_WORLD); return false; } try { final String[] split = args[1].split(";"); final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id); + plot = MainUtil.getPlot(plotworld.worldname, id); if (plot == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID); return false; } - world = Bukkit.getWorld(args[0]); + world = args[0]; if (args.length == 3) { args = new String[] { args[2] }; } else { args = new String[0]; } } catch (final Exception e) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.INFO_SYNTAX_CONSOLE); + MainUtil.sendMessage(player, C.INFO_SYNTAX_CONSOLE); return false; } } @@ -111,7 +106,7 @@ public class Info extends SubCommand { } // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); + MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); return true; } String owner = "none"; @@ -125,13 +120,13 @@ public class Info extends SubCommand { if (args.length == 1) { info = getCaption(args[0].toLowerCase()); if (info == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); + MainUtil.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); return false; } } info = format(info, world, plot, player); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_HEADER); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), info, false); + MainUtil.sendMessage(player, C.PLOT_INFO_HEADER); + MainUtil.sendMessage(player, info, false); return true; } @@ -162,18 +157,18 @@ public class Info extends SubCommand { } } - private String format(String info, final World world, final Plot plot, final Player player) { + private String format(String info, final String world, final Plot plot, final PlotPlayer player) { final PlotId id = plot.id; - final PlotId id2 = MainUtil.getTopPlot(world, plot).id; + final PlotId id2 = MainUtil.getTopPlot(plot).id; final int num = MainUtil.getPlotSelectionIds(id, id2).size(); final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; - final String biome = getBiomeAt(plot).toString(); + final String biome = BlockManager.manager.getBiome(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1)); final String helpers = getPlayerList(plot.helpers); final String trusted = getPlayerList(plot.trusted); final String denied = getPlayerList(plot.denied); final String rating = String.format("%.1f", DBFunc.getRatings(plot)); final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none"); - final boolean build = (player == null) || plot.hasRights(player); + final boolean build = (player == null) || plot.isAdded(player.getUUID()); String owner = "none"; if (plot.owner != null) { owner = UUIDHandler.getName(plot.owner); @@ -226,10 +221,4 @@ public class Info extends SubCommand { } return name; } - - private Biome getBiomeAt(final Plot plot) { - final World w = Bukkit.getWorld(plot.world); - final Location bl = MainUtil.getPlotTopLoc(w, plot.id); - return bl.getBlock().getBiome(); - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 9d9e839b8..45a02eb21 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class MusicSubcommand extends SubCommand { public MusicSubcommand() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 435dc061e..2998aa84b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -26,7 +26,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({ "unused", "deprecated", "javadoc" }) 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 1a302f0b4..a043251a7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -47,7 +47,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 fe50a2b6f..6ce585498 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -30,7 +30,6 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 629e5765f..1ae3155f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index d1da24fb4..61741c1bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -31,9 +31,9 @@ public class InfoInventory implements InventoryHolder { * * @param plot from which we take information */ - public InfoInventory(final Plot plot, final Player player) { + public InfoInventory(final Plot plot, final PlotPlayer plr) { this.plot = plot; - this.player = player; + this.player = ((BukkitPlayer) plr).player; this.inventory = Bukkit.createInventory(this, 9, "Plot: " + plot.id.toString()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index cf5928a1f..238c055b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -27,6 +27,7 @@ import org.bukkit.block.Biome; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -106,9 +107,9 @@ public class PlotSettings { /** * @return biome at plot loc */ - public Biome getBiome() { + public String getBiome() { final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); - return BukkitUtil.getBiome(loc); + return BlockManager.manager.getBiome(loc); } public BlockLoc getPosition() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 272e25422..afed23651 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -29,6 +29,8 @@ public abstract class BlockManager { return (int) r; } + public abstract String getBiome(Location loc); + public abstract Location getSpawn(String world); public abstract String[] getSign(Location loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index c3bb572d9..ea44975a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -52,8 +52,9 @@ public class BukkitUtil extends BlockManager { return lastPlotPlayer; } - public static Biome getBiome(final Location loc) { - return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()); + @Override + public String getBiome(final Location loc) { + return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()).name(); } public static Location getLocation(org.bukkit.Location loc) { From 6f87471e8a56c3c27d6cb58ec5af243bb7af18f9 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:14:49 +1100 Subject: [PATCH 106/124] inventory --- .../com/intellectualcrafters/plot/commands/Inventory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java index e816e5e14..785217c9c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java @@ -28,6 +28,7 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.PlotPlayer; public class Inventory extends SubCommand { @@ -48,7 +49,8 @@ public class Inventory extends SubCommand { for (final SubCommand cmd : cmds) { inventory.addItem(getItem(cmd)); } - plr.openInventory(inventory); + // FIXME unchecked cast + ((BukkitPlayer) plr).player.openInventory(inventory); return true; } From caafd524e2f98709b1eef9d01592e2921e5a0b68 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:17:13 +1100 Subject: [PATCH 107/124] kick --- .../intellectualcrafters/plot/commands/Kick.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 5c7850a95..e2228c6c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -20,14 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -52,16 +51,16 @@ public class Kick extends SubCommand { MainUtil.sendMessage(plr, "&c/plot kick "); return false; } - if (Bukkit.getPlayer(args[0]) == null) { + PlotPlayer player = UUIDHandler.getPlayer(args[0]); + if (player == null) { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - final Player player = Bukkit.getPlayer(args[0]); - if (!player.getWorld().equals(plr.getWorld()) || !BukkitPlayerFunctions.isInPlot(player) || (MainUtil.getPlot(loc) == null) || !MainUtil.getPlot(loc).equals(plot)) { + if (!player.getLocation().getWorld().equals(loc.getWorld()) || !plot.equals(MainUtil.getPlot(loc))) { MainUtil.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); return false; } - player.teleport(player.getWorld().getSpawnLocation()); + player.teleport(BlockManager.manager.getSpawn(loc.getWorld())); return true; } } From a4dae60af0b2fefe280316e8aa29f0485b34bf6b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:18:37 +1100 Subject: [PATCH 108/124] list --- .../com/intellectualcrafters/plot/commands/list.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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 5d8981f90..3d0f89b5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -23,8 +23,6 @@ package com.intellectualcrafters.plot.commands; import java.util.HashMap; import java.util.UUID; -import org.bukkit.ChatColor; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.flag.Flag; @@ -75,7 +73,7 @@ public class list extends SubCommand { final StringBuilder string = new StringBuilder(); string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "buyable")).append("\n"); int idx = 0; - for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) { + for (final Plot p : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { final 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"); @@ -157,7 +155,7 @@ public class list extends SubCommand { } 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 = PlotSquared.getPlots(plr.getWorld()); + final HashMap plots = PlotSquared.getPlots(plr.getLocation().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"); } @@ -174,12 +172,8 @@ public class list extends SubCommand { private String getArgumentList(final String[] strings) { final StringBuilder builder = new StringBuilder(); for (final String s : strings) { - builder.append(getString(s)); + builder.append(MainUtil.colorise('&', s)); } return builder.toString().substring(1, builder.toString().length() - 1); } - - private String getString(final String s) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); - } } From 1c2a5a2f9161e5e0c34591cc5e7979f4662cf0b0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:19:26 +1100 Subject: [PATCH 109/124] main cmd --- .../com/intellectualcrafters/plot/commands/MainCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f0c4a0297..ef4feef90 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -41,7 +41,7 @@ public class MainCommand { /** * Main Permission Node */ - 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() }; + private final static SubCommand[] _subCommands = new SubCommand[] { new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), 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() { { addAll(Arrays.asList(_subCommands)); From 64d81326aa0ee46a8b7690da9845ad7ccc1b960e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:23:10 +1100 Subject: [PATCH 110/124] merge --- .../plot/commands/MainCommand.java | 1 - .../plot/commands/Merge.java | 42 +++++++++---------- .../plot/util/MainUtil.java | 22 ++++++++++ 3 files changed, 42 insertions(+), 23 deletions(-) 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 ef4feef90..a0d12fe46 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -20,7 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.awt.datatransfer.Clipboard; import java.util.ArrayList; import java.util.Arrays; import java.util.List; 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 a824c664e..151118e02 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -25,8 +25,6 @@ import java.util.ArrayList; import net.milkbowl.vault.economy.Economy; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.World; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -38,7 +36,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -107,35 +105,35 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); return false; } - final World world = plr.getWorld(); - PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id; - PlotId top = MainUtil.getTopPlot(world, plot).id; + PlotId bot = MainUtil.getBottomPlot(plot).id; + PlotId top = MainUtil.getTopPlot(plot).id; ArrayList plots; + String world = plr.getLocation().getWorld(); switch (direction) { case 0: // north = -y - plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); + plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); break; case 1: // east = +x - plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); + plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); break; case 2: // south = +y - plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); + plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); break; case 3: // west = -x - plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); + plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); break; default: return false; } final PlotId botId = plots.get(0); final PlotId topId = plots.get(plots.size() - 1); - final PlotId bot1 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, botId)).id; - final PlotId bot2 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, topId)).id; - final PlotId top1 = MainUtil.getTopPlot(world, MainUtil.getPlot(world, topId)).id; - final PlotId top2 = MainUtil.getTopPlot(world, MainUtil.getPlot(world, botId)).id; + final PlotId bot1 = MainUtil.getBottomPlot(MainUtil.getPlot(world, botId)).id; + final PlotId bot2 = MainUtil.getBottomPlot(MainUtil.getPlot(world, topId)).id; + final PlotId top1 = MainUtil.getTopPlot(MainUtil.getPlot(world, topId)).id; + final PlotId top2 = MainUtil.getTopPlot(MainUtil.getPlot(world, botId)).id; bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y)); top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y)); - plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, bot, top); + plots = MainUtil.getMaxPlotSelectionIds(world, bot, top); for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) { @@ -144,12 +142,12 @@ public class Merge extends SubCommand { } } final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); - if (PlotSquared.useEconomy && plotWorld.USE_ECONOMY) { + if (PlotSquared.economy != null && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; cost = plots.size() * cost; if (cost > 0d) { final Economy economy = PlotSquared.economy; - if (economy.getBalance(plr) < cost) { + if (EconHandler.getBalance(plr) < cost) { sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + ""); return false; } @@ -157,16 +155,16 @@ public class Merge extends SubCommand { sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } - final PlotMergeEvent event = new PlotMergeEvent(world, plot, plots); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - event.setCancelled(true); + //FIXME PlotMergeEvent + // boolean result = event.isCancelled(); + boolean result = false; + if (result) { MainUtil.sendMessage(plr, "&cMerge has been cancelled"); return false; } MainUtil.sendMessage(plr, "&cPlots have been merged"); MainUtil.mergePlots(world, plots, true); - MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); MainUtil.update(plr.getLocation()); return true; } 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 53414359c..249803912 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -54,6 +54,28 @@ public class MainUtil { public static HashMap lastPlot = new HashMap<>(); public static HashMap worldBorder = new HashMap<>(); + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { + + final Plot plot1 = PlotSquared.getPlots(world).get(pos1); + final Plot plot2 = PlotSquared.getPlots(world).get(pos2); + + if (plot1 != null) { + pos1 = getBottomPlot(plot1).id; + } + + if (plot2 != null) { + pos2 = getTopPlot(plot2).id; + } + + final ArrayList myplots = new ArrayList<>(); + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + myplots.add(new PlotId(x, y)); + } + } + return myplots; + } + /** * Get the number of plots for a player * From 2e5fee41ef5f1f53e356595267430e144783dbce Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:24:14 +1100 Subject: [PATCH 111/124] move --- .../java/com/intellectualcrafters/plot/commands/Move.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 e7b76d167..7c1267523 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.World; - import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -45,7 +43,7 @@ public class Move extends SubCommand { MainUtil.sendMessage(plr, "/plot move "); return false; } - final World world = plr.getWorld(); + final String world = plr.getLocation().getWorld(); final PlotId plot1 = MainUtil.parseId(args[0]); final PlotId plot2 = MainUtil.parseId(args[1]); if ((plot1 == null) || (plot2 == null)) { From e8a698816a52bb6114a79c48dd66c4b7ee834bfe Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:26:17 +1100 Subject: [PATCH 112/124] music/plugin cmds --- .../plot/commands/MusicSubcommand.java | 10 ++++++---- .../com/intellectualcrafters/plot/commands/plugin.java | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 45a02eb21..ced6c571d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -29,6 +29,7 @@ import org.bukkit.inventory.meta.ItemMeta; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.listeners.PlotPlusListener; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -41,12 +42,12 @@ public class MusicSubcommand extends SubCommand { @Override public boolean execute(final PlotPlayer player, final String... args) { - Location loc = plr.getLocation(); + Location loc = player.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { - return !sendMessage(plr, C.NOT_IN_PLOT); + return !sendMessage(player, C.NOT_IN_PLOT); } - if (!plot.hasRights(player)) { + if (!plot.isAdded(player.getUUID())) { sendMessage(player, C.NO_PLOT_PERMS); return true; } @@ -59,7 +60,8 @@ public class MusicSubcommand extends SubCommand { stack.setItemMeta(itemMeta); inventory.addItem(stack); } - player.openInventory(inventory); + // FIXME unchecked casting + ((BukkitPlayer) player).player.openInventory(inventory); return true; } } 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 fad1bb18e..8f1b73f78 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -32,6 +32,7 @@ import org.bukkit.plugin.java.JavaPlugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.TaskManager; public class plugin extends SubCommand { public static String downloads, version; @@ -90,12 +91,12 @@ public class plugin extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { final ArrayList strings = new ArrayList() { { - add(String.format("&c>> &6PlotSquared (Version: %s)", PlotSquared.getMain().getDescription().getVersion())); + add(String.format("&c>> &6PlotSquared (Version: %s)", PlotSquared.IMP.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)); From 42aeb1479dfc50b7ff94890b0b059675e6f71714 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:28:52 +1100 Subject: [PATCH 113/124] purge --- .../plot/commands/Purge.java | 16 ++++++++-------- .../plot/commands/plugin.java | 13 +++++-------- 2 files changed, 13 insertions(+), 16 deletions(-) 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 50057bc14..e4c9a83ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -93,12 +94,11 @@ public class Purge extends SubCommand { MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } - final World world = Bukkit.getWorld(args[1]); - if ((world == null) || !PlotSquared.isPlotWorld(world)) { - MainUtil.sendMessage(null, C.NOT_VALID_PLOT_WORLD); + final String worldname = args[0]; + if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) { + MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } - final String worldname = world.getName(); final String arg = args[0].toLowerCase(); final PlotId id = getId(arg); if (id != null) { @@ -112,7 +112,7 @@ public class Purge extends SubCommand { } final UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - final Set plots = PlotSquared.getPlots(world, uuid); + final Set plots = PlotSquared.getPlots(worldname, uuid); final Set ids = new HashSet<>(); for (final Plot plot : plots) { ids.add(plot.id); @@ -121,7 +121,7 @@ public class Purge extends SubCommand { return finishPurge(ids.size()); } if (arg.equals("all")) { - final Set ids = PlotSquared.getPlots(world).keySet(); + final Set ids = PlotSquared.getPlots(worldname).keySet(); if (ids.size() == 0) { return MainUtil.sendMessage(null, "&cNo plots found"); } @@ -129,7 +129,7 @@ public class Purge extends SubCommand { return finishPurge(ids.size()); } if (arg.equals("unknown")) { - final Collection plots = PlotSquared.getPlots(world).values(); + final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { if (plot.owner != null) { @@ -146,7 +146,7 @@ public class Purge extends SubCommand { return finishPurge(ids.size()); } if (arg.equals("unowned")) { - final Collection plots = PlotSquared.getPlots(world).values(); + final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { if (plot.owner == null) { 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 8f1b73f78..f65091931 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -26,9 +26,6 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -41,8 +38,8 @@ public class plugin extends SubCommand { super("plugin", "plots.use", "Show plugin information", "plugin", "version", CommandCategory.INFO, false); } - public static void setup(final JavaPlugin plugin) { - plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { + public static void setup() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { @@ -51,8 +48,8 @@ public class plugin extends SubCommand { downloads = "unknown"; } } - }, 1l); - plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { + }); + TaskManager.runTaskLaterAsync(new Runnable() { @Override public void run() { try { @@ -62,7 +59,7 @@ public class plugin extends SubCommand { version = "unknown"; } } - }, 200l); + }, 200); } private static String convertToNumericString(final String str, final boolean dividers) { From d62841de3ee40af74df949d0a3d457aa3a2a9553 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:30:39 +1100 Subject: [PATCH 114/124] RGAR --- .../intellectualcrafters/plot/commands/Rate.java | 1 - .../plot/commands/RegenAllRoads.java | 14 +++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 2998aa84b..dfe8c9652 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -28,7 +28,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings({ "unused", "deprecated", "javadoc" }) public class Rate extends SubCommand { /* * String cmd, String permission, String description, String usage, String 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 f482ab200..d8d27b0d8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -20,18 +20,16 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; - -import org.bukkit.Bukkit; -import org.bukkit.World; +import java.util.List; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.HybridPlotManager; +import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; +import com.intellectualcrafters.plot.util.AChunkManager; public class RegenAllRoads extends SubCommand { public RegenAllRoads() { @@ -54,14 +52,12 @@ public class RegenAllRoads extends SubCommand { sendMessage(player, C.NOT_VALID_PLOT_WORLD); return false; } - final HybridPlotManager hpm = (HybridPlotManager) manager; - final World world = Bukkit.getWorld(name); - final ArrayList chunks = ChunkManager.getChunkChunks(world); + final List chunks = AChunkManager.manager.getChunkChunks(name); PlotSquared.log("&cIf no schematic is set, the following will not do anything"); PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); PlotSquared.log("&6Potential chunks to update: &7" + (chunks.size() * 1024)); PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds"); - final boolean result = hpm.scheduleRoadUpdate(world); + final boolean result = HybridUtils.manager.scheduleRoadUpdate(name); if (!result) { PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); return false; From 79a01e722ffca3da0711d82454fefbc4d41a3912 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 22:30:46 +1100 Subject: [PATCH 115/124] schematic --- .../plot/commands/Schematic.java | 83 ++++++++++--------- .../plot/util/BlockManager.java | 2 + .../plot/util/TaskManager.java | 37 +++++---- .../plot/util/bukkit/BukkitTaskManager.java | 29 ++++--- .../plot/util/bukkit/BukkitUtil.java | 5 ++ 5 files changed, 91 insertions(+), 65 deletions(-) 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 a219479ca..c18c907c5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -23,23 +23,21 @@ package com.intellectualcrafters.plot.commands; import java.util.Collection; import java.util.HashMap; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.plugin.Plugin; - import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -64,9 +62,9 @@ public class Schematic extends SubCommand { final String file; final SchematicHandler.Schematic schematic; switch (arg) { - case "paste": + case "paste": { if (plr == null) { - PlotSquared.log(C.IS_CONSOLE); + PlotSquared.log(C.IS_CONSOLE.s()); return false; } if (!Permissions.hasPermission(plr, "plots.schematic.paste")) { @@ -77,7 +75,9 @@ public class Schematic extends SubCommand { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); break; } - if (!BukkitPlayerFunctions.isInPlot(plr)) { + final Location loc = plr.getLocation(); + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { sendMessage(plr, C.NOT_IN_PLOT); break; } @@ -88,7 +88,7 @@ public class Schematic extends SubCommand { final String file2 = args[1]; this.running = true; this.counter = 0; - Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { final SchematicHandler.Schematic schematic = SchematicHandler.getSchematic(file2); @@ -101,8 +101,8 @@ public class Schematic extends SubCommand { final int z; final Plot plot2 = MainUtil.getPlot(loc); final Dimension dem = schematic.getSchematicDimension(); - final Location bot = MainUtil.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1); - final int length2 = MainUtil.getPlotWidth(plr.getWorld(), plot2.id); + final Location bot = MainUtil.getPlotBottomLoc(loc.getWorld(), plot2.id).add(1, 0, 1); + final int length2 = MainUtil.getPlotWidth(loc.getWorld(), plot2.id); if ((dem.getX() > length2) || (dem.getZ() > length2)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2)); Schematic.this.running = false; @@ -110,20 +110,19 @@ public class Schematic extends SubCommand { } if ((dem.getX() != length2) || (dem.getZ() != length2)) { final Location loc = plr.getLocation(); - x = Math.min(length2 - dem.getX(), loc.getBlockX() - bot.getBlockX()); - z = Math.min(length2 - dem.getZ(), loc.getBlockZ() - bot.getBlockZ()); + x = Math.min(length2 - dem.getX(), loc.getX() - bot.getX()); + z = Math.min(length2 - dem.getZ(), loc.getZ() - bot.getZ()); } else { x = 0; z = 0; } - final World w = plot2.getWorld(); final DataCollection[] b = schematic.getBlockCollection(); - final int sy = w.getHighestBlockYAt(bot.getBlockX(), bot.getBlockZ()); + final int sy = BlockManager.manager.getHeighestBlock(bot); final Location l1 = bot.add(0, sy - 1, 0); final int WIDTH = schematic.getSchematicDimension().getX(); final int LENGTH = schematic.getSchematicDimension().getZ(); final int blen = b.length - 1; - Schematic.this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { + Schematic.this.task = TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { boolean result = false; @@ -133,21 +132,22 @@ public class Schematic extends SubCommand { sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); MainUtil.update(plr.getLocation()); Schematic.this.running = false; - Bukkit.getScheduler().cancelTask(Schematic.this.task); + PlotSquared.TASK.cancelTask(Schematic.this.task); return; } final int end = Math.min(start + 5000, blen); - result = SchematicHandler.pastePart(w, b, l1, x, z, start, end, WIDTH, LENGTH); + result = SchematicHandler.pastePart(loc.getWorld(), b, l1, x, z, start, end, WIDTH, LENGTH); Schematic.this.counter++; } } - }, 1, 1); + }, 1); } }); break; - case "test": + } + case "test": { if (plr == null) { - PlotSquared.log(C.IS_CONSOLE); + PlotSquared.log(C.IS_CONSOLE.s()); return false; } if (!Permissions.hasPermission(plr, "plots.schematic.test")) { @@ -164,18 +164,20 @@ public class Schematic extends SubCommand { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent"); break; } + Location loc = plr.getLocation(); final int l1 = schematic.getSchematicDimension().getX(); final int l2 = schematic.getSchematicDimension().getZ(); final Plot plot = MainUtil.getPlot(loc); - final int length = MainUtil.getPlotWidth(plr.getWorld(), plot.id); + final int length = MainUtil.getPlotWidth(loc.getWorld(), plot.id); if ((l1 < length) || (l2 < length)) { sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); break; } sendMessage(plr, C.SCHEMATIC_VALID); break; + } case "saveall": - case "exportall": + case "exportall": { if (plr != null) { MainUtil.sendMessage(plr, C.NOT_CONSOLE); return false; @@ -195,30 +197,28 @@ public class Schematic extends SubCommand { } PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); - final World worldObj = Bukkit.getWorld(args[1]); - final String worldname = Bukkit.getWorld(args[1]).getName(); - final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); + final String worldname = args[1]; final Collection values = plotmap.values(); this.plots = values.toArray(new Plot[values.size()]); this.running = true; this.counter = 0; - this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { + this.task = TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { if (Schematic.this.counter >= Schematic.this.plots.length) { PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); Schematic.this.running = false; - Bukkit.getScheduler().cancelTask(Schematic.this.task); + PlotSquared.TASK.cancelTask(Schematic.this.task); return; } final Plot plot = Schematic.this.plots[Schematic.this.counter]; - final CompoundTag sch = SchematicHandler.getCompoundTag(worldObj, plot.id); + final CompoundTag sch = SchematicHandler.getCompoundTag(worldname, plot.id); final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); } else { - Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { MainUtil.sendMessage(null, "&6ID: " + plot.id); @@ -233,10 +233,12 @@ public class Schematic extends SubCommand { } Schematic.this.counter++; } - }, 20, 20); + }, 20); break; + } case "export": case "save": + { if (!Permissions.hasPermission(plr, "plots.schematic.save")) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); return false; @@ -253,11 +255,11 @@ public class Schematic extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (!myplot.hasRights(plr)) { + if (!plot.isAdded(plr.getUUID())) { sendMessage(plr, C.NO_PLOT_PERMS); return false; } - p2 = myplot; + p2 = plot; world = loc.getWorld(); } else { if (args.length == 3) { @@ -279,27 +281,26 @@ public class Schematic extends SubCommand { return false; } } - final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); this.plots = new Plot[] { p2 }; this.running = true; this.counter = 0; - this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin2, new Runnable() { + this.task = TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { if (Schematic.this.counter >= Schematic.this.plots.length) { PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); Schematic.this.running = false; - Bukkit.getScheduler().cancelTask(Schematic.this.task); + PlotSquared.TASK.cancelTask(Schematic.this.task); return; } final Plot plot = Schematic.this.plots[Schematic.this.counter]; - final CompoundTag sch = SchematicHandler.getCompoundTag(Bukkit.getWorld(world), plot.id); + final CompoundTag sch = SchematicHandler.getCompoundTag(world, plot.id); final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); } else { - Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, "&6ID: " + plot.id); @@ -314,11 +315,13 @@ public class Schematic extends SubCommand { } Schematic.this.counter++; } - }, 20, 60); + }, 60); break; - default: + } + default: { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); break; + } } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index afed23651..2bfbe0b97 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -29,6 +29,8 @@ public abstract class BlockManager { return (int) r; } + public abstract int getHeighestBlock(Location loc); + public abstract String getBiome(Location loc); public abstract Location getSpawn(String world); 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 fb284e553..27b62fdf3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -7,43 +7,50 @@ import com.intellectualcrafters.plot.PlotSquared; public abstract class TaskManager { public static HashSet TELEPORT_QUEUE = new HashSet<>(); - public abstract void taskRepeat(final Runnable r, int interval); + public abstract int taskRepeat(final Runnable r, int interval); - public abstract void taskAsync(final Runnable r); + public abstract int taskAsync(final Runnable r); - public abstract void task(final Runnable r); + public abstract int task(final Runnable r); - public abstract void taskLater(final Runnable r, int delay); + public abstract int taskLater(final Runnable r, int delay); - public abstract void taskLaterAsync(final Runnable r, int delay); + public abstract int taskLaterAsync(final Runnable r, int delay); - public static void runTaskRepeat(final Runnable r, final int interval) { + public abstract void cancelTask(int task); + + public static int runTaskRepeat(final Runnable r, final int interval) { if (r != null) { - PlotSquared.TASK.taskRepeat(r, interval); + return PlotSquared.TASK.taskRepeat(r, interval); } + return -1; } - public static void runTaskAsync(final Runnable r) { + public static int runTaskAsync(final Runnable r) { if (r != null) { - PlotSquared.TASK.taskAsync(r); + return PlotSquared.TASK.taskAsync(r); } + return -1; } - public static void runTask(final Runnable r) { + public static int runTask(final Runnable r) { if (r != null) { - PlotSquared.TASK.task(r); + return PlotSquared.TASK.task(r); } + return -1; } - public static void runTaskLater(final Runnable r, final int delay) { + public static int runTaskLater(final Runnable r, final int delay) { if (r != null) { - PlotSquared.TASK.taskLater(r, delay); + return PlotSquared.TASK.taskLater(r, delay); } + return -1; } - public static void runTaskLaterAsync(final Runnable r, final int delay) { + public static int runTaskLaterAsync(final Runnable r, final int delay) { if (r != null) { - PlotSquared.TASK.taskLaterAsync(r, delay); + return PlotSquared.TASK.taskLaterAsync(r, delay); } + return -1; } } 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 1a796fb43..f4125b702 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 @@ -1,31 +1,40 @@ package com.intellectualcrafters.plot.util.bukkit; +import org.bukkit.Bukkit; + import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.util.TaskManager; public class BukkitTaskManager extends TaskManager { @Override - public void taskRepeat(final Runnable r, final int interval) { - BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval); + public int taskRepeat(final Runnable r, final int interval) { + return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval); } @Override - public void taskAsync(final Runnable r) { - BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r); + public int taskAsync(final Runnable r) { + return BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r).getTaskId(); } @Override - public void task(final Runnable r) { - BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r); + public int task(final Runnable r) { + return BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r).getTaskId(); } @Override - public void taskLater(final Runnable r, final int delay) { - BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay); + public int taskLater(final Runnable r, final int delay) { + return BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay).getTaskId(); } @Override - public void taskLaterAsync(final Runnable r, final int delay) { - BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay); + public int taskLaterAsync(final Runnable r, final int delay) { + return BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay).getTaskId(); + } + + @Override + public void cancelTask(int task) { + if (task != -1) { + Bukkit.getScheduler().cancelTask(task); + } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index ea44975a2..83d560647 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -217,4 +217,9 @@ public class BukkitUtil extends BlockManager { org.bukkit.Location temp = getWorld(world).getSpawnLocation(); return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ()); } + + @Override + public int getHeighestBlock(Location loc) { + return getWorld(loc.getWorld()).getHighestBlockAt(loc.getX(), loc.getZ()).getY(); + } } From 1d969e439cf1d7fc7305cf7fb4e79223878c8d33 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 23:24:48 +1100 Subject: [PATCH 116/124] set --- .../plot/commands/Set.java | 83 ++++++------------- .../plot/config/Configuration.java | 18 ++-- .../plot/flag/FlagManager.java | 18 +--- .../plot/generator/AugmentedPopulator.java | 4 +- .../plot/generator/HybridGen.java | 2 +- .../plot/object/PlotWorld.java | 19 ++--- .../plot/util/BlockManager.java | 6 ++ .../plot/util/bukkit/BukkitUtil.java | 30 +++++++ 8 files changed, 87 insertions(+), 93 deletions(-) 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 a043251a7..3aadda2bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -24,11 +24,6 @@ import java.util.Arrays; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Biome; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -39,14 +34,19 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -72,7 +72,7 @@ public class Set extends SubCommand { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(plr) && !Permissions.hasPermission(plr, "plots.admin.command.set")) { + if (!plot.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.set")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -95,13 +95,6 @@ public class Set extends SubCommand { if (args[0].equalsIgnoreCase("flag")) { if (args.length < 2) { String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6"); - if (PlotSquared.worldGuardListener != null) { - if (message.equals("")) { - message = StringUtils.join(PlotSquared.worldGuardListener.str_flags, "&c, &6"); - } else { - message += "," + StringUtils.join(PlotSquared.worldGuardListener.str_flags, "&c, &6"); - } - } MainUtil.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } @@ -111,7 +104,7 @@ public class Set extends SubCommand { } catch (final Exception e) { af = new AbstractFlag(args[1].toLowerCase()); } - if (!FlagManager.getFlags().contains(af) && ((PlotSquared.worldGuardListener == null) || !PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) { + if (!FlagManager.getFlags().contains(af)) { MainUtil.sendMessage(plr, C.NOT_VALID_FLAG); return false; } @@ -121,12 +114,6 @@ public class Set extends SubCommand { } if (args.length == 2) { if (FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()) == null) { - if (PlotSquared.worldGuardListener != null) { - if (PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { - PlotSquared.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]); - return false; - } - } MainUtil.sendMessage(plr, C.FLAG_NOT_IN_PLOT); return false; } @@ -146,10 +133,6 @@ public class Set extends SubCommand { MainUtil.sendMessage(plr, af.getValueDesc()); return false; } - 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; - } final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed_value); final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { @@ -174,13 +157,13 @@ public class Set extends SubCommand { return MainUtil.sendMessage(plr, C.HOME_ARGUMENT); } //set to current location - final World world = plr.getWorld(); + final String world = plr.getLocation().getWorld(); final Location base = MainUtil.getPlotBottomLoc(world, plot.id); base.setY(0); - final Location relative = plr.getLocation().subtract(base); - final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); + final Location relative = plr.getLocation().subtract(base.getX(), base.getZ(), base.getY()); + final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ()); plot.settings.setPosition(blockloc); - DBFunc.setPosition(loc.getWorld(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); + DBFunc.setPosition(loc.getWorld(), plot, relative.getX() + "," + relative.getY() + "," + relative.getZ()); return MainUtil.sendMessage(plr, C.POSITION_SET); } if (args[0].equalsIgnoreCase("alias")) { @@ -193,7 +176,7 @@ public class Set extends SubCommand { MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG); return false; } - for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) { + for (final Plot p : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { if (p.settings.getAlias().equalsIgnoreCase(alias)) { MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; @@ -216,7 +199,7 @@ public class Set extends SubCommand { sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2"); return true; } - final Biome biome = Biome.valueOf(new StringComparison(args[1], Biome.values()).getBestMatch()); + final int biome = BlockManager.manager.getBiomeFromString(args[1]); /* * for (Biome b : Biome.values()) { * if (b.toString().equalsIgnoreCase(args[1])) { @@ -225,19 +208,19 @@ public class Set extends SubCommand { * } * } */ - if (biome == null) { - MainUtil.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); + if (biome == -1) { + MainUtil.sendMessage(plr, getBiomeList(BlockManager.manager.getBiomeList())); return true; } - MainUtil.setBiome(plr.getWorld(), plot, biome); - MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); + MainUtil.setBiome(plr.getLocation().getWorld(), plot, args[1].toUpperCase()); + MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + args[1].toLowerCase()); return true; } // Get components - final World world = plr.getWorld(); + final String world = plr.getLocation().getWorld(); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); - final String[] components = manager.getPlotComponents(world, plotworld, plot.id); + final String[] components = manager.getPlotComponents(plotworld, plot.id); for (final String component : components) { if (component.equalsIgnoreCase(args[0])) { if (args.length < 2) { @@ -249,13 +232,13 @@ public class Set extends SubCommand { blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseObject(args[2]); } catch (final Exception e) { try { - blocks = new PlotBlock[] { new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0) }; + blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[2]), (byte) 0) }; } catch (final Exception e2) { MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); return false; } } - manager.setComponent(world, plotworld, plot.id, component, blocks); + manager.setComponent(plotworld, plot.id, component, blocks); MainUtil.sendMessage(plr, C.GENERATING_COMPONENT); return true; } @@ -274,7 +257,7 @@ public class Set extends SubCommand { a.append(" ").append(args[x]); } } - plr.performCommand("plot set flag " + args[0] + a.toString()); + MainCommand.onCommand(plr, world, ("plot set flag " + args[0] + a.toString()).split(" ")); return true; } } @@ -282,16 +265,8 @@ public class Set extends SubCommand { return false; } - private String getMaterial(final Material m) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase())); - } - - private String getBiome(final Biome b) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase())); - } - private String getString(final String s) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); + return MainUtil.colorise('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); } private String getArgumentList(final String[] strings) { @@ -302,16 +277,12 @@ public class Set extends SubCommand { return builder.toString().substring(1, builder.toString().length() - 1); } - private String getBiomeList(final List biomes) { + private String getBiomeList(final String[] biomes) { final StringBuilder builder = new StringBuilder(); - builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); - for (final Biome b : biomes) { - builder.append(getBiome(b)); + builder.append(MainUtil.colorise('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); + for (final String b : biomes) { + builder.append(getString(b)); } return builder.toString().substring(1, builder.toString().length() - 1); } - - private Material getMaterial(final String input, final List blocks) { - return Material.valueOf(new StringComparison(input, blocks.toArray()).getBestMatch()); - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java index 7d312e2e8..e47f641df 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -22,9 +22,8 @@ package com.intellectualcrafters.plot.config; import java.util.ArrayList; -import org.bukkit.block.Biome; - import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.util.BlockManager; /** * Main Configuration Utility @@ -107,7 +106,10 @@ public class Configuration { @Override public boolean validateValue(final String string) { try { - Biome.valueOf(string.toUpperCase()); + int biome = BlockManager.manager.getBiomeFromString(string.toUpperCase()); + if (biome == -1) { + return false; + } return true; } catch (final Exception e) { return false; @@ -116,17 +118,15 @@ public class Configuration { @Override public Object parseString(final String string) { - for (final Biome biome : Biome.values()) { - if (biome.name().equals(string.toUpperCase())) { - return biome; - } + if (validateValue(string)) { + return string.toUpperCase(); } - return Biome.FOREST; + return "FOREST"; } @Override public Object parseObject(final Object object) { - return (((Biome) object)).toString(); + return object.toString(); } }; public static final SettingValue BLOCK = new SettingValue("BLOCK") { 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 00f2433ba..6d8cb5545 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -26,9 +26,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -36,6 +33,7 @@ import com.intellectualcrafters.plot.events.PlotFlagAddEvent; import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; @@ -141,11 +139,7 @@ public class FlagManager { * @param flag */ public static boolean addPlotFlag(final Plot plot, final Flag flag) { - final PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return false; - } + // FIXME PlotFlagAddEvent final Flag hasFlag = getPlotFlag(plot, flag.getKey()); if (hasFlag != null) { plot.settings.flags.remove(hasFlag); @@ -197,11 +191,7 @@ public class FlagManager { if (hasFlag != null) { final Flag flagObj = FlagManager.getPlotFlagAbs(plot, flag); if (flagObj != null) { - final PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flagObj, plot); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return false; - } + // FIXME PlotFlagRemoveEvent plot.settings.flags.remove(hasFlag); DBFunc.setFlags(plot.world, plot, plot.settings.flags); return true; @@ -281,7 +271,7 @@ public class FlagManager { * * @return List (AbstractFlag) */ - public static List getFlags(final Player player) { + public static List getFlags(final PlotPlayer player) { final List returnFlags = new ArrayList<>(); for (final AbstractFlag flag : flags) { if (player.hasPermission("plots.set.flag." + flag.getKey().toLowerCase())) { 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 766274c7e..fb6f190f3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -7,6 +7,7 @@ import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotSquared; @@ -152,10 +153,11 @@ public class AugmentedPopulator extends BlockPopulator { } private void populateBiome(final World world, final int x, final int z) { + Biome biome = Biome.valueOf(this.plotworld.PLOT_BIOME); if (this.b) { for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { - world.setBiome(x + i, z + j, this.plotworld.PLOT_BIOME); + world.setBiome(x + i, z + j, biome); } } } 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 ed144089a..6651f5d79 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -118,7 +118,7 @@ public class HybridGen extends PlotGenerator { this.pathWidthLower = (short) (Math.floor(this.pathsize / 2)); } this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); - this.biome = this.plotworld.PLOT_BIOME; + this.biome = Biome.valueOf(this.plotworld.PLOT_BIOME); try { this.maxY = Bukkit.getWorld(world).getMaxHeight(); } catch (final NullPointerException e) { 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 af9070eec..dab6601d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -25,8 +25,6 @@ import java.util.HashMap; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.bukkit.Material; -import org.bukkit.block.Biome; import org.bukkit.configuration.ConfigurationSection; import com.intellectualcrafters.plot.PlotSquared; @@ -42,7 +40,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; public abstract class PlotWorld { public final static boolean AUTO_MERGE_DEFAULT = false; public final static boolean MOB_SPAWNING_DEFAULT = false; - public final static Biome PLOT_BIOME_DEFAULT = Biome.FOREST; + public final static String PLOT_BIOME_DEFAULT = "FOREST"; public final static boolean PLOT_CHAT_DEFAULT = false; public final static boolean SCHEMATIC_CLAIM_SPECIFY_DEFAULT = false; public final static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false; @@ -62,19 +60,16 @@ public abstract class PlotWorld { // require claim in cluster // TODO make this configurable // make non static and static_default_valu + add config option - public static List BLOCKS; + public static int[] BLOCKS; static { - BLOCKS = new ArrayList<>(); - for (final Material material : Material.values()) { - if (material.isBlock() && material.isSolid() && !material.hasGravity() && !material.isTransparent() && material.isOccluding() && (material != Material.DROPPER) && (material != Material.COMMAND)) { - BLOCKS.add(material); - } - } + BLOCKS = new int[] { + 1,2,3,4,5,7,14,15,16,17,19,21,22,23,24,25,35,41,42,43,45,47,48,49,52,56,57,58,61,62,73,74,80,82,84,86,87,88,91,97,98,99,100,103,110,112,120,121,123,124,125,129,133,153,155,159,162,165,166,168,170,172,173,174,179,181 + }; } public final String worldname; public boolean AUTO_MERGE; public boolean MOB_SPAWNING; - public Biome PLOT_BIOME; + public String PLOT_BIOME; public boolean PLOT_CHAT; public boolean SCHEMATIC_CLAIM_SPECIFY = false; public boolean SCHEMATIC_ON_CLAIM; @@ -110,7 +105,7 @@ public abstract class PlotWorld { } this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); - this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome")); + this.PLOT_BIOME = (String) Configuration.BIOME.parseString(config.getString("plot.biome")); this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim"); this.SCHEMATIC_FILE = config.getString("schematic.file"); this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 2bfbe0b97..db169b370 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -29,6 +29,12 @@ public abstract class BlockManager { return (int) r; } + public abstract String[] getBiomeList(); + + public abstract int getBiomeFromString(String biome); + + public abstract int getBlockIdFromString(String block); + public abstract int getHeighestBlock(Location loc); public abstract String getBiome(Location loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 83d560647..02ae85378 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.util.bukkit; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -20,6 +21,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.StringComparison; public class BukkitUtil extends BlockManager { private static HashMap worlds = new HashMap<>(); @@ -222,4 +224,32 @@ public class BukkitUtil extends BlockManager { public int getHeighestBlock(Location loc) { return getWorld(loc.getWorld()).getHighestBlockAt(loc.getX(), loc.getZ()).getY(); } + + @Override + public int getBiomeFromString(String biomeStr) { + Biome biome = Biome.valueOf(biomeStr.toUpperCase()); + if (biome == null) { + return -1; + } + return Arrays.asList(Biome.values()).indexOf(biome); + } + + @Override + public String[] getBiomeList() { + Biome[] biomes = Biome.values(); + String[] list = new String[biomes.length]; + for (int i = 0; i< biomes.length; i++) { + list[i] = biomes[i].name(); + } + return list; + } + + @Override + public int getBlockIdFromString(String block) { + Material material = Material.valueOf(block.toUpperCase()); + if (material == null) { + return -1; + } + return material.getId(); + } } From b3a5f0aff2a60bfaeac9ea5dabe12246a2ceac24 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 23:40:36 +1100 Subject: [PATCH 117/124] more cmds --- .../plot/commands/SetOwner.java | 16 +++++++--------- .../plot/commands/Setup.java | 9 ++------- .../intellectualcrafters/plot/commands/Swap.java | 9 +++++---- .../intellectualcrafters/plot/commands/TP.java | 3 --- .../plot/commands/Target.java | 7 +++---- .../plot/commands/Template.java | 3 --- .../intellectualcrafters/plot/commands/Trim.java | 4 ---- .../plot/commands/Trusted.java | 2 -- .../plot/commands/Unclaim.java | 2 -- .../plot/commands/Unlink.java | 4 ---- .../plot/util/AChunkManager.java | 3 +++ .../plot/util/bukkit/ChunkManager.java | 5 +++++ 12 files changed, 25 insertions(+), 42 deletions(-) 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 6712f851a..7b52d578b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -23,15 +23,15 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.UUID; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -51,6 +51,7 @@ public class SetOwner extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || (plot.owner == null)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); @@ -64,9 +65,9 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } - final World world = plr.getWorld(); - final PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id; - final PlotId top = MainUtil.getTopPlot(world, plot).id; + final String world = loc.getWorld(); + final PlotId bot = MainUtil.getBottomPlot(plot).id; + final PlotId top = MainUtil.getTopPlot( plot).id; final ArrayList plots = MainUtil.getPlotSelectionIds(bot, top); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); @@ -78,11 +79,8 @@ public class SetOwner extends SubCommand { current.owner = uuid; PlotSquared.updatePlot(current); DBFunc.setOwner(current, current.owner); - if (PlotSquared.worldGuardListener != null) { - PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); - } } - MainUtil.setSign(world, args[0], plot); + MainUtil.setSign(args[0], plot); MainUtil.sendMessage(plr, C.SET_OWNER); return true; } 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 47c439242..b0511e266 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -27,12 +27,6 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.WorldCreator; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -41,6 +35,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; public class Setup extends SubCommand { @@ -205,7 +200,7 @@ public class Setup extends SubCommand { MainUtil.sendMessage(plr, "&cYou need to choose a world name!"); return false; } - if (Bukkit.getWorld(args[0]) != null) { + if (BlockManager.manager.isWorld(args[0])) { MainUtil.sendMessage(plr, "&cThat world name is already taken!"); } object.world = args[0]; 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 6ce585498..de87982bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -29,7 +29,9 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -64,7 +66,7 @@ public class Swap extends SubCommand { } final String id = args[0]; PlotId plotid; - final World world = plr.getWorld(); + final String world = loc.getWorld(); try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotSquared.getPlots(world).get(plotid); @@ -83,10 +85,9 @@ public class Swap extends SubCommand { MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } - PlotSelection.swap(world, plot.id, plotid); - // TODO Requires testing!! + AChunkManager.manager.swap(world, plot.id, plotid); + // FIXME Requires testing!! DBFunc.dbManager.swapPlots(plot, MainUtil.getPlot(world, plotid)); - // TODO Requires testing!! MainUtil.sendMessage(plr, C.SWAP_SUCCESS); MainUtil.update(plr.getLocation()); return true; 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 7755edf82..8ca015391 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -21,9 +21,6 @@ package com.intellectualcrafters.plot.commands; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; 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 a0c676b44..3890c8555 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.Location; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; @@ -35,7 +33,8 @@ public class Target extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!PlotSquared.isPlotWorld(plr.getWorld())) { + Location ploc = plr.getLocation(); + if (!PlotSquared.isPlotWorld(ploc.getWorld())) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } @@ -45,7 +44,7 @@ public class Target extends SubCommand { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } - final Location loc = MainUtil.getPlotHome(plr.getWorld(), id); + final Location loc = MainUtil.getPlotHome(loc.getWorld(), id); plr.setCompassTarget(loc); MainUtil.sendMessage(plr, C.COMPASS_TARGET); return true; 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 3c408382d..cad1dd87c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -25,9 +25,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.GZIPOutputStream; -import org.bukkit.Bukkit; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; 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 b5c455783..6f25bfc3c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -28,10 +28,6 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.HashSet; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; 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 1ae3155f5..20bbcf123 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -22,8 +22,6 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; 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 3ee36d6a1..49865681d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -22,8 +22,6 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 0fc40c6c4..c349958f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -22,10 +22,6 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java index 04471e9a0..e9b1b7b54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -6,6 +6,7 @@ import java.util.List; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.RegionWrapper; public abstract class AChunkManager { @@ -33,4 +34,6 @@ public abstract class AChunkManager { public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone); public abstract void clearAllEntities(final Plot plot); + + public abstract void swap(String world, PlotId id, PlotId plotid); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 5bfb6c591..e486e57f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -760,4 +760,9 @@ public class ChunkManager extends AChunkManager { public boolean loadChunk(String world, ChunkLoc loc) { return BukkitUtil.getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); } + + @Override + public void swap(String world, PlotId id, PlotId plotid) { + // FIXME swap plots + } } From 81f3e6ef241a8b1a808a8f9c60a012012309b98f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 23:46:47 +1100 Subject: [PATCH 118/124] target --- .../java/com/intellectualcrafters/plot/commands/Target.java | 3 ++- .../com/intellectualcrafters/plot/object/BukkitPlayer.java | 6 ++++++ .../com/intellectualcrafters/plot/object/PlotPlayer.java | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) 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 3890c8555..b037251b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -44,7 +45,7 @@ public class Target extends SubCommand { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } - final Location loc = MainUtil.getPlotHome(loc.getWorld(), id); + final Location loc = MainUtil.getPlotHome(ploc.getWorld(), id); plr.setCompassTarget(loc); MainUtil.sendMessage(plr, C.COMPASS_TARGET); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 5c75a4ebf..02735f673 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -95,5 +95,11 @@ public class BukkitPlayer implements PlotPlayer { public boolean isOnline() { return this.player.isOnline(); } + + @Override + public void setCompassTarget(Location loc) { + player.setCompassTarget(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ())); + + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index f5682afdf..f74f500f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -23,4 +23,6 @@ public interface PlotPlayer { public boolean isOnline(); public String getName(); + + public void setCompassTarget(Location loc); } From 0e9e813dbf54765bd00f6f6fcf3193c207850c0b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 23:47:43 +1100 Subject: [PATCH 119/124] template --- .../com/intellectualcrafters/plot/commands/Template.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 cad1dd87c..0f18ea275 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -29,6 +29,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; public class Template extends SubCommand { @@ -42,9 +43,9 @@ public class Template extends SubCommand { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); return false; } - final World world = Bukkit.getWorld(args[1]); - final PlotWorld plotworld = PlotSquared.getPlotWorld(args[1]); - if ((world == null) || (plotworld == null)) { + String world = args[1]; + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + if (!BlockManager.manager.isWorld(world) || (plotworld == null)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); return false; } From cdf45c7efcc34c1e6f805f65f41c8e78e3fd060d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 23:51:02 +1100 Subject: [PATCH 120/124] TP --- .../intellectualcrafters/plot/PlotSquared.java | 5 +++++ .../intellectualcrafters/plot/commands/Kick.java | 1 - .../plot/commands/Merge.java | 1 - .../plot/commands/Purge.java | 3 --- .../plot/commands/Schematic.java | 1 - .../intellectualcrafters/plot/commands/Set.java | 4 ---- .../plot/commands/SetOwner.java | 1 - .../plot/commands/Setup.java | 4 ++++ .../intellectualcrafters/plot/commands/Swap.java | 2 -- .../intellectualcrafters/plot/commands/TP.java | 16 ++++++++++------ .../intellectualcrafters/plot/commands/Trim.java | 2 ++ .../plot/commands/Trusted.java | 2 ++ .../plot/commands/Unlink.java | 2 ++ 13 files changed, 25 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 4d13d0f3f..bb84e0258 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -142,6 +142,11 @@ public class PlotSquared { return getPlots(world, uuid); } + public static Set getPlots(final String world, final PlotPlayer player) { + final UUID uuid = player.getUUID(); + return getPlots(world, uuid); + } + public static Set getPlots(final String world, final UUID uuid) { final ArrayList myplots = new ArrayList<>(); for (final Plot plot : getPlots(world).values()) { 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 e2228c6c1..0e5fc4394 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -27,7 +27,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({ "unused", "deprecation", "javadoc" }) 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 151118e02..8e36e9c69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -28,7 +28,6 @@ import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; 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 e4c9a83ef..a9e1b0b97 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -25,9 +25,6 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 c18c907c5..f692996b5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -38,7 +38,6 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Schematic extends SubCommand { 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 3aadda2bf..46136d4a4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -21,7 +21,6 @@ package com.intellectualcrafters.plot.commands; import java.util.Arrays; -import java.util.List; import org.apache.commons.lang.StringUtils; @@ -41,12 +40,9 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** 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 7b52d578b..41d048662 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -32,7 +32,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class SetOwner extends SubCommand { 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 b0511e266..dc68bc39c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -27,6 +27,10 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.WorldCreator; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; 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 de87982bc..89629f7ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; 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 8ca015391..4763f14d1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -24,10 +24,13 @@ import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret @@ -45,10 +48,12 @@ public class TP extends SubCommand { } final String id = args[0]; PlotId plotid; - World world = plr.getWorld(); + Location loc = plr.getLocation(); + String pworld = loc.getWorld(); + String world = pworld; if (args.length == 2) { - if (Bukkit.getWorld(args[1]) != null) { - world = Bukkit.getWorld(args[1]); + if (BlockManager.manager.isWorld(args[1])) { + world = args[1]; } } if (!PlotSquared.isPlotWorld(world)) { @@ -70,7 +75,7 @@ public class TP extends SubCommand { return false; } - private Plot isAlias(final World world, String a) { + private Plot isAlias(final String world, String a) { int index = 0; if (a.contains(";")) { final String[] split = a.split(";"); @@ -79,8 +84,7 @@ public class TP extends SubCommand { } a = split[0]; } - @SuppressWarnings("deprecation") - final Player player = Bukkit.getPlayer(a); + final PlotPlayer player = UUIDHandler.getPlayer(a); if (player != null) { final java.util.Set plotMainPlots = PlotSquared.getPlots(world, player); final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]); 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 6f25bfc3c..75713e057 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -28,6 +28,8 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.HashSet; +import org.bukkit.Bukkit; + import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; 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 20bbcf123..1ae3155f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -22,6 +22,8 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; +import org.bukkit.Bukkit; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; 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 c349958f6..0e3113a97 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -22,6 +22,8 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; +import org.bukkit.Bukkit; + import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; From c4d017cc063315c0566a250724df4c2027fe21aa Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 23:57:59 +1100 Subject: [PATCH 121/124] more cmds --- .../plot/commands/Trim.java | 57 +++++-------------- .../plot/commands/Trusted.java | 7 +-- .../plot/commands/Unclaim.java | 13 +++-- .../plot/commands/Unlink.java | 42 +++++--------- 4 files changed, 38 insertions(+), 81 deletions(-) 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 75713e057..bce3fa5fa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -28,15 +28,15 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.HashSet; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.AChunkManager; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; @@ -87,8 +87,8 @@ public class Trim extends SubCommand { MainUtil.sendMessage(plr, C.TRIM_SYNTAX); return false; } - final World world = Bukkit.getWorld(args[1]); - if ((world == null) || (PlotSquared.getPlotWorld(world) == null)) { + final String world = args[1]; + if (!BlockManager.manager.isWorld(world) || (PlotSquared.getPlotWorld(world) == null)) { MainUtil.sendMessage(plr, C.NOT_VALID_WORLD); return false; } @@ -107,14 +107,14 @@ public class Trim extends SubCommand { return true; } - public static boolean getBulkRegions(final ArrayList empty, final World world, final Runnable whenDone) { + public static boolean getBulkRegions(final ArrayList empty, final String world, final Runnable whenDone) { if (Trim.TASK) { return false; } TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - final String directory = world.getName() + File.separator + "region"; + final String directory = world + File.separator + "region"; final File folder = new File(directory); final File[] regionFiles = folder.listFiles(); for (final File file : regionFiles) { @@ -173,7 +173,7 @@ public class Trim extends SubCommand { sendMessage(" - MCA #: " + chunks.size()); sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)"); sendMessage(" - TIME ESTIMATE: " + (chunks.size() / 1200) + " minutes"); - Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() { + Trim.TASK_ID = TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { final long start = System.currentTimeMillis(); @@ -183,62 +183,31 @@ public class Trim extends SubCommand { System.out.print("DONE!"); Trim.TASK = false; TaskManager.runTaskAsync(whenDone); - Bukkit.getScheduler().cancelTask(Trim.TASK_ID); + PlotSquared.TASK.cancelTask(Trim.TASK_ID); return; } final Plot plot = plots.get(0); plots.remove(0); final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id); final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); - final Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ()); - final Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ()); + final Location pos3 = new Location(world, pos1.getX(), 64, pos2.getZ()); + final Location pos4 = new Location(world, pos2.getX(), 64, pos1.getZ()); chunks.remove(ChunkManager.getChunkChunk(pos1)); chunks.remove(ChunkManager.getChunkChunk(pos2)); chunks.remove(ChunkManager.getChunkChunk(pos3)); chunks.remove(ChunkManager.getChunkChunk(pos4)); } } - }, 20L, 20L); + }, 20); Trim.TASK = true; return true; } public static ArrayList expired = null; - // public static void updateUnmodifiedPlots(final World world) { - // final SquarePlotManager manager = (SquarePlotManager) PlotSquared.getPlotManager(world); - // final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getPlotWorld(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(PlotSquared.getMain(), new Runnable() { - // @Override - // public void run() { - // if (manager != null && plots.size() > 0) { - // Plot plot = plots.iterator().next(); - // if (plot.hasOwner()) { - // SquarePlotManager.checkModified(plot, 0); - // } - // if (plot.owner == null || !SquarePlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) { - // expired.add(plot); - // sendMessage("found expired: " + plot); - // } - // } - // else { - // Trim.expired = expired; - // Trim.TASK = false; - // sendMessage("Done!"); - // Bukkit.getScheduler().cancelTask(Trim.TASK_ID); - // return; - // } - // } - // }, 1, 1); - // } - // - public static void deleteChunks(final World world, final ArrayList chunks) { - final String worldname = world.getName(); + public static void deleteChunks(final String world, final ArrayList chunks) { for (final ChunkLoc loc : chunks) { - ChunkManager.deleteRegionFile(worldname, loc); + AChunkManager.manager.deleteRegionFile(world, loc); } } 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 1ae3155f5..4c4c2279f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") @@ -84,8 +85,7 @@ public class Trusted extends SubCommand { } plot.addTrusted(uuid); DBFunc.setTrusted(loc.getWorld(), plot, uuid); - final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); - Bukkit.getPluginManager().callEvent(event); + // FIXME PlayerPlotTrustedEvent } else { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; @@ -107,8 +107,7 @@ public class Trusted extends SubCommand { final UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeTrusted(uuid); DBFunc.removeTrusted(loc.getWorld(), plot, uuid); - final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false); - Bukkit.getPluginManager().callEvent(event); + // FIXME PlayerPlotTrustedEvent MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); } else { MainUtil.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); 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 49865681d..e9b2a6826 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -29,7 +29,9 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -45,7 +47,7 @@ public class Unclaim extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) { @@ -53,19 +55,18 @@ public class Unclaim extends SubCommand { } assert plot != null; final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world); - if (PlotSquared.useEconomy && pWorld.USE_ECONOMY) { + if (PlotSquared.economy != null && pWorld.USE_ECONOMY) { final double c = pWorld.SELL_PRICE; if (c > 0d) { final Economy economy = PlotSquared.economy; - economy.depositPlayer(plr, c); + EconHandler.depositPlayer(plr, c); sendMessage(plr, C.ADDED_BALANCE, c + ""); } } final boolean result = PlotSquared.removePlot(loc.getWorld(), plot.id, true); if (result) { - final World world = plr.getWorld(); - final String worldname = world.getName(); - PlotSquared.getPlotManager(world).unclaimPlot(world, pWorld, plot); + final String worldname = plr.getLocation().getWorld(); + PlotSquared.getPlotManager(worldname).unclaimPlot(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 0e3113a97..9bccf27bb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -35,6 +35,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -58,41 +59,28 @@ public class Unlink extends SubCommand { if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } - if (MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_IMPOSSIBLE); } - final World world = plr.getWorld(); - if (!unlinkPlot(world, plot)) { + final String world = plr.getLocation().getWorld(); + if (!unlinkPlot(plot)) { MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); return false; } - try { - MainUtil.update(plr.getLocation()); - } catch (final Exception e) { - // execute(final PlotPlayer plr, final String... args) { - try { - PlotSquared.log("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); - } catch (final Exception ex) { - ex.printStackTrace(); - } - } + MainUtil.update(plr.getLocation()); MainUtil.sendMessage(plr, "&6Plots unlinked successfully!"); return true; } - public static boolean unlinkPlot(final World world, final Plot plot) { - final PlotId pos1 = BukkitPlayerFunctions.getBottomPlot(world, plot).id; - final PlotId pos2 = MainUtil.getTopPlot(world, plot).id; + public static boolean unlinkPlot(final Plot plot) { + String world = plot.world; + final PlotId pos1 = MainUtil.getBottomPlot(plot).id; + final PlotId pos2 = MainUtil.getTopPlot(plot).id; final ArrayList ids = MainUtil.getPlotSelectionIds(pos1, pos2); - final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - event.setCancelled(true); - return false; - } + // FIXME PlotUnlinkEvent (cancellable) final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - manager.startPlotUnlink(world, plotworld, ids); + manager.startPlotUnlink(plotworld, ids); for (final PlotId id : ids) { final Plot myplot = PlotSquared.getPlots(world).get(id); if (plot == null) { @@ -106,7 +94,7 @@ public class Unlink extends SubCommand { } myplot.deny_entry = plot.deny_entry; myplot.settings.setMerged(new boolean[] { false, false, false, false }); - DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged()); + DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); } for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -122,16 +110,16 @@ public class Unlink extends SubCommand { if (ly) { manager.createRoadSouth(plotworld, p); } - MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } } - manager.finishPlotUnlink(world, plotworld, ids); + manager.finishPlotUnlink(plotworld, ids); for (final PlotId id : ids) { final Plot myPlot = MainUtil.getPlot(world, id); if (plot.hasOwner()) { final String name = UUIDHandler.getName(myPlot.owner); if (name != null) { - MainUtil.setSign(world, name, myPlot); + MainUtil.setSign(name, myPlot); } } } From 623c14273da514c7f96969f83bc8aa03193e2b50 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Feb 2015 00:04:24 +1100 Subject: [PATCH 122/124] cleanup --- .../java/com/intellectualcrafters/plot/commands/Trusted.java | 3 --- .../java/com/intellectualcrafters/plot/commands/Unclaim.java | 1 - .../java/com/intellectualcrafters/plot/commands/Unlink.java | 5 ----- .../java/com/intellectualcrafters/plot/flag/FlagManager.java | 2 -- .../com/intellectualcrafters/plot/object/PlotSettings.java | 3 --- .../java/com/intellectualcrafters/plot/object/PlotWorld.java | 1 - .../intellectualcrafters/plot/util/bukkit/BukkitUtil.java | 1 - 7 files changed, 16 deletions(-) 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 4c4c2279f..ae707efdc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -22,11 +22,8 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; 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 e9b2a6826..ec49c1abf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -32,7 +32,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Unclaim extends SubCommand { 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 9bccf27bb..097cc77a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -22,12 +22,9 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlotUnlinkEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -36,7 +33,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -62,7 +58,6 @@ public class Unlink extends SubCommand { if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_IMPOSSIBLE); } - final String world = plr.getLocation().getWorld(); if (!unlinkPlot(plot)) { MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); return false; 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 6d8cb5545..1e10f15a3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -29,8 +29,6 @@ import java.util.Set; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlotFlagAddEvent; -import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotPlayer; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 238c055b2..c21fc6e3b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -23,13 +23,10 @@ package com.intellectualcrafters.plot.object; import java.util.ArrayList; import java.util.Set; -import org.bukkit.block.Biome; - import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** * plot settings 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 dab6601d4..1b3b0a3c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -20,7 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.object; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 02ae85378..08e7c6fc1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -21,7 +21,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.StringComparison; public class BukkitUtil extends BlockManager { private static HashMap worlds = new HashMap<>(); From 02623d9cc2b45bf88ca74f6e53028d6c5d34cfa6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Feb 2015 00:12:32 +1100 Subject: [PATCH 123/124] Setup --- .../plot/commands/Setup.java | 172 ++---------------- .../plot/object/SetupObject.java | 13 ++ .../plot/util/SetupUtils.java | 20 ++ .../plot/util/bukkit/BukkitSetupUtils.java | 88 +++++++++ 4 files changed, 139 insertions(+), 154 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java 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 dc68bc39c..b0e9649a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -20,89 +20,45 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.io.IOException; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; - import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.WorldCreator; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.plugin.Plugin; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.generator.SquarePlotManager; -import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetupUtils; public class Setup extends SubCommand { - public final static Map setupMap = new HashMap<>(); - public HashMap generators = new HashMap<>(); - public Setup() { super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, true); } - private class SetupObject { - int current = 0; - int setup_index = 0; - String world = null; - String generator = null; - int type = 0; - int terrain = 0; - ConfigurationNode[] step = null; - } - - public void updateGenerators() { - if (this.generators.size() > 0) { - return; - } - final String testWorld = "CheckingPlotSquaredGenerator"; - for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { - if (plugin.isEnabled()) { - final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); - if (generator != null) { - PlotSquared.removePlotWorld(testWorld); - final String name = plugin.getDescription().getName(); - if (generator instanceof PlotGenerator) { - final PlotGenerator pgen = (PlotGenerator) generator; - if (pgen.getPlotManager() instanceof SquarePlotManager) { - this.generators.put(name, pgen); - } - } - } - } - } - } - @Override public boolean execute(final PlotPlayer plr, final String... args) { // going through setup final String name = plr.getName(); - if (!setupMap.containsKey(name)) { + if (!SetupUtils.setupMap.containsKey(name)) { final SetupObject object = new SetupObject(); - setupMap.put(name, object); - updateGenerators(); + SetupUtils.setupMap.put(name, object); + SetupUtils.manager.updateGenerators(); final String prefix = "\n&8 - &7"; sendMessage(plr, C.SETUP_INIT); - MainUtil.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + MainUtil.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); return false; } if (args.length == 1) { if (args[0].equalsIgnoreCase("cancel")) { - setupMap.remove(plr.getName()); + SetupUtils.setupMap.remove(plr.getName()); MainUtil.sendMessage(plr, "&aCancelled setup"); return false; } if (args[0].equalsIgnoreCase("back")) { - final SetupObject object = setupMap.get(plr.getName()); + final SetupObject object = SetupUtils.setupMap.get(plr.getName()); if (object.setup_index > 0) { object.setup_index--; final ConfigurationNode node = object.step[object.current]; @@ -113,13 +69,13 @@ public class Setup extends SubCommand { } } } - final SetupObject object = setupMap.get(name); + final SetupObject object = SetupUtils.setupMap.get(name); final int index = object.current; switch (index) { case 0: { // choose generator - if ((args.length != 1) || !this.generators.containsKey(args[0])) { + if ((args.length != 1) || !SetupUtils.generators.containsKey(args[0])) { final String prefix = "\n&8 - &7"; - MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); sendMessage(plr, C.SETUP_INIT); return false; } @@ -144,7 +100,7 @@ public class Setup extends SubCommand { if (object.type == 0) { object.current++; if (object.step == null) { - object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); + object.step = SetupUtils.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); } final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); @@ -163,7 +119,7 @@ public class Setup extends SubCommand { object.terrain = terrain.indexOf(args[0].toLowerCase()); object.current++; if (object.step == null) { - object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); + object.step = SetupUtils.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); } final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); @@ -208,112 +164,20 @@ public class Setup extends SubCommand { MainUtil.sendMessage(plr, "&cThat world name is already taken!"); } object.world = args[0]; - setupMap.remove(plr.getName()); - final World world = setupWorld(object); + SetupUtils.setupMap.remove(plr.getName()); + final String world = SetupUtils.manager.setupWorld(object); try { - plr.teleport(world.getSpawnLocation()); + plr.teleport(BlockManager.manager.getSpawn(world)); } catch (final Exception e) { plr.sendMessage("&cAn error occured. See console for more information"); e.printStackTrace(); } sendMessage(plr, C.SETUP_FINISHED, object.world); - setupMap.remove(plr.getName()); + SetupUtils.setupMap.remove(plr.getName()); } } - /* - * 0.0 normal hybrid no clusters - * 0.1 normal hybrid with clusters - * 0.2 normal hybrid require clusters - * 1.0 augmented whole world - * 1.1 augmented whole world with ore - * 1.2 augmented whole world with terrain - * 2.1 augmented partial world - * 2.2 augmented partial world with ore - * 2.3 augmented partial world with terrain - * 3.0 no generation + normal manager - * - * generator.TYPE: PlotSquared, augmented, partial - * generator.TERRAIN - * - * WORLD.TYPE: hybrid, augmented, partial - * if (augmented/partial) - * WORLD.TERRAIN: - * - * - * types (0, 1, 2, 3) - * 0: no options - * 1: - * - * - * - return null - * - schedule task to create world later - * - externalize multiverse/world hooks to separate class - * - create vanilla world - * - add augmented populator - * - add config option type - * - Work on heirarchy for setting nodes so you don't need to provide irrelevent info (world setup) - * - use code from setup command for world arguments (above) so that it persists - * - work on plot clearing for augmented plot worlds (terrain) (heads, banners, paintings, animals, inventoryhandler) - * - make a generic clear function for any generator - * - clean up plotmanager class (remove unnecessary methods) - * - make simple plot manager which can be used by external generators (don't make abstract) - * - plugins will override any of it's methods - * - make heirarchy of generators of increasing abstraction: - * = totally abstract (circle plots, moving plots, no tesselation) - * = tessellating generator - * = grid generator - * = square generator - * = square plot generator (must have plot section and road section) (plot height, road height) - * = hybrid generator - * - * - All will support whole world augmentation - * - Only grid will support partial plot worlds - * - */ return false; } - public World setupWorld(final SetupObject object) { - // Configuration - final ConfigurationNode[] steps = object.step; - final String world = object.world; - for (final ConfigurationNode step : steps) { - PlotSquared.config.set("worlds." + world + "." + step.getConstant(), step.getValue()); - } - if (object.type != 0) { - 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 { - PlotSquared.config.save(PlotSquared.configFile); - } catch (final IOException e) { - e.printStackTrace(); - } - if (object.type == 0) { - if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.generator); - } else { - if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator); - } else { - final WorldCreator wc = new WorldCreator(object.world); - wc.generator(object.generator); - wc.environment(Environment.NORMAL); - Bukkit.createWorld(wc); - } - } - } else { - if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal"); - } else { - if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world); - } else { - Bukkit.createWorld(new WorldCreator(object.world).environment(World.Environment.NORMAL)); - } - } - } - return Bukkit.getWorld(object.world); - } + } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java new file mode 100644 index 000000000..f809c99ef --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java @@ -0,0 +1,13 @@ +package com.intellectualcrafters.plot.object; + +import com.intellectualcrafters.plot.config.ConfigurationNode; + +public class SetupObject { + public int current = 0; + public int setup_index = 0; + public String world = null; + public String generator = null; + public int type = 0; + public int terrain = 0; + public ConfigurationNode[] step = null; +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java new file mode 100644 index 000000000..54d491ec6 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -0,0 +1,20 @@ +package com.intellectualcrafters.plot.util; + +import java.util.HashMap; +import java.util.Map; + +import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.SetupObject; +import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; + +public abstract class SetupUtils { + + public static SetupUtils manager = new BukkitSetupUtils(); + + public final static Map setupMap = new HashMap<>(); + public static HashMap generators = new HashMap<>(); + + public abstract void updateGenerators(); + + public abstract String setupWorld(final SetupObject object); +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java new file mode 100644 index 000000000..f4f1d7bf7 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -0,0 +1,88 @@ +package com.intellectualcrafters.plot.util.bukkit; + +import java.io.IOException; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.WorldCreator; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.plugin.Plugin; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.ConfigurationNode; +import com.intellectualcrafters.plot.generator.SquarePlotManager; +import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.SetupObject; +import com.intellectualcrafters.plot.util.SetupUtils; + +public class BukkitSetupUtils extends SetupUtils { + + @Override + public void updateGenerators() { + if (SetupUtils.generators.size() > 0) { + return; + } + final String testWorld = "CheckingPlotSquaredGenerator"; + for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { + if (plugin.isEnabled()) { + final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); + if (generator != null) { + PlotSquared.removePlotWorld(testWorld); + final String name = plugin.getDescription().getName(); + if (generator instanceof PlotGenerator) { + final PlotGenerator pgen = (PlotGenerator) generator; + if (pgen.getPlotManager() instanceof SquarePlotManager) { + SetupUtils.generators.put(name, pgen); + } + } + } + } + } + } + + @Override + public String setupWorld(final SetupObject object) { + final ConfigurationNode[] steps = object.step; + final String world = object.world; + for (final ConfigurationNode step : steps) { + PlotSquared.config.set("worlds." + world + "." + step.getConstant(), step.getValue()); + } + if (object.type != 0) { + 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 { + PlotSquared.config.save(PlotSquared.configFile); + } catch (final IOException e) { + e.printStackTrace(); + } + if (object.type == 0) { + if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.generator); + } else { + if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator); + } else { + final WorldCreator wc = new WorldCreator(object.world); + wc.generator(object.generator); + wc.environment(Environment.NORMAL); + Bukkit.createWorld(wc); + } + } + } else { + if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal"); + } else { + if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world); + } else { + Bukkit.createWorld(new WorldCreator(object.world).environment(World.Environment.NORMAL)); + } + } + } + return object.world; + } + +} From a5731d94be2606ea9cce79e7c542000179d5dec2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Feb 2015 00:20:41 +1100 Subject: [PATCH 124/124] mostly done --- .../intellectualcrafters/plot/BukkitMain.java | 18 +++++++++++++++++- .../intellectualcrafters/plot/IPlotMain.java | 9 ++++++++- .../intellectualcrafters/plot/PlotSquared.java | 9 ++++++++- .../plot/generator/HybridUtils.java | 2 +- .../plot/listeners/PlayerEvents.java | 5 +++-- .../plot/util/BlockManager.java | 2 +- .../plot/util/ExpireManager.java | 2 +- .../plot/util/SetupUtils.java | 2 +- 8 files changed, 40 insertions(+), 9 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 9ca66e3e7..1d5b63dea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -29,7 +29,9 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.PlotMeConverter; import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.listeners.ForceFieldListener; import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.PlayerEvents; @@ -37,9 +39,12 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.Metrics; @@ -265,7 +270,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } @Override - public void initSetBlockManager() { + public BlockManager initBlockManager() { if (checkVersion(1, 8, 0)) { try { SetBlockManager.setBlockManager = new SetBlockFast_1_8(); @@ -286,6 +291,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } catch (final Throwable e) { MainUtil.canSendChunk = false; } + return BlockManager.manager = new BukkitUtil(); } @Override @@ -321,4 +327,14 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return true; } + + @Override + public HybridUtils initHybridUtils() { + return new BukkitHybridUtils(); + } + + @Override + public SetupUtils initSetupUtils() { + return new BukkitSetupUtils(); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index dba352914..76c59e5ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -4,7 +4,10 @@ import java.io.File; import net.milkbowl.vault.economy.Economy; +import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; public interface IPlotMain { @@ -34,7 +37,11 @@ public interface IPlotMain { public Economy getEconomy(); - public void initSetBlockManager(); + public BlockManager initBlockManager(); + + public SetupUtils initSetupUtils(); + + public HybridUtils initHybridUtils(); public boolean initPlotMeConverter(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index bb84e0258..ed5d96fd1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.ClassicPlotWorld; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; @@ -48,9 +49,11 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.Logger; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.Logger.LogLevel; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; @@ -434,8 +437,12 @@ public class PlotSquared { IMP.registerPlotPlusEvents(); IMP.registerForceFieldEvents(); IMP.registerWorldEditEvents(); + // create Hybrid utility class + HybridUtils.manager = IMP.initHybridUtils(); + // create setup util class + SetupUtils.manager = IMP.initSetupUtils(); // Set block - IMP.initSetBlockManager(); + BlockManager.manager = IMP.initBlockManager(); // PlotMe TaskManager.runTaskLater(new Runnable() { @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index e206b7439..2ba65f1c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -19,7 +19,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class HybridUtils { - public static HybridUtils manager = new BukkitHybridUtils(); + public static HybridUtils manager; public boolean checkModified(final Plot plot, int requiredChanges) { final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); 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 717c66c97..4e9fa59ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -101,6 +101,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -752,8 +753,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public static void onLeave(final PlayerQuitEvent event) { String name = event.getPlayer().getName(); - if (Setup.setupMap.containsKey(name)) { - Setup.setupMap.remove(name); + if (SetupUtils.setupMap.containsKey(name)) { + SetupUtils.setupMap.remove(name); } BukkitUtil.removePlayer(name); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index db169b370..500cc2a88 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class BlockManager { - public static BlockManager manager = new BukkitUtil(); + public static BlockManager manager; private static long state = 1; public static long nextLong() { 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 a7026c09f..0efd9348f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -109,7 +109,7 @@ public class ExpireManager { } final PlotManager manager = PlotSquared.getPlotManager(world); if (plot.settings.isMerged()) { - Unlink.unlinkPlot(Bukkit.getWorld(world), plot); + Unlink.unlinkPlot(plot); } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.clearPlot(plotworld, plot, false, null); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java index 54d491ec6..06456b903 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -9,7 +9,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; public abstract class SetupUtils { - public static SetupUtils manager = new BukkitSetupUtils(); + public static SetupUtils manager; public final static Map setupMap = new HashMap<>(); public static HashMap generators = new HashMap<>();