misc fixes

This commit is contained in:
boy0001 2015-03-15 11:49:22 +11:00
parent 6075de6460
commit e0970dcdd2
9 changed files with 21 additions and 47 deletions

View File

@ -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.8.9</version> <version>2.8.10</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -275,7 +275,12 @@ 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 = false;
}
else {
MainUtil.canSendChunk = true; MainUtil.canSendChunk = true;
}
} catch (final Throwable e) { } catch (final Throwable e) {
MainUtil.canSendChunk = false; MainUtil.canSendChunk = false;
} }

View File

@ -666,6 +666,6 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
*/ */
public int getAllowedPlots(final Player player) { public int getAllowedPlots(final Player player) {
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
return MainUtil.getAllowedPlots(pp, MainUtil.getPlayerPlotCount(player.getWorld().getName(), pp)); return MainUtil.getAllowedPlots(pp);
} }
} }

View File

@ -62,7 +62,7 @@ public class Clear extends SubCommand {
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.clear(world, plot, true, null); MainUtil.clear(world, plot, plot.owner == null, null);
PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); PlotSquared.log("Plot " + plot.getId().toString() + " cleared.");
} }
}; };
@ -122,7 +122,7 @@ public class Clear extends SubCommand {
@Override @Override
public void run() { public void run() {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
final boolean result = MainUtil.clearAsPlayer(plot, false, new Runnable() { final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));

View File

@ -147,6 +147,9 @@ public class HybridPlotManager extends ClassicPlotManager {
final int I = i; final int I = i;
final int J = j; final int J = j;
BukkitUtil.regenerateChunk(world, I / 16, J / 16); BukkitUtil.regenerateChunk(world, I / 16, J / 16);
if (!MainUtil.canSendChunk) {
BukkitUtil.refreshChunk(world, I / 16, J / 16);
}
} }
} }
setWall(dpw, plot.id, new PlotBlock[] { wall }); setWall(dpw, plot.id, new PlotBlock[] { wall });

View File

@ -665,44 +665,6 @@ public class MainUtil {
return getPlotHome(w, plot.id); return getPlotHome(w, plot.id);
} }
/**
* Refresh the plot chunks
*
* @param world World in which the plot is located
* @param plot Plot Object
*/
public static void refreshPlotChunks(final String world, final Plot plot) {
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
final int topX = getPlotTopLoc(world, plot.id).getX();
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
final int topZ = getPlotTopLoc(world, plot.id).getZ();
final int minChunkX = (int) Math.floor((double) bottomX / 16);
final int maxChunkX = (int) Math.floor((double) topX / 16);
final int minChunkZ = (int) Math.floor((double) bottomZ / 16);
final int maxChunkZ = (int) Math.floor((double) topZ / 16);
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
for (int x = minChunkX; x <= maxChunkX; x++) {
for (int z = minChunkZ; z <= maxChunkZ; z++) {
if (canSendChunk) {
final ChunkLoc chunk = new ChunkLoc(x, z);
chunks.add(chunk);
} else {
BukkitUtil.refreshChunk(world, x, z);
}
}
}
try {
SendChunk.sendChunk(world, chunks);
} catch (final Throwable e) {
canSendChunk = false;
for (int x = minChunkX; x <= maxChunkX; x++) {
for (int z = minChunkZ; z <= maxChunkZ; z++) {
BukkitUtil.refreshChunk(world, x, z);
}
}
}
}
/** /**
* Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot
* use getPlotTopLoc(...) * use getPlotTopLoc(...)

View File

@ -145,8 +145,10 @@ public class BukkitUtil extends BlockManager {
} }
} }
public static void refreshChunk(final String world, final int x, final int z) { public static void refreshChunk(final String name, final int x, final int z) {
getWorld(world).refreshChunk(x, z); World world = getWorld(name);
world.unloadChunk(x, z);
world.loadChunk(x, z);
} }
public static void regenerateChunk(final String world, final int x, final int z) { public static void regenerateChunk(final String world, final int x, final int z) {

View File

@ -90,7 +90,8 @@ public class SetBlockFast extends BukkitSetBlockManager {
if (!MainUtil.canSendChunk) { if (!MainUtil.canSendChunk) {
final World world = chunks.get(0).getWorld(); final World world = chunks.get(0).getWorld();
for (final Chunk chunk : chunks) { for (final Chunk chunk : chunks) {
world.refreshChunk(chunk.getX(), chunk.getZ()); world.unloadChunk(chunk);
world.loadChunk(chunk);
} }
return; return;
} }

View File

@ -294,7 +294,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
if (!MainUtil.canSendChunk) { if (!MainUtil.canSendChunk) {
final World world = chunks.get(0).getWorld(); final World world = chunks.get(0).getWorld();
for (final Chunk chunk : chunks) { for (final Chunk chunk : chunks) {
world.refreshChunk(chunk.getX(), chunk.getZ()); world.unloadChunk(chunk);
world.loadChunk(chunk);
} }
return; return;
} }