Significantly faster clearing for new world types

This commit is contained in:
boy0001 2015-02-10 20:24:19 +11:00
parent b87cb614ed
commit 79f48ff7d6
3 changed files with 15 additions and 37 deletions

View File

@ -106,24 +106,6 @@ public class SQLManager implements AbstractDB {
} }
//
// public void setTimout() {
// TaskManager.runTask(new Runnable() {
// @Override
// public void run() {
// try {
// final PreparedStatement statement =
// connection.prepareStatement("SET GLOBAL wait_timeout =28800;");
// statement.executeQuery();
// statement.close();
// } catch (final SQLException e) {
// e.printStackTrace();
// PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Could not reset MySQL timout.");
// }
// }
// });
// }
/** /**
* Set Plot owner * Set Plot owner
* *
@ -508,7 +490,7 @@ public class SQLManager implements AbstractDB {
} }
/** /**
* @return * Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap
*/ */
@Override @Override
public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() { public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() {

View File

@ -111,12 +111,10 @@ public abstract class PlotWorld {
* @param config Configuration Section * @param config Configuration Section
*/ */
public void loadDefaultConfiguration(final ConfigurationSection config) { public void loadDefaultConfiguration(final ConfigurationSection config) {
if (Settings.ENABLE_CLUSTERS) { if (config.contains("generator.terrain")) {
if (config.contains("generator.terrain")) { this.TERRAIN = config.getInt("generator.terrain");
this.TERRAIN = config.getInt("generator.terrain"); this.TYPE = config.getInt("generator.type");
this.TYPE = config.getInt("generator.type"); }
}
}
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome")); this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome"));

View File

@ -145,7 +145,9 @@ public class ChunkManager {
initMaps(); initMaps();
int absX = x << 4; int absX = x << 4;
int absZ = z << 4; int absZ = z << 4;
boolean save = false;
if (x == c1x || z == c1z) { if (x == c1x || z == c1z) {
save = true;
for (int X = 0; X < 16; X++) { for (int X = 0; X < 16; X++) {
for (int Z = 0; Z < 16; Z++) { for (int Z = 0; Z < 16; Z++) {
if ((X + absX < sx || Z + absZ < sz) || (X + absX > ex || Z + absZ > ez)) { if ((X + absX < sx || Z + absZ < sz) || (X + absX > ex || Z + absZ > ez)) {
@ -156,6 +158,7 @@ public class ChunkManager {
} }
else if (x == c2x || z == c2z) { else if (x == c2x || z == c2z) {
for (int X = 0; X < 16; X++) { for (int X = 0; X < 16; X++) {
save = true;
for (int Z = 0; Z < 16; Z++) { for (int Z = 0; Z < 16; Z++) {
if ((X + absX > ex || Z + absZ > ez) || (X + absX < sx || Z + absZ < sz)) { if ((X + absX > ex || Z + absZ > ez) || (X + absX < sx || Z + absZ < sz)) {
saveBlock(world, maxY, X + absX, Z + absZ); saveBlock(world, maxY, X + absX, Z + absZ);
@ -163,10 +166,14 @@ public class ChunkManager {
} }
} }
} }
saveEntities(chunk, CURRENT_PLOT_CLEAR); if (save) {
saveEntities(chunk, CURRENT_PLOT_CLEAR);
}
world.regenerateChunk(x, z); world.regenerateChunk(x, z);
restoreBlocks(world, 0, 0); if (save) {
restoreEntities(world, 0, 0); restoreBlocks(world, 0, 0);
restoreEntities(world, 0, 0);
}
chunk.unload(); chunk.unload();
chunk.load(); chunk.load();
} }
@ -217,15 +224,6 @@ public class ChunkManager {
} }
EntityWrapper wrap = new EntityWrapper(entity, (short) 2); EntityWrapper wrap = new EntityWrapper(entity, (short) 2);
entities.add(wrap); entities.add(wrap);
// int y = loc.getBlockY();
// BlockLoc bl = new BlockLoc(x, y, z);
// EntityWrapper wrap = new EntityWrapper(entity.getType().getTypeId());
// entities.put(wrap, bl);
// System.out.print(entity.isDead());
// entity.teleport(new Location(chunk.getWorld(), 0, 65, 0));
} }
} }