Various other fixes

This commit is contained in:
boy0001 2015-04-02 11:56:34 +11:00
parent b03c428ca4
commit b0384f4074
12 changed files with 72 additions and 29 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<artifactId>PlotSquared</artifactId>
<version>2.9.1</version>
<version>2.9.2</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -289,12 +289,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
BlockUpdateUtil.setBlockManager = BukkitSetBlockManager.setBlockManager;
try {
new SendChunk();
if (checkVersion(1, 7, 10) && !checkVersion(1, 7, 11)) {
MainUtil.canSendChunk = false;
}
else {
MainUtil.canSendChunk = true;
}
MainUtil.canSendChunk = true;
} catch (final Throwable e) {
MainUtil.canSendChunk = false;
}

View File

@ -11,6 +11,7 @@ import org.bukkit.generator.BlockPopulator;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.object.BlockWrapper;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotGenerator;
@ -19,6 +20,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
@ -128,7 +130,7 @@ public class AugmentedPopulator extends BlockPopulator {
@Override
public void run() {
populateBiome(world, x, z);
chunk.unload(true, true);
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
}
}, 20);
} else {
@ -143,7 +145,7 @@ public class AugmentedPopulator extends BlockPopulator {
public void run() {
chunk.load(true);
populateBlocks(world, rand, X, Z, x, z, check);
chunk.unload(true, true);
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
}
}, 40 + rand.nextInt(40));
}

View File

@ -151,7 +151,7 @@ public class BukkitHybridUtils extends HybridUtils {
final Chunk chunk = world.getChunkAt(x, z);
chunks2.add(chunk);
regenerateRoad(worldname, new ChunkLoc(x, z));
ChunkManager.manager.unloadChunk(worldname, new ChunkLoc(x, z));
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
}
}
}

View File

@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotCluster;
@ -276,7 +277,7 @@ public class ClusterManager {
public void run() {
if ((populator == null) || (plotworld.TYPE == 0)) {
world.regenerateChunk(chunk.getX(), chunk.getZ());
chunk.unload(true, true);
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
} else {
populator.populate(world, rand, chunk);
}

View File

@ -21,6 +21,7 @@
package com.intellectualcrafters.plot.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;
@ -29,6 +30,7 @@ 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;
@ -170,6 +172,10 @@ public class MainUtil {
}
}
public static void update(String world, ChunkLoc loc) {
BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc));
}
// public static void update(final Location loc) {
// final String world = loc.getWorld();
// int ox = loc.getX() >> 4;
@ -862,14 +868,12 @@ public class MainUtil {
final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot2.id);
final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id);
if (plot1.owner == null) {
TaskManager.runTaskLater(whenDone, 1);
return false;
}
final Plot pos1 = getBottomPlot(plot1);
final Plot pos2 = getTopPlot(plot1);
final PlotId size = MainUtil.getSize(plot1.world, plot1);
if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) {
TaskManager.runTaskLater(whenDone, 1);
return false;
}
final int offset_x = plot2.id.x - pos1.id.x;

View File

@ -234,9 +234,6 @@ public class BukkitChunkManager extends ChunkManager {
restoreBlocks(newWorld, relX, relZ);
restoreEntities(newWorld, relX, relZ);
BukkitSetBlockManager.setBlockManager.update(chunks);
for (final Chunk chunk : chunks) {
chunk.unload(true, true);
}
TaskManager.runTask(whenDone);
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
@ -344,7 +341,7 @@ public class BukkitChunkManager extends ChunkManager {
restoreBlocks(world, 0, 0);
restoreEntities(world, 0, 0);
}
chunk.unload(true, true);
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
}
CURRENT_PLOT_CLEAR = null;

View File

@ -32,9 +32,9 @@ public class BukkitSetupUtils extends SetupUtils {
final String name = plugin.getDescription().getName();
if (generator instanceof PlotGenerator) {
final PlotGenerator pgen = (PlotGenerator) generator;
if (pgen.getPlotManager() instanceof SquarePlotManager) {
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
SetupUtils.generators.put(name, pgen);
}
// }
}
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import com.intellectualcrafters.plot.BukkitMain;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
@ -22,6 +23,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
* @author Empire92
*/
public class SendChunk {
private static boolean v1_7_10 = BukkitMain.checkVersion(1, 7, 10) && !BukkitMain.checkVersion(1, 8, 0);
// Ref Class
private static final RefClass classWorld = getRefClass("{nms}.World");
private static final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
@ -58,6 +61,7 @@ public class SendChunk {
int diffx, diffz;
final int view = Bukkit.getServer().getViewDistance() << 4;
for (final Chunk chunk : chunks) {
boolean unload = true;
final Object c = methodGetHandle.of(chunk).call();
final Object w = world.of(c).get();
final Object p = players.of(w).get();
@ -67,11 +71,22 @@ public class SendChunk {
diffx = Math.abs(x - (chunk.getX() << 4));
diffz = Math.abs(z - (chunk.getZ() << 4));
if ((diffx <= view) && (diffz <= view)) {
final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ());
final Object pq = chunkCoordIntPairQueue.of(ep).get();
((List) pq).add(pair);
unload = false;
if (v1_7_10) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
chunk.load(true);
}
else {
final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ());
final Object pq = chunkCoordIntPairQueue.of(ep).get();
((List) pq).add(pair);
}
}
}
if (unload) {
chunk.unload(true, true);
System.out.print("UNLOADING CHUNK");
}
}
}

View File

@ -71,6 +71,8 @@ public class SetBlockFast extends BukkitSetBlockManager {
}, 20);
}
private ChunkLoc lastLoc = null;
/**
* Set the block at the location
*
@ -84,6 +86,19 @@ public class SetBlockFast extends BukkitSetBlockManager {
*/
@Override
public void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) {
int X = x >> 4;
int Z = z >> 4;
ChunkLoc loc = new ChunkLoc(X, Z);
if (!loc.equals(lastLoc)) {
Chunk chunk = toUpdate.get(loc);
if (chunk == null) {
chunk = world.getChunkAt(X, Z);
toUpdate.put(loc, chunk);
}
chunk.load(false);
}
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);
@ -101,9 +116,9 @@ public class SetBlockFast extends BukkitSetBlockManager {
return;
}
if (!MainUtil.canSendChunk) {
for (final Chunk chunk : chunks) {
chunk.unload();
chunk.load(false);
for (Chunk chunk : chunks) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
chunk.load(true);
}
return;
}

View File

@ -317,9 +317,9 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
return;
}
if (!MainUtil.canSendChunk) {
for (final Chunk chunk : chunks) {
chunk.unload();
chunk.load(false);
for (Chunk chunk : chunks) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
chunk.load(true);
}
return;
}

View File

@ -6,6 +6,8 @@ import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import com.intellectualcrafters.plot.util.MainUtil;
public class SetBlockSlow extends BukkitSetBlockManager {
@Override
public void set(final World world, final int x, final int y, final int z, final int id, final byte data) {
@ -25,6 +27,18 @@ public class SetBlockSlow extends BukkitSetBlockManager {
@Override
public void update(final Collection<Chunk> chunks) {
// TODO Auto-generated method stub
if (MainUtil.canSendChunk) {
try {
SendChunk.sendChunk(chunks);
} catch (final Throwable e) {
MainUtil.canSendChunk = false;
}
}
else {
for (Chunk chunk : chunks) {
chunk.unload();
chunk.load(true);
}
}
}
}