From 68e6de8ebbfac40de97ef4e59c76f4ad9338b259 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Wed, 11 May 2022 11:46:36 -0400 Subject: [PATCH] Add plugin loggers --- src/main/java/emu/grasscutter/plugin/Plugin.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/emu/grasscutter/plugin/Plugin.java b/src/main/java/emu/grasscutter/plugin/Plugin.java index f1ce18a6b..b45e642a5 100644 --- a/src/main/java/emu/grasscutter/plugin/Plugin.java +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -3,6 +3,8 @@ package emu.grasscutter.plugin; import emu.grasscutter.Grasscutter; import emu.grasscutter.plugin.api.ServerHook; import emu.grasscutter.server.game.GameServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.InputStream; @@ -19,6 +21,7 @@ public abstract class Plugin { private PluginIdentifier identifier; private URLClassLoader classLoader; private File dataFolder; + private Logger logger; /** * This method is reflected into. @@ -35,6 +38,7 @@ public abstract class Plugin { this.identifier = identifier; this.classLoader = classLoader; this.dataFolder = new File(PLUGINS_FOLDER, identifier.name); + this.logger = LoggerFactory.getLogger(identifier.name); if(!this.dataFolder.exists() && !this.dataFolder.mkdirs()) { Grasscutter.getLogger().warn("Failed to create plugin data folder for " + this.identifier.name); @@ -103,6 +107,14 @@ public abstract class Plugin { public final ServerHook getHandle() { return this.server; } + + /** + * Returns the plugin's logger. + * @return A SLF4J logger. + */ + public final Logger getLogger() { + return this.logger; + } /* Called when the plugin is first loaded. */ public void onLoad() { }