core: Allow attaching a default description to arguments

This commit is contained in:
Zach Levis 2021-01-11 23:56:42 -08:00 committed by Alexander Söderberg
parent b38c725dc5
commit 78b081ccc2
29 changed files with 323 additions and 83 deletions

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -53,9 +54,10 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
) {
super(required, name, new EnchantmentParser<>(), defaultValue, Enchantment.class, suggestionsProvider);
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new EnchantmentParser<>(), defaultValue, Enchantment.class, suggestionsProvider, defaultDescription);
}
/**
@ -118,7 +120,8 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
this.isRequired(),
this.getName(),
this.getDefaultValue(),
this.getSuggestionsProvider()
this.getSuggestionsProvider(),
this.getDefaultDescription()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -52,8 +53,9 @@ public class MaterialArgument<C> extends CommandArgument<C, Material> {
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
) {
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new MaterialParser<>(), defaultValue, Material.class, suggestionsProvider);
}
@ -117,7 +119,8 @@ public class MaterialArgument<C> extends CommandArgument<C, Material> {
this.isRequired(),
this.getName(),
this.getDefaultValue(),
this.getSuggestionsProvider()
this.getSuggestionsProvider(),
this.getDefaultDescription()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -58,9 +59,18 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new OfflinePlayerParser<>(), defaultValue, OfflinePlayer.class, suggestionsProvider);
super(
required,
name,
new OfflinePlayerParser<>(),
defaultValue,
OfflinePlayer.class,
suggestionsProvider,
defaultDescription
);
}
/**
@ -126,7 +136,7 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
@Override
public @NonNull OfflinePlayerArgument<C> build() {
return new OfflinePlayerArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(),
this.getSuggestionsProvider()
this.getSuggestionsProvider(), this.getDefaultDescription()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -54,9 +55,10 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new PlayerParser<>(), defaultValue, Player.class, suggestionsProvider);
super(required, name, new PlayerParser<>(), defaultValue, Player.class, suggestionsProvider, defaultDescription);
}
/**
@ -121,7 +123,13 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
*/
@Override
public @NonNull PlayerArgument<C> build() {
return new PlayerArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(), this.getSuggestionsProvider());
return new PlayerArgument<>(
this.isRequired(),
this.getName(),
this.getDefaultValue(),
this.getSuggestionsProvider(),
this.getDefaultDescription()
);
}
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -52,9 +53,10 @@ public class WorldArgument<C> extends CommandArgument<C, World> {
final boolean required,
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new WorldParser<>(), defaultValue, World.class, suggestionsProvider);
super(required, name, new WorldParser<>(), defaultValue, World.class, suggestionsProvider, defaultDescription);
}
/**
@ -114,7 +116,13 @@ public class WorldArgument<C> extends CommandArgument<C, World> {
@Override
public @NonNull CommandArgument<C, World> build() {
return new WorldArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(), this.getSuggestionsProvider());
return new WorldArgument<>(
this.isRequired(),
this.getName(),
this.getDefaultValue(),
this.getSuggestionsProvider(),
this.getDefaultDescription()
);
}
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers.location;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -57,6 +58,7 @@ public final class Location2DArgument<C> extends CommandArgument<C, Location2D>
final boolean required,
final @NonNull String name,
final @NonNull String defaultValue,
final @NonNull ArgumentDescription defaultDescription,
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>,
@NonNull Queue<@NonNull String>, @NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
@ -68,6 +70,7 @@ public final class Location2DArgument<C> extends CommandArgument<C, Location2D>
defaultValue,
TypeToken.get(Location2D.class),
suggestionsProvider,
defaultDescription,
argumentPreprocessors
);
}
@ -133,6 +136,7 @@ public final class Location2DArgument<C> extends CommandArgument<C, Location2D>
this.isRequired(),
this.getName(),
this.getDefaultValue(),
this.getDefaultDescription(),
this.getSuggestionsProvider(),
new LinkedList<>()
);

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers.location;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -63,6 +64,7 @@ public final class LocationArgument<C> extends CommandArgument<C, Location> {
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription,
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>,
@NonNull Queue<@NonNull String>, @NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
) {
@ -73,6 +75,7 @@ public final class LocationArgument<C> extends CommandArgument<C, Location> {
defaultValue,
TypeToken.get(Location.class),
suggestionsProvider,
defaultDescription,
argumentPreprocessors
);
}
@ -139,6 +142,7 @@ public final class LocationArgument<C> extends CommandArgument<C, Location> {
this.getName(),
this.getDefaultValue(),
this.getSuggestionsProvider(),
this.getDefaultDescription(),
new LinkedList<>()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers.selector;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -47,10 +48,11 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new MultipleEntitySelectorParser<>(), defaultValue, MultipleEntitySelector.class,
suggestionsProvider
suggestionsProvider, defaultDescription
);
}
@ -117,7 +119,7 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
@Override
public @NonNull MultipleEntitySelectorArgument<C> build() {
return new MultipleEntitySelectorArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(),
this.getSuggestionsProvider()
this.getSuggestionsProvider(), this.getDefaultDescription()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers.selector;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -51,10 +52,11 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new MultiplePlayerSelectorParser<>(), defaultValue, MultiplePlayerSelector.class,
suggestionsProvider
suggestionsProvider, defaultDescription
);
}
@ -121,7 +123,7 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
@Override
public @NonNull MultiplePlayerSelectorArgument<C> build() {
return new MultiplePlayerSelectorArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(),
this.getSuggestionsProvider()
this.getSuggestionsProvider(), this.getDefaultDescription()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers.selector;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -47,9 +48,18 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new SingleEntitySelectorParser<>(), defaultValue, SingleEntitySelector.class, suggestionsProvider);
super(
required,
name,
new SingleEntitySelectorParser<>(),
defaultValue,
SingleEntitySelector.class,
suggestionsProvider,
defaultDescription
);
}
/**
@ -115,7 +125,7 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
@Override
public @NonNull SingleEntitySelectorArgument<C> build() {
return new SingleEntitySelectorArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(),
this.getSuggestionsProvider()
this.getSuggestionsProvider(), this.getDefaultDescription()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bukkit.parsers.selector;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -51,9 +52,18 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
final @NonNull String name,
final @NonNull String defaultValue,
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String,
@NonNull List<@NonNull String>> suggestionsProvider
@NonNull List<@NonNull String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription
) {
super(required, name, new SinglePlayerSelectorParser<>(), defaultValue, SinglePlayerSelector.class, suggestionsProvider);
super(
required,
name,
new SinglePlayerSelectorParser<>(),
defaultValue,
SinglePlayerSelector.class,
suggestionsProvider,
defaultDescription
);
}
/**
@ -119,7 +129,7 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
@Override
public @NonNull SinglePlayerSelectorArgument<C> build() {
return new SinglePlayerSelectorArgument<>(this.isRequired(), this.getName(), this.getDefaultValue(),
this.getSuggestionsProvider()
this.getSuggestionsProvider(), this.getDefaultDescription()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bungee.arguments;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -56,6 +57,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, ProxiedPlayer> {
final boolean required,
final @NonNull String name,
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionProvider,
final @NonNull ArgumentDescription defaultDescription,
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
@NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
) {
@ -66,6 +68,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, ProxiedPlayer> {
"",
TypeToken.get(ProxiedPlayer.class),
suggestionProvider,
defaultDescription,
argumentPreprocessors
);
}
@ -128,6 +131,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, ProxiedPlayer> {
this.isRequired(),
this.getName(),
this.getSuggestionsProvider(),
this.getDefaultDescription(),
new LinkedList<>()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.bungee.arguments;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -56,6 +57,7 @@ public final class ServerArgument<C> extends CommandArgument<C, ServerInfo> {
final boolean required,
final @NonNull String name,
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription,
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
@NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
) {
@ -66,6 +68,7 @@ public final class ServerArgument<C> extends CommandArgument<C, ServerInfo> {
"",
TypeToken.get(ServerInfo.class),
suggestionsProvider,
defaultDescription,
argumentPreprocessors
);
}
@ -127,6 +130,7 @@ public final class ServerArgument<C> extends CommandArgument<C, ServerInfo> {
this.isRequired(),
this.getName(),
this.getSuggestionsProvider(),
this.getDefaultDescription(),
new LinkedList<>()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.velocity.arguments;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -56,6 +57,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
final boolean required,
final @NonNull String name,
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription,
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
@NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
) {
@ -66,6 +68,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
"",
TypeToken.get(Player.class),
suggestionsProvider,
defaultDescription,
argumentPreprocessors
);
}
@ -126,6 +129,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
this.isRequired(),
this.getName(),
this.getSuggestionsProvider(),
this.getDefaultDescription(),
new LinkedList<>()
);
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.velocity.arguments;
import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.ArgumentParser;
@ -56,6 +57,7 @@ public final class ServerArgument<C> extends CommandArgument<C, RegisteredServer
final boolean required,
final @NonNull String name,
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
final @NonNull ArgumentDescription defaultDescription,
final @NonNull Collection<@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
@NonNull ArgumentParseResult<Boolean>>> argumentPreprocessors
) {
@ -66,6 +68,7 @@ public final class ServerArgument<C> extends CommandArgument<C, RegisteredServer
"",
TypeToken.get(RegisteredServer.class),
suggestionsProvider,
defaultDescription,
argumentPreprocessors
);
}
@ -123,6 +126,7 @@ public final class ServerArgument<C> extends CommandArgument<C, RegisteredServer
this.isRequired(),
this.getName(),
this.getSuggestionsProvider(),
this.getDefaultDescription(),
new LinkedList<>()
);
}