From ffa696b9632c95cb04a931836fea7b5cb5de9eca Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Fri, 22 Jun 2018 14:37:29 -0300 Subject: [PATCH] LoggerWrapper changes, @Getter --- .../us/myles/ViaVersion/SpongePlugin.java | 12 +-- .../ViaVersion/sponge/util/LoggerWrapper.java | 96 ++++--------------- 2 files changed, 22 insertions(+), 86 deletions(-) diff --git a/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java b/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java index dd2ea5b66..7ca0ac3f6 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java +++ b/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java @@ -55,7 +55,9 @@ public class SpongePlugin implements ViaPlatform { @DefaultConfig(sharedRoot = false) private File defaultConfig; + @Getter private SpongeViaAPI api = new SpongeViaAPI(); + @Getter private SpongeConfigAPI conf; @Getter @@ -191,16 +193,6 @@ public class SpongePlugin implements ViaPlatform { return true; } - @Override - public ViaAPI getApi() { - return api; - } - - @Override - public SpongeConfigAPI getConf() { - return conf; - } - @Override public ConfigurationProvider getConfigurationProvider() { return conf; diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/util/LoggerWrapper.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/util/LoggerWrapper.java index 8c69bf2d4..819019c8f 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/util/LoggerWrapper.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/util/LoggerWrapper.java @@ -2,6 +2,7 @@ package us.myles.ViaVersion.sponge.util; import org.slf4j.Logger; +import java.text.MessageFormat; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -20,106 +21,49 @@ public class LoggerWrapper extends java.util.logging.Logger { @Override public void log(Level level, String msg) { - if (level == Level.FINEST) { - base.trace(msg); - return; - } - if (level == Level.FINE) { + if (level == Level.FINE) base.debug(msg); - return; - } - if (level == Level.WARNING) { + else if (level == Level.WARNING) base.warn(msg); - return; - } - if (level == Level.SEVERE) { + else if (level == Level.SEVERE) base.error(msg); - return; - } - if (level == Level.INFO) { + else if (level == Level.INFO) base.info(msg); - return; - } - base.trace(msg); - return; + else + base.trace(msg); } @Override public void log(Level level, String msg, Object param1) { - if (level == Level.FINEST) { - base.trace(msg, param1); - return; - } - if (level == Level.FINE) { + if (level == Level.FINE) base.debug(msg, param1); - return; - } - if (level == Level.WARNING) { + else if (level == Level.WARNING) base.warn(msg, param1); - return; - } - if (level == Level.SEVERE) { + else if (level == Level.SEVERE) base.error(msg, param1); - return; - } - if (level == Level.INFO) { + else if (level == Level.INFO) base.info(msg, param1); - return; - } - base.trace(msg, param1); - return; + else + base.trace(msg, param1); } @Override public void log(Level level, String msg, Object[] params) { - if (level == Level.FINEST) { - base.trace(msg, params); - return; - } - if (level == Level.FINE) { - base.debug(msg, params); - return; - } - if (level == Level.WARNING) { - base.warn(msg, params); - return; - } - if (level == Level.SEVERE) { - base.error(msg, params); - return; - } - if (level == Level.INFO) { - base.info(msg, params); - return; - } - base.trace(msg, params); - return; + log(level, MessageFormat.format(msg, params)); // workaround not formatting correctly } @Override public void log(Level level, String msg, Throwable params) { - if (level == Level.FINEST) { - base.trace(msg, params); - return; - } - if (level == Level.FINE) { + if (level == Level.FINE) base.debug(msg, params); - return; - } - if (level == Level.WARNING) { + else if (level == Level.WARNING) base.warn(msg, params); - return; - } - if (level == Level.SEVERE) { + else if (level == Level.SEVERE) base.error(msg, params); - return; - } - if (level == Level.INFO) { + else if (level == Level.INFO) base.info(msg, params); - return; - } - base.trace(msg, params); - return; + else + base.trace(msg, params); } }