Work towards making CommandMeta typesafe (#173)

Co-authored-by: Alexander Söderberg <sauilitired@gmail.com>
This commit is contained in:
zml 2020-12-16 03:07:22 -08:00 committed by Alexander Söderberg
parent ab366be24d
commit 1e91273e0e
33 changed files with 450 additions and 64 deletions

View file

@ -31,6 +31,7 @@ import cloud.commandframework.exceptions.InvalidCommandSenderException;
import cloud.commandframework.exceptions.InvalidSyntaxException;
import cloud.commandframework.exceptions.NoPermissionException;
import cloud.commandframework.exceptions.NoSuchCommandException;
import cloud.commandframework.meta.CommandMeta;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginIdentifiableCommand;
@ -63,7 +64,7 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
) {
super(
label,
cloudCommand.getCommandMeta().getOrDefault("description", ""),
cloudCommand.getCommandMeta().getOrDefault(CommandMeta.DESCRIPTION, ""),
"",
aliases
);
@ -163,7 +164,7 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
@Override
public String getDescription() {
return this.cloudCommand.getCommandMeta().getOrDefault("description", "");
return this.cloudCommand.getCommandMeta().getOrDefault(CommandMeta.DESCRIPTION, "");
}
@Override

View file

@ -215,6 +215,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> implements Brigad
* @return Meta data
*/
@Override
@SuppressWarnings("deprecation")
public @NonNull BukkitCommandMeta createDefaultCommandMeta() {
return BukkitCommandMetaBuilder.builder().withDescription("").build();
}

View file

@ -26,6 +26,12 @@ package cloud.commandframework.bukkit;
import cloud.commandframework.meta.SimpleCommandMeta;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Bukkit-specific command metadata holder.
*
* @deprecated for removal since 1.3.0. Use the standard {@link SimpleCommandMeta instead}.
*/
@Deprecated
public class BukkitCommandMeta extends SimpleCommandMeta {
/**
@ -34,7 +40,7 @@ public class BukkitCommandMeta extends SimpleCommandMeta {
* @param simpleCommandMeta Simple command meta data instance that gets mirrored
*/
public BukkitCommandMeta(final @NonNull SimpleCommandMeta simpleCommandMeta) {
super(simpleCommandMeta.getAll());
super(simpleCommandMeta);
}
}

View file

@ -24,8 +24,15 @@
package cloud.commandframework.bukkit;
import cloud.commandframework.meta.CommandMeta;
import cloud.commandframework.meta.SimpleCommandMeta;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Command meta builder with bukkit-specific parameters.
*
* @deprecated for removal since 1.3.0, use plain {@link SimpleCommandMeta.Builder} instead.
*/
@Deprecated
public final class BukkitCommandMetaBuilder {
private BukkitCommandMetaBuilder() {
@ -73,7 +80,7 @@ public final class BukkitCommandMetaBuilder {
* @return Meta instance
*/
public @NonNull BukkitCommandMeta build() {
return new BukkitCommandMeta(CommandMeta.simple().with("description", this.description).build());
return new BukkitCommandMeta(CommandMeta.simple().with(CommandMeta.DESCRIPTION, this.description).build());
}
}