Fix load / flush queue before sending message

This commit is contained in:
Jesse Boyd 2016-06-16 17:31:02 +10:00
parent b2997b7c7b
commit 2bbfec1a32
2 changed files with 4 additions and 9 deletions

View File

@ -13,7 +13,6 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
@ -68,14 +67,14 @@ public class Load extends SubCommand {
String schematic;
try {
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
} catch (NumberFormatException ignored) {
} catch (Exception ignored) {
// use /plot load <index>
MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ')');
return false;
}
final URL url;
try {
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic + ".schematic");
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic);
} catch (MalformedURLException e) {
e.printStackTrace();
MainUtil.sendMessage(player, C.LOAD_FAILED);

View File

@ -1,6 +1,5 @@
package com.intellectualcrafters.plot.util;
import com.google.common.collect.Lists;
import com.intellectualcrafters.jnbt.ByteArrayTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.IntTag;
@ -247,12 +246,9 @@ public abstract class SchematicHandler {
int i2 = (rz * WIDTH) + i1;
for (int rx = xxb - p1x; rx <= (xxt - p1x); rx++) {
int i = i2 + rx;
int xx = p1x + rx;
int zz = p1z + rz;
int id = ids[i];
switch (id) {
case 0:
case 2:
@ -338,11 +334,11 @@ public abstract class SchematicHandler {
BlockLoc loc = entry.getKey();
restoreTile(queue, entry.getValue(), p1x + xOffset + loc.x, loc.y + y_offset_actual, p1z + zOffset + loc.z);
}
queue.flush();
if (whenDone != null) {
whenDone.value = true;
whenDone.run();
}
queue.flush();
}
}
});
@ -513,7 +509,7 @@ public abstract class SchematicHandler {
String schematic = array.getString(i);
schematics.add(schematic);
}
return Lists.reverse(schematics);
return schematics;
} catch (JSONException | IOException e) {
e.printStackTrace();
PS.debug("ERROR PARSING: " + rawJSON);