Implement a default command exception handler to show stacktrace

This commit is contained in:
Ben Woo 2025-03-08 12:58:31 +08:00
parent 120b51e9e6
commit dc9a386af1
2 changed files with 20 additions and 0 deletions

View File

@ -57,6 +57,7 @@ public class MVCommandManager extends PaperCommandManager {
MVCommandConditions.load(this, worldManager, worldNameChecker);
this.enableUnstableAPI("help");
this.setDefaultExceptionHandler(new MVDefaultExceptionHandler());
}
/**

View File

@ -0,0 +1,19 @@
package org.mvplugins.multiverse.core.commandtools;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.ExceptionHandler;
import co.aikar.commands.RegisteredCommand;
import com.dumptruckman.minecraft.util.Logging;
import java.util.List;
public class MVDefaultExceptionHandler implements ExceptionHandler {
@Override
public boolean execute(BaseCommand command, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) {
Logging.severe("Failed to execute command /%s %s %s",
registeredCommand.getCommand(), registeredCommand.getPrefSubCommand(), String.join(" ", args));
t.printStackTrace();
return false;
}
}