mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-03 14:01:58 +01:00
Catch command execution
This commit is contained in:
parent
2606f2b291
commit
512ec8dcbc
@ -1,5 +1,6 @@
|
|||||||
package net.minestom.server.command.builder;
|
package net.minestom.server.command.builder;
|
||||||
|
|
||||||
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.command.CommandSender;
|
import net.minestom.server.command.CommandSender;
|
||||||
import net.minestom.server.command.builder.condition.CommandCondition;
|
import net.minestom.server.command.builder.condition.CommandCondition;
|
||||||
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
|
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
|
||||||
@ -54,11 +55,19 @@ public class ParsedCommand {
|
|||||||
final CommandCondition commandCondition = syntax.getCommandCondition();
|
final CommandCondition commandCondition = syntax.getCommandCondition();
|
||||||
if (commandCondition == null || commandCondition.canUse(source, commandString)) {
|
if (commandCondition == null || commandCondition.canUse(source, commandString)) {
|
||||||
context.retrieveDefaultValues(syntax.getDefaultValuesMap());
|
context.retrieveDefaultValues(syntax.getDefaultValuesMap());
|
||||||
executor.apply(source, context);
|
try {
|
||||||
|
executor.apply(source, context);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
MinecraftServer.getExceptionManager().handleException(exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The executor is probably the default one
|
// The executor is probably the default one
|
||||||
executor.apply(source, context);
|
try {
|
||||||
|
executor.apply(source, context);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
MinecraftServer.getExceptionManager().handleException(exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (callback != null && argumentSyntaxException != null) {
|
} else if (callback != null && argumentSyntaxException != null) {
|
||||||
// No syntax has been validated but the faulty argument with a callback has been found
|
// No syntax has been validated but the faulty argument with a callback has been found
|
||||||
|
Loading…
Reference in New Issue
Block a user