closes #673
closes #668
closes #672
closes #664 (hopefully)
This commit is contained in:
Jesse Boyd 2015-10-17 22:50:52 +11:00
parent 50c6753bf4
commit 54655c1a72
11 changed files with 139 additions and 101 deletions

View File

@ -44,15 +44,12 @@ import com.intellectualcrafters.plot.database.SQLite;
import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.flag.FlagValue;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.PlotGenerator; import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.generator.SquarePlotManager;
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis; import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotFilter; import com.intellectualcrafters.plot.object.PlotFilter;
import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotHandler;
@ -1314,13 +1311,6 @@ public class PS {
// save configuration // save configuration
final String[] split = args.split(","); final String[] split = args.split(",");
final HybridPlotWorld plotworld = new HybridPlotWorld(world); final HybridPlotWorld plotworld = new HybridPlotWorld(world);
final int width = SquarePlotWorld.PLOT_WIDTH_DEFAULT;
final int gap = SquarePlotWorld.ROAD_WIDTH_DEFAULT;
final int height = ClassicPlotWorld.PLOT_HEIGHT_DEFAULT;
final PlotBlock[] floor = ClassicPlotWorld.TOP_BLOCK_DEFAULT;
final PlotBlock[] main = ClassicPlotWorld.MAIN_BLOCK_DEFAULT;
final PlotBlock wall = ClassicPlotWorld.WALL_FILLING_DEFAULT;
final PlotBlock border = ClassicPlotWorld.WALL_BLOCK_DEFAULT;
for (final String element : split) { for (final String element : split) {
final String[] pair = element.split("="); final String[] pair = element.split("=");
if (pair.length != 2) { if (pair.length != 2) {
@ -1329,43 +1319,44 @@ public class PS {
} }
final String key = pair[0].toLowerCase(); final String key = pair[0].toLowerCase();
final String value = pair[1]; final String value = pair[1];
final String base = "worlds." + world + ".";
try { try {
switch (key) { switch (key) {
case "s": case "s":
case "size": { case "size": {
SquarePlotWorld.PLOT_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue(); config.set(base + "plot.size", Configuration.INTEGER.parseString(value).shortValue());
break; break;
} }
case "g": case "g":
case "gap": { case "gap": {
SquarePlotWorld.ROAD_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue(); config.set(base + "road.width", Configuration.INTEGER.parseString(value).shortValue());
break; break;
} }
case "h": case "h":
case "height": { case "height": {
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); config.set(base + "road.height", Configuration.INTEGER.parseString(value).shortValue());
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); config.set(base + "plot.height", Configuration.INTEGER.parseString(value).shortValue());
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value); config.set(base + "wall.height", Configuration.INTEGER.parseString(value).shortValue());
break; break;
} }
case "f": case "f":
case "floor": { case "floor": {
ClassicPlotWorld.TOP_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value); config.set(base + "plot.floor", Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(",")));
break; break;
} }
case "m": case "m":
case "main": { case "main": {
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value); config.set(base + "plot.filling", Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(",")));
break; break;
} }
case "w": case "w":
case "wall": { case "wall": {
ClassicPlotWorld.WALL_FILLING_DEFAULT = Configuration.BLOCK.parseString(value); config.set(base + "wall.filling", Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(",")));
break; break;
} }
case "b": case "b":
case "border": { case "border": {
ClassicPlotWorld.WALL_BLOCK_DEFAULT = Configuration.BLOCK.parseString(value); config.set(base + "wall.block", Configuration.BLOCK.parseString(value).toString());
break; break;
} }
default: { default: {
@ -1380,20 +1371,8 @@ public class PS {
} }
} }
try { try {
final String root = "worlds." + world; plotworld.loadConfiguration(config);
if (!config.contains(root)) { config.save(configFile);
config.createSection(root);
}
plotworld.saveConfiguration(config.getConfigurationSection(root));
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = height;
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = height;
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = height;
ClassicPlotWorld.TOP_BLOCK_DEFAULT = floor;
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = main;
ClassicPlotWorld.WALL_BLOCK_DEFAULT = border;
ClassicPlotWorld.WALL_FILLING_DEFAULT = wall;
SquarePlotWorld.PLOT_WIDTH_DEFAULT = width;
SquarePlotWorld.ROAD_WIDTH_DEFAULT = gap;
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -75,7 +75,7 @@ public class Inbox extends SubCommand {
} else { } else {
color = "&7"; color = "&7";
} }
string.append("&8[&7#" + x + "&8][&7" + c.world + ";" + c.id + "&8][&6" + c.senderName + "&8]" + color + c.comment + "\n"); string.append("&8[&7#" + (x + 1) + "&8][&7" + c.world + ";" + c.id + "&8][&6" + c.senderName + "&8]" + color + c.comment + "\n");
} }
MainUtil.sendMessage(player, string.toString()); MainUtil.sendMessage(player, string.toString());
} }
@ -155,6 +155,7 @@ public class Inbox extends SubCommand {
final List<PlotComment> comments = (List<PlotComment>) value; final List<PlotComment> comments = (List<PlotComment>) value;
if (index > comments.size()) { if (index > comments.size()) {
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + ""); sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
return;
} }
final PlotComment comment = comments.get(index - 1); final PlotComment comment = comments.get(index - 1);
inbox.removeComment(plot, comment); inbox.removeComment(plot, comment);

