mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Various other fixes
This commit is contained in:
parent
b03c428ca4
commit
b0384f4074
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>2.9.1</version>
|
<version>2.9.2</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -289,12 +289,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
BlockUpdateUtil.setBlockManager = BukkitSetBlockManager.setBlockManager;
|
BlockUpdateUtil.setBlockManager = BukkitSetBlockManager.setBlockManager;
|
||||||
try {
|
try {
|
||||||
new SendChunk();
|
new SendChunk();
|
||||||
if (checkVersion(1, 7, 10) && !checkVersion(1, 7, 11)) {
|
MainUtil.canSendChunk = true;
|
||||||
MainUtil.canSendChunk = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MainUtil.canSendChunk = true;
|
|
||||||
}
|
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
MainUtil.canSendChunk = false;
|
MainUtil.canSendChunk = false;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.generator.BlockPopulator;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.object.BlockWrapper;
|
import com.intellectualcrafters.plot.object.BlockWrapper;
|
||||||
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
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.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||||
@ -128,7 +130,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
populateBiome(world, x, z);
|
populateBiome(world, x, z);
|
||||||
chunk.unload(true, true);
|
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
} else {
|
} else {
|
||||||
@ -143,7 +145,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
public void run() {
|
public void run() {
|
||||||
chunk.load(true);
|
chunk.load(true);
|
||||||
populateBlocks(world, rand, X, Z, x, z, check);
|
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));
|
}, 40 + rand.nextInt(40));
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
final Chunk chunk = world.getChunkAt(x, z);
|
final Chunk chunk = world.getChunkAt(x, z);
|
||||||
chunks2.add(chunk);
|
chunks2.add(chunk);
|
||||||
regenerateRoad(worldname, new ChunkLoc(x, z));
|
regenerateRoad(worldname, new ChunkLoc(x, z));
|
||||||
ChunkManager.manager.unloadChunk(worldname, new ChunkLoc(x, z));
|
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||||
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.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
@ -276,7 +277,7 @@ public class ClusterManager {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if ((populator == null) || (plotworld.TYPE == 0)) {
|
if ((populator == null) || (plotworld.TYPE == 0)) {
|
||||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||||
chunk.unload(true, true);
|
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
||||||
} else {
|
} else {
|
||||||
populator.populate(world, rand, chunk);
|
populator.populate(world, rand, chunk);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ import com.intellectualcrafters.plot.config.C;
|
|||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
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;
|
||||||
@ -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) {
|
// public static void update(final Location loc) {
|
||||||
// final String world = loc.getWorld();
|
// final String world = loc.getWorld();
|
||||||
// int ox = loc.getX() >> 4;
|
// 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 com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot2.id);
|
||||||
final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id);
|
final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id);
|
||||||
if (plot1.owner == null) {
|
if (plot1.owner == null) {
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Plot pos1 = getBottomPlot(plot1);
|
final Plot pos1 = getBottomPlot(plot1);
|
||||||
final Plot pos2 = getTopPlot(plot1);
|
final Plot pos2 = getTopPlot(plot1);
|
||||||
final PlotId size = MainUtil.getSize(plot1.world, 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))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
final int offset_x = plot2.id.x - pos1.id.x;
|
final int offset_x = plot2.id.x - pos1.id.x;
|
||||||
|
@ -234,9 +234,6 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
restoreBlocks(newWorld, relX, relZ);
|
restoreBlocks(newWorld, relX, relZ);
|
||||||
restoreEntities(newWorld, relX, relZ);
|
restoreEntities(newWorld, relX, relZ);
|
||||||
BukkitSetBlockManager.setBlockManager.update(chunks);
|
BukkitSetBlockManager.setBlockManager.update(chunks);
|
||||||
for (final Chunk chunk : chunks) {
|
|
||||||
chunk.unload(true, true);
|
|
||||||
}
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.tasks.remove(currentIndex);
|
||||||
@ -344,7 +341,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
restoreBlocks(world, 0, 0);
|
restoreBlocks(world, 0, 0);
|
||||||
restoreEntities(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 }));
|
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
||||||
}
|
}
|
||||||
CURRENT_PLOT_CLEAR = null;
|
CURRENT_PLOT_CLEAR = null;
|
||||||
|
@ -32,9 +32,9 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
final String name = plugin.getDescription().getName();
|
final String name = plugin.getDescription().getName();
|
||||||
if (generator instanceof PlotGenerator) {
|
if (generator instanceof PlotGenerator) {
|
||||||
final PlotGenerator pgen = (PlotGenerator) generator;
|
final PlotGenerator pgen = (PlotGenerator) generator;
|
||||||
if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
||||||
SetupUtils.generators.put(name, pgen);
|
SetupUtils.generators.put(name, pgen);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.BukkitMain;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
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;
|
||||||
@ -22,6 +23,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class SendChunk {
|
public class SendChunk {
|
||||||
|
|
||||||
|
private static boolean v1_7_10 = BukkitMain.checkVersion(1, 7, 10) && !BukkitMain.checkVersion(1, 8, 0);
|
||||||
// Ref Class
|
// Ref Class
|
||||||
private static final RefClass classWorld = getRefClass("{nms}.World");
|
private static final RefClass classWorld = getRefClass("{nms}.World");
|
||||||
private static final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
private static final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||||
@ -58,6 +61,7 @@ public class SendChunk {
|
|||||||
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) {
|
||||||
|
boolean unload = true;
|
||||||
final Object c = methodGetHandle.of(chunk).call();
|
final Object c = methodGetHandle.of(chunk).call();
|
||||||
final Object w = world.of(c).get();
|
final Object w = world.of(c).get();
|
||||||
final Object p = players.of(w).get();
|
final Object p = players.of(w).get();
|
||||||
@ -67,11 +71,22 @@ public class SendChunk {
|
|||||||
diffx = Math.abs(x - (chunk.getX() << 4));
|
diffx = Math.abs(x - (chunk.getX() << 4));
|
||||||
diffz = Math.abs(z - (chunk.getZ() << 4));
|
diffz = Math.abs(z - (chunk.getZ() << 4));
|
||||||
if ((diffx <= view) && (diffz <= view)) {
|
if ((diffx <= view) && (diffz <= view)) {
|
||||||
final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ());
|
unload = false;
|
||||||
final Object pq = chunkCoordIntPairQueue.of(ep).get();
|
if (v1_7_10) {
|
||||||
((List) pq).add(pair);
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@ public class SetBlockFast extends BukkitSetBlockManager {
|
|||||||
}, 20);
|
}, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ChunkLoc lastLoc = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the block at the location
|
* Set the block at the location
|
||||||
*
|
*
|
||||||
@ -84,6 +86,19 @@ public class SetBlockFast extends BukkitSetBlockManager {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void 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) {
|
||||||
|
|
||||||
|
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 w = methodGetHandle.of(world).call();
|
||||||
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
|
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
|
||||||
final Object block = methodGetById.of(null).call(blockId);
|
final Object block = methodGetById.of(null).call(blockId);
|
||||||
@ -101,9 +116,9 @@ public class SetBlockFast extends BukkitSetBlockManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MainUtil.canSendChunk) {
|
if (!MainUtil.canSendChunk) {
|
||||||
for (final Chunk chunk : chunks) {
|
for (Chunk chunk : chunks) {
|
||||||
chunk.unload();
|
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||||
chunk.load(false);
|
chunk.load(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -317,9 +317,9 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MainUtil.canSendChunk) {
|
if (!MainUtil.canSendChunk) {
|
||||||
for (final Chunk chunk : chunks) {
|
for (Chunk chunk : chunks) {
|
||||||
chunk.unload();
|
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||||
chunk.load(false);
|
chunk.load(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
|
||||||
public class SetBlockSlow extends BukkitSetBlockManager {
|
public class SetBlockSlow extends BukkitSetBlockManager {
|
||||||
@Override
|
@Override
|
||||||
public void set(final World world, final int x, final int y, final int z, final int id, final byte data) {
|
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
|
@Override
|
||||||
public void update(final Collection<Chunk> chunks) {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user