Feedback for failed uploads + fix plot list done

This commit is contained in:
boy0001 2015-08-28 09:51:59 +10:00
parent ac27a7f37a
commit 552ace359a
4 changed files with 53 additions and 35 deletions

View File

@ -1647,6 +1647,13 @@ public class PS {
for (final String flag : intFlags) { for (final String flag : intFlags) {
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue())); FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
} }
FlagManager.addFlag(new AbstractFlag("cluster") {
@Override
public Object parseValueRaw(String value) {
String[] split = value.split(";");
return ClusterManager.getCluster(split[0], split[1]);
}
}, true);
FlagManager.addFlag(new AbstractFlag("done", new FlagValue.StringValue()), true); FlagManager.addFlag(new AbstractFlag("done", new FlagValue.StringValue()), true);
FlagManager.addFlag(new AbstractFlag("analysis", new FlagValue.IntegerListValue()), true); FlagManager.addFlag(new AbstractFlag("analysis", new FlagValue.IntegerListValue()), true);
FlagManager.addFlag(new AbstractFlag("disable-physics", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("disable-physics", new FlagValue.BooleanValue()));
@ -1814,6 +1821,7 @@ public class PS {
options.put("approval.ratings.require-done", Settings.REQUIRE_DONE); options.put("approval.ratings.require-done", Settings.REQUIRE_DONE);
options.put("approval.done.counts-towards-limit", Settings.DONE_COUNTS_TOWARDS_LIMIT); options.put("approval.done.counts-towards-limit", Settings.DONE_COUNTS_TOWARDS_LIMIT);
options.put("approval.done.restrict-building", Settings.DONE_RESTRICTS_BUILDING); options.put("approval.done.restrict-building", Settings.DONE_RESTRICTS_BUILDING);
options.put("approval.done.required-for-download", Settings.DOWNLOAD_REQUIRES_DONE);
// Schematics // Schematics
options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH);
@ -1928,6 +1936,7 @@ public class PS {
Settings.REQUIRE_DONE = config.getBoolean("approval.ratings.require-done"); Settings.REQUIRE_DONE = config.getBoolean("approval.ratings.require-done");
Settings.DONE_COUNTS_TOWARDS_LIMIT = config.getBoolean("approval.done.counts-towards-limit"); Settings.DONE_COUNTS_TOWARDS_LIMIT = config.getBoolean("approval.done.counts-towards-limit");
Settings.DONE_RESTRICTS_BUILDING = config.getBoolean("approval.done.restrict-building"); Settings.DONE_RESTRICTS_BUILDING = config.getBoolean("approval.done.restrict-building");
Settings.DOWNLOAD_REQUIRES_DONE = config.getBoolean("approval.done.required-for-download");
// Schematics // Schematics
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");

View File

@ -104,7 +104,7 @@ public class list extends SubCommand {
args.add("<world>"); args.add("<world>");
} }
if (Permissions.hasPermission(player, "plots.list.done")) { if (Permissions.hasPermission(player, "plots.list.done")) {
args.add("<world>"); args.add("done");
} }
return args.toArray(new String[args.size()]); return args.toArray(new String[args.size()]);
} }
@ -188,7 +188,7 @@ public class list extends SubCommand {
plots = new ArrayList<>(); plots = new ArrayList<>();
String match; String match;
if (args.length == 2) { if (args.length == 2) {
match = args[2]; match = args[1];
} }
else { else {
match = null; match = null;
@ -196,32 +196,37 @@ public class list extends SubCommand {
for (Plot plot : PS.get().getPlots()) { for (Plot plot : PS.get().getPlots()) {
Flag flag = plot.getSettings().flags.get("done"); Flag flag = plot.getSettings().flags.get("done");
if (flag == null) { if (flag == null) {
return false; continue;
} }
if (match != null) { if (match != null) {
flag.getValueString().matches(match); try {
if (flag.getValueString().matches(match)) {
plots.add(plot);
}
}
catch (Exception e) {
break;
}
} }
else { else {
plots.add(plot); plots.add(plot);
} }
} }
if (match != null) { Collections.sort(plots, new Comparator<Plot>() {
Collections.sort(plots, new Comparator<Plot>() { @Override
@Override public int compare(Plot a, Plot b) {
public int compare(Plot a, Plot b) { String va = a.getSettings().flags.get("done").getValueString();
String va = a.getSettings().flags.get("done").getValueString(); String vb = b.getSettings().flags.get("done").getValueString();
String vb = b.getSettings().flags.get("done").getValueString(); if (MathMan.isInteger(va)) {
if (MathMan.isInteger(va)) { if (MathMan.isInteger(vb)) {
if (MathMan.isInteger(vb)) { return Integer.parseInt(vb) - Integer.parseInt(va);
return Integer.parseInt(va) - Integer.parseInt(vb);
}
return -1;
} }
return 1; return -1;
} }
}); return 1;
sort = false; }
} });
sort = false;
break; break;
} }
case "top": { case "top": {

View File

@ -215,7 +215,7 @@ public enum C {
/* /*
* Done * Done
*/ */
DONE_ALREADY_DONE("$2This plot is already marked as done, and you are not allowed to claim more plots","Done"), DONE_ALREADY_DONE("$2This plot is already marked as done","Done"),
DONE_NOT_DONE("$2This plot is not marked as done.","Done"), DONE_NOT_DONE("$2This plot is not marked as done.","Done"),
DONE_INSUFFICIENT_COMPLEXITY("$2This plot is too simple. Please add more detail before using this command.","Done"), DONE_INSUFFICIENT_COMPLEXITY("$2This plot is too simple. Please add more detail before using this command.","Done"),
DONE_SUCCESS("$1Successfully marked this plot as done.","Done"), DONE_SUCCESS("$1Successfully marked this plot as done.","Done"),

View File

@ -10,11 +10,13 @@ import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.Reader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -603,21 +605,23 @@ public abstract class SchematicHandler {
nos.close(); nos.close();
output.close(); output.close();
} }
// try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) { try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) {
// final char[] buffer = new char[256]; final char[] buffer = new char[256];
// StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
// while (true) { while (true) {
// int r = response.read(buffer); int r = response.read(buffer);
// if (r < 0) { if (r < 0) {
// break; break;
// } }
// result.append(buffer, 0, r); result.append(buffer, 0, r);
// } }
// System.out.print(result); if (!result.toString().equals("The file plot.schematic has been uploaded.")) {
// } PS.debug(result);
// catch (Exception e) { }
// e.printStackTrace(); }
// } catch (Exception e) {
e.printStackTrace();
}
int responseCode = ((HttpURLConnection) con).getResponseCode(); int responseCode = ((HttpURLConnection) con).getResponseCode();
if (responseCode != 200) { if (responseCode != 200) {
return null; return null;