Catch Throwable instead of Exception

This commit is contained in:
TheMode 2021-08-22 18:35:19 +02:00
parent 1b55bd0137
commit f1c9268897
2 changed files with 18 additions and 10 deletions

View File

@ -44,8 +44,7 @@ public class ParsedCommand {
final CommandCondition condition = command.getCondition(); final CommandCondition condition = command.getCondition();
if (condition != null) { if (condition != null) {
final boolean result = condition.canUse(source, commandString); final boolean result = condition.canUse(source, commandString);
if (!result) if (!result) return null;
return null;
} }
// Condition is respected // Condition is respected
if (executor != null) { if (executor != null) {
@ -58,16 +57,16 @@ public class ParsedCommand {
context.retrieveDefaultValues(syntax.getDefaultValuesMap()); context.retrieveDefaultValues(syntax.getDefaultValuesMap());
try { try {
executor.apply(source, context); executor.apply(source, context);
} catch (Exception exception) { } catch (Throwable throwable) {
MinecraftServer.getExceptionManager().handleException(exception); MinecraftServer.getExceptionManager().handleException(throwable);
} }
} }
} else { } else {
// The executor is probably the default one // The executor is probably the default one
try { try {
executor.apply(source, context); executor.apply(source, context);
} catch (Exception exception) { } catch (Throwable throwable) {
MinecraftServer.getExceptionManager().handleException(exception); MinecraftServer.getExceptionManager().handleException(throwable);
} }
} }
} else if (callback != null && argumentSyntaxException != null) { } else if (callback != null && argumentSyntaxException != null) {

View File

@ -397,7 +397,12 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
this.listeners.add(e -> { this.listeners.add(e -> {
if (hasPredicate) { if (hasPredicate) {
final Object value = filter.getHandler(e); final Object value = filter.getHandler(e);
if (!predicate.test(e, value)) return; try {
if (!predicate.test(e, value)) return;
} catch (Throwable t) {
MinecraftServer.getExceptionManager().handleException(t);
return;
}
} }
if (!listenersCopy.isEmpty()) { if (!listenersCopy.isEmpty()) {
for (EventListener<E> listener : listenersCopy) { for (EventListener<E> listener : listenersCopy) {
@ -406,7 +411,11 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
} }
if (!bindingsCopy.isEmpty()) { if (!bindingsCopy.isEmpty()) {
for (Consumer<E> eConsumer : bindingsCopy) { for (Consumer<E> eConsumer : bindingsCopy) {
eConsumer.accept(e); try {
eConsumer.accept(e);
} catch (Throwable t) {
MinecraftServer.getExceptionManager().handleException(t);
}
} }
} }
}); });
@ -416,9 +425,9 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
EventListener.Result result; EventListener.Result result;
try { try {
result = listener.run(event); result = listener.run(event);
} catch (Exception e) { } catch (Throwable t) {
result = EventListener.Result.EXCEPTION; result = EventListener.Result.EXCEPTION;
MinecraftServer.getExceptionManager().handleException(e); MinecraftServer.getExceptionManager().handleException(t);
} }
if (result == EventListener.Result.EXPIRED) { if (result == EventListener.Result.EXPIRED) {
targetNode.removeListener(listener); targetNode.removeListener(listener);