This commit is contained in:
dordsor21 2021-10-25 15:04:59 +01:00
parent 47f25c4f31
commit 1b1f3bbcbe
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -112,6 +112,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.Event;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.internal.command.CommandArgParser;
@ -910,11 +911,22 @@ public final class PlatformCommandManager {
try {
suggestions = commandManager.getSuggestions(access, argStrings);
} catch (Throwable t) { // catch errors which are *not* command exceptions generated by parsers/suggesters
if (!(t instanceof CommandException)) {
LOGGER.error("Unexpected error occurred while generating suggestions for input: {}", arguments, t);
return;
if (!(t instanceof InputParseException) && !(t instanceof CommandException)) {
Throwable cause = t;
// These exceptions can be very nested, and should not be printed as they are not an actual error.
boolean printError = true;
while ((cause = cause.getCause()) != null) {
if (cause instanceof InputParseException || cause instanceof CommandException) {
printError = false;
break;
}
}
if (printError) {
LOGGER.error("Unexpected error occurred while generating suggestions for input: {}", arguments, t);
return;
}
}
throw t;
return;
}
event.setSuggestions(suggestions.stream()