diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java index 7b2f3d01f..002e29337 100644 --- a/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/src/main/java/com/intellectualcrafters/plot/PS.java @@ -1647,6 +1647,13 @@ public class PS { for (final String flag : intFlags) { 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("analysis", new FlagValue.IntegerListValue()), true); 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.done.counts-towards-limit", Settings.DONE_COUNTS_TOWARDS_LIMIT); options.put("approval.done.restrict-building", Settings.DONE_RESTRICTS_BUILDING); + options.put("approval.done.required-for-download", Settings.DOWNLOAD_REQUIRES_DONE); // Schematics 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.DONE_COUNTS_TOWARDS_LIMIT = config.getBoolean("approval.done.counts-towards-limit"); Settings.DONE_RESTRICTS_BUILDING = config.getBoolean("approval.done.restrict-building"); + Settings.DOWNLOAD_REQUIRES_DONE = config.getBoolean("approval.done.required-for-download"); // Schematics Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/list.java b/src/main/java/com/intellectualcrafters/plot/commands/list.java index aae23fddf..a294fc796 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -104,7 +104,7 @@ public class list extends SubCommand { args.add(""); } if (Permissions.hasPermission(player, "plots.list.done")) { - args.add(""); + args.add("done"); } return args.toArray(new String[args.size()]); } @@ -188,7 +188,7 @@ public class list extends SubCommand { plots = new ArrayList<>(); String match; if (args.length == 2) { - match = args[2]; + match = args[1]; } else { match = null; @@ -196,32 +196,37 @@ public class list extends SubCommand { for (Plot plot : PS.get().getPlots()) { Flag flag = plot.getSettings().flags.get("done"); if (flag == null) { - return false; + continue; } if (match != null) { - flag.getValueString().matches(match); + try { + if (flag.getValueString().matches(match)) { + plots.add(plot); + } + } + catch (Exception e) { + break; + } } else { plots.add(plot); } } - if (match != null) { - Collections.sort(plots, new Comparator() { - @Override - public int compare(Plot a, Plot b) { - String va = a.getSettings().flags.get("done").getValueString(); - String vb = b.getSettings().flags.get("done").getValueString(); - if (MathMan.isInteger(va)) { - if (MathMan.isInteger(vb)) { - return Integer.parseInt(va) - Integer.parseInt(vb); - } - return -1; + Collections.sort(plots, new Comparator() { + @Override + public int compare(Plot a, Plot b) { + String va = a.getSettings().flags.get("done").getValueString(); + String vb = b.getSettings().flags.get("done").getValueString(); + if (MathMan.isInteger(va)) { + if (MathMan.isInteger(vb)) { + return Integer.parseInt(vb) - Integer.parseInt(va); } - return 1; + return -1; } - }); - sort = false; - } + return 1; + } + }); + sort = false; break; } case "top": { diff --git a/src/main/java/com/intellectualcrafters/plot/config/C.java b/src/main/java/com/intellectualcrafters/plot/config/C.java index dcdc9e24a..0240131bc 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -215,7 +215,7 @@ public enum C { /* * 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_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"), diff --git a/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index a98c13a60..45223eb68 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -10,11 +10,13 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Reader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -603,21 +605,23 @@ public abstract class SchematicHandler { nos.close(); output.close(); } -// try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) { -// final char[] buffer = new char[256]; -// StringBuilder result = new StringBuilder(); -// while (true) { -// int r = response.read(buffer); -// if (r < 0) { -// break; -// } -// result.append(buffer, 0, r); -// } -// System.out.print(result); -// } -// catch (Exception e) { -// e.printStackTrace(); -// } + try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) { + final char[] buffer = new char[256]; + StringBuilder result = new StringBuilder(); + while (true) { + int r = response.read(buffer); + if (r < 0) { + break; + } + result.append(buffer, 0, r); + } + if (!result.toString().equals("The file plot.schematic has been uploaded.")) { + PS.debug(result); + } + } + catch (Exception e) { + e.printStackTrace(); + } int responseCode = ((HttpURLConnection) con).getResponseCode(); if (responseCode != 200) { return null;