mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 08:36:38 +00:00
Add plugin loggers
This commit is contained in:
parent
89bd4b9aeb
commit
68e6de8ebb
@ -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() { }
|
||||
|
Loading…
Reference in New Issue
Block a user