✨ Cleanup annotations and remove Cloud Brigs Pair (#32)
This commit is contained in:
parent
c3469706ab
commit
f1d4529276
10 changed files with 93 additions and 117 deletions
|
|
@ -58,14 +58,14 @@ public class JDACommandListener<C> extends ListenerAdapter {
|
|||
|
||||
@Override
|
||||
public final void onMessageReceived(final @NonNull MessageReceivedEvent event) {
|
||||
Message message = event.getMessage();
|
||||
C sender = commandManager.getCommandSenderMapper().apply(event);
|
||||
final Message message = event.getMessage();
|
||||
final C sender = this.commandManager.getCommandSenderMapper().apply(event);
|
||||
|
||||
if (commandManager.getBotId() == event.getAuthor().getIdLong()) {
|
||||
if (this.commandManager.getBotId() == event.getAuthor().getIdLong()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String prefix = commandManager.getPrefixMapper().apply(sender);
|
||||
final String prefix = this.commandManager.getPrefixMapper().apply(sender);
|
||||
String content = message.getContentRaw();
|
||||
|
||||
if (!content.startsWith(prefix)) {
|
||||
|
|
@ -81,40 +81,40 @@ public class JDACommandListener<C> extends ListenerAdapter {
|
|||
}
|
||||
|
||||
if (throwable instanceof InvalidSyntaxException) {
|
||||
commandManager.handleException(sender,
|
||||
this.commandManager.handleException(sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable, (c, e) -> {
|
||||
sendMessage(event,
|
||||
this.sendMessage(event,
|
||||
MESSAGE_INVALID_SYNTAX + prefix + ((InvalidSyntaxException) throwable)
|
||||
.getCorrectSyntax());
|
||||
});
|
||||
} else if (throwable instanceof InvalidCommandSenderException) {
|
||||
commandManager.handleException(sender,
|
||||
this.commandManager.handleException(sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable, (c, e) ->
|
||||
sendMessage(event, throwable.getMessage())
|
||||
this.sendMessage(event, throwable.getMessage())
|
||||
);
|
||||
} else if (throwable instanceof NoPermissionException) {
|
||||
commandManager.handleException(sender,
|
||||
this.commandManager.handleException(sender,
|
||||
NoPermissionException.class,
|
||||
(NoPermissionException) throwable, (c, e) ->
|
||||
sendMessage(event, MESSAGE_NO_PERMS)
|
||||
this.sendMessage(event, MESSAGE_NO_PERMS)
|
||||
);
|
||||
} else if (throwable instanceof NoSuchCommandException) {
|
||||
commandManager.handleException(sender,
|
||||
this.commandManager.handleException(sender,
|
||||
NoSuchCommandException.class,
|
||||
(NoSuchCommandException) throwable, (c, e) ->
|
||||
sendMessage(event, MESSAGE_UNKNOWN_COMMAND)
|
||||
this.sendMessage(event, MESSAGE_UNKNOWN_COMMAND)
|
||||
);
|
||||
} else if (throwable instanceof ArgumentParseException) {
|
||||
commandManager.handleException(sender, ArgumentParseException.class,
|
||||
this.commandManager.handleException(sender, ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable, (c, e) -> {
|
||||
sendMessage(event,
|
||||
this.sendMessage(event,
|
||||
"Invalid Command Argument: " + throwable.getCause()
|
||||
.getMessage());
|
||||
});
|
||||
} else {
|
||||
sendMessage(event, throwable.getMessage());
|
||||
this.sendMessage(event, throwable.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ public class JDACommandManager<C> extends CommandManager<C> {
|
|||
private final Function<@NonNull C, @NonNull MessageReceivedEvent> backwardsCommandSenderMapper;
|
||||
|
||||
/**
|
||||
* final
|
||||
* Construct a new JDA Command Manager
|
||||
*
|
||||
* @param jda JDA instance to register against
|
||||
|
|
@ -86,7 +85,7 @@ public class JDACommandManager<C> extends CommandManager<C> {
|
|||
*
|
||||
* @return Prefix mapper
|
||||
*/
|
||||
public final @NonNull Function<C, String> getPrefixMapper() {
|
||||
public final @NonNull Function<@NonNull C, @NonNull String> getPrefixMapper() {
|
||||
return this.prefixMapper;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,13 +87,6 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
return UserArgument.<C>newBuilder(name, jda).asOptional().build();
|
||||
}
|
||||
|
||||
|
||||
public enum ParserMode {
|
||||
MENTION,
|
||||
ID,
|
||||
NAME
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the modes enabled on the parser
|
||||
*
|
||||
|
|
@ -103,6 +96,14 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
return modes;
|
||||
}
|
||||
|
||||
|
||||
public enum ParserMode {
|
||||
MENTION,
|
||||
ID,
|
||||
NAME
|
||||
}
|
||||
|
||||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, User> {
|
||||
private final JDA jda;
|
||||
private List<ParserMode> modes = new ArrayList<>();
|
||||
|
|
@ -158,7 +159,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
if (modes.contains(ParserMode.MENTION)) {
|
||||
if (input.endsWith(">")) {
|
||||
String id;
|
||||
final String id;
|
||||
if (input.startsWith("<@!")) {
|
||||
id = input.substring(3, input.length() - 1);
|
||||
} else {
|
||||
|
|
@ -166,10 +167,10 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
}
|
||||
|
||||
try {
|
||||
final ArgumentParseResult<User> result = userFromId(input, id);
|
||||
final ArgumentParseResult<User> result = this.userFromId(input, id);
|
||||
inputQueue.remove();
|
||||
return result;
|
||||
} catch (UserNotFoundParseException | NumberFormatException e) {
|
||||
} catch (final UserNotFoundParseException | NumberFormatException e) {
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
|
|
@ -177,16 +178,16 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
if (modes.contains(ParserMode.ID)) {
|
||||
try {
|
||||
final ArgumentParseResult<User> result = userFromId(input, input);
|
||||
final ArgumentParseResult<User> result = this.userFromId(input, input);
|
||||
inputQueue.remove();
|
||||
return result;
|
||||
} catch (UserNotFoundParseException | NumberFormatException e) {
|
||||
} catch (final UserNotFoundParseException | NumberFormatException e) {
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (modes.contains(ParserMode.NAME)) {
|
||||
List<User> users = jda.getUsersByName(input, true);
|
||||
final List<User> users = jda.getUsersByName(input, true);
|
||||
|
||||
if (users.size() == 0) {
|
||||
exception = new UserNotFoundParseException(input);
|
||||
|
|
@ -209,7 +210,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
private @NonNull ArgumentParseResult<User> userFromId(final @NonNull String input, final @NonNull String id)
|
||||
throws UserNotFoundParseException, NumberFormatException {
|
||||
User user = jda.getUserById(id);
|
||||
final User user = jda.getUserById(id);
|
||||
|
||||
if (user == null) {
|
||||
throw new UserNotFoundParseException(input);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import cloud.commandframework.context.CommandContext;
|
|||
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
|
||||
import cloud.commandframework.permission.CommandPermission;
|
||||
import cloud.commandframework.permission.Permission;
|
||||
import cloud.commandframework.types.tuples.Pair;
|
||||
import com.mojang.brigadier.LiteralMessage;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
|
|
@ -83,8 +84,7 @@ import java.util.function.Supplier;
|
|||
*/
|
||||
public final class CloudBrigadierManager<C, S> {
|
||||
|
||||
private final Map<Class<?>, cloud.commandframework.types.tuples.Pair<Function<? extends ArgumentParser<C, ?>,
|
||||
? extends ArgumentType<?>>, Boolean>> mappers;
|
||||
private final Map<Class<?>, Pair<Function<? extends ArgumentParser<C, ?>, ? extends ArgumentType<?>>, Boolean>> mappers;
|
||||
private final Map<@NonNull Class<?>, @NonNull Supplier<@Nullable ArgumentType<?>>> defaultArgumentTypeSuppliers;
|
||||
private final Supplier<CommandContext<C>> dummyContextProvider;
|
||||
private final CommandManager<C> commandManager;
|
||||
|
|
@ -203,8 +203,7 @@ public final class CloudBrigadierManager<C, S> {
|
|||
final boolean nativeSuggestions,
|
||||
final @NonNull Function<@NonNull ? extends K,
|
||||
@NonNull ? extends ArgumentType<O>> mapper) {
|
||||
this.mappers.put(GenericTypeReflector.erase(argumentType.getType()),
|
||||
cloud.commandframework.types.tuples.Pair.of(mapper, nativeSuggestions));
|
||||
this.mappers.put(GenericTypeReflector.erase(argumentType.getType()), Pair.of(mapper, nativeSuggestions));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -224,12 +223,11 @@ public final class CloudBrigadierManager<C, S> {
|
|||
final @NonNull TypeToken<T> argumentType,
|
||||
final @NonNull K argument) {
|
||||
final ArgumentParser<C, ?> commandArgument = (ArgumentParser<C, ?>) argument;
|
||||
final cloud.commandframework.types.tuples.Pair pair
|
||||
= this.mappers.get(GenericTypeReflector.erase(argumentType.getType()));
|
||||
final Pair pair = this.mappers.get(GenericTypeReflector.erase(argumentType.getType()));
|
||||
if (pair == null || pair.getFirst() == null) {
|
||||
return this.createDefaultMapper(valueType, commandArgument);
|
||||
}
|
||||
return new Pair<>((ArgumentType<?>) ((Function) pair.getFirst()).apply(commandArgument),
|
||||
return Pair.of((ArgumentType<?>) ((Function) pair.getFirst()).apply(commandArgument),
|
||||
(boolean) pair.getSecond());
|
||||
}
|
||||
|
||||
|
|
@ -245,9 +243,9 @@ public final class CloudBrigadierManager<C, S> {
|
|||
defaultType = null;
|
||||
}
|
||||
if (defaultType != null) {
|
||||
return new Pair<>(argumentTypeSupplier.get(), true);
|
||||
return Pair.of(argumentTypeSupplier.get(), true);
|
||||
}
|
||||
return new Pair<>(StringArgumentType.string(), false);
|
||||
return Pair.of(StringArgumentType.string(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -339,10 +337,10 @@ public final class CloudBrigadierManager<C, S> {
|
|||
final Pair<ArgumentType<?>, Boolean> pair = this.getArgument(TypeToken.get((Class<?>) types[i]),
|
||||
TypeToken.get(parser.getClass()),
|
||||
parser);
|
||||
final SuggestionProvider<S> provider = pair.getRight() ? null : suggestionProvider;
|
||||
final SuggestionProvider<S> provider = pair.getSecond() ? null : suggestionProvider;
|
||||
|
||||
final ArgumentBuilder<S, ?> fragmentBuilder = RequiredArgumentBuilder
|
||||
.<S, Object>argument((String) names[i], (ArgumentType<Object>) pair.getLeft())
|
||||
.<S, Object>argument((String) names[i], (ArgumentType<Object>) pair.getFirst())
|
||||
.suggests(provider)
|
||||
.requires(sender -> permissionChecker.test(sender,
|
||||
(CommandPermission) root.getNodeMeta()
|
||||
|
|
@ -378,12 +376,12 @@ public final class CloudBrigadierManager<C, S> {
|
|||
final Pair<ArgumentType<?>, Boolean> pair = this.getArgument(root.getValue().getValueType(),
|
||||
TypeToken.get(root.getValue().getParser().getClass()),
|
||||
root.getValue().getParser());
|
||||
final SuggestionProvider<S> provider = pair.getRight()
|
||||
final SuggestionProvider<S> provider = pair.getSecond()
|
||||
? null
|
||||
: (context, builder) -> this.buildSuggestions(root.getValue(),
|
||||
context, builder);
|
||||
argumentBuilder = RequiredArgumentBuilder
|
||||
.<S, Object>argument(root.getValue().getName(), (ArgumentType<Object>) pair.getLeft())
|
||||
.<S, Object>argument(root.getValue().getName(), (ArgumentType<Object>) pair.getFirst())
|
||||
.suggests(provider)
|
||||
.requires(sender -> permissionChecker.test(sender,
|
||||
(CommandPermission) root.getNodeMeta()
|
||||
|
|
@ -440,26 +438,4 @@ public final class CloudBrigadierManager<C, S> {
|
|||
return builder.buildFuture();
|
||||
}
|
||||
|
||||
|
||||
private static final class Pair<L, R> {
|
||||
|
||||
private final L left;
|
||||
private final R right;
|
||||
|
||||
private Pair(final @NonNull L left,
|
||||
final @NonNull R right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
private @NonNull L getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
private @NonNull R getRight() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,9 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final CommandSender commandSender, final String s, final String[] strings) {
|
||||
public boolean execute(final @NonNull CommandSender commandSender,
|
||||
final @NonNull String s,
|
||||
final @NonNull String @NonNull [] strings) {
|
||||
/* Join input */
|
||||
final StringBuilder builder = new StringBuilder(this.command.getName());
|
||||
for (final String string : strings) {
|
||||
|
|
@ -135,8 +137,10 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(final CommandSender sender, final String alias, final String[] args) throws
|
||||
IllegalArgumentException {
|
||||
public List<String> tabComplete(final @NonNull CommandSender sender,
|
||||
final @NonNull String alias,
|
||||
final @NonNull String @NonNull [] args)
|
||||
throws IllegalArgumentException {
|
||||
final StringBuilder builder = new StringBuilder(this.command.getName());
|
||||
for (final String string : args) {
|
||||
builder.append(" ").append(string);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -39,17 +39,17 @@ class AsyncCommandSuggestionsListener<C> implements Listener {
|
|||
|
||||
private final PaperCommandManager<C> paperCommandManager;
|
||||
|
||||
AsyncCommandSuggestionsListener(@Nonnull final PaperCommandManager<C> paperCommandManager) {
|
||||
AsyncCommandSuggestionsListener(final @NonNull PaperCommandManager<C> paperCommandManager) {
|
||||
this.paperCommandManager = paperCommandManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onTabCompletion(@Nonnull final AsyncTabCompleteEvent event) throws Exception {
|
||||
void onTabCompletion(final @NonNull AsyncTabCompleteEvent event) throws Exception {
|
||||
if (event.getBuffer().isEmpty() || !event.getBuffer().startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
final String[] arguments = event.getBuffer().substring(1).split(" ");
|
||||
if (paperCommandManager.getCommandTree().getNamedNode(arguments[0]) == null) {
|
||||
if (this.paperCommandManager.getCommandTree().getNamedNode(arguments[0]) == null) {
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ import org.bukkit.enchantments.Enchantment;
|
|||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.UUID;
|
||||
|
|
@ -60,7 +60,7 @@ class PaperBrigadierListener<C> implements Listener {
|
|||
private final PaperCommandManager<C> paperCommandManager;
|
||||
private final String nmsVersion;
|
||||
|
||||
PaperBrigadierListener(@Nonnull final PaperCommandManager<C> paperCommandManager) {
|
||||
PaperBrigadierListener(final @NonNull PaperCommandManager<C> paperCommandManager) {
|
||||
this.paperCommandManager = paperCommandManager;
|
||||
this.brigadierManager = new CloudBrigadierManager<>(this.paperCommandManager,
|
||||
() -> new CommandContext<>(
|
||||
|
|
@ -120,8 +120,7 @@ class PaperBrigadierListener<C> implements Listener {
|
|||
* @return Argument class
|
||||
* @throws Exception If the type cannot be retrieved
|
||||
*/
|
||||
@Nonnull
|
||||
private Class<?> getNMSArgument(@Nonnull final String argument) throws Exception {
|
||||
private @NonNull Class<?> getNMSArgument(final @NonNull String argument) throws Exception {
|
||||
return Class.forName(String.format("net.minecraft.server.%s.Argument%s", this.nmsVersion, argument));
|
||||
}
|
||||
|
||||
|
|
@ -131,8 +130,8 @@ class PaperBrigadierListener<C> implements Listener {
|
|||
* @param type Type to map
|
||||
* @param constructor Constructor that construct the NMS argument type
|
||||
*/
|
||||
public void mapSimpleNMS(@Nonnull final Class<?> type,
|
||||
@Nonnull final Constructor<?> constructor) {
|
||||
public void mapSimpleNMS(final @NonNull Class<?> type,
|
||||
final @NonNull Constructor<?> constructor) {
|
||||
try {
|
||||
this.brigadierManager.registerDefaultArgumentTypeSupplier(type, () -> {
|
||||
try {
|
||||
|
|
@ -156,8 +155,8 @@ class PaperBrigadierListener<C> implements Listener {
|
|||
* @param type Type to map
|
||||
* @param argumentTypeSupplier Supplier of the NMS argument type
|
||||
*/
|
||||
public void mapComplexNMS(@Nonnull final Class<?> type,
|
||||
@Nonnull final Supplier<ArgumentType<?>> argumentTypeSupplier) {
|
||||
public void mapComplexNMS(final @NonNull Class<?> type,
|
||||
final @NonNull Supplier<ArgumentType<?>> argumentTypeSupplier) {
|
||||
try {
|
||||
this.brigadierManager.registerDefaultArgumentTypeSupplier(type, argumentTypeSupplier);
|
||||
} catch (final Exception e) {
|
||||
|
|
@ -170,7 +169,7 @@ class PaperBrigadierListener<C> implements Listener {
|
|||
|
||||
@EventHandler
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onCommandRegister(@Nonnull final CommandRegisteredEvent<BukkitBrigadierCommandSource> event) {
|
||||
public void onCommandRegister(final @NonNull CommandRegisteredEvent<BukkitBrigadierCommandSource> event) {
|
||||
if (!(event.getCommand() instanceof PluginIdentifiableCommand)) {
|
||||
return;
|
||||
} else if (!((PluginIdentifiableCommand) event.getCommand())
|
||||
|
|
@ -190,8 +189,8 @@ class PaperBrigadierListener<C> implements Listener {
|
|||
return;
|
||||
}
|
||||
final BiPredicate<BukkitBrigadierCommandSource, CommandPermission> permissionChecker = (s, p) -> {
|
||||
final C sender = paperCommandManager.getCommandSenderMapper().apply(s.getBukkitSender());
|
||||
return paperCommandManager.hasPermission(sender, p);
|
||||
final C sender = this.paperCommandManager.getCommandSenderMapper().apply(s.getBukkitSender());
|
||||
return this.paperCommandManager.hasPermission(sender, p);
|
||||
};
|
||||
event.setLiteral(this.brigadierManager.createLiteralCommandNode(node,
|
||||
event.getLiteral(),
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ import cloud.commandframework.execution.CommandExecutionCoordinator;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
|
|
@ -50,11 +50,11 @@ public class PaperCommandManager<C> extends BukkitCommandManager<C> {
|
|||
* @param backwardsCommandSenderMapper Function that maps the command sender type to {@link CommandSender}
|
||||
* @throws Exception If the construction of the manager fails
|
||||
*/
|
||||
public PaperCommandManager(@Nonnull final Plugin owningPlugin,
|
||||
@Nonnull final Function<CommandTree<C>,
|
||||
public PaperCommandManager(final @NonNull Plugin owningPlugin,
|
||||
final @NonNull Function<CommandTree<C>,
|
||||
CommandExecutionCoordinator<C>> commandExecutionCoordinator,
|
||||
@Nonnull final Function<CommandSender, C> commandSenderMapper,
|
||||
@Nonnull final Function<C, CommandSender> backwardsCommandSenderMapper) throws
|
||||
final @NonNull Function<CommandSender, C> commandSenderMapper,
|
||||
final @NonNull Function<C, CommandSender> backwardsCommandSenderMapper) throws
|
||||
Exception {
|
||||
super(owningPlugin, commandExecutionCoordinator, commandSenderMapper, backwardsCommandSenderMapper);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ import cloud.commandframework.meta.CommandMeta;
|
|||
import cloud.commandframework.meta.SimpleCommandMeta;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
|
|
@ -54,10 +54,10 @@ public class VelocityCommandManager<C> extends CommandManager<C> {
|
|||
* @param backwardsCommandSenderMapper Function that maps the command sender type to {@link CommandSource}
|
||||
*/
|
||||
public VelocityCommandManager(
|
||||
@Nonnull final ProxyServer proxyServer,
|
||||
@Nonnull final Function<CommandTree<C>, CommandExecutionCoordinator<C>> commandExecutionCoordinator,
|
||||
@Nonnull final Function<CommandSource, C> commandSenderMapper,
|
||||
@Nonnull final Function<C, CommandSource> backwardsCommandSenderMapper) {
|
||||
final @NonNull ProxyServer proxyServer,
|
||||
final @NonNull Function<@NonNull CommandTree<C>, @NonNull CommandExecutionCoordinator<C>> commandExecutionCoordinator,
|
||||
final @NonNull Function<@NonNull CommandSource, @NonNull C> commandSenderMapper,
|
||||
final @NonNull Function<@NonNull C, @NonNull CommandSource> backwardsCommandSenderMapper) {
|
||||
super(commandExecutionCoordinator, new VelocityPluginRegistrationHandler<>());
|
||||
((VelocityPluginRegistrationHandler<C>) this.getCommandRegistrationHandler()).initialize(this);
|
||||
this.proxyServer = proxyServer;
|
||||
|
|
@ -66,23 +66,20 @@ public class VelocityCommandManager<C> extends CommandManager<C> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final boolean hasPermission(@Nonnull final C sender, @Nonnull final String permission) {
|
||||
public final boolean hasPermission(final @NonNull C sender, final @NonNull String permission) {
|
||||
return this.backwardsCommandSenderMapper.apply(sender).hasPermission(permission);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final CommandMeta createDefaultCommandMeta() {
|
||||
public final @NonNull CommandMeta createDefaultCommandMeta() {
|
||||
return SimpleCommandMeta.empty();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
final ProxyServer getProxyServer() {
|
||||
final @NonNull ProxyServer getProxyServer() {
|
||||
return this.proxyServer;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
final Function<CommandSource, C> getCommandSenderMapper() {
|
||||
final @NonNull Function<@NonNull CommandSource, @NonNull C> getCommandSenderMapper() {
|
||||
return this.commandSenderMapper;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ import com.velocitypowered.api.command.CommandMeta;
|
|||
import com.velocitypowered.api.command.CommandSource;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ final class VelocityPluginRegistrationHandler<C> implements CommandRegistrationH
|
|||
private CloudBrigadierManager<C, CommandSource> brigadierManager;
|
||||
private VelocityCommandManager<C> manager;
|
||||
|
||||
void initialize(@Nonnull final VelocityCommandManager<C> velocityCommandManager) {
|
||||
void initialize(final @NonNull VelocityCommandManager<C> velocityCommandManager) {
|
||||
this.manager = velocityCommandManager;
|
||||
this.brigadierManager = new CloudBrigadierManager<>(velocityCommandManager,
|
||||
() -> new CommandContext<>(
|
||||
|
|
@ -65,7 +65,7 @@ final class VelocityPluginRegistrationHandler<C> implements CommandRegistrationH
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean registerCommand(@Nonnull final Command<?> command) {
|
||||
public boolean registerCommand(final @NonNull Command<?> command) {
|
||||
final CommandArgument<?, ?> argument = command.getArguments().get(0);
|
||||
final List<String> aliases = ((StaticArgument<C>) argument).getAlternativeAliases();
|
||||
final BrigadierCommand brigadierCommand = new BrigadierCommand(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue