sendchunk

This commit is contained in:
boy0001 2015-02-20 16:53:00 +11:00
parent 2b7053895c
commit 3f71e0e772
2 changed files with 14 additions and 4 deletions

View File

@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock; 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 minChunkZ = (int) Math.floor((double) bottomZ / 16);
final int maxChunkZ = (int) Math.floor((double) topZ / 16); final int maxChunkZ = (int) Math.floor((double) topZ / 16);
final ArrayList<Chunk> chunks = new ArrayList<>(); final ArrayList<ChunkLoc> chunks = new ArrayList<>();
for (int x = minChunkX; x <= maxChunkX; x++) { for (int x = minChunkX; x <= maxChunkX; x++) {
for (int z = minChunkZ; z <= maxChunkZ; z++) { for (int z = minChunkZ; z <= maxChunkZ; z++) {
if (canSendChunk) { if (canSendChunk) {
final Chunk chunk = BukkitUtil.getChunkAt(world, x, z); final ChunkLoc chunk = new ChunkLoc(x, z);
chunks.add(chunk); chunks.add(chunk);
} else { } else {
BukkitUtil.refreshChunk(world, x, z); BukkitUtil.refreshChunk(world, x, z);
@ -647,7 +648,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
} }
} }
try { try {
SendChunk.sendChunk(chunks); SendChunk.sendChunk(world, chunks);
} catch (final Throwable e) { } catch (final Throwable e) {
canSendChunk = false; canSendChunk = false;
for (int x = minChunkX; x <= maxChunkX; x++) { for (int x = minChunkX; x <= maxChunkX; x++) {

View File

@ -2,11 +2,15 @@ package com.intellectualcrafters.plot.util;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; 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.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
@ -57,7 +61,12 @@ public class SendChunk {
ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class);
} }
public static void sendChunk(final List<Chunk> chunks) { public static void sendChunk(String worldname, List<ChunkLoc> locs) {
World myworld = Bukkit.getWorld(worldname);
HashSet<Chunk> chunks = new HashSet<>();
for (ChunkLoc loc : locs) {
chunks.add(myworld.getChunkAt(loc.x, loc.z));
}
int diffx, diffz; int diffx, diffz;
final int view = Bukkit.getServer().getViewDistance() << 4; final int view = Bukkit.getServer().getViewDistance() << 4;
for (final Chunk chunk : chunks) { for (final Chunk chunk : chunks) {