Add placeholders/warnings for when minecraft versions cannot be detected

This commit is contained in:
ME1312 2018-05-23 00:26:03 -04:00
parent 0e87345a8b
commit 1ff9a5cf41
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
19 changed files with 26 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -675,7 +675,14 @@ public final class SubAPI {
return new Version(System.getProperty("subservers.minecraft.version"));
} else {
String raw = plugin.getGameVersion();
if (raw.contains(",")) {
if (raw == null) {
if (System.getProperty("subservers.minecraft.version.unknown", "false").equalsIgnoreCase("false")) {
System.setProperty("subservers.minecraft.version.unknown", "true");
System.out.println("Could not determine compatible Minecraft version(s); Now using 1.x.x as a placeholder.");
System.out.println("Use this launch argument to specify a compatible Minecraft version: -Dsubservers.minecraft.version=1.x.x");
}
return new Version("1.x.x");
} else if (raw.contains(",")) {
String[] split = raw.split(",\\s*");
return new Version(split[split.length - 1]);
} else if (raw.contains("-")) {

Binary file not shown.

View File

@ -141,7 +141,12 @@ public final class SubAPI {
try {
return new Version(Bukkit.getBukkitVersion().split("-")[0]);
} catch (ArrayIndexOutOfBoundsException e) {
return new Version(plugin.version.toString().substring(0, plugin.version.toString().length() - 1));
if (System.getProperty("subservers.minecraft.version.unknown", "false").equalsIgnoreCase("false")) {
System.setProperty("subservers.minecraft.version.unknown", "true");
System.out.println("Could not determine this server's game version; Now using 1.x.x as a placeholder.");
System.out.println("Use this launch argument to specify what version this server serves: -Dsubservers.minecraft.version=1.x.x");
}
return new Version("1.x.x");
}
}
}

Binary file not shown.

View File

@ -507,6 +507,8 @@ public final class ExHost {
}
if (subdata != null) Util.isException(() -> subdata.destroy(0));
if (new File(dir, "Templates").exists()) Util.deleteDirectory(new File(dir, "Templates"));
Util.isException(FileLogger::end);
System.exit(exit);
}

View File

@ -19,7 +19,7 @@ public final class FileLogger extends OutputStream {
this.origin = origin;
if (file == null) {
new File(dir, "Logs").mkdirs();
file = new FileWriter(new File(dir, "Logs" + File.separator + "SubServers #" + (new File(dir, "Logs").list().length + 1) + " (" + new SimpleDateFormat("MM-dd-yyyy").format(Calendar.getInstance().getTime()) + ").log"));
file = new FileWriter(new File(dir, "Logs" + File.separator + "SubServers.Host #" + (new File(dir, "Logs").list().length + 1) + " (" + new SimpleDateFormat("MM-dd-yyyy").format(Calendar.getInstance().getTime()) + ").log"));
}
}

View File

@ -89,7 +89,7 @@ public final class SubAPI {
*/
public void addCommand(Command command, String... handles) {
for (String handle : handles) {
commands.put(handle, command);
commands.put(handle.toLowerCase(), command);
}
}

Binary file not shown.

View File

@ -150,7 +150,14 @@ public final class SubAPI {
return new Version(System.getProperty("subservers.minecraft.version"));
} else {
String raw = plugin.getGameVersion();
if (raw.contains(",")) {
if (raw == null) {
if (System.getProperty("subservers.minecraft.version.unknown", "false").equalsIgnoreCase("false")) {
System.setProperty("subservers.minecraft.version.unknown", "true");
System.out.println("Could not determine compatible Minecraft version(s); Now using 1.x.x as a placeholder.");
System.out.println("Use this launch argument to specify a compatible Minecraft version: -Dsubservers.minecraft.version=1.x.x");
}
return new Version("1.x.x");
} else if (raw.contains(",")) {
String[] split = raw.split(",\\s*");
return new Version(split[split.length - 1]);
} else if (raw.contains("-")) {