Skip to content

Commit

Permalink
Fix consistency issues in /sub version
Browse files Browse the repository at this point in the history
The version command looks a little different in SubServers.Host. Let's fix that.
  • Loading branch information
ME1312 committed Oct 18, 2018
1 parent 52c6da2 commit a9f5c38
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 38 deletions.
39 changes: 29 additions & 10 deletions SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Launch.java
Expand Up @@ -48,19 +48,38 @@ public static void main(String[] args) throws Exception {
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("");
Expand Down
@@ -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
Expand Down
35 changes: 31 additions & 4 deletions SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java
Expand Up @@ -61,9 +61,36 @@ public void execute(CommandSender sender, String[] args) {
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("");
Expand Down Expand Up @@ -356,7 +383,7 @@ public void execute(CommandSender sender, String[] args) {
}
}
} 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) {
Expand Down
Expand Up @@ -44,9 +44,35 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
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("");
Expand Down
Expand Up @@ -147,13 +147,40 @@ public final class VERSION 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);
Expand Down
32 changes: 29 additions & 3 deletions SubServers.Host/src/net/ME1312/SubServers/Host/ExHost.java
Expand Up @@ -66,11 +66,37 @@ static void main(String[] args) throws Exception {
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)
Expand All @@ -84,8 +110,8 @@ static void main(String[] args) throws Exception {
} 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 + ')':""));
Expand Down
Expand Up @@ -266,7 +266,7 @@ public void command(String handle, String[] args) {
}
}
} 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(
Expand Down

0 comments on commit a9f5c38

Please sign in to comment.