diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 7ee59060..26a0f975 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -77,6 +77,11 @@ fastlogin.paperlib + + + + + @@ -147,9 +152,9 @@ - com.destroystokyo.paper + io.papermc.paper paper-api - 1.15.2-R0.1-SNAPSHOT + 1.18-R0.1-SNAPSHOT provided @@ -158,7 +163,6 @@ io.papermc paperlib 1.0.7 - compile diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java index c3171bc0..1450fc17 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java @@ -79,7 +79,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPluginfastlogin.slf4j + + + + + @@ -120,8 +125,15 @@ net.md-5 bungeecord-proxy - 1.16-R0.5-SNAPSHOT + 1.18-R0.1-SNAPSHOT provided + + + + org.slf4j + slf4j-api + + diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java index b2a8648f..5346bf8b 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java @@ -81,7 +81,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin(this); diff --git a/core/pom.xml b/core/pom.xml index 4436d965..12ceed39 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -68,6 +68,14 @@ com.zaxxer HikariCP 4.0.3 + + + + + org.slf4j + slf4j-api + + @@ -149,17 +157,5 @@ gson 2.8.9 - - - org.slf4j - slf4j-api - 2.0.0-alpha5 - - - org.slf4j - slf4j-simple - 2.0.0-alpha5 - runtime - diff --git a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java index f2803c4b..81b54b98 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java @@ -70,7 +70,24 @@ public class CommonUtil { return new String(chars); } - public static Logger createLoggerFromJDK(java.util.logging.Logger parent) { + /** + * This creates a SLF4J logger. In the process it initializes the SLF4J service provider. This method looks + * for the provider in the plugin jar instead of in the server jar when creating a Logger. The provider is only + * initialized once, so this method should be called early. + * + * The provider is bound to the service class `SLF4JServiceProvider`. Relocating this class makes it available + * for exclusive own usage. Other dependencies will use the relocated service too, and therefore will find the + * initialized provider. + * + * @param parent JDK logger + * @return slf4j logger + */ + public static Logger initializeLoggerService(java.util.logging.Logger parent) { + // set the class loader to the plugin one to find our own SLF4J provider in the plugin jar and not in the global + ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); + + ClassLoader pluginLoader = CommonUtil.class.getClassLoader(); + Thread.currentThread().setContextClassLoader(pluginLoader); try { parent.setLevel(Level.ALL); @@ -82,6 +99,9 @@ public class CommonUtil { parent.log(Level.WARNING, "Cannot create slf4j logging adapter", reflectEx); parent.log(Level.WARNING, "Creating logger instance manually..."); return LoggerFactory.getLogger(parent.getName()); + } finally { + // restore previous class loader + Thread.currentThread().setContextClassLoader(oldLoader); } }