✨ Prevent command arguments from being used in multiple commands
Also get rid of some random annoying warnings.
This commit is contained in:
parent
b564ecf60d
commit
a4544a8550
5 changed files with 44 additions and 2 deletions
|
|
@ -85,7 +85,7 @@ 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<?>, Supplier<ArgumentType<?>>> defaultArgumentTypeSuppliers;
|
||||
private final Map<@NonNull Class<?>, @NonNull Supplier<@Nullable ArgumentType<?>>> defaultArgumentTypeSuppliers;
|
||||
private final Supplier<CommandContext<C>> dummyContextProvider;
|
||||
private final CommandManager<C> commandManager;
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ public final class CloudBrigadierManager<C, S> {
|
|||
* @param supplier Supplier that supplies the argument type
|
||||
*/
|
||||
public void registerDefaultArgumentTypeSupplier(final @NonNull Class<?> clazz,
|
||||
final @NonNull Supplier<@NonNull ArgumentType<?>> supplier) {
|
||||
final @NonNull Supplier<@Nullable ArgumentType<?>> supplier) {
|
||||
this.defaultArgumentTypeSuppliers.put(clazz, supplier);
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +238,13 @@ public final class CloudBrigadierManager<C, S> {
|
|||
final @NonNull ArgumentParser<C, T> argument) {
|
||||
final Supplier<ArgumentType<?>> argumentTypeSupplier = this.defaultArgumentTypeSuppliers
|
||||
.get(GenericTypeReflector.erase(clazz.getType()));
|
||||
@Nullable final ArgumentType<?> defaultType;
|
||||
if (argumentTypeSupplier != null) {
|
||||
defaultType = argumentTypeSupplier.get();
|
||||
} else {
|
||||
defaultType = null;
|
||||
}
|
||||
if (defaultType != null) {
|
||||
return new Pair<>(argumentTypeSupplier.get(), true);
|
||||
}
|
||||
return new Pair<>(StringArgumentType.string(), false);
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ class PaperBrigadierListener<C> implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onCommandRegister(@Nonnull final CommandRegisteredEvent<BukkitBrigadierCommandSource> event) {
|
||||
if (!(event.getCommand() instanceof PluginIdentifiableCommand)) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue