Various minor cleanup

This commit is contained in:
Jason Penilla 2021-06-28 02:13:48 -07:00 committed by Jason
parent 0c5fec4187
commit f7b7b93251
12 changed files with 29 additions and 21 deletions

View file

@ -746,7 +746,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
}
/**
* A variant of builders designed for subclassing, that returns a self type .
* A variant of builders designed for subclassing, that returns a self type.
*
* @param <C> sender type
* @param <T> argument value type

View file

@ -212,7 +212,7 @@ cloud mappings for the Fabric mod loader for Minecraft 1.16+
**gradle**:
```groovy
dependencies {
modImplementation 'cloud.commandframework:cloud-fabric:1.3.0-SNAPSHOT'
modImplementation 'cloud.commandframework:cloud-fabric:1.5.0-SNAPSHOT'
}
```

View file

@ -46,6 +46,7 @@ public interface ProtoItemStack {
* Get whether this {@link ProtoItemStack} contains extra data besides the {@link Material}.
*
* @return whether there is extra data
* @since 1.5.0
*/
boolean hasExtraData();
@ -56,6 +57,7 @@ public interface ProtoItemStack {
* @param respectMaximumStackSize whether to respect the maximum stack size for the material
* @return the created {@link ItemStack}
* @throws IllegalArgumentException if the {@link ItemStack} could not be created, due to max stack size or other reasons
* @since 1.5.0
*/
@NonNull ItemStack createItemStack(int stackSize, boolean respectMaximumStackSize)
throws IllegalArgumentException;

View file

@ -47,6 +47,7 @@
*/
package cloud.commandframework.bukkit.internal;
import com.google.common.annotations.Beta;
import com.mojang.brigadier.arguments.ArgumentType;
import org.bukkit.NamespacedKey;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -58,9 +59,12 @@ import java.util.Arrays;
/**
* A registry of the {@link ArgumentType}s provided by Minecraft.
*
* <p>
* This file is taken from MIT licensed code in commodore (https://github.com/lucko/commodore).
*
* <p>This is not API, and as such, may break, change, or be removed without any notice.</p>
*/
@Beta
public final class MinecraftArgumentTypes {
private MinecraftArgumentTypes() {
@ -116,7 +120,9 @@ public final class MinecraftArgumentTypes {
* @throws IllegalArgumentException if no such argument is registered
*/
@SuppressWarnings("unchecked")
public static Class<? extends ArgumentType<?>> getClassByKey(final @NonNull NamespacedKey key) throws IllegalArgumentException {
public static Class<? extends ArgumentType<?>> getClassByKey(
final @NonNull NamespacedKey key
) throws IllegalArgumentException {
try {
Object minecraftKey = MINECRAFT_KEY_CONSTRUCTOR.newInstance(key.getNamespace(), key.getKey());
Object entry = ARGUMENT_REGISTRY_GET_BY_KEY_METHOD.invoke(null, minecraftKey);

View file

@ -22,6 +22,6 @@
// SOFTWARE.
//
/**
* cloud implementation for Bukkit 1.8-1.16
* cloud implementation for Bukkit 1.8-1.17
*/
package cloud.commandframework.bukkit;

View file

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"id": "cloud-v1",
"id": "cloud",
"version": "${version}",
"name": "Cloud",

View file

@ -30,6 +30,6 @@
"fabricloader": ">=0.7.4",
"fabric-command-api-v1": "*",
"minecraft": ">=1.14",
"cloud-v1": "*"
"cloud": "*"
}
}

View file

@ -167,15 +167,15 @@ public class VelocityCommandManager<C> extends CommandManager<C> implements Brig
return ((VelocityPluginRegistrationHandler<C>) this.getCommandRegistrationHandler()).brigadierManager();
}
final @NonNull ProxyServer getProxyServer() {
final @NonNull ProxyServer proxyServer() {
return this.proxyServer;
}
final @NonNull Function<@NonNull CommandSource, @NonNull C> getCommandSenderMapper() {
final @NonNull Function<@NonNull CommandSource, @NonNull C> commandSenderMapper() {
return this.commandSenderMapper;
}
final @NonNull Function<@NonNull C, @NonNull CommandSource> getBackwardsCommandSenderMapper() {
final @NonNull Function<@NonNull C, @NonNull CommandSource> backwardsCommandSenderMapper() {
return this.backwardsCommandSenderMapper;
}

View file

@ -51,7 +51,7 @@ final class VelocityCommandPreprocessor<C> implements CommandPreprocessor<C> {
public void accept(final @NonNull CommandPreprocessingContext<C> context) {
context.getCommandContext().store(
VelocityContextKeys.PROXY_SERVER_KEY,
this.mgr.getProxyServer()
this.mgr.proxyServer()
);
}

View file

@ -59,7 +59,7 @@ final class VelocityExecutor<C> implements Command<CommandSource> {
public int run(final @NonNull CommandContext<CommandSource> commandContext) {
final CommandSource source = commandContext.getSource();
final String input = commandContext.getInput();
final C sender = this.manager.getCommandSenderMapper().apply(
final C sender = this.manager.commandSenderMapper().apply(
source);
this.manager.executeCommand(sender, input).whenComplete(this.getResultConsumer(source, sender));
return com.mojang.brigadier.Command.SINGLE_SUCCESS;

View file

@ -46,16 +46,16 @@ final class VelocityPluginRegistrationHandler<C> implements CommandRegistrationH
this.brigadierManager = new CloudBrigadierManager<>(
velocityCommandManager,
() -> new CommandContext<>(
velocityCommandManager.getCommandSenderMapper()
.apply(velocityCommandManager.getProxyServer()
velocityCommandManager.commandSenderMapper()
.apply(velocityCommandManager.proxyServer()
.getConsoleCommandSource()),
velocityCommandManager
)
);
this.brigadierManager.brigadierSenderMapper(
sender -> this.manager.getCommandSenderMapper().apply(sender)
sender -> this.manager.commandSenderMapper().apply(sender)
);
this.brigadierManager.backwardsBrigadierSenderMapper(this.manager.getBackwardsCommandSenderMapper());
this.brigadierManager.backwardsBrigadierSenderMapper(this.manager.backwardsCommandSenderMapper());
}
@Override
@ -68,18 +68,18 @@ final class VelocityPluginRegistrationHandler<C> implements CommandRegistrationH
command.getArguments().get(0).getName(),
(Command<C>) command,
(c, p) -> this.manager.hasPermission(
this.manager.getCommandSenderMapper().apply(c),
this.manager.commandSenderMapper().apply(c),
p
),
true,
new VelocityExecutor<>(this.manager)
)
);
final CommandMeta commandMeta = this.manager.getProxyServer().getCommandManager()
final CommandMeta commandMeta = this.manager.proxyServer().getCommandManager()
.metaBuilder(brigadierCommand)
.aliases(aliases.toArray(new String[0])).build();
aliases.forEach(this.manager.getProxyServer().getCommandManager()::unregister);
this.manager.getProxyServer().getCommandManager().register(commandMeta, brigadierCommand);
aliases.forEach(this.manager.proxyServer().getCommandManager()::unregister);
this.manager.proxyServer().getCommandManager().register(commandMeta, brigadierCommand);
return true;
}

View file

@ -70,7 +70,7 @@ public final class ExamplePlugin extends Plugin {
mapperFunction
);
} catch (final Exception e) {
this.getLogger().severe("Failed to initialize the command this.manager");
this.getLogger().severe("Failed to initialize the command manager");
return;
}