From 3abb437c5bf2bafd1d8b6778714e73de7bb5a573 Mon Sep 17 00:00:00 2001 From: Minecon724 <39800107+Minecon724@users.noreply.github.com> Date: Sat, 20 Jan 2024 12:17:20 +0000 Subject: [PATCH] release 0.5.0.1 fixed oopsie namely disabled logging by default it can be enabled by adding "logging: true" to body of config.yml --- pom.xml | 2 +- src/main/java/pl/minecon724/realweather/RW.java | 5 ++++- .../java/pl/minecon724/realweather/SubLogger.java | 12 ++++++++---- src/main/resources/config.yml | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 71ed2b7..0a1bb26 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 pl.minecon724 realweather - 0.5.0 + 0.5.0.1 17 diff --git a/src/main/java/pl/minecon724/realweather/RW.java b/src/main/java/pl/minecon724/realweather/RW.java index 42e5b3d..0c19e40 100644 --- a/src/main/java/pl/minecon724/realweather/RW.java +++ b/src/main/java/pl/minecon724/realweather/RW.java @@ -22,7 +22,10 @@ public class RW extends JavaPlugin { saveDefaultConfig(); config = getConfig(); - SubLogger.init(getLogger()); + SubLogger.init( + getLogger(), + config.getBoolean("logging", false) + ); WorldMap.init( config.getConfigurationSection("map") diff --git a/src/main/java/pl/minecon724/realweather/SubLogger.java b/src/main/java/pl/minecon724/realweather/SubLogger.java index 8076e3f..7c7887a 100644 --- a/src/main/java/pl/minecon724/realweather/SubLogger.java +++ b/src/main/java/pl/minecon724/realweather/SubLogger.java @@ -4,11 +4,13 @@ import java.util.logging.Level; import java.util.logging.Logger; public class SubLogger { - private static Logger logger; + private static Logger LOGGER; + private static boolean ENABLED; private String name; - static void init(Logger loger) { - logger = loger; + static void init(Logger logger, boolean enabled) { + LOGGER = logger; + ENABLED = enabled; } public SubLogger(String name) { @@ -16,11 +18,13 @@ public class SubLogger { } public void log(Level level, String format, Object... args) { + if (!ENABLED) return; + Object[] combinedArgs = new Object[args.length + 1]; combinedArgs[0] = name; System.arraycopy(args, 0, combinedArgs, 1, args.length); - logger.log(level, String.format("[%s] " + format, combinedArgs)); + LOGGER.log(level, String.format("[%s] " + format, combinedArgs)); } public void info(String format, Object... args) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 243ab27..a121267 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -64,4 +64,4 @@ time: # each player has time offset like timezones # uses timezone as base, unless auto # uses settings from map - per_player: false + per_player: false \ No newline at end of file