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 d4210dd80..2ab38c675 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -74,7 +74,6 @@ public class Claim extends SubCommand { SchematicHandler.manager.paste(sch, plot2, 0, 0); } PlotSquared.getPlotManager(world).claimPlot(plotworld, plot); - MainUtil.update(loc); } return result; } 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 67d9598c2..0be56253d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -70,7 +70,6 @@ public class Copy extends SubCommand { @Override public void run() { MainUtil.sendMessage(plr, C.COPY_SUCCESS); - MainUtil.update(plr.getLocation()); } })) { return true; 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 acc0b0fff..3d41ef692 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -45,7 +45,6 @@ public class CreateRoadSchematic extends SubCommand { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } HybridUtils.manager.setupRoadSchematic(plot); - MainUtil.update(loc); MainUtil.sendMessage(player, "&6Saved new road schematic"); 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 8ba3ee56f..046c9b775 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -43,11 +43,7 @@ public class DebugRoadRegen extends SubCommand { } final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); final boolean result = HybridUtils.manager.regenerateRoad(world, chunk); - if (result) { - MainUtil.update(loc); - } MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); - MainUtil.update(loc); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 731ded1bc..d330383c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -193,7 +193,6 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); - MainUtil.update(loc); } MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); } @@ -223,7 +222,6 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); - MainUtil.update(loc); 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 c6fd03374..8630cacd0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -86,7 +86,6 @@ public class Move extends SubCommand { @Override public void run() { MainUtil.sendMessage(plr, C.MOVE_SUCCESS); - MainUtil.update(plr.getLocation()); } })) { return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 0524b48e0..ce57799a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -139,7 +139,6 @@ public class SchematicCmd extends SubCommand { if (start > blen) { SchematicHandler.manager.pasteStates(schematic, plot, 0, 0); sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); - MainUtil.update(plr.getLocation()); SchematicCmd.this.running = false; PlotSquared.TASK.cancelTask(SchematicCmd.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 bfaf58697..b24829271 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -246,7 +246,6 @@ public class Set extends SubCommand { } } manager.setComponent(plotworld, plot.id, component, blocks); - MainUtil.update(loc); MainUtil.sendMessage(plr, C.GENERATING_COMPONENT); 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 aadda2c06..ffdd46aa7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -125,7 +125,6 @@ public class Swap extends SubCommand { public void run() { if (last) { MainUtil.sendMessage(plr, C.SWAP_SUCCESS); - MainUtil.update(plr.getLocation()); } } }); 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 936ef01a2..00b8f64c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -70,7 +70,6 @@ public class Unlink extends SubCommand { MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); return; } - MainUtil.update(plr.getLocation()); MainUtil.sendMessage(plr, C.UNLINK_SUCCESS); } }; 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 b050e8a7b..9991b745f 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,5 @@ package com.intellectualcrafters.plot.generator; -import java.util.Arrays; import java.util.Iterator; import java.util.Random; @@ -19,9 +18,7 @@ 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.BlockUpdateUtil; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; @@ -132,7 +129,6 @@ public class AugmentedPopulator extends BlockPopulator { public void run() { populateBiome(world, x, z); chunk.unload(true, true); - BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } }, 20); } else { @@ -148,7 +144,6 @@ public class AugmentedPopulator extends BlockPopulator { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); chunk.unload(true, true); - BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } }, 40 + rand.nextInt(40)); } @@ -190,9 +185,6 @@ public class AugmentedPopulator extends BlockPopulator { } for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) { Chunk chunk = world.getChunkAt(X, Z); - if (MainUtil.canSetFast) { - ((BukkitSetBlockManager) BlockUpdateUtil.setBlockManager).update(Arrays.asList(chunk)); - } populator.populate(world, this.r, chunk); } } 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 da5f1714a..155f1c960 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -11,12 +11,10 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.api.PlotAPI; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { 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 944792816..07d304dba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -24,10 +24,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import java.util.Random; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; 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 9f8292b0d..4f8d467ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -2,12 +2,9 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.HashSet; -import java.util.Random; -import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Biome; -import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotLoc; @@ -17,7 +14,6 @@ import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.ChunkManager; /** * @author Citymonstret diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index 87e05f043..d5f52d744 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -1,17 +1,13 @@ package com.intellectualcrafters.plot.object; import java.util.HashMap; -import java.util.HashSet; -import java.util.Random; import java.util.Map.Entry; +import java.util.Random; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.object.schematic.PlotItem; -import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; 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 e72b90695..93c54dbc4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -2,7 +2,6 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.schematic.PlotItem; public abstract class BlockManager { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java index 4ffb0c881..09b982afb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java @@ -1,11 +1,11 @@ package com.intellectualcrafters.plot.util; -import java.util.List; +import java.util.Collection; import com.intellectualcrafters.plot.object.ChunkLoc; public abstract class BlockUpdateUtil { public static BlockUpdateUtil setBlockManager = null; - public abstract void update(String worldname, List chunkLocs); + public abstract void update(String worldname, Collection chunkLocs); } 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 27ecae543..916d660f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.util; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Random; @@ -23,7 +22,6 @@ 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.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -277,7 +275,6 @@ public class ClusterManager { @Override public void run() { if ((populator == null) || (plotworld.TYPE == 0)) { - BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); world.regenerateChunk(chunk.getX(), chunk.getZ()); chunk.unload(true, true); } else { 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 7dc920c1c..90faf6f75 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -29,7 +29,6 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; 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; @@ -171,20 +170,20 @@ public class MainUtil { } } - public static void update(final Location loc) { - final String world = loc.getWorld(); - int ox = loc.getX() >> 4; - int oz = loc.getZ() >> 4; - 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(ox + cx, oz + cz); - chunks.add(chunk); - } - } - BlockUpdateUtil.setBlockManager.update(world, chunks); - } +// public static void update(final Location loc) { +// final String world = loc.getWorld(); +// int ox = loc.getX() >> 4; +// int oz = loc.getZ() >> 4; +// 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(ox + cx, oz + cz); +// chunks.add(chunk); +// } +// } +// BlockUpdateUtil.setBlockManager.update(world, chunks); +// } public static void createWorld(final String world, final String generator) { } @@ -418,7 +417,6 @@ public class MainUtil { } merge = false; } - update(getPlotHome(world, plot)); } private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { @@ -547,7 +545,6 @@ public class MainUtil { MainUtil.setBiome(world, plot, "FOREST"); runners.remove(plot); TaskManager.runTask(whenDone); - update(location); } }; manager.clearPlot(plotworld, plot, isDelete, run); @@ -611,7 +608,6 @@ public class MainUtil { 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); - update(getPlotHome(world, plot)); } public static int getHeighestBlock(final String world, final int x, final int z) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java index e9a718e43..e6e68c79e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java @@ -1,7 +1,7 @@ package com.intellectualcrafters.plot.util.bukkit; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import org.bukkit.Chunk; import org.bukkit.World; @@ -14,10 +14,10 @@ public abstract class BukkitSetBlockManager extends BlockUpdateUtil { 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); + public abstract void update(Collection list); @Override - public void update(final String worldname, final List chunkLocs) { + public void update(final String worldname, final Collection chunkLocs) { final World world = BukkitUtil.getWorld(worldname); final ArrayList chunks = new ArrayList(); for (final ChunkLoc loc : chunkLocs) { 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 478d8502f..04be68615 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,5 @@ package com.intellectualcrafters.plot.util.bukkit; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -95,17 +94,17 @@ public class BukkitUtil extends BlockManager { return world.getChunkAt(x, z); } - 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++) { - final Chunk chunk = getChunkAt(world, (x >> 4) + cx, (z >> 4) + cz); - chunks.add(chunk); - } - } - BukkitSetBlockManager.setBlockManager.update(chunks); - } +// 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++) { +// final Chunk chunk = getChunkAt(world, (x >> 4) + cx, (z >> 4) + cz); +// chunks.add(chunk); +// } +// } +// BukkitSetBlockManager.setBlockManager.update(chunks); +// } public static String getWorld(final Entity entity) { return entity.getWorld().getName(); 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 f0b3eac37..75ec4bc8b 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 @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.bukkit.Bukkit; @@ -53,7 +54,7 @@ public class SendChunk { ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); } - public static void sendChunk(final List chunks) { + public static void sendChunk(final Collection chunks) { int diffx, diffz; final int view = Bukkit.getServer().getViewDistance() << 4; for (final Chunk chunk : 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 d149ce32b..e4570822b 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 @@ -22,14 +22,16 @@ package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; -import java.util.List; +import java.util.Collection; +import java.util.HashMap; import org.bukkit.Chunk; -import org.bukkit.World; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; +import com.intellectualcrafters.plot.util.TaskManager; /** * SetBlockFast class
Used to do fast world editing @@ -45,6 +47,8 @@ public class SetBlockFast extends BukkitSetBlockManager { private static RefMethod methodGetChunkAt; private static RefMethod methodA; private static RefMethod methodGetById; + + public static HashMap toUpdate = new HashMap<>(); /** * Constructor @@ -56,6 +60,15 @@ public class SetBlockFast extends BukkitSetBlockManager { methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class); methodGetById = classBlock.getMethod("getById", int.class); + TaskManager.runTaskRepeat(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + update(toUpdate.values()); + toUpdate = new HashMap<>(); + } + }, 20); } /** @@ -83,14 +96,13 @@ public class SetBlockFast extends BukkitSetBlockManager { * @param chunks list of chunks to update */ @Override - public void update(final List chunks) { + public void update(final Collection chunks) { if (chunks.size() == 0) { return; } if (!MainUtil.canSendChunk) { - final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.refreshChunk(chunk.getX(), chunk.getZ()); + chunk.unload(); chunk.load(false); } 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 8f871a61b..255456cec 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 @@ -22,7 +22,8 @@ package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; -import java.util.List; +import java.util.Collection; +import java.util.HashMap; import org.bukkit.Chunk; import org.bukkit.World; @@ -33,6 +34,7 @@ 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; +import com.intellectualcrafters.plot.util.TaskManager; /** * SetBlockFast class
Used to do fast world editing @@ -52,6 +54,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { private static RefMethod methodGetByCombinedId; private static RefConstructor constructorBlockPosition; + public static HashMap toUpdate = new HashMap<>(); + /** * Constructor * @@ -63,6 +67,15 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { methodGetHandle = classCraftWorld.getMethod("getHandle"); methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); methodA = classChunk.getMethod("a", classBlockPosition, classIBlockData); + TaskManager.runTaskRepeat(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + update(toUpdate.values()); + toUpdate = new HashMap<>(); + } + }, 20); } private ChunkLoc lastLoc = null; @@ -270,8 +283,12 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { int Z = z >> 4; ChunkLoc loc = new ChunkLoc(X, Z); if (!loc.equals(lastLoc)) { - world.loadChunk(X, Z, false); - lastLoc = loc; + Chunk chunk = toUpdate.get(loc); + if (chunk == null) { + chunk = world.getChunkAt(X, Z); + toUpdate.put(loc, chunk); + } + chunk.load(false); } // check sign final Object w = methodGetHandle.of(world).call(); @@ -281,20 +298,14 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { methodA.of(chunk).call(pos, combined); } - /** - * Update chunks - * - * @param chunks chunks to be updated - */ @Override - public void update(final List chunks) { + public void update(final Collection chunks) { if (chunks.size() == 0) { return; } if (!MainUtil.canSendChunk) { - final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.refreshChunk(chunk.getX(), chunk.getZ()); + chunk.unload(); chunk.load(false); } 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 2f8a80697..8420a3ad2 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 @@ -1,6 +1,6 @@ package com.intellectualcrafters.plot.util.bukkit; -import java.util.List; +import java.util.Collection; import org.bukkit.Chunk; import org.bukkit.World; @@ -24,7 +24,7 @@ public class SetBlockSlow extends BukkitSetBlockManager { } @Override - public void update(final List chunks) { + public void update(final Collection chunks) { // TODO Auto-generated method stub } }