mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
parent
50c6753bf4
commit
54655c1a72
@ -44,15 +44,12 @@ import com.intellectualcrafters.plot.database.SQLite;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotFilter;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
@ -1314,13 +1311,6 @@ public class PS {
|
||||
// save configuration
|
||||
final String[] split = args.split(",");
|
||||
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) {
|
||||
final String[] pair = element.split("=");
|
||||
if (pair.length != 2) {
|
||||
@ -1329,43 +1319,44 @@ public class PS {
|
||||
}
|
||||
final String key = pair[0].toLowerCase();
|
||||
final String value = pair[1];
|
||||
final String base = "worlds." + world + ".";
|
||||
try {
|
||||
switch (key) {
|
||||
case "s":
|
||||
case "size": {
|
||||
SquarePlotWorld.PLOT_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
|
||||
config.set(base + "plot.size", Configuration.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
}
|
||||
case "g":
|
||||
case "gap": {
|
||||
SquarePlotWorld.ROAD_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
|
||||
config.set(base + "road.width", Configuration.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
}
|
||||
case "h":
|
||||
case "height": {
|
||||
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
config.set(base + "road.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||
config.set(base + "plot.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||
config.set(base + "wall.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
}
|
||||
case "f":
|
||||
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;
|
||||
}
|
||||
case "m":
|
||||
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;
|
||||
}
|
||||
case "w":
|
||||
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;
|
||||
}
|
||||
case "b":
|
||||
case "border": {
|
||||
ClassicPlotWorld.WALL_BLOCK_DEFAULT = Configuration.BLOCK.parseString(value);
|
||||
config.set(base + "wall.block", Configuration.BLOCK.parseString(value).toString());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -1380,20 +1371,8 @@ public class PS {
|
||||
}
|
||||
}
|
||||
try {
|
||||
final String root = "worlds." + world;
|
||||
if (!config.contains(root)) {
|
||||
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;
|
||||
plotworld.loadConfiguration(config);
|
||||
config.save(configFile);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class Inbox extends SubCommand {
|
||||
} else {
|
||||
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());
|
||||
}
|
||||
@ -155,6 +155,7 @@ public class Inbox extends SubCommand {
|
||||
final List<PlotComment> comments = (List<PlotComment>) value;
|
||||
if (index > comments.size()) {
|
||||
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||
return;
|
||||
}
|
||||
final PlotComment comment = comments.get(index - 1);
|
||||
inbox.removeComment(plot, comment);
|
||||
|
@ -112,7 +112,7 @@ public interface AbstractDB {
|
||||
*
|
||||
* @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
|
||||
|
@ -53,7 +53,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
@ -145,12 +144,31 @@ public class SQLManager implements AbstractDB {
|
||||
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);
|
||||
if (tasks == null) {
|
||||
tasks = new ConcurrentLinkedQueue<>();
|
||||
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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
public int getId(final Plot plot) {
|
||||
if (plot.temp > 0) {
|
||||
@ -2114,7 +2172,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
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") {
|
||||
@Override
|
||||
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
|
||||
public HashMap<String, HashSet<PlotCluster>> getClusters() {
|
||||
final LinkedHashMap<String, HashSet<PlotCluster>> newClusters = new LinkedHashMap<>();
|
||||
@ -2229,7 +2261,7 @@ public class SQLManager implements AbstractDB {
|
||||
user = UUID.fromString(owner);
|
||||
uuids.put(owner, user);
|
||||
}
|
||||
cluster = new PlotCluster(worldname, pos1, pos2, user);
|
||||
cluster = new PlotCluster(worldname, pos1, pos2, user, id);
|
||||
clusters.put(id, cluster);
|
||||
}
|
||||
/*
|
||||
@ -2381,7 +2413,7 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setString(1, flag_string.toString());
|
||||
stmt.setInt(2, getClusterId(cluster.world, ClusterManager.getClusterId(cluster)));
|
||||
stmt.setInt(2, getClusterId(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2397,7 +2429,7 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setString(1, name);
|
||||
stmt.setInt(2, getClusterId(cluster.world, ClusterManager.getClusterId(cluster)));
|
||||
stmt.setInt(2, getClusterId(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2413,7 +2445,7 @@ public class SQLManager implements AbstractDB {
|
||||
addClusterTask(cluster, new UniqueStatement("removeHelper") {
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
|
||||
@ -2429,7 +2461,7 @@ public class SQLManager implements AbstractDB {
|
||||
addClusterTask(cluster, new UniqueStatement("setHelper") {
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
|
||||
@ -2442,7 +2474,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void createCluster(final PlotCluster cluster) {
|
||||
addClusterTask(cluster, new UniqueStatement("createCluster") {
|
||||
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setInt(1, cluster.getP1().x);
|
||||
@ -2451,22 +2483,32 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setInt(4, cluster.getP2().y);
|
||||
stmt.setString(5, cluster.owner.toString());
|
||||
stmt.setString(6, cluster.world);
|
||||
// TODO resultset getId
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
final int id = getClusterId(cluster.world, ClusterManager.getClusterId(cluster));
|
||||
stmt.setInt(1, id);
|
||||
stmt.setInt(1, getClusterId(cluster));
|
||||
stmt.setString(2, cluster.settings.getAlias());
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2490,7 +2532,7 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setInt(2, pos1.y);
|
||||
stmt.setInt(3, pos2.x);
|
||||
stmt.setInt(4, pos2.y);
|
||||
stmt.setInt(5, getClusterId(current.world, ClusterManager.getClusterId(current)));
|
||||
stmt.setInt(5, getClusterId(current));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2506,7 +2548,7 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setString(1, position);
|
||||
stmt.setInt(2, getClusterId(cluster.world, ClusterManager.getClusterId(cluster)));
|
||||
stmt.setInt(2, getClusterId(cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2521,7 +2563,7 @@ public class SQLManager implements AbstractDB {
|
||||
addClusterTask(cluster, new UniqueStatement("removeInvited") {
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
|
||||
@ -2537,7 +2579,7 @@ public class SQLManager implements AbstractDB {
|
||||
addClusterTask(cluster, new UniqueStatement("setInvited") {
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@ public class PlotCluster {
|
||||
private PlotId pos1;
|
||||
private PlotId pos2;
|
||||
|
||||
public int temp;
|
||||
|
||||
public PlotId getP1() {
|
||||
return pos1;
|
||||
}
|
||||
@ -36,6 +38,16 @@ public class PlotCluster {
|
||||
this.pos2 = pos2;
|
||||
this.owner = owner;
|
||||
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) {
|
||||
|
@ -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) {
|
||||
final String message = event.getMessage().toLowerCase().replaceAll("/", "").trim();
|
||||
if (message.length() == 0) {
|
||||
|
@ -130,21 +130,22 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final World newWorld = Bukkit.getWorld(newPos.getWorld());
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
|
||||
initMaps();
|
||||
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run() {
|
||||
initMaps();
|
||||
|
||||
final int bx = value[2];
|
||||
final int bz = value[3];
|
||||
|
||||
final int tx = value[4];
|
||||
final int tz = value[5];
|
||||
|
||||
// Load chunks
|
||||
final ChunkLoc loc1 = new ChunkLoc(value[0], value[1]);
|
||||
final ChunkLoc loc2 = new ChunkLoc(loc1.x + relCX, loc1.z + relCZ);
|
||||
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);
|
||||
c2.load(true);
|
||||
chunks.add(c2);
|
||||
@ -165,11 +166,11 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
// restore chunk
|
||||
restoreBlocks(newWorld, relX, relZ);
|
||||
restoreEntities(newWorld, relX, relZ);
|
||||
BukkitSetBlockManager.setBlockManager.update(chunks);
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BukkitSetBlockManager.setBlockManager.update(chunks);
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}, 5);
|
||||
@ -854,7 +855,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -121,11 +121,11 @@ public class SendChunk {
|
||||
public void run() {
|
||||
try {
|
||||
chunk.unload(true, false);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable e) {
|
||||
final String worldname = chunk.getWorld().getName();
|
||||
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 - $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)");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -94,7 +94,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
|
||||
chunksender = new SendChunk();
|
||||
}
|
||||
|
||||
private final ChunkLoc lastLoc = null;
|
||||
private ChunkLoc lastLoc = null;
|
||||
|
||||
/**
|
||||
* Set the block at the location
|
||||
@ -109,6 +109,18 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
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) {
|
||||
world.getBlockAt(x, y, z).setData(data, false);
|
||||
return;
|
||||
@ -313,17 +325,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
|
||||
}
|
||||
// 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
|
||||
final Object w = methodGetHandle.of(world).call();
|
||||
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user