diff --git a/SubServers.Host/src/net/ME1312/SubServers/Host/ExHost.java b/SubServers.Host/src/net/ME1312/SubServers/Host/ExHost.java index 93df0d5e..1c05b943 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/ExHost.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/ExHost.java @@ -16,6 +16,7 @@ import net.ME1312.Galaxi.Library.Version.VersionType; import net.ME1312.Galaxi.Plugin.Plugin; import net.ME1312.Galaxi.Plugin.PluginInfo; import net.ME1312.SubServers.Host.Executable.SubCreator; +import net.ME1312.SubServers.Host.Executable.SubLogger; import net.ME1312.SubServers.Host.Executable.SubServer; import net.ME1312.SubServers.Host.Library.*; import net.ME1312.SubServers.Host.Network.Cipher; @@ -190,6 +191,9 @@ public final class ExHost { } } + Util.reflect(SubLogger.class.getDeclaredField("logn"), null, config.get().getSection("Settings").getBoolean("Network-Log", true)); + Util.reflect(SubLogger.class.getDeclaredField("logc"), null, config.get().getSection("Settings").getBoolean("Console-Log", true)); + engine.getPluginManager().loadPlugins(new UniversalFile(engine.getRuntimeDirectory(), "Plugins")); running = true; @@ -253,6 +257,13 @@ public final class ExHost { config.reload(); + try { + Util.reflect(SubLogger.class.getDeclaredField("logn"), null, config.get().getSection("Settings").getBoolean("Network-Log", true)); + Util.reflect(SubLogger.class.getDeclaredField("logc"), null, config.get().getSection("Settings").getBoolean("Console-Log", true)); + } catch (Exception e) { + e.printStackTrace(); + } + Cipher cipher = null; if (!config.get().getSection("Settings").getSection("SubData").getRawString("Encryption", "NONE").equalsIgnoreCase("NONE")) { if (config.get().getSection("Settings").getSection("SubData").getString("Password", "").length() == 0) { diff --git a/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubLogger.java b/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubLogger.java index b1590d60..0dbdf235 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubLogger.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubLogger.java @@ -23,6 +23,8 @@ public class SubLogger { protected final String name; protected UUID address; protected Container log; + protected static boolean logn = true; + protected static boolean logc = true; protected File file; private PrintWriter writer = null; private boolean started = false; @@ -71,12 +73,10 @@ public class SubLogger { @SuppressWarnings("deprecation") private void start(InputStream in, boolean isErr) { try { - boolean network = SubAPI.getInstance().getInternals().config.get().getSection("Settings").getBoolean("Network-Log", true), - console = SubAPI.getInstance().getInternals().config.get().getSection("Settings").getBoolean("Console-Log", true); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; while ((line = br.readLine()) != null) { - log(line, network, console); + log(line); } } catch (IOException e) {} finally { if (isErr) { @@ -89,7 +89,7 @@ public class SubLogger { } } - private void log(String line, boolean network, boolean console) { + private void log(String line) { if (!line.startsWith(">")) { String msg = line; LogStream level; @@ -121,10 +121,10 @@ public class SubLogger { } // Log to NETWORK - if (log.get() && network) SubAPI.getInstance().getSubDataNetwork().sendPacket(new PacketOutExLogMessage(address, line)); + if (log.get() && logn) SubAPI.getInstance().getSubDataNetwork().sendPacket(new PacketOutExLogMessage(address, line)); // Log to CONSOLE - if (log.get() && console) level.println(TextColor.convertColor(msg)); + if (log.get() && logc) level.println(TextColor.convertColor(msg)); // Log to FILE if (writer != null) {