View File

@ -112,7 +112,7 @@ public interface AbstractDB {
* *
* @return Integer = Cluster Entry Id * @return Integer = Cluster Entry Id
*/ */
int getClusterId(final String world, final PlotClusterId id); int getClusterId(final PlotCluster cluster);
/** /**
* @return A linked hashmap containing all plots * @return A linked hashmap containing all plots

View File

@ -53,7 +53,6 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.object.comment.PlotComment;
import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
@ -145,12 +144,31 @@ public class SQLManager implements AbstractDB {
tasks.add(task); tasks.add(task);
} }
public synchronized void addClusterTask(final PlotCluster cluster, final UniqueStatement task) { public synchronized void addClusterTask(final PlotCluster cluster, UniqueStatement task) {
Queue<UniqueStatement> tasks = clusterTasks.get(cluster); Queue<UniqueStatement> tasks = clusterTasks.get(cluster);
if (tasks == null) { if (tasks == null) {
tasks = new ConcurrentLinkedQueue<>(); tasks = new ConcurrentLinkedQueue<>();
clusterTasks.put(cluster, tasks); clusterTasks.put(cluster, tasks);
} }
if (task == null) {
task = new UniqueStatement(cluster.hashCode() + "") {
@Override
public PreparedStatement get() throws SQLException {
return null;
}
@Override
public void set(final PreparedStatement stmt) throws SQLException {}
@Override
public void addBatch(final PreparedStatement stmt) throws SQLException {}
@Override
public void execute(final PreparedStatement stmt) throws SQLException {}
};
}
tasks.add(task); tasks.add(task);
} }
@ -1271,6 +1289,46 @@ public class SQLManager implements AbstractDB {
}); });
} }
@Override
public int getClusterId(final PlotCluster cluster) {
if (cluster.temp > 0) {
return cluster.temp;
}
PreparedStatement stmt = null;
try {
commit();
if (cluster.temp > 0) {
return cluster.temp;
}
stmt = connection.prepareStatement("SELECT `id` FROM `"
+ prefix
+ "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC");
stmt.setInt(1, cluster.getP1().x);
stmt.setInt(2, cluster.getP1().y);
stmt.setInt(3, cluster.getP2().x);
stmt.setInt(4, cluster.getP2().y);
stmt.setString(5, cluster.world);
final ResultSet r = stmt.executeQuery();
int c_id = Integer.MAX_VALUE;
while (r.next()) {
c_id = r.getInt("id");
}
stmt.close();
r.close();
if ((c_id == Integer.MAX_VALUE) || (c_id == 0)) {
if (cluster.temp > 0) {
return cluster.temp;
}
throw new SQLException("Cluster does not exist in database");
}
cluster.temp = c_id;
return c_id;
} catch (final SQLException e) {
e.printStackTrace();
}
return Integer.MAX_VALUE;
}
@Override @Override
public int getId(final Plot plot) { public int getId(final Plot plot) {
if (plot.temp > 0) { if (plot.temp > 0) {
@ -2114,7 +2172,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void delete(final PlotCluster cluster) { public void delete(final PlotCluster cluster) {
final int id = getClusterId(cluster.world, ClusterManager.getClusterId(cluster)); final int id = getClusterId(cluster);
addClusterTask(cluster, new UniqueStatement("delete_cluster_settings") { addClusterTask(cluster, new UniqueStatement("delete_cluster_settings") {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
@ -2161,32 +2219,6 @@ public class SQLManager implements AbstractDB {
}); });
} }
@Override
public int getClusterId(final String world, final PlotClusterId id) {
PreparedStatement stmt = null;
try {
stmt = connection.prepareStatement("SELECT `id` FROM `"
+ prefix
+ "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC");
stmt.setInt(1, id.pos1.x);
stmt.setInt(2, id.pos1.y);
stmt.setInt(3, id.pos2.x);
stmt.setInt(4, id.pos2.y);
stmt.setString(5, world);
final ResultSet r = stmt.executeQuery();
int c_id = Integer.MAX_VALUE;
while (r.next()) {
c_id = r.getInt("id");
}
stmt.close();
r.close();
return c_id;
} catch (final SQLException e) {
e.printStackTrace();
}
return Integer.MAX_VALUE;
}
@Override @Override
public HashMap<String, HashSet<PlotCluster>> getClusters() { public HashMap<String, HashSet<PlotCluster>> getClusters() {
final LinkedHashMap<String, HashSet<PlotCluster>> newClusters = new LinkedHashMap<>(); final LinkedHashMap<String, HashSet<PlotCluster>> newClusters = new LinkedHashMap<>();
@ -2229,7 +2261,7 @@ public class SQLManager implements AbstractDB {
user = UUID.fromString(owner); user = UUID.fromString(owner);
uuids.put(owner, user); uuids.put(owner, user);
} }
cluster = new PlotCluster(worldname, pos1, pos2, user); cluster = new PlotCluster(worldname, pos1, pos2, user, id);
clusters.put(id, cluster); clusters.put(id, cluster);
} }
/* /*
@ -2381,7 +2413,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
stmt.setString(1, flag_string.toString()); stmt.setString(1, flag_string.toString());
stmt.setInt(2, getClusterId(cluster.world, ClusterManager.getClusterId(cluster))); stmt.setInt(2, getClusterId(cluster));
} }
@Override @Override
@ -2397,7 +2429,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
stmt.setString(1, name); stmt.setString(1, name);
stmt.setInt(2, getClusterId(cluster.world, ClusterManager.getClusterId(cluster))); stmt.setInt(2, getClusterId(cluster));
} }
@Override @Override
@ -2413,7 +2445,7 @@ public class SQLManager implements AbstractDB {
addClusterTask(cluster, new UniqueStatement("removeHelper") { addClusterTask(cluster, new UniqueStatement("removeHelper") {
@Override @Override
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
statement.setInt(1, getClusterId(cluster.world, ClusterManager.getClusterId(cluster))); statement.setInt(1, getClusterId(cluster));
statement.setString(2, uuid.toString()); statement.setString(2, uuid.toString());
} }
@ -2429,7 +2461,7 @@ public class SQLManager implements AbstractDB {
addClusterTask(cluster, new UniqueStatement("setHelper") { addClusterTask(cluster, new UniqueStatement("setHelper") {
@Override @Override
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
statement.setInt(1, getClusterId(cluster.world, ClusterManager.getClusterId(cluster))); statement.setInt(1, getClusterId(cluster));
statement.setString(2, uuid.toString()); statement.setString(2, uuid.toString());
} }
@ -2442,7 +2474,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void createCluster(final PlotCluster cluster) { public void createCluster(final PlotCluster cluster) {
addClusterTask(cluster, new UniqueStatement("createCluster") { addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
stmt.setInt(1, cluster.getP1().x); stmt.setInt(1, cluster.getP1().x);
@ -2451,22 +2483,32 @@ public class SQLManager implements AbstractDB {
stmt.setInt(4, cluster.getP2().y); stmt.setInt(4, cluster.getP2().y);
stmt.setString(5, cluster.owner.toString()); stmt.setString(5, cluster.owner.toString());
stmt.setString(6, cluster.world); stmt.setString(6, cluster.world);
// TODO resultset getId
} }
@Override @Override
public PreparedStatement get() throws SQLException { public PreparedStatement get() throws SQLException {
return connection.prepareStatement(CREATE_CLUSTER); return connection.prepareStatement(CREATE_CLUSTER, Statement.RETURN_GENERATED_KEYS);
}
@Override
public void execute(final PreparedStatement stmt) throws SQLException {
}
@Override
public void addBatch(final PreparedStatement stmt) throws SQLException {
stmt.executeUpdate();
final ResultSet keys = stmt.getGeneratedKeys();
if (keys.next()) {
cluster.temp = keys.getInt(1);
}
} }
}); });
addClusterTask(cluster, new UniqueStatement("createClusterSettings") { addClusterTask(cluster, new UniqueStatement("createCluster_settings_" + cluster.hashCode()) {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
final int id = getClusterId(cluster.world, ClusterManager.getClusterId(cluster)); stmt.setInt(1, getClusterId(cluster));
stmt.setInt(1, id);
stmt.setString(2, cluster.settings.getAlias()); stmt.setString(2, cluster.settings.getAlias());
stmt.executeUpdate();
stmt.close();
} }
@Override @Override
@ -2490,7 +2532,7 @@ public class SQLManager implements AbstractDB {
stmt.setInt(2, pos1.y); stmt.setInt(2, pos1.y);
stmt.setInt(3, pos2.x); stmt.setInt(3, pos2.x);
stmt.setInt(4, pos2.y); stmt.setInt(4, pos2.y);
stmt.setInt(5, getClusterId(current.world, ClusterManager.getClusterId(current))); stmt.setInt(5, getClusterId(current));
} }
@Override @Override
@ -2506,7 +2548,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
stmt.setString(1, position); stmt.setString(1, position);
stmt.setInt(2, getClusterId(cluster.world, ClusterManager.getClusterId(cluster))); stmt.setInt(2, getClusterId(cluster));
} }
@Override @Override
@ -2521,7 +2563,7 @@ public class SQLManager implements AbstractDB {
addClusterTask(cluster, new UniqueStatement("removeInvited") { addClusterTask(cluster, new UniqueStatement("removeInvited") {
@Override @Override
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
statement.setInt(1, getClusterId(cluster.world, ClusterManager.getClusterId(cluster))); statement.setInt(1, getClusterId(cluster));
statement.setString(2, uuid.toString()); statement.setString(2, uuid.toString());
} }
@ -2537,7 +2579,7 @@ public class SQLManager implements AbstractDB {
addClusterTask(cluster, new UniqueStatement("setInvited") { addClusterTask(cluster, new UniqueStatement("setInvited") {
@Override @Override
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
statement.setInt(1, getClusterId(cluster.world, ClusterManager.getClusterId(cluster))); statement.setInt(1, getClusterId(cluster));
statement.setString(2, uuid.toString()); statement.setString(2, uuid.toString());
} }

View File

@ -14,6 +14,8 @@ public class PlotCluster {
private PlotId pos1; private PlotId pos1;
private PlotId pos2; private PlotId pos2;
public int temp;
public PlotId getP1() { public PlotId getP1() {
return pos1; return pos1;
} }
@ -36,6 +38,16 @@ public class PlotCluster {
this.pos2 = pos2; this.pos2 = pos2;
this.owner = owner; this.owner = owner;
settings = new PlotSettings(); settings = new PlotSettings();
this.temp = -1;
}
public PlotCluster(final String world, final PlotId pos1, final PlotId pos2, final UUID owner, int temp) {
this.world = world;
this.pos1 = pos1;
this.pos2 = pos2;
this.owner = owner;
settings = new PlotSettings();
this.temp = temp;
} }
public boolean isAdded(final UUID uuid) { public boolean isAdded(final UUID uuid) {

View File

@ -310,7 +310,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
} }
@EventHandler @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void PlayerCommand(final PlayerCommandPreprocessEvent event) { public void PlayerCommand(final PlayerCommandPreprocessEvent event) {
final String message = event.getMessage().toLowerCase().replaceAll("/", "").trim(); final String message = event.getMessage().toLowerCase().replaceAll("/", "").trim();
if (message.length() == 0) { if (message.length() == 0) {

View File

@ -130,21 +130,22 @@ public class BukkitChunkManager extends ChunkManager {
final World newWorld = Bukkit.getWorld(newPos.getWorld()); final World newWorld = Bukkit.getWorld(newPos.getWorld());
final ArrayList<Chunk> chunks = new ArrayList<>(); final ArrayList<Chunk> chunks = new ArrayList<>();
initMaps();
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override @Override
public void run() { public void run() {
initMaps();
final int bx = value[2]; final int bx = value[2];
final int bz = value[3]; final int bz = value[3];
final int tx = value[4]; final int tx = value[4];
final int tz = value[5]; final int tz = value[5];
// Load chunks // Load chunks
final ChunkLoc loc1 = new ChunkLoc(value[0], value[1]); final ChunkLoc loc1 = new ChunkLoc(value[0], value[1]);
final ChunkLoc loc2 = new ChunkLoc(loc1.x + relCX, loc1.z + relCZ); final ChunkLoc loc2 = new ChunkLoc(loc1.x + relCX, loc1.z + relCZ);
final Chunk c1 = oldWorld.getChunkAt(loc1.x, loc1.z); final Chunk c1 = oldWorld.getChunkAt(loc1.x, loc1.z);
final Chunk c2 = oldWorld.getChunkAt(loc2.x, loc2.z); final Chunk c2 = newWorld.getChunkAt(loc2.x, loc2.z);
c1.load(true); c1.load(true);
c2.load(true); c2.load(true);
chunks.add(c2); chunks.add(c2);
@ -165,11 +166,11 @@ public class BukkitChunkManager extends ChunkManager {
// restore chunk // restore chunk
restoreBlocks(newWorld, relX, relZ); restoreBlocks(newWorld, relX, relZ);
restoreEntities(newWorld, relX, relZ); restoreEntities(newWorld, relX, relZ);
BukkitSetBlockManager.setBlockManager.update(chunks);
} }
}, new Runnable() { }, new Runnable() {
@Override @Override
public void run() { public void run() {
BukkitSetBlockManager.setBlockManager.update(chunks);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
} }
}, 5); }, 5);
@ -854,7 +855,8 @@ public class BukkitChunkManager extends ChunkManager {
@Override @Override
public boolean loadChunk(final String world, final ChunkLoc loc, final boolean force) { public boolean loadChunk(final String world, final ChunkLoc loc, final boolean force) {
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force); boolean result = BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
return result;
} }
@Override @Override

View File

@ -121,11 +121,11 @@ public class SendChunk {
public void run() { public void run() {
try { try {
chunk.unload(true, false); chunk.unload(true, false);
} catch (final Exception e) { } catch (final Throwable e) {
final String worldname = chunk.getWorld().getName(); final String worldname = chunk.getWorld().getName();
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ()); PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)"); PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname + "level_old.dat may be corrupt (try repairing or removing these)"); PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname + "/level_old.dat may be corrupt (try repairing or removing these)");
} }
} }
}); });

View File

@ -94,7 +94,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
chunksender = new SendChunk(); chunksender = new SendChunk();
} }
private final ChunkLoc lastLoc = null; private ChunkLoc lastLoc = null;
/** /**
* Set the block at the location * Set the block at the location
@ -109,6 +109,18 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@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) {
final int X = x >> 4;
final int Z = z >> 4;
final ChunkLoc loc = new ChunkLoc(X, Z);
if (lastLoc == null || loc.x != lastLoc.x || loc.z != lastLoc.z) {
lastLoc = loc;
Chunk chunk = toUpdate.get(loc);
if (chunk == null) {
chunk = world.getChunkAt(X, Z);
toUpdate.put(loc, chunk);
}
chunk.load(true);
}
if (id == -1) { if (id == -1) {
world.getBlockAt(x, y, z).setData(data, false); world.getBlockAt(x, y, z).setData(data, false);
return; return;
@ -313,17 +325,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
} }
// End blockstate workaround // // End blockstate workaround //
final int X = x >> 4;
final int Z = z >> 4;
final 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);
}
// check sign // check sign
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);

Binary file not shown.

Binary file not shown.