From 5e0fe761b2ece67e613d13eb5094d9c0527598a7 Mon Sep 17 00:00:00 2001 From: Antti Koponen Date: Sat, 24 Jul 2021 16:02:24 +0300 Subject: [PATCH] Fix getErrorLogger NPE (#2029) --- .../main/java/net/playeranalytics/plan/PlanFabric.java | 2 +- .../playeranalytics/plan/commands/CommandManager.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Plan/fabric/src/main/java/net/playeranalytics/plan/PlanFabric.java b/Plan/fabric/src/main/java/net/playeranalytics/plan/PlanFabric.java index e10df21bd..7a43e4c50 100644 --- a/Plan/fabric/src/main/java/net/playeranalytics/plan/PlanFabric.java +++ b/Plan/fabric/src/main/java/net/playeranalytics/plan/PlanFabric.java @@ -161,7 +161,7 @@ public class PlanFabric implements PlanPlugin, DedicatedServerModInitializer { onEnable(); }); - CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> commandManager = new CommandManager(dispatcher, system.getErrorLogger())); + CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> commandManager = new CommandManager(dispatcher, this)); ServerLifecycleEvents.SERVER_STOPPING.register(server -> onDisable()); } diff --git a/Plan/fabric/src/main/java/net/playeranalytics/plan/commands/CommandManager.java b/Plan/fabric/src/main/java/net/playeranalytics/plan/commands/CommandManager.java index dc26360b3..39d394aad 100644 --- a/Plan/fabric/src/main/java/net/playeranalytics/plan/commands/CommandManager.java +++ b/Plan/fabric/src/main/java/net/playeranalytics/plan/commands/CommandManager.java @@ -21,7 +21,6 @@ import com.djrapitops.plan.commands.use.CMDSender; import com.djrapitops.plan.commands.use.CommandWithSubcommands; import com.djrapitops.plan.commands.use.Subcommand; import com.djrapitops.plan.utilities.logging.ErrorContext; -import com.djrapitops.plan.utilities.logging.ErrorLogger; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; @@ -34,6 +33,7 @@ import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.CommandSource; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.LiteralText; +import net.playeranalytics.plan.PlanFabric; import net.playeranalytics.plugin.scheduling.RunnableFactory; import java.util.concurrent.CompletableFuture; @@ -43,11 +43,11 @@ public class CommandManager { private final CommandDispatcher dispatcher; private RunnableFactory runnableFactory; private LiteralArgumentBuilder root; - private final ErrorLogger errorLogger; + private final PlanFabric plugin; - public CommandManager(CommandDispatcher dispatcher, ErrorLogger errorLogger) { + public CommandManager(CommandDispatcher dispatcher, PlanFabric plugin) { this.dispatcher = dispatcher; - this.errorLogger = errorLogger; + this.plugin = plugin; } public static boolean checkPermission(ServerCommandSource src, String permission) { @@ -82,7 +82,7 @@ public class CommandManager { subcommand.getExecutor().accept((CMDSender) ctx.getSource(), new Arguments(getCommandArguments(ctx))); } catch (Exception e) { ctx.getSource().sendError(new LiteralText("An internal error occurred, see the console for details.")); - errorLogger.error(e, ErrorContext.builder() + plugin.getSystem().getErrorLogger().error(e, ErrorContext.builder() .related(ctx.getSource().getClass()) .related(subcommand.getPrimaryAlias() + " " + getCommandArguments(ctx)) .build());