aboutsummaryrefslogtreecommitdiff
path: root/spark-sponge8/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'spark-sponge8/src/main/java/me')
-rw-r--r--spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java
index e82fb6d..0195b24 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java
+++ b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java
@@ -31,6 +31,7 @@ import me.lucko.spark.common.tick.TickHook;
import net.kyori.adventure.text.Component;
+import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.api.Game;
import org.spongepowered.api.Server;
@@ -52,6 +53,7 @@ import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
+import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -59,6 +61,7 @@ import java.util.stream.Stream;
public class Sponge8SparkPlugin implements SparkPlugin {
private final PluginContainer pluginContainer;
+ private final Logger logger;
private final Game game;
private final Path configDirectory;
private final ExecutorService asyncExecutor;
@@ -67,8 +70,9 @@ public class Sponge8SparkPlugin implements SparkPlugin {
private final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread();
@Inject
- public Sponge8SparkPlugin(PluginContainer pluginContainer, Game game, @ConfigDir(sharedRoot = false) Path configDirectory) {
+ public Sponge8SparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory) {
this.pluginContainer = pluginContainer;
+ this.logger = logger;
this.game = game;
this.configDirectory = configDirectory;
this.asyncExecutor = game.asyncScheduler().executor(pluginContainer);
@@ -120,6 +124,19 @@ public class Sponge8SparkPlugin implements SparkPlugin {
}
@Override
+ public void log(Level level, String msg) {
+ if (level == Level.INFO) {
+ this.logger.info(msg);
+ } else if (level == Level.WARNING) {
+ this.logger.warn(msg);
+ } else if (level == Level.SEVERE) {
+ this.logger.error(msg);
+ } else {
+ throw new IllegalArgumentException(level.getName());
+ }
+ }
+
+ @Override
public ThreadDumper getDefaultThreadDumper() {
return this.threadDumper.get();
}