Fix consistency issues in /sub version

The version command looks a little different in SubServers.Host. Let's fix that.
This commit is contained in:
ME1312 2018-10-17 23:17:23 -04:00
parent 52c6da2517
commit a9f5c387cc
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
10 changed files with 207 additions and 38 deletions

View File

@ -48,19 +48,38 @@ public final class Launch {
parser.accepts("noconsole");
joptsimple.OptionSet options = parser.parse(args);
if(options.has("version") || options.has("v")) {
boolean build = false;
try {
Field f = Version.class.getDeclaredField("type");
f.setAccessible(true);
build = f.get(SubPlugin.version) != VersionType.SNAPSHOT && SubPlugin.class.getPackage().getSpecificationTitle() != null;
f.setAccessible(false);
} catch (Exception e) {}
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
System.out.println("");
System.out.println(System.getProperty("os.name") + " " + System.getProperty("os.version") + ',');
System.out.println("Java " + System.getProperty("java.version") + ",");
System.out.println(System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"") + ',');
System.out.println("Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"") + ',');
System.out.println("BungeeCord" + ((patched)?" [Patched] ":" ") + net.md_5.bungee.Bootstrap.class.getPackage().getImplementationVersion() + ',');
System.out.println("SubServers.Bungee v" + SubPlugin.version.toExtendedString() + ((build)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("SubServers.Bungee v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("");
} else {
System.out.println("");

View File

@ -1,4 +1,4 @@
# SubCreator Sponge Forge Script
# SubCreator Sponge Forge Build Script
# Usage: "bash build.sh <forge version> <sponge version>"
#
#!/usr/bin/env bash

View File

@ -61,9 +61,36 @@ public final class SubCommand extends CommandX {
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
sender.sendMessages(printHelp());
} else if (args[0].equalsIgnoreCase("version") || args[0].equalsIgnoreCase("ver")) {
sender.sendMessage("SubServers > These are the platforms and versions that are running SubServers.Bungee:");
sender.sendMessage(" " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") + ',');
sender.sendMessage(" Java " + System.getProperty("java.version") + ',');
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
sender.sendMessage("SubServers > These are the platforms and versions that are running SubServers.Sync:");
sender.sendMessage(" " + System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"") + ',');
sender.sendMessage(" Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"") + ',');
sender.sendMessage(" " + plugin.getBungeeName() + ((plugin.isPatched)?" [Patched] ":" ") + net.md_5.bungee.Bootstrap.class.getPackage().getImplementationVersion() + ',');
sender.sendMessage(" SubServers.Bungee v" + SubPlugin.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
sender.sendMessage("");
@ -356,7 +383,7 @@ public final class SubCommand extends CommandX {
}
}
} else {
sender.sendMessage("SubServers > Usage: " + label + " " + args[1].toLowerCase() + " [proxy|host|group|server] <Name>");
sender.sendMessage("SubServers > Usage: " + label + " " + args[0].toLowerCase() + " [proxy|host|group|server] <Name>");
}
} else if (args[0].equalsIgnoreCase("start")) {
if (args.length > 1) {

View File

@ -44,9 +44,35 @@ public final class SubCommand implements CommandExecutor {
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
sender.sendMessage(printHelp(label));
} else if (args[0].equalsIgnoreCase("version") || args[0].equalsIgnoreCase("ver")) {
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Version").replace("$str$", "SubServers.Client.Bukkit"));
sender.sendMessage(ChatColor.WHITE + " " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") + ChatColor.RESET + ',');
sender.sendMessage(ChatColor.WHITE + " Java " + System.getProperty("java.version") + ChatColor.RESET + ',');
sender.sendMessage(ChatColor.WHITE + " " + System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"") + ChatColor.RESET + ',');
sender.sendMessage(ChatColor.WHITE + " Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"") + ChatColor.RESET + ',');
sender.sendMessage(ChatColor.WHITE + " " + Bukkit.getName() + ' ' + Bukkit.getVersion() + ChatColor.RESET + ',');
sender.sendMessage(ChatColor.WHITE + " SubServers.Client.Bukkit v" + plugin.version.toExtendedString() + ((plugin.api.getPluginBuild() != null)?" (" + plugin.api.getPluginBuild() + ')':""));
sender.sendMessage("");

View File

@ -147,13 +147,40 @@ public final class SubCommand implements CommandExecutor {
@SuppressWarnings("unchecked")
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
if (canRun(sender)) {
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
PluginContainer container = null;
if (container == null) container = Util.getDespiteException(() -> (PluginContainer) Platform.class.getMethod("getContainer", Class.forName("org.spongepowered.api.Platform$Component")).invoke(Sponge.getPlatform(), Enum.valueOf((Class<Enum>) Class.forName("org.spongepowered.api.Platform$Component"), "IMPLEMENTATION")), null);
if (container == null) container = Util.getDespiteException(() -> (PluginContainer) Platform.class.getMethod("getImplementation").invoke(Sponge.getPlatform()), null);
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Version").replace("$str$", "SubServers.Client.Sponge")));
sender.sendMessage(Text.builder(" " + System.getProperty("os.name") + ' ' + System.getProperty("os.version")).color(TextColors.WHITE).append(Text.of(",")).build());
sender.sendMessage(Text.builder(" Java " + System.getProperty("java.version")).color(TextColors.WHITE).append(Text.of(",")).build());
sender.sendMessage(Text.builder(" " + System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"")).color(TextColors.WHITE).append(Text.of(",")).build());
sender.sendMessage(Text.builder(" Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"")).color(TextColors.WHITE).append(Text.of(",")).build());
sender.sendMessage(Text.builder(" " + container.getName() + ' ' + container.getVersion().get()).color(TextColors.WHITE).append(Text.of(",")).build());
sender.sendMessage(Text.builder(" SubServers.Client.Sponge v" + plugin.version.toExtendedString() + ((plugin.api.getPluginBuild() != null)?" (" + plugin.api.getPluginBuild() + ')':"")).color(TextColors.WHITE).build());
sender.sendMessage(Text.EMPTY);

View File

@ -66,11 +66,37 @@ public final class ExHost {
parser.accepts("noconsole");
joptsimple.OptionSet options = parser.parse(args);
if(options.has("version") || options.has("v")) {
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
Version galaxi = Version.fromString(GalaxiEngine.class.getAnnotation(Plugin.class).version());
Version subservers = Version.fromString(ExHost.class.getAnnotation(Plugin.class).version());
Version galaxibuild = null;
Version subserversbuild = null;
try {
Manifest manifest = new Manifest(GalaxiEngine.class.getResourceAsStream("/META-INF/GalaxiEngine.MF"));
if (manifest.getMainAttributes().getValue("Implementation-Version") != null && manifest.getMainAttributes().getValue("Implementation-Version").length() > 0)
@ -84,8 +110,8 @@ public final class ExHost {
} catch (Exception e) {}
System.out.println("");
System.out.println(System.getProperty("os.name") + " " + System.getProperty("os.version") + ',');
System.out.println("Java " + System.getProperty("java.version") + ",");
System.out.println(System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"") + ',');
System.out.println("Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"") + ',');
System.out.println(GalaxiEngine.class.getAnnotation(Plugin.class).name() + " v" + galaxi.toExtendedString() + ((galaxibuild != null)?" (" + galaxibuild + ')':"")
+ ((GalaxiEngine.class.getProtectionDomain().getCodeSource().getLocation().equals(ExHost.class.getProtectionDomain().getCodeSource().getLocation()))?" [Patched]":"") + ',');
System.out.println(ExHost.class.getAnnotation(Plugin.class).name() + " v" + subservers.toExtendedString() + ((subserversbuild != null)?" (" + subserversbuild + ')':""));

View File

@ -266,7 +266,7 @@ public class SubCommand {
}
}
} else {
host.log.message.println("SubServers > Usage: " + handle + " " + args[1].toLowerCase() + " [proxy|host|group|server] <Name>");
host.log.message.println("SubServers > Usage: /" + handle + " [proxy|host|group|server] <Name>");
}
}
}.usage("[proxy|host|group|server]", "<Name>").description("Gets information about an Object").help(

View File

@ -48,19 +48,38 @@ public final class Launch {
parser.accepts("noconsole");
joptsimple.OptionSet options = parser.parse(args);
if(options.has("version") || options.has("v")) {
boolean build = false;
try {
Field f = Version.class.getDeclaredField("type");
f.setAccessible(true);
build = f.get(SubPlugin.version) != VersionType.SNAPSHOT && SubPlugin.class.getPackage().getSpecificationTitle() != null;
f.setAccessible(false);
} catch (Exception e) {}
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
System.out.println("");
System.out.println(System.getProperty("os.name") + " " + System.getProperty("os.version") + ',');
System.out.println("Java " + System.getProperty("java.version") + ",");
System.out.println(System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"") + ',');
System.out.println("Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"") + ',');
System.out.println("BungeeCord" + ((patched)?" [Patched] ":" ") + net.md_5.bungee.Bootstrap.class.getPackage().getImplementationVersion() + ',');
System.out.println("SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((build)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("");
} else {
System.out.println("");

View File

@ -59,9 +59,36 @@ public final class SubCommand extends CommandX {
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
sender.sendMessages(printHelp());
} else if (args[0].equalsIgnoreCase("version") || args[0].equalsIgnoreCase("ver")) {
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
sender.sendMessage("SubServers > These are the platforms and versions that are running SubServers.Sync:");
sender.sendMessage(" " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") + ',');
sender.sendMessage(" Java " + System.getProperty("java.version") + ',');
sender.sendMessage(" " + System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"") + ',');
sender.sendMessage(" Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"") + ',');
sender.sendMessage(" " + plugin.getBungeeName() + ((plugin.isPatched)?" [Patched] ":" ") + net.md_5.bungee.Bootstrap.class.getPackage().getImplementationVersion() + ',');
sender.sendMessage(" SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
sender.sendMessage("");
@ -302,7 +329,7 @@ public final class SubCommand extends CommandX {
}
}
} else {
sender.sendMessage("SubServers > Usage: " + label + " " + args[1].toLowerCase() + " [proxy|host|group|server] <Name>");
sender.sendMessage("SubServers > Usage: " + label + " " + args[0].toLowerCase() + " [proxy|host|group|server] <Name>");
}
} else if (args[0].equalsIgnoreCase("start")) {
if (args.length > 1) {

View File

@ -380,12 +380,10 @@ public final class SubPlugin extends BungeeCord implements Listener {
}
public void connect(ServerContainer server, String address) {
System.out.println("SubServers > Networked Server: " + server.getName());
server.setSubData(address);
}
public void disconnect(ServerContainer server) {
System.out.println("SubServers > Unnetworked Server: " + server.getName());
server.setSubData(null);
}