mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Feedback for failed uploads + fix plot list done
This commit is contained in:
parent
ac27a7f37a
commit
552ace359a
@ -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");
|
||||||
|
@ -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,16 +196,22 @@ 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) {
|
||||||
@ -213,7 +219,7 @@ public class list extends SubCommand {
|
|||||||
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(va) - Integer.parseInt(vb);
|
return Integer.parseInt(vb) - Integer.parseInt(va);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -221,7 +227,6 @@ public class list extends SubCommand {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
sort = false;
|
sort = false;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "top": {
|
case "top": {
|
||||||
|
@ -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"),
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user