Fix an issue created by breaking changes in Velocity. CommandSource#sendMessage now requires an Identity

This commit is contained in:
allenclan23 2020-10-15 23:21:07 -04:00 committed by Alexander Söderberg
parent 42d56a4bbe
commit 4de9946683

View file

@ -32,6 +32,7 @@ import cloud.commandframework.execution.CommandResult;
import com.mojang.brigadier.Command; import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.CommandSource;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@ -79,6 +80,7 @@ final class VelocityExecutor<C> implements Command<CommandSource> {
(InvalidSyntaxException) throwable, (InvalidSyntaxException) throwable,
(c, e) -> (c, e) ->
source.sendMessage( source.sendMessage(
Identity.nil(),
Component Component
.text() .text()
.append( .append(
@ -100,6 +102,7 @@ final class VelocityExecutor<C> implements Command<CommandSource> {
(InvalidCommandSenderException) throwable, (InvalidCommandSenderException) throwable,
(c, e) -> (c, e) ->
source.sendMessage( source.sendMessage(
Identity.nil(),
Component.text( Component.text(
finalThrowable.getMessage(), finalThrowable.getMessage(),
NamedTextColor.RED NamedTextColor.RED
@ -111,14 +114,14 @@ final class VelocityExecutor<C> implements Command<CommandSource> {
sender, sender,
NoPermissionException.class, NoPermissionException.class,
(NoPermissionException) throwable, (NoPermissionException) throwable,
(c, e) -> source.sendMessage(Component.text(MESSAGE_NO_PERMS)) (c, e) -> source.sendMessage(Identity.nil(), Component.text(MESSAGE_NO_PERMS))
); );
} else if (throwable instanceof NoSuchCommandException) { } else if (throwable instanceof NoSuchCommandException) {
this.manager.handleException( this.manager.handleException(
sender, sender,
NoSuchCommandException.class, NoSuchCommandException.class,
(NoSuchCommandException) throwable, (NoSuchCommandException) throwable,
(c, e) -> source.sendMessage(Component.text(MESSAGE_UNKNOWN_COMMAND)) (c, e) -> source.sendMessage(Identity.nil(), Component.text(MESSAGE_UNKNOWN_COMMAND))
); );
} else if (throwable instanceof ArgumentParseException) { } else if (throwable instanceof ArgumentParseException) {
this.manager.handleException( this.manager.handleException(
@ -127,6 +130,7 @@ final class VelocityExecutor<C> implements Command<CommandSource> {
(ArgumentParseException) throwable, (ArgumentParseException) throwable,
(c, e) -> (c, e) ->
source.sendMessage( source.sendMessage(
Identity.nil(),
Component.text() Component.text()
.append(Component.text( .append(Component.text(
"Invalid Command Argument: ", "Invalid Command Argument: ",
@ -140,6 +144,7 @@ final class VelocityExecutor<C> implements Command<CommandSource> {
); );
} else { } else {
source.sendMessage( source.sendMessage(
Identity.nil(),
Component.text(throwable.getMessage(), NamedTextColor.RED) Component.text(throwable.getMessage(), NamedTextColor.RED)
); );
throwable.printStackTrace(); throwable.printStackTrace();