mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 09:37:54 +01:00
Fix Velocity not loading slf4j logger properly
- Applied relocation hack suggested by Vankka - Removed metrics for velocity (They were using the unrelocated logger, but there was no way to unrelocate it) Affects issues: - Fixed #2497
This commit is contained in:
parent
2527c37d61
commit
703c1bdbba
@ -58,11 +58,11 @@ shadowJar {
|
||||
exclude "jakarta/xml/**/*"
|
||||
exclude "javassist/**/*"
|
||||
|
||||
relocate('org.slf4j', 'plan.org.slf4j') {
|
||||
exclude 'com.djrapitops.plan.PlanVelocity'
|
||||
exclude 'net.playeranalytics.plugin.VelocityPlatformLayer'
|
||||
exclude 'net.playeranalytics.plugin.server.VelocityPluginLogger'
|
||||
}
|
||||
relocate('org.slf4j', 'plan.org.slf4j')
|
||||
|
||||
// Unrelocate a package to use platform version of some libraries that were relocated in Plan
|
||||
exclude "com/djrapitops/plan/unrelocate/**/*"
|
||||
relocate('com.djrapitops.plan.unrelocate.', '')
|
||||
|
||||
relocate('org.apache', 'plan.org.apache') {
|
||||
exclude 'org/apache/logging/**'
|
||||
|
@ -13,7 +13,6 @@ dependencies {
|
||||
|
||||
shadow "net.playeranalytics:platform-abstraction-layer-api:$palVersion"
|
||||
shadow "net.playeranalytics:platform-abstraction-layer-velocity:$palVersion"
|
||||
shadow "org.bstats:bstats-velocity:$bstatsVersion"
|
||||
|
||||
compileOnly "com.velocitypowered:velocity-api:$velocityVersion"
|
||||
annotationProcessor "com.velocitypowered:velocity-api:$velocityVersion"
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.velocity.Metrics;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BStatsVelocity {
|
||||
|
||||
private final Database database;
|
||||
|
||||
private final Metrics metrics;
|
||||
|
||||
public BStatsVelocity(Database database, Metrics metrics) {
|
||||
this.database = database;
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
public void registerMetrics() {
|
||||
registerConfigSettingGraphs();
|
||||
}
|
||||
|
||||
private void registerConfigSettingGraphs() {
|
||||
addStringSettingPie("database_type", () -> database.getType().getName());
|
||||
addStringSettingPie("network_servers", () -> String.valueOf(database.query(ServerQueries.fetchPlanServerInformationCollection()).size()));
|
||||
}
|
||||
|
||||
protected void addStringSettingPie(String id, Supplier<String> setting) {
|
||||
metrics.addCustomChart(new SimplePie(id, setting::get));
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.exceptions.EnableException;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.unrelocate.org.slf4j.Logger;
|
||||
import com.djrapitops.plan.utilities.java.ThreadContextClassLoaderSwap;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
@ -37,8 +38,6 @@ import net.playeranalytics.plugin.PlatformAbstractionLayer;
|
||||
import net.playeranalytics.plugin.VelocityPlatformLayer;
|
||||
import net.playeranalytics.plugin.scheduling.RunnableFactory;
|
||||
import net.playeranalytics.plugin.server.PluginLogger;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@ -64,7 +63,6 @@ import java.util.logging.Level;
|
||||
)
|
||||
public class PlanVelocity implements PlanPlugin {
|
||||
|
||||
private final Metrics.Factory metricsFactory;
|
||||
private final ProxyServer proxy;
|
||||
private final Logger slf4jLogger;
|
||||
private final Path dataFolderPath;
|
||||
@ -79,18 +77,16 @@ public class PlanVelocity implements PlanPlugin {
|
||||
public PlanVelocity(
|
||||
ProxyServer proxy,
|
||||
Logger slf4jLogger,
|
||||
@DataDirectory Path dataFolderPath,
|
||||
Metrics.Factory metricsFactory
|
||||
@DataDirectory Path dataFolderPath
|
||||
) {
|
||||
this.proxy = proxy;
|
||||
this.slf4jLogger = slf4jLogger;
|
||||
this.dataFolderPath = dataFolderPath;
|
||||
this.metricsFactory = metricsFactory;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyStart(ProxyInitializeEvent event) {
|
||||
abstractionLayer = new VelocityPlatformLayer(this, proxy, slf4jLogger, dataFolderPath);
|
||||
abstractionLayer = new VelocityPlatformLayer(this, proxy, new Slf4jLoggerWrapper(slf4jLogger), dataFolderPath);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
|
||||
@ -114,12 +110,6 @@ public class PlanVelocity implements PlanPlugin {
|
||||
locale = system.getLocaleSystem().getLocale();
|
||||
system.enable();
|
||||
|
||||
int pluginId = 10326;
|
||||
new BStatsVelocity(
|
||||
system.getDatabaseSystem().getDatabase(),
|
||||
metricsFactory.make(this, pluginId)
|
||||
).registerMetrics();
|
||||
|
||||
logger.info(locale.getString(PluginLang.ENABLED));
|
||||
} catch (AbstractMethodError e) {
|
||||
logger.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||
|
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.event.Level;
|
||||
import org.slf4j.spi.LoggingEventBuilder;
|
||||
|
||||
/**
|
||||
* Delegates org.slf4j.Logger (unrelocated) to plan.org.slf4j.Logger (relocated).
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class Slf4jLoggerWrapper implements Logger {
|
||||
|
||||
private final com.djrapitops.plan.unrelocate.org.slf4j.Logger logger;
|
||||
|
||||
public Slf4jLoggerWrapper(com.djrapitops.plan.unrelocate.org.slf4j.Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {return logger.getName();}
|
||||
|
||||
@Override
|
||||
public LoggingEventBuilder makeLoggingEventBuilder(Level level) {return logger.makeLoggingEventBuilder(level);}
|
||||
|
||||
@Override
|
||||
public LoggingEventBuilder atLevel(Level level) {return logger.atLevel(level);}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForLevel(Level level) {return logger.isEnabledForLevel(level);}
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled() {return logger.isTraceEnabled();}
|
||||
|
||||
@Override
|
||||
public void trace(String msg) {logger.trace(msg);}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object arg) {logger.trace(format, arg);}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object arg1, Object arg2) {logger.trace(format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object... arguments) {logger.trace(format, arguments);}
|
||||
|
||||
@Override
|
||||
public void trace(String msg, Throwable t) {logger.trace(msg, t);}
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled(Marker marker) {return logger.isTraceEnabled(marker);}
|
||||
|
||||
@Override
|
||||
public LoggingEventBuilder atTrace() {return logger.atTrace();}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String msg) {logger.trace(marker, msg);}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String format, Object arg) {logger.trace(marker, format, arg);}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String format, Object arg1, Object arg2) {logger.trace(marker, format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String format, Object... argArray) {logger.trace(marker, format, argArray);}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String msg, Throwable t) {logger.trace(marker, msg, t);}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {return logger.isDebugEnabled();}
|
||||
|
||||
@Override
|
||||
public void debug(String msg) {logger.debug(msg);}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object arg) {logger.debug(format, arg);}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object arg1, Object arg2) {logger.debug(format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object... arguments) {logger.debug(format, arguments);}
|
||||
|
||||
@Override
|
||||
public void debug(String msg, Throwable t) {logger.debug(msg, t);}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled(Marker marker) {return logger.isDebugEnabled(marker);}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String msg) {logger.debug(marker, msg);}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String format, Object arg) {logger.debug(marker, format, arg);}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String format, Object arg1, Object arg2) {logger.debug(marker, format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String format, Object... arguments) {logger.debug(marker, format, arguments);}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String msg, Throwable t) {logger.debug(marker, msg, t);}
|
||||
|
||||
@Override
|
||||
public LoggingEventBuilder atDebug() {return logger.atDebug();}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled() {return logger.isInfoEnabled();}
|
||||
|
||||
@Override
|
||||
public void info(String msg) {logger.info(msg);}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object arg) {logger.info(format, arg);}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object arg1, Object arg2) {logger.info(format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object... arguments) {logger.info(format, arguments);}
|
||||
|
||||
@Override
|
||||
public void info(String msg, Throwable t) {logger.info(msg, t);}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled(Marker marker) {return logger.isInfoEnabled(marker);}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String msg) {logger.info(marker, msg);}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String format, Object arg) {logger.info(marker, format, arg);}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String format, Object arg1, Object arg2) {logger.info(marker, format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String format, Object... arguments) {logger.info(marker, format, arguments);}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String msg, Throwable t) {logger.info(marker, msg, t);}
|
||||
|
||||
@Override
|
||||
public LoggingEventBuilder atInfo() {return logger.atInfo();}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled() {return logger.isWarnEnabled();}
|
||||
|
||||
@Override
|
||||
public void warn(String msg) {logger.warn(msg);}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object arg) {logger.warn(format, arg);}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object... arguments) {logger.warn(format, arguments);}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object arg1, Object arg2) {logger.warn(format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void warn(String msg, Throwable t) {logger.warn(msg, t);}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled(Marker marker) {return logger.isWarnEnabled(marker);}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String msg) {logger.warn(marker, msg);}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String format, Object arg) {logger.warn(marker, format, arg);}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String format, Object arg1, Object arg2) {logger.warn(marker, format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String format, Object... arguments) {logger.warn(marker, format, arguments);}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String msg, Throwable t) {logger.warn(marker, msg, t);}
|
||||
|
||||
@Override
|
||||
public LoggingEventBuilder atWarn() {return logger.atWarn();}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnabled() {return logger.isErrorEnabled();}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {logger.error(msg);}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object arg) {logger.error(format, arg);}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object arg1, Object arg2) {logger.error(format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object... arguments) {logger.error(format, arguments);}
|
||||
|
||||
@Override
|
||||
public void error(String msg, Throwable t) {logger.error(msg, t);}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnabled(Marker marker) {return logger.isErrorEnabled(marker);}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String msg) {logger.error(marker, msg);}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String format, Object arg) {logger.error(marker, format, arg);}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String format, Object arg1, Object arg2) {logger.error(marker, format, arg1, arg2);}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String format, Object... arguments) {logger.error(marker, format, arguments);}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String msg, Throwable t) {logger.error(marker, msg, t);}
|
||||
|
||||
@Override
|
||||
public LoggingEventBuilder atError() {return logger.atError();}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.unrelocate.org.slf4j;
|
||||
|
||||
/**
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public interface Logger extends org.slf4j.Logger {}
|
Loading…
Reference in New Issue
Block a user