mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-04 06:34:42 +02:00
Use plot metadata to track tasks
This commit is contained in:
@ -283,8 +283,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = MainUtil.parseId(args[1]);
|
||||
PlotId pos2 = MainUtil.parseId(args[2]);
|
||||
PlotId pos1 = PlotId.fromString(args[1]);
|
||||
PlotId pos2 = PlotId.fromString(args[2]);
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
|
@ -56,12 +56,12 @@ public class Done extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.runners.put(plot, 1);
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK);
|
||||
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) {
|
||||
final Flag flag = new Flag(FlagManager.getFlag("done"), (System.currentTimeMillis() / 1000));
|
||||
FlagManager.addPlotFlag(plot, flag);
|
||||
|
@ -46,7 +46,7 @@ public class Download extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.runners.put(plot, 1);
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK);
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
@ -57,11 +57,11 @@ public class Download extends SubCommand {
|
||||
final URL url = SchematicHandler.manager.upload(value, null, null);
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -80,22 +80,21 @@ public class Load extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
MainUtil.runners.put(plot, 1);
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Schematic schematic = SchematicHandler.manager.getSchematic(url);
|
||||
if (schematic == null) {
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
|
||||
return;
|
||||
}
|
||||
SchematicHandler.manager.paste(schematic, plot, 0, 0, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
if (value) {
|
||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
@ -107,7 +106,7 @@ public class Load extends SubCommand {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot load <index>");
|
||||
return false;
|
||||
}
|
||||
@ -116,12 +115,12 @@ public class Load extends SubCommand {
|
||||
|
||||
final List<String> schematics = (List<String>) plr.getMeta("plot_schematics");
|
||||
if (schematics == null) {
|
||||
MainUtil.runners.put(plot, 1);
|
||||
plot.addRunning();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<String> schematics = SchematicHandler.manager.getSaves(plr.getUUID());
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
if ((schematics == null) || (schematics.size() == 0)) {
|
||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||
return;
|
||||
|
@ -49,7 +49,7 @@ public class Save extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.runners.put(plot, 1);
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -68,7 +68,7 @@ public class Save extends SubCommand {
|
||||
final URL url = SchematicHandler.manager.upload(value, uuid, file);
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.SAVE_FAILED);
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SAVE_SUCCESS);
|
||||
@ -76,7 +76,7 @@ public class Save extends SubCommand {
|
||||
if (schematics != null) {
|
||||
schematics.add(file);
|
||||
}
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class Target extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
PlotId id = MainUtil.parseId(args[0]);
|
||||
PlotId id = PlotId.fromString(args[0]);
|
||||
if (id == null) {
|
||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||
Plot closest = null;
|
||||
|
Reference in New Issue
Block a user