From 4a314144c67deaf8ccc16dfdc5bc9271f08b52f8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 14:24:05 +1100 Subject: [PATCH] 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