Fix the scuff
This commit is contained in:
parent
45bea50c91
commit
b75a78f3d3
@ -37,6 +37,11 @@ public interface Helper {
|
||||
*/
|
||||
Helper HELPER = new Helper() {};
|
||||
|
||||
/**
|
||||
* Instance of the game
|
||||
*/
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
static ITextComponent getPrefix() {
|
||||
// Inner text component
|
||||
ITextComponent baritone = new TextComponentString(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
@ -52,8 +57,6 @@ public interface Helper {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
/**
|
||||
* Send a message to chat only if chatDebug is on
|
||||
*
|
||||
|
@ -72,8 +72,7 @@ public class ArgParserManager {
|
||||
public static <T> T parseStateless(Class<T> type, CommandArgument arg) throws CommandInvalidTypeException {
|
||||
IArgParser.Stateless<T> parser = getParserStateless(type);
|
||||
if (parser == null) {
|
||||
// TODO: Fix this scuff lol
|
||||
throw new CommandUnhandledException(new CommandNoParserForTypeException(type));
|
||||
throw new CommandNoParserForTypeException(type);
|
||||
}
|
||||
try {
|
||||
return parser.parseArg(arg);
|
||||
@ -95,8 +94,7 @@ public class ArgParserManager {
|
||||
public static <T, S> T parseStated(Class<T> type, Class<S> stateKlass, CommandArgument arg, S state) throws CommandInvalidTypeException {
|
||||
IArgParser.Stated<T, S> parser = getParserStated(type, stateKlass);
|
||||
if (parser == null) {
|
||||
// TODO: Fix this scuff lol
|
||||
throw new CommandUnhandledException(new CommandNoParserForTypeException(type));
|
||||
throw new CommandNoParserForTypeException(type);
|
||||
}
|
||||
try {
|
||||
return parser.parseArg(arg, state);
|
||||
|
@ -17,12 +17,9 @@
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
|
||||
public class CommandNoParserForTypeException extends CommandErrorMessageException {
|
||||
|
||||
public final Class<?> klass;
|
||||
public class CommandNoParserForTypeException extends CommandUnhandledException {
|
||||
|
||||
public CommandNoParserForTypeException(Class<?> klass) {
|
||||
super(String.format("Could not find a handler for type %s", klass.getSimpleName()));
|
||||
this.klass = klass;
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,30 @@
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argument.CommandArgument;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static baritone.api.utils.Helper.HELPER;
|
||||
|
||||
public class CommandUnhandledException extends RuntimeException implements ICommandException {
|
||||
|
||||
public CommandUnhandledException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CommandUnhandledException(Throwable cause) {
|
||||
super("An unhandled exception occurred. The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues");
|
||||
cause.printStackTrace();
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Command command, List<CommandArgument> args) {
|
||||
HELPER.logDirect("An unhandled exception occurred." +
|
||||
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
|
||||
TextFormatting.RED);
|
||||
|
||||
this.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argument.CommandArgument;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandUnhandledException;
|
||||
import baritone.api.utils.command.exception.ICommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.manager.ICommandManager;
|
||||
import com.mojang.realmsclient.util.Pair;
|
||||
@ -68,10 +69,13 @@ public class CommandExecution {
|
||||
public void execute() {
|
||||
try {
|
||||
command.execute(this);
|
||||
} catch (CommandException e) {
|
||||
e.handle(command, args.args);
|
||||
} catch (Throwable t) {
|
||||
new CommandUnhandledException(t).handle(command, args.args);
|
||||
// Create a handleable exception, wrap if needed
|
||||
ICommandException exception = t instanceof ICommandException
|
||||
? (ICommandException) t
|
||||
: new CommandUnhandledException(t);
|
||||
|
||||
exception.handle(command, args.args);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user