From 08e3e202e3b7fdde0dae6d58f2c894986ff680b1 Mon Sep 17 00:00:00 2001 From: ME1312 Date: Sat, 25 May 2019 18:53:23 -0400 Subject: [PATCH] Fix bug in first-time RSA setup --- .../net/ME1312/SubServers/Bungee/Launch.java | 13 ++++++------- .../ME1312/SubServers/Bungee/SubPlugin.java | 1 + .../net/ME1312/SubServers/Sync/Launch.java | 19 +++++++------------ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Launch.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Launch.java index 7b615ab9..d7b8119c 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Launch.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Launch.java @@ -8,7 +8,6 @@ import java.security.Security; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; -import java.util.jar.Manifest; import java.util.logging.Logger; /** @@ -87,9 +86,11 @@ public final class Launch { System.out.println("SubServers.Bungee v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':"")); System.out.println(""); } else { - boolean gb; - if (!(gb = !Util.isException(() -> Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null, - Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Bungee.")))) { + boolean gb = Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").getReturnType().equals(Class.forName("net.ME1312.Galaxi.Plugin.PluginInfo")), false); + if (gb) { + Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null, + Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Bungee."); + } else { System.out.println(""); System.out.println("*******************************************"); System.out.println("*** Warning: this build is unofficial ***"); @@ -126,14 +127,12 @@ public final class Launch { plugin.start(); if (!options.has("noconsole")) { - try { + if (!gb) try { if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands") != null, false)) { // Waterfall Setup Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands").invoke(null); } else if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("start") != null, false)) { Class console = Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole"); console.getMethod("start").invoke(console.getConstructor().newInstance()); - } else if (Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").invoke(null).getClass().getCanonicalName().equals("net.ME1312.Galaxi.Plugin.PluginInfo"), false)) { - // GalaxiBungee initializes its console automatically } else { plugin.canSudo = true; String line; diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java index da766b66..8e52e070 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java @@ -318,6 +318,7 @@ public final class SubPlugin extends BungeeCord implements Listener { } else if (ciphers[0].equals("RSA") || ciphers[0].equals("RSA-2048") || ciphers[0].equals("RSA-3072") || ciphers[0].equals("RSA-4096")) { try { int length = (ciphers[0].contains("-"))?Integer.parseInt(ciphers[0].split("-")[1]):2048; + if (!(new UniversalFile("SubServers:Cache").exists())) new UniversalFile("SubServers:Cache").mkdirs(); subprotocol.registerCipher("RSA", new RSA(length, new UniversalFile("SubServers:Cache:private.rsa.key"), new UniversalFile("SubServers:subdata.rsa.key"))); cipher = "RSA" + cipher.substring(ciphers[0].length()); diff --git a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Launch.java b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Launch.java index d767b497..157f6f3f 100644 --- a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Launch.java +++ b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Launch.java @@ -1,12 +1,9 @@ package net.ME1312.SubServers.Sync; -import net.ME1312.Galaxi.Library.Container; import net.ME1312.Galaxi.Library.Util; import net.ME1312.Galaxi.Library.Version.Version; -import net.ME1312.Galaxi.Library.Version.VersionType; import net.ME1312.SubServers.Sync.Library.Compatibility.GalaxiInfo; -import java.lang.reflect.Field; import java.security.Security; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -24,7 +21,7 @@ public final class Launch { * @param args Launch Arguments * @throws Exception */ - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation", "unchecked"}) public static void main(String[] args) throws Exception { System.setProperty("apple.laf.useScreenMenuBar", "true"); @@ -89,9 +86,11 @@ public final class Launch { System.out.println("SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':"")); System.out.println(""); } else { - boolean gb; - if (!(gb = !Util.isException(() -> Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null, - Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Sync.")))) { + boolean gb = Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").getReturnType().equals(Class.forName("net.ME1312.Galaxi.Plugin.PluginInfo")), false); + if (gb) { + Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null, + Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Sync."); + } else { System.out.println(""); System.out.println("*******************************************"); System.out.println("*** Warning: this build is Unofficial ***"); @@ -120,8 +119,6 @@ public final class Launch { System.out.println("*******************************************"); } System.out.println(""); - } else { - } SubPlugin plugin = new SubPlugin(System.out, patched); @@ -130,14 +127,12 @@ public final class Launch { plugin.start(); if (!options.has("noconsole")) { - try { + if (!gb) try { if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands") != null, false)) { // Waterfall Setup Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands").invoke(null); } else if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("start") != null, false)) { Class console = Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole"); console.getMethod("start").invoke(console.getConstructor().newInstance()); - } else if (Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").invoke(null).getClass().getCanonicalName().equals("net.ME1312.Galaxi.Plugin.PluginInfo"), false)) { - // GalaxiBungee initializes its console automatically } else { String line; while (plugin.isRunning && (line = plugin.getConsoleReader().readLine(">")) != null) {