From 3f71e0e7729e46781514b8ea0bc564919ac95b40 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 16:53:00 +1100 Subject: [PATCH] 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) {