mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 14:21:56 +00:00
Unwrap CommandExceptions thrown by Bukkit before passing to Exception handlers
This commit is contained in:
@@ -30,6 +30,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginIdentifiableCommand;
|
||||
@@ -365,4 +366,12 @@ public class BukkitCommandManager extends CommandManager<
|
||||
public String getCommandPrefix(CommandIssuer issuer) {
|
||||
return issuer.isPlayer() ? "/" : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) {
|
||||
if (t instanceof CommandException && t.getCause() != null && t.getMessage().startsWith("Unhandled exception")) {
|
||||
t = t.getCause();
|
||||
}
|
||||
return super.handleUncaughtException(scope, registeredCommand, sender, args, t);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user