Search in sources :

Example 1 with CmdException

use of net.wurstclient.features.Cmd.CmdException in project Wurst-MC-1.12 by Wurst-Imperium.

the class CmdManager method runCommand.

public void runCommand(String input) {
    String[] parts = input.split(" ");
    Cmd cmd = getCommandByName(parts[0]);
    if (cmd == null) {
        ChatUtils.error("Unknown command: ." + parts[0]);
        if (input.startsWith("/"))
            ChatUtils.message("Use \".say " + input + "\" to send it as a chat command.");
        else
            ChatUtils.message("Type \".help\" for a list of commands or \".say ." + input + "\" to send it as a chat message.");
        return;
    }
    try {
        cmd.call(Arrays.copyOfRange(parts, 1, parts.length));
    } catch (CmdException e) {
        e.printToChat();
    } catch (Throwable e) {
        CrashReport crashReport = CrashReport.makeCrashReport(e, "Running Wurst command");
        CrashReportCategory crashReportCategory = crashReport.makeCategory("Affected command");
        crashReportCategory.setDetail("Command input", () -> input);
        throw new ReportedException(crashReport);
    }
}
Also used : CmdException(net.wurstclient.features.Cmd.CmdException) CrashReport(net.minecraft.crash.CrashReport) Cmd(net.wurstclient.features.Cmd) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Aggregations

CrashReport (net.minecraft.crash.CrashReport)1 CrashReportCategory (net.minecraft.crash.CrashReportCategory)1 ReportedException (net.minecraft.util.ReportedException)1 Cmd (net.wurstclient.features.Cmd)1 CmdException (net.wurstclient.features.Cmd.CmdException)1