Fix requiring restart for /ps load after /ps save & make descriptions nicer

This commit is contained in:
dordsor21 2019-01-11 12:50:38 +00:00
parent daf3e3dde5
commit 0d76e46fa2
2 changed files with 16 additions and 18 deletions

View File

@ -103,17 +103,15 @@ import java.util.List;
List<String> schematics = player.getMeta("plot_schematics"); List<String> schematics = player.getMeta("plot_schematics");
if (schematics == null) { if (schematics == null) {
plot.addRunning(); plot.addRunning();
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(() -> {
@Override public void run() { List<String> schematics1 = SchematicHandler.manager.getSaves(player.getUUID());
List<String> schematics = SchematicHandler.manager.getSaves(player.getUUID());
plot.removeRunning(); plot.removeRunning();
if ((schematics == null) || schematics.isEmpty()) { if ((schematics1 == null) || schematics1.isEmpty()) {
MainUtil.sendMessage(player, C.LOAD_FAILED); MainUtil.sendMessage(player, C.LOAD_FAILED);
return; return;
} }
player.setMeta("plot_schematics", schematics); player.setMeta("plot_schematics", schematics1);
displaySaves(player); displaySaves(player);
}
}); });
} else { } else {
displaySaves(player); displaySaves(player);
@ -125,7 +123,7 @@ import java.util.List;
List<String> schematics = player.getMeta("plot_schematics"); List<String> schematics = player.getMeta("plot_schematics");
for (int i = 0; i < Math.min(schematics.size(), 32); i++) { for (int i = 0; i < Math.min(schematics.size(), 32); i++) {
try { try {
String schematic = schematics.get(i); String schematic = schematics.get(i).split("\\.")[0];
String[] split = schematic.split("_"); String[] split = schematic.split("_");
if (split.length < 5) { if (split.length < 5) {
continue; continue;
@ -151,30 +149,30 @@ import java.util.List;
if (time >= 33868800) { if (time >= 33868800) {
int years = (int) (time / 33868800); int years = (int) (time / 33868800);
time -= years * 33868800; time -= years * 33868800;
toreturn.append(years + "y "); toreturn.append(years).append("y ");
} }
if (time >= 604800) { if (time >= 604800) {
int weeks = (int) (time / 604800); int weeks = (int) (time / 604800);
time -= weeks * 604800; time -= weeks * 604800;
toreturn.append(weeks + "w "); toreturn.append(weeks).append("w ");
} }
if (time >= 86400) { if (time >= 86400) {
int days = (int) (time / 86400); int days = (int) (time / 86400);
time -= days * 86400; time -= days * 86400;
toreturn.append(days + "d "); toreturn.append(days).append("d ");
} }
if (time >= 3600) { if (time >= 3600) {
int hours = (int) (time / 3600); int hours = (int) (time / 3600);
time -= hours * 3600; time -= hours * 3600;
toreturn.append(hours + "h "); toreturn.append(hours).append("h ");
} }
if (time >= 60) { if (time >= 60) {
int minutes = (int) (time / 60); int minutes = (int) (time / 60);
time -= minutes * 60; time -= minutes * 60;
toreturn.append(minutes + "m "); toreturn.append(minutes).append("m ");
} }
if (toreturn.length() == 0 || (time > 0)) { if (toreturn.length() == 0 || (time > 0)) {
toreturn.append(time + "s "); toreturn.append(time).append("s ");
} }
return toreturn.toString().trim(); return toreturn.toString().trim();
} }

View File

@ -64,7 +64,7 @@ import java.util.UUID;
MainUtil.sendMessage(player, C.SAVE_SUCCESS); MainUtil.sendMessage(player, C.SAVE_SUCCESS);
List<String> schematics = player.getMeta("plot_schematics"); List<String> schematics = player.getMeta("plot_schematics");
if (schematics != null) { if (schematics != null) {
schematics.add(file); schematics.add(file + ".schematic");
} }
} }
}); });