diff --git a/buildscript/loader.gradle b/buildscript/loader.gradle
index 7eeb63d6..34282c51 100644
--- a/buildscript/loader.gradle
+++ b/buildscript/loader.gradle
@@ -5,7 +5,4 @@ apply from: rootProject.file('buildscript/final.gradle')
shadowJar {
// Include the bootstrap
from parent.tasks.shadowJar.archiveFile
-
- // Relocate the dependency
- relocate 'dev.vankka.mcdependencydownload', 'com.discordsrv.dependencies.dev.vankka.mcdependencydownload'
}
diff --git a/buildscript/relocations.gradle b/buildscript/relocations.gradle
index 67ed42f8..559545a3 100644
--- a/buildscript/relocations.gradle
+++ b/buildscript/relocations.gradle
@@ -2,11 +2,18 @@
shadowJar {
[
- // JDA, Trove, WS, okhttp
+ // JDA, WS
'net.dv8tion.jda',
'com.iwebpp',
- 'gnu.trove',
'com.neovisionaries.ws',
+
+ // Trove
+ 'gnu.trove',
+
+ // Jackson
+ 'com.fasterxml.jackson',
+
+ // okhttp
'okhttp3',
'okio',
@@ -46,4 +53,11 @@ shadowJar {
].each {
relocate it, 'com.discordsrv.dependencies.' + it
}
+
+ // SLF4J
+ relocate('org.slf4j', 'com.discordsrv.dependencies.org.slf4j') {
+ include('*')
+ exclude('com.discordsrv.logging.impl.SLF4JLoggerImpl')
+ exclude('com.discordsrv.velocity.DiscordSRVVelocityBootstrap')
+ }
}
diff --git a/bukkit/build.gradle b/bukkit/build.gradle
index cc1c380d..04265e92 100644
--- a/bukkit/build.gradle
+++ b/bukkit/build.gradle
@@ -16,7 +16,8 @@ allprojects {
dependencies {
// Common
- implementation project(':common:common-server')
+ compileOnly project(':common:common-server')
+ implementation project(path: ':common:common-server', configuration: 'runtimeElements')
// DependencyDownload
implementation 'dev.vankka.minecraftdependencydownload:bukkit:' + rootProject.mddVersion
diff --git a/bukkit/loader/build.gradle b/bukkit/loader/build.gradle
index 8e0ccebf..7a922f5d 100644
--- a/bukkit/loader/build.gradle
+++ b/bukkit/loader/build.gradle
@@ -4,7 +4,7 @@ apply from: rootProject.file('buildscript/loader.gradle')
dependencies {
// API
- implementation project(':api')
+ implementation project(':common:common-api')
// DependencyDownload
implementation 'dev.vankka.minecraftdependencydownload:bukkit-loader:' + rootProject.mddVersion
diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java
index 0cb53b4b..ff09e967 100644
--- a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java
+++ b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java
@@ -29,7 +29,7 @@ import com.discordsrv.bukkit.player.BukkitPlayerProvider;
import com.discordsrv.bukkit.scheduler.BukkitScheduler;
import com.discordsrv.common.config.manager.ConnectionConfigManager;
import com.discordsrv.common.config.manager.MainConfigManager;
-import com.discordsrv.common.logging.logger.Logger;
+import com.discordsrv.logging.Logger;
import com.discordsrv.common.server.ServerDiscordSRV;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.Server;
diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java b/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java
index 0d25663b..68ddc08f 100644
--- a/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java
+++ b/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java
@@ -19,8 +19,8 @@
package com.discordsrv.bukkit;
import com.discordsrv.common.dependency.InitialDependencyLoader;
-import com.discordsrv.common.logging.logger.Logger;
-import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
+import com.discordsrv.logging.Logger;
+import com.discordsrv.logging.impl.JavaLoggerImpl;
import dev.vankka.mcdependencydownload.bukkit.bootstrap.BukkitBootstrap;
import dev.vankka.mcdependencydownload.classloader.JarInJarClassLoader;
import org.bukkit.plugin.java.JavaPlugin;
diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java b/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java
index d89a1b14..0eed3bf1 100644
--- a/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java
+++ b/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java
@@ -20,9 +20,9 @@ package com.discordsrv.bukkit.console;
import com.discordsrv.bukkit.BukkitDiscordSRV;
import com.discordsrv.common.console.Console;
-import com.discordsrv.common.logging.logger.backend.LoggingBackend;
-import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
-import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
+import com.discordsrv.logging.backend.LoggingBackend;
+import com.discordsrv.logging.impl.JavaLoggerImpl;
+import com.discordsrv.logging.impl.Log4JLoggerImpl;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
diff --git a/bungee/loader/build.gradle b/bungee/loader/build.gradle
index 6d99de09..d66400c8 100644
--- a/bungee/loader/build.gradle
+++ b/bungee/loader/build.gradle
@@ -4,7 +4,7 @@ apply from: rootProject.file('buildscript/loader.gradle')
dependencies {
// API
- implementation project(':api')
+ implementation project(':common:common-api')
// DependencyDownload
implementation 'dev.vankka.minecraftdependencydownload:bungee-loader:' + rootProject.mddVersion
diff --git a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java
index 0ae2a1a1..7a0f808f 100644
--- a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java
+++ b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java
@@ -24,7 +24,7 @@ import com.discordsrv.common.config.connection.ConnectionConfig;
import com.discordsrv.common.config.main.MainConfig;
import com.discordsrv.common.config.manager.ConnectionConfigManager;
import com.discordsrv.common.config.manager.MainConfigManager;
-import com.discordsrv.common.logging.logger.Logger;
+import com.discordsrv.logging.Logger;
import com.discordsrv.common.proxy.ProxyDiscordSRV;
import com.discordsrv.common.scheduler.StandardScheduler;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
diff --git a/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java b/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java
index 8040b2b7..db0df28a 100644
--- a/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java
+++ b/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java
@@ -19,8 +19,8 @@
package com.discordsrv.bungee;
import com.discordsrv.common.dependency.InitialDependencyLoader;
-import com.discordsrv.common.logging.logger.Logger;
-import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
+import com.discordsrv.logging.Logger;
+import com.discordsrv.logging.impl.JavaLoggerImpl;
import dev.vankka.mcdependencydownload.bungee.bootstrap.BungeeBootstrap;
import dev.vankka.mcdependencydownload.classloader.JarInJarClassLoader;
import net.md_5.bungee.api.plugin.Plugin;
diff --git a/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java b/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java
index 94d73e7f..6b83a3c7 100644
--- a/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java
+++ b/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java
@@ -20,8 +20,8 @@ package com.discordsrv.bungee.console;
import com.discordsrv.bungee.BungeeDiscordSRV;
import com.discordsrv.common.console.Console;
-import com.discordsrv.common.logging.logger.backend.LoggingBackend;
-import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
+import com.discordsrv.logging.backend.LoggingBackend;
+import com.discordsrv.logging.impl.JavaLoggerImpl;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
diff --git a/common/api/build.gradle b/common/api/build.gradle
new file mode 100644
index 00000000..4bacae88
--- /dev/null
+++ b/common/api/build.gradle
@@ -0,0 +1,8 @@
+dependencies {
+ // API
+ api project(':api')
+
+ // Logging
+ api 'org.slf4j:slf4j-api:1.6.99'
+ compileOnly 'org.apache.logging.log4j:log4j-core:2.0-beta9'
+}
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/LogLevel.java b/common/api/src/main/java/com/discordsrv/logging/LogLevel.java
similarity index 97%
rename from common/src/main/java/com/discordsrv/common/logging/logger/LogLevel.java
rename to common/api/src/main/java/com/discordsrv/logging/LogLevel.java
index df99caa6..e5abf64e 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/LogLevel.java
+++ b/common/api/src/main/java/com/discordsrv/logging/LogLevel.java
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger;
+package com.discordsrv.logging;
public interface LogLevel {
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/Logger.java b/common/api/src/main/java/com/discordsrv/logging/Logger.java
similarity index 95%
rename from common/src/main/java/com/discordsrv/common/logging/logger/Logger.java
rename to common/api/src/main/java/com/discordsrv/logging/Logger.java
index a041522c..eb924e35 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/Logger.java
+++ b/common/api/src/main/java/com/discordsrv/logging/Logger.java
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger;
+package com.discordsrv.logging;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -67,6 +67,6 @@ public interface Logger {
log(LogLevel.TRACE, message, throwable);
}
- void log(@NotNull LogLevel LogLevel, @Nullable String message, @Nullable Throwable throwable);
+ void log(@NotNull LogLevel logLevel, @Nullable String message, @Nullable Throwable throwable);
}
diff --git a/common/api/src/main/java/com/discordsrv/logging/adapter/DependencyLoggerAdapter.java b/common/api/src/main/java/com/discordsrv/logging/adapter/DependencyLoggerAdapter.java
new file mode 100644
index 00000000..2d10757e
--- /dev/null
+++ b/common/api/src/main/java/com/discordsrv/logging/adapter/DependencyLoggerAdapter.java
@@ -0,0 +1,217 @@
+/*
+ * This file is part of DiscordSRV, licensed under the GPLv3 License
+ * Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.discordsrv.logging.adapter;
+
+import com.discordsrv.logging.LogLevel;
+import com.discordsrv.logging.backend.LogAppender;
+import org.slf4j.Marker;
+import org.slf4j.helpers.MarkerIgnoringBase;
+import org.slf4j.spi.LocationAwareLogger;
+
+public class DependencyLoggerAdapter extends MarkerIgnoringBase implements LocationAwareLogger {
+
+ private static LogAppender APPENDER;
+
+ public static void setAppender(LogAppender appender) {
+ APPENDER = appender;
+ }
+
+ private final String name;
+
+ public DependencyLoggerAdapter(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public void log(Marker marker, String fqcn, int level, String message, Object[] argArray, Throwable t) {
+ if (APPENDER == null) {
+ // Adapter isn't set, do nothing
+ return;
+ }
+ APPENDER.append(name, getLevel(level), String.format(message, argArray), t);
+ }
+
+ private LogLevel getLevel(int level) {
+ switch (level) {
+ case LocationAwareLogger.TRACE_INT:
+ return LogLevel.TRACE;
+ case LocationAwareLogger.DEBUG_INT:
+ return LogLevel.DEBUG;
+ case LocationAwareLogger.INFO_INT:
+ return LogLevel.INFO;
+ case LocationAwareLogger.WARN_INT:
+ return LogLevel.WARNING;
+ case LocationAwareLogger.ERROR_INT:
+ return LogLevel.ERROR;
+ default:
+ throw new IllegalStateException("Level number " + level + " is not recognized.");
+ }
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return true;
+ }
+
+ @Override
+ public void trace(String msg) {
+ trace(msg, (Throwable) null);
+
+ }
+
+ @Override
+ public void trace(String format, Object arg) {
+ trace(String.format(format, arg));
+ }
+
+ @Override
+ public void trace(String format, Object arg1, Object arg2) {
+ trace(String.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void trace(String format, Object... arguments) {
+ trace(String.format(format, arguments));
+ }
+
+ @Override
+ public void trace(String msg, Throwable t) {
+ APPENDER.append(name, LogLevel.TRACE, msg, t);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return true;
+ }
+
+ @Override
+ public void debug(String msg) {
+ debug(msg, (Throwable) null);
+ }
+
+ @Override
+ public void debug(String format, Object arg) {
+ debug(String.format(format, arg));
+ }
+
+ @Override
+ public void debug(String format, Object arg1, Object arg2) {
+ debug(String.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void debug(String format, Object... arguments) {
+ debug(String.format(format, arguments));
+ }
+
+ @Override
+ public void debug(String msg, Throwable t) {
+ APPENDER.append(name, LogLevel.DEBUG, msg, t);
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return true;
+ }
+
+ @Override
+ public void info(String msg) {
+ info(msg, (Throwable) null);
+ }
+
+ @Override
+ public void info(String format, Object arg) {
+ info(String.format(format, arg));
+ }
+
+ @Override
+ public void info(String format, Object arg1, Object arg2) {
+ info(String.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void info(String format, Object... arguments) {
+ info(String.format(format, arguments));
+ }
+
+ @Override
+ public void info(String msg, Throwable t) {
+ APPENDER.append(name, LogLevel.INFO, msg, t);
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return true;
+ }
+
+ @Override
+ public void warn(String msg) {
+ warn(msg, (Throwable) null);
+ }
+
+ @Override
+ public void warn(String format, Object arg) {
+ warn(String.format(format, arg));
+ }
+
+ @Override
+ public void warn(String format, Object... arguments) {
+ warn(String.format(format, arguments));
+ }
+
+ @Override
+ public void warn(String format, Object arg1, Object arg2) {
+ warn(String.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void warn(String msg, Throwable t) {
+ APPENDER.append(name, LogLevel.WARNING, msg, t);
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return true;
+ }
+
+ @Override
+ public void error(String msg) {
+ error(msg, (Throwable) null);
+ }
+
+ @Override
+ public void error(String format, Object arg) {
+ error(String.format(format, arg));
+ }
+
+ @Override
+ public void error(String format, Object arg1, Object arg2) {
+ error(String.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void error(String format, Object... arguments) {
+ error(String.format(format, arguments));
+ }
+
+ @Override
+ public void error(String msg, Throwable t) {
+ APPENDER.append(name, LogLevel.ERROR, msg, t);
+ }
+}
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/backend/LogAppender.java b/common/api/src/main/java/com/discordsrv/logging/backend/LogAppender.java
similarity index 91%
rename from common/src/main/java/com/discordsrv/common/logging/logger/backend/LogAppender.java
rename to common/api/src/main/java/com/discordsrv/logging/backend/LogAppender.java
index 9bba56e3..c853ec37 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/backend/LogAppender.java
+++ b/common/api/src/main/java/com/discordsrv/logging/backend/LogAppender.java
@@ -16,9 +16,9 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger.backend;
+package com.discordsrv.logging.backend;
-import com.discordsrv.common.logging.logger.LogLevel;
+import com.discordsrv.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/backend/LogFilter.java b/common/api/src/main/java/com/discordsrv/logging/backend/LogFilter.java
similarity index 91%
rename from common/src/main/java/com/discordsrv/common/logging/logger/backend/LogFilter.java
rename to common/api/src/main/java/com/discordsrv/logging/backend/LogFilter.java
index 7ca2e73e..fa9a638b 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/backend/LogFilter.java
+++ b/common/api/src/main/java/com/discordsrv/logging/backend/LogFilter.java
@@ -16,9 +16,9 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger.backend;
+package com.discordsrv.logging.backend;
-import com.discordsrv.common.logging.logger.LogLevel;
+import com.discordsrv.logging.LogLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/backend/LoggingBackend.java b/common/api/src/main/java/com/discordsrv/logging/backend/LoggingBackend.java
similarity index 95%
rename from common/src/main/java/com/discordsrv/common/logging/logger/backend/LoggingBackend.java
rename to common/api/src/main/java/com/discordsrv/logging/backend/LoggingBackend.java
index eeea2d31..04fc2a9e 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/backend/LoggingBackend.java
+++ b/common/api/src/main/java/com/discordsrv/logging/backend/LoggingBackend.java
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger.backend;
+package com.discordsrv.logging.backend;
public interface LoggingBackend {
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/impl/JavaLoggerImpl.java b/common/api/src/main/java/com/discordsrv/logging/impl/JavaLoggerImpl.java
similarity index 93%
rename from common/src/main/java/com/discordsrv/common/logging/logger/impl/JavaLoggerImpl.java
rename to common/api/src/main/java/com/discordsrv/logging/impl/JavaLoggerImpl.java
index cbc58522..fcd718fe 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/impl/JavaLoggerImpl.java
+++ b/common/api/src/main/java/com/discordsrv/logging/impl/JavaLoggerImpl.java
@@ -16,13 +16,13 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger.impl;
+package com.discordsrv.logging.impl;
-import com.discordsrv.common.logging.logger.LogLevel;
-import com.discordsrv.common.logging.logger.Logger;
-import com.discordsrv.common.logging.logger.backend.LogAppender;
-import com.discordsrv.common.logging.logger.backend.LogFilter;
-import com.discordsrv.common.logging.logger.backend.LoggingBackend;
+import com.discordsrv.logging.LogLevel;
+import com.discordsrv.logging.Logger;
+import com.discordsrv.logging.backend.LogAppender;
+import com.discordsrv.logging.backend.LogFilter;
+import com.discordsrv.logging.backend.LoggingBackend;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/impl/Log4JLoggerImpl.java b/common/api/src/main/java/com/discordsrv/logging/impl/Log4JLoggerImpl.java
similarity index 96%
rename from common/src/main/java/com/discordsrv/common/logging/logger/impl/Log4JLoggerImpl.java
rename to common/api/src/main/java/com/discordsrv/logging/impl/Log4JLoggerImpl.java
index 95b6b79b..ca23a6da 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/impl/Log4JLoggerImpl.java
+++ b/common/api/src/main/java/com/discordsrv/logging/impl/Log4JLoggerImpl.java
@@ -16,13 +16,13 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger.impl;
+package com.discordsrv.logging.impl;
-import com.discordsrv.common.logging.logger.LogLevel;
-import com.discordsrv.common.logging.logger.backend.LogAppender;
-import com.discordsrv.common.logging.logger.backend.LogFilter;
-import com.discordsrv.common.logging.logger.backend.LoggingBackend;
-import com.discordsrv.common.logging.logger.Logger;
+import com.discordsrv.logging.LogLevel;
+import com.discordsrv.logging.backend.LogAppender;
+import com.discordsrv.logging.backend.LogFilter;
+import com.discordsrv.logging.backend.LoggingBackend;
+import com.discordsrv.logging.Logger;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
diff --git a/common/src/main/java/com/discordsrv/common/logging/logger/impl/SLF4JLoggerImpl.java b/common/api/src/main/java/com/discordsrv/logging/impl/SLF4JLoggerImpl.java
similarity index 92%
rename from common/src/main/java/com/discordsrv/common/logging/logger/impl/SLF4JLoggerImpl.java
rename to common/api/src/main/java/com/discordsrv/logging/impl/SLF4JLoggerImpl.java
index 264dd0aa..bac0445e 100644
--- a/common/src/main/java/com/discordsrv/common/logging/logger/impl/SLF4JLoggerImpl.java
+++ b/common/api/src/main/java/com/discordsrv/logging/impl/SLF4JLoggerImpl.java
@@ -16,10 +16,10 @@
* along with this program. If not, see .
*/
-package com.discordsrv.common.logging.logger.impl;
+package com.discordsrv.logging.impl;
-import com.discordsrv.common.logging.logger.LogLevel;
-import com.discordsrv.common.logging.logger.Logger;
+import com.discordsrv.logging.LogLevel;
+import com.discordsrv.logging.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
diff --git a/common/api/src/main/java/org/slf4j/impl/DiscordSRVLoggerFactory.java b/common/api/src/main/java/org/slf4j/impl/DiscordSRVLoggerFactory.java
new file mode 100644
index 00000000..1ccbdef1
--- /dev/null
+++ b/common/api/src/main/java/org/slf4j/impl/DiscordSRVLoggerFactory.java
@@ -0,0 +1,37 @@
+/*
+ * This file is part of DiscordSRV, licensed under the GPLv3 License
+ * Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.slf4j.impl;
+
+import com.discordsrv.logging.adapter.DependencyLoggerAdapter;
+import org.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+
+import java.util.Locale;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+public class DiscordSRVLoggerFactory implements ILoggerFactory {
+
+ private final ConcurrentMap loggerMap = new ConcurrentHashMap<>();
+
+ @Override
+ public Logger getLogger(String s) {
+ return loggerMap.computeIfAbsent(s.toLowerCase(Locale.ROOT), DependencyLoggerAdapter::new);
+ }
+}
diff --git a/common/api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/common/api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
new file mode 100644
index 00000000..86548d58
--- /dev/null
+++ b/common/api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -0,0 +1,51 @@
+/*
+ * This file is part of DiscordSRV, licensed under the GPLv3 License
+ * Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+@SuppressWarnings("unused")
+public class StaticLoggerBinder implements LoggerFactoryBinder {
+
+ private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+
+ public static StaticLoggerBinder getSingleton() {
+ return SINGLETON;
+ }
+
+ // to avoid constant folding by the compiler, this field must *not* be final
+ public static String REQUESTED_API_VERSION = "1.6.99"; // !final
+
+ private static final String loggerFactoryClassStr = DiscordSRVLoggerFactory.class.getName();
+
+ private final ILoggerFactory loggerFactory;
+
+ private StaticLoggerBinder() {
+ loggerFactory = new DiscordSRVLoggerFactory();
+ }
+
+ public ILoggerFactory getLoggerFactory() {
+ return loggerFactory;
+ }
+
+ public String getLoggerFactoryClassStr() {
+ return loggerFactoryClassStr;
+ }
+}
diff --git a/common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java
new file mode 100644
index 00000000..298660e2
--- /dev/null
+++ b/common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java
@@ -0,0 +1,42 @@
+/*
+ * This file is part of DiscordSRV, licensed under the GPLv3 License
+ * Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.helpers.BasicMDCAdapter;
+import org.slf4j.spi.MDCAdapter;
+
+@SuppressWarnings("unused")
+public class StaticMDCBinder {
+
+ public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
+
+ private StaticMDCBinder() {}
+
+ public static StaticMDCBinder getSingleton() {
+ return SINGLETON;
+ }
+
+ public MDCAdapter getMDCA() {
+ return new BasicMDCAdapter();
+ }
+
+ public String getMDCAdapterClassStr() {
+ return BasicMDCAdapter.class.getName();
+ }
+}
diff --git a/common/api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/common/api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
new file mode 100644
index 00000000..797205d7
--- /dev/null
+++ b/common/api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
@@ -0,0 +1,46 @@
+/*
+ * This file is part of DiscordSRV, licensed under the GPLv3 License
+ * Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.helpers.BasicMarkerFactory;
+import org.slf4j.spi.MarkerFactoryBinder;
+
+@SuppressWarnings("unused")
+public class StaticMarkerBinder implements MarkerFactoryBinder {
+
+ public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
+
+ final IMarkerFactory markerFactory = new BasicMarkerFactory();
+
+ private StaticMarkerBinder() {}
+
+ public static StaticMarkerBinder getSingleton() {
+ return SINGLETON;
+ }
+
+ public IMarkerFactory getMarkerFactory() {
+ return markerFactory;
+ }
+
+ public String getMarkerFactoryClassStr() {
+ return BasicMarkerFactory.class.getName();
+ }
+
+}
diff --git a/common/build.gradle b/common/build.gradle
index b8d5a657..36d6e686 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -20,8 +20,8 @@ task generateResourceForMySQLDriver(type: GenerateDependencyDownloadResourceTask
dependencies {
// API
annotationProcessor project(':api')
- compileOnlyApi project(':api')
- testImplementation project(':api')
+ compileOnlyApi project(':common:common-api')
+ testImplementation project(':common:common-api')
// DependencyDownload
api 'dev.vankka.dependencydownload:runtime:' + rootProject.ddVersion
@@ -51,10 +51,6 @@ dependencies {
// Database Drivers
h2Driver 'com.h2database:h2:1.4.200'
mysqlDriver 'mysql:mysql-connector-java:8.0.25'
-
- // Logging (provided by platforms)
- compileOnlyApi 'org.apache.logging.log4j:log4j-core:2.0-beta9'
- compileOnlyApi 'org.slf4j:slf4j-api:1.7.32'
}
processResources {
diff --git a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java
index b145a66a..502c10e3 100644
--- a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java
+++ b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java
@@ -40,11 +40,11 @@ import com.discordsrv.common.listener.ChannelLookupListener;
import com.discordsrv.common.listener.DiscordAPIListener;
import com.discordsrv.common.listener.DiscordChatListener;
import com.discordsrv.common.listener.GameChatListener;
-import com.discordsrv.common.logging.DependencyLoggingFilter;
-import com.discordsrv.common.logging.logger.backend.LoggingBackend;
+import com.discordsrv.common.logging.DependencyLoggingHandler;
import com.discordsrv.common.placeholder.ComponentResultStringifier;
import com.discordsrv.common.placeholder.PlaceholderServiceImpl;
import com.discordsrv.common.placeholder.context.GlobalTextHandlingContext;
+import com.discordsrv.logging.adapter.DependencyLoggerAdapter;
import net.dv8tion.jda.api.JDA;
import org.jetbrains.annotations.NotNull;
@@ -79,7 +79,6 @@ public abstract class AbstractDiscordSRV> BLACKLISTED_MESSAGES = new HashMap<>();
private static final Map LOGGER_MAPPINGS = new HashMap<>();
@@ -46,14 +46,15 @@ public class DependencyLoggingFilter implements LogFilter {
private final DiscordSRV discordSRV;
- public DependencyLoggingFilter(DiscordSRV discordSRV) {
+ public DependencyLoggingHandler(DiscordSRV discordSRV) {
this.discordSRV = discordSRV;
}
@Override
- public Result filter(@Nullable String loggerName, @NotNull LogLevel logLevel, @Nullable String message, @Nullable Throwable throwable) {
+ public void append(@Nullable String loggerName, @NotNull LogLevel logLevel, @Nullable String message,
+ @Nullable Throwable throwable) {
if (loggerName == null || !loggerName.startsWith("com.discordsrv.dependencies")) {
- return Result.IGNORE;
+ return;
}
if (message != null) {
@@ -69,7 +70,7 @@ public class DependencyLoggingFilter implements LogFilter {
// Go through the blacklisted messages we gathered
for (String blacklistedMessage : blacklistedMessages) {
if (message.contains(blacklistedMessage)) {
- return Result.BLOCK;
+ return;
}
}
}
@@ -84,6 +85,5 @@ public class DependencyLoggingFilter implements LogFilter {
}
discordSRV.logger().log(logLevel, "[" + name + "]" + (message != null ? " " + message : ""), throwable);
- return Result.BLOCK;
}
}
diff --git a/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java b/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java
index 9a3efccd..f988ec7c 100644
--- a/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java
+++ b/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java
@@ -23,8 +23,8 @@ import com.discordsrv.common.config.main.MainConfig;
import com.discordsrv.common.config.manager.ConnectionConfigManager;
import com.discordsrv.common.config.manager.MainConfigManager;
import com.discordsrv.common.console.Console;
-import com.discordsrv.common.logging.logger.Logger;
-import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
+import com.discordsrv.logging.Logger;
+import com.discordsrv.logging.impl.JavaLoggerImpl;
import com.discordsrv.common.player.provider.AbstractPlayerProvider;
import com.discordsrv.common.scheduler.Scheduler;
import com.discordsrv.common.scheduler.StandardScheduler;
diff --git a/settings.gradle b/settings.gradle
index 9a0e7ee0..d71438f5 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -9,7 +9,7 @@ pluginManagement {
rootProject.name = 'DiscordSRV2'
[
- 'common', 'common:server', 'common:proxy',
+ 'common', 'common:api', 'common:server', 'common:proxy',
'i18n',
'api',
'bukkit', 'bukkit:loader',
diff --git a/sponge/loader/build.gradle b/sponge/loader/build.gradle
index 38b34c54..f0197580 100644
--- a/sponge/loader/build.gradle
+++ b/sponge/loader/build.gradle
@@ -9,7 +9,7 @@ apply from: rootProject.file('buildscript/loader.gradle')
dependencies {
// API
- implementation project(':api')
+ implementation project(':common:common-api')
// DependencyDownload
implementation 'dev.vankka.minecraftdependencydownload:jarinjar-loader:' + rootProject.mddVersion
diff --git a/sponge/src/main/java/com/discordsrv/sponge/DiscordSRVSpongeBootstrap.java b/sponge/src/main/java/com/discordsrv/sponge/DiscordSRVSpongeBootstrap.java
index 582325f3..1ad9df3b 100644
--- a/sponge/src/main/java/com/discordsrv/sponge/DiscordSRVSpongeBootstrap.java
+++ b/sponge/src/main/java/com/discordsrv/sponge/DiscordSRVSpongeBootstrap.java
@@ -19,8 +19,8 @@
package com.discordsrv.sponge;
import com.discordsrv.common.dependency.InitialDependencyLoader;
-import com.discordsrv.common.logging.logger.Logger;
-import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
+import com.discordsrv.logging.Logger;
+import com.discordsrv.logging.impl.Log4JLoggerImpl;
import com.discordsrv.sponge.bootstrap.ISpongeBootstrap;
import dev.vankka.mcdependencydownload.bootstrap.AbstractBootstrap;
import dev.vankka.mcdependencydownload.bootstrap.classpath.JarInJarClasspathAppender;
diff --git a/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java b/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java
index 749f1cf0..a5b063a8 100644
--- a/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java
+++ b/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java
@@ -23,7 +23,7 @@ import com.discordsrv.common.config.connection.ConnectionConfig;
import com.discordsrv.common.config.main.MainConfig;
import com.discordsrv.common.config.manager.ConnectionConfigManager;
import com.discordsrv.common.config.manager.MainConfigManager;
-import com.discordsrv.common.logging.logger.Logger;
+import com.discordsrv.logging.Logger;
import com.discordsrv.common.server.ServerDiscordSRV;
import com.discordsrv.sponge.console.SpongeConsole;
import com.discordsrv.sponge.player.SpongePlayerProvider;
diff --git a/sponge/src/main/java/com/discordsrv/sponge/console/SpongeConsole.java b/sponge/src/main/java/com/discordsrv/sponge/console/SpongeConsole.java
index bd7a724f..23e6bcdb 100644
--- a/sponge/src/main/java/com/discordsrv/sponge/console/SpongeConsole.java
+++ b/sponge/src/main/java/com/discordsrv/sponge/console/SpongeConsole.java
@@ -19,8 +19,8 @@
package com.discordsrv.sponge.console;
import com.discordsrv.common.console.Console;
-import com.discordsrv.common.logging.logger.backend.LoggingBackend;
-import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
+import com.discordsrv.logging.backend.LoggingBackend;
+import com.discordsrv.logging.impl.Log4JLoggerImpl;
import com.discordsrv.sponge.SpongeDiscordSRV;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
diff --git a/velocity/build.gradle b/velocity/build.gradle
index 0c611fe4..89ea9c40 100644
--- a/velocity/build.gradle
+++ b/velocity/build.gradle
@@ -9,7 +9,7 @@ var velocityVersion = '3.0.0'
dependencies {
// API
annotationProcessor project(':api')
- implementation project(':api')
+ implementation project(':common:common-api')
// Common
implementation project(':common:common-proxy')
diff --git a/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java b/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java
index 00fc43da..dd3a0215 100644
--- a/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java
+++ b/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java
@@ -19,8 +19,8 @@
package com.discordsrv.velocity;
import com.discordsrv.common.dependency.InitialDependencyLoader;
-import com.discordsrv.common.logging.logger.Logger;
-import com.discordsrv.common.logging.logger.impl.SLF4JLoggerImpl;
+import com.discordsrv.logging.Logger;
+import com.discordsrv.logging.impl.SLF4JLoggerImpl;
import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
diff --git a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java
index 39271edb..08e8d1c0 100644
--- a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java
+++ b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java
@@ -22,7 +22,7 @@ import com.discordsrv.common.config.connection.ConnectionConfig;
import com.discordsrv.common.config.main.MainConfig;
import com.discordsrv.common.config.manager.ConnectionConfigManager;
import com.discordsrv.common.config.manager.MainConfigManager;
-import com.discordsrv.common.logging.logger.Logger;
+import com.discordsrv.logging.Logger;
import com.discordsrv.common.proxy.ProxyDiscordSRV;
import com.discordsrv.common.scheduler.StandardScheduler;
import com.discordsrv.velocity.console.VelocityConsole;
diff --git a/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java b/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java
index dea87e9f..53cb82be 100644
--- a/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java
+++ b/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java
@@ -19,8 +19,8 @@
package com.discordsrv.velocity.console;
import com.discordsrv.common.console.Console;
-import com.discordsrv.common.logging.logger.backend.LoggingBackend;
-import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
+import com.discordsrv.logging.backend.LoggingBackend;
+import com.discordsrv.logging.impl.Log4JLoggerImpl;
import com.discordsrv.velocity.VelocityDiscordSRV;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;