mirror of
https://github.com/Grasscutters/PluginTemplate.git
synced 2024-11-23 12:09:44 +00:00
Use Plugin#getLogger
This commit is contained in:
parent
0af3b0dcc6
commit
4e3be31d19
@ -5,7 +5,6 @@ import emu.grasscutter.plugin.Plugin;
|
||||
import emu.grasscutter.server.event.EventHandler;
|
||||
import emu.grasscutter.server.event.HandlerPriority;
|
||||
import emu.grasscutter.server.event.player.PlayerJoinEvent;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.grasscutters.pltm.objects.PluginConfig;
|
||||
|
||||
import java.io.*;
|
||||
@ -27,8 +26,6 @@ public final class PluginTemplate extends Plugin {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/* A proper plugin logger will be introduced in v1.0.4-dev. */
|
||||
private final Logger logger = Grasscutter.getLogger();
|
||||
/* The plugin's configuration instance. */
|
||||
private PluginConfig configuration;
|
||||
|
||||
@ -45,18 +42,18 @@ public final class PluginTemplate extends Plugin {
|
||||
// Load the configuration.
|
||||
try {
|
||||
if(!config.exists() && !config.createNewFile()) {
|
||||
this.logger.error("Failed to create config file.");
|
||||
this.getLogger().error("Failed to create config file.");
|
||||
} else {
|
||||
try (FileWriter writer = new FileWriter(config)) {
|
||||
InputStream configStream = this.getResource("config.json");
|
||||
if(configStream == null) {
|
||||
this.logger.error("Failed to save default config file.");
|
||||
this.getLogger().error("Failed to save default config file.");
|
||||
} else {
|
||||
writer.write(new BufferedReader(
|
||||
new InputStreamReader(configStream)).lines().collect(Collectors.joining("\n"))
|
||||
); writer.close();
|
||||
|
||||
this.logger.info("Saved default config file.");
|
||||
|
||||
this.getLogger().info("Saved default config file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,7 +61,7 @@ public final class PluginTemplate extends Plugin {
|
||||
// Put the configuration into an instance of the config class.
|
||||
this.configuration = Grasscutter.getGsonFactory().fromJson(new FileReader(config), PluginConfig.class);
|
||||
} catch (IOException exception) {
|
||||
this.logger.error("Failed to create config file.", exception);
|
||||
this.getLogger().error("Failed to create config file.", exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user