mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-29 20:24:43 +02:00
Multiple changes
Working on async schematic saving Default plot clearing is now properly async (and somewhat slower) Offline mode servers now default to lowercase (there has been ample time to update) Fixed some issues with plot expiry Fixed some issues with UUID caching Optimized UUID fetching from cache (marginal)
This commit is contained in:
@ -41,6 +41,7 @@ import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.StateWrapper;
|
||||
|
||||
/**
|
||||
@ -52,8 +53,14 @@ import com.intellectualcrafters.plot.object.schematic.StateWrapper;
|
||||
public class BukkitSchematicHandler extends SchematicHandler {
|
||||
|
||||
@Override
|
||||
public CompoundTag getCompoundTag(final String world, final Location pos1, final Location pos2) {
|
||||
// loading chunks
|
||||
public void getCompoundTag(final String world, final Location pos1, final Location pos2, RunnableVal<CompoundTag> whenDone) {
|
||||
|
||||
// create schematic one chunk at a time
|
||||
// load chunk sync
|
||||
// get blocks async
|
||||
// add to schematic async
|
||||
// save final async
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
@ -62,13 +69,15 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
boolean result = ChunkManager.manager.loadChunk(world, new ChunkLoc(i, j));
|
||||
if (!result) {
|
||||
PS.log("&cIllegal selection. Cannot save non-existent chunk at " + (i / 16) + ", " + (j / 16));
|
||||
return null;
|
||||
whenDone.run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
PS.log("&cIllegal selection. Cannot save corrupt chunk at " + (i / 16) + ", " + (j / 16));
|
||||
return null;
|
||||
whenDone.run();
|
||||
return;
|
||||
}
|
||||
final int width = (pos2.getX() - pos1.getX()) + 1;
|
||||
final int height = (pos2.getY() - pos1.getY()) + 1;
|
||||
@ -93,18 +102,20 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
pos2.getZ();
|
||||
final int sy = pos1.getY();
|
||||
pos2.getY();
|
||||
|
||||
List<Tag> tileEntities = new ArrayList<Tag>();
|
||||
|
||||
World worldObj = Bukkit.getWorld(world);
|
||||
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
int i1 = (y * width * length);
|
||||
int syy = sy + y;
|
||||
for (int z = 0; z < length; z++) {
|
||||
int i2 = i1 + (z * width);
|
||||
int szz = sz + z;
|
||||
for (int x = 0; x < width; x++) {
|
||||
final int index = i2 + x;
|
||||
Block block = worldObj.getBlockAt(sx + x, sy + y, sz + z);
|
||||
Block block = worldObj.getBlockAt(sx + x, syy, szz);
|
||||
int id = block.getTypeId();
|
||||
switch(id) {
|
||||
case 0:
|
||||
@ -249,6 +260,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
@ -257,7 +269,10 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
if (addBlocks != null) {
|
||||
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||
}
|
||||
return new CompoundTag("Schematic", schematic);
|
||||
|
||||
|
||||
whenDone.value = new CompoundTag("Schematic", schematic);
|
||||
whenDone.run();
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,8 +125,8 @@ public class ExpireManager {
|
||||
if (Settings.CLEAR_THRESHOLD != -1 && plotworld.TYPE == 0 && changed != null) {
|
||||
if (changed.getComplexity() > Settings.CLEAR_THRESHOLD) {
|
||||
PS.log("$2[&5Expire&dManager$2] &bIgnoring modified plot: " + plot + " : " + changed.getComplexity() + " - " + changed.changes);
|
||||
FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("modified-blocks"), value));
|
||||
expiredPlots.get(world).remove(plot);
|
||||
FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("analysis"), value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.object.schematic.StateWrapper;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
@ -57,15 +58,11 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
exportAll = true;
|
||||
final ArrayList<Plot> plots = new ArrayList<Plot>(collection);
|
||||
TaskManager.index.increment();
|
||||
final Integer currentIndex = TaskManager.index.toInteger();
|
||||
final int task = TaskManager.runTaskRepeat(new Runnable() {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plots.size() == 0) {
|
||||
exportAll = false;
|
||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||
TaskManager.tasks.remove(currentIndex);
|
||||
TaskManager.runTask(ifSuccess);
|
||||
return;
|
||||
}
|
||||
@ -94,27 +91,38 @@ public abstract class SchematicHandler {
|
||||
new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
|
||||
}
|
||||
else {
|
||||
final CompoundTag sch = SchematicHandler.manager.getCompoundTag(plot.world, plot.id);
|
||||
if (sch == null) {
|
||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||
} else {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(null, "&6ID: " + plot.id);
|
||||
final boolean result = SchematicHandler.manager.save(sch, directory + File.separator + name + ".schematic");
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id);
|
||||
} else {
|
||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.id);
|
||||
}
|
||||
final Runnable THIS = this;
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (value == null) {
|
||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(null, "&6ID: " + plot.id);
|
||||
final boolean result = SchematicHandler.manager.save(value, directory + File.separator + name + ".schematic");
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id);
|
||||
} else {
|
||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.id);
|
||||
}
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
THIS.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
TaskManager.tasks.put(currentIndex, task);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -409,16 +417,16 @@ public abstract class SchematicHandler {
|
||||
*
|
||||
* @return tag
|
||||
*/
|
||||
public CompoundTag getCompoundTag(final String world, final PlotId id) {
|
||||
public void getCompoundTag(final String world, final PlotId id, RunnableVal<CompoundTag> whenDone) {
|
||||
if (!PS.get().getPlots(world).containsKey(id)) {
|
||||
return null;
|
||||
whenDone.run();
|
||||
}
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, id);
|
||||
return getCompoundTag(world, pos1, pos2);
|
||||
getCompoundTag(world, pos1, pos2, whenDone);
|
||||
}
|
||||
|
||||
public abstract CompoundTag getCompoundTag(final String world, final Location pos1, final Location pos2);
|
||||
public abstract void getCompoundTag(final String world, final Location pos1, final Location pos2, RunnableVal<CompoundTag> whenDone);
|
||||
|
||||
public boolean pastePart(final String world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) {
|
||||
int length = 0;
|
||||
|
@ -210,7 +210,10 @@ public class UUIDHandler {
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
long last = (long) bukkit.get("lastPlayed");
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
if (!Settings.UUID_LOWERCASE || !name.toLowerCase().equals(name)) {
|
||||
if (Settings.UUID_LOWERCASE && !name.toLowerCase().equals(name)) {
|
||||
uuid = uuidWrapper.getUUID(name);
|
||||
}
|
||||
else {
|
||||
long most = (long) compound.get("UUIDMost");
|
||||
long least = (long) compound.get("UUIDLeast");
|
||||
uuid = new UUID(most, least);
|
||||
|
Reference in New Issue
Block a user