🎨 Add caption for string "No input was provided"
This commit is contained in:
parent
c67cc35cf6
commit
fba29041e6
29 changed files with 191 additions and 31 deletions
|
|
@ -26,6 +26,7 @@ package cloud.commandframework.arguments;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -112,7 +113,10 @@ public final class StaticArgument<C> extends CommandArgument<C, String> {
|
|||
) {
|
||||
final String string = inputQueue.peek();
|
||||
if (string == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
StaticArgumentParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
if (this.allAcceptedAliases.contains(string)) {
|
||||
inputQueue.remove();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import cloud.commandframework.captions.Caption;
|
|||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Queue;
|
||||
|
|
@ -89,7 +90,10 @@ public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandCo
|
|||
) {
|
||||
final String head = strings.peek();
|
||||
if (head == null) {
|
||||
throw new NullPointerException("No input");
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
RegexPreprocessor.class,
|
||||
context
|
||||
));
|
||||
}
|
||||
if (predicate.test(head)) {
|
||||
return ArgumentParseResult.success(true);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -173,7 +174,10 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
BooleanParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
inputQueue.remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.NumberParseException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -189,7 +190,10 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
ByteParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
try {
|
||||
final byte value = Byte.parseByte(input);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -129,7 +130,10 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
CharacterParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
if (input.length() != 1) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.NumberParseException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -189,7 +190,10 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
DoubleParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
try {
|
||||
final double value = Double.parseDouble(input);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -167,7 +168,10 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
EnumParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
for (final E value : this.allowedValues) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.NumberParseException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -189,7 +190,10 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
FloatParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
try {
|
||||
final float value = Float.parseFloat(input);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.NumberParseException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -226,7 +227,10 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
IntegerParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
try {
|
||||
final int value = Integer.parseInt(input);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.NumberParseException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -183,7 +184,10 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
LongParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
try {
|
||||
final long value = Long.parseLong(input);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.NumberParseException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -189,7 +190,10 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
ShortParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
try {
|
||||
final short value = Short.parseShort(input);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import cloud.commandframework.util.StringUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -297,7 +298,10 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
StringParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
if (this.stringMode == StringMode.SINGLE) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -128,7 +129,10 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
UUIDParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ import java.util.function.BiFunction;
|
|||
*/
|
||||
public class SimpleCaptionRegistry<C> implements FactoryDelegatingCaptionRegistry<C> {
|
||||
|
||||
/**
|
||||
* Default caption for {@link StandardCaptionKeys#ARGUMENT_PARSE_FAILURE_NO_INPUT_PROVIDED}.
|
||||
*/
|
||||
public static final String ARGUMENT_PARSE_FAILURE_NO_INPUT_PROVIDED = "No input was provided";
|
||||
/**
|
||||
* Default caption for {@link StandardCaptionKeys#ARGUMENT_PARSE_FAILURE_BOOLEAN}.
|
||||
*/
|
||||
|
|
@ -84,6 +88,10 @@ public class SimpleCaptionRegistry<C> implements FactoryDelegatingCaptionRegistr
|
|||
private final Map<Caption, BiFunction<Caption, C, String>> messageFactories = new HashMap<>();
|
||||
|
||||
protected SimpleCaptionRegistry() {
|
||||
this.registerMessageFactory(
|
||||
StandardCaptionKeys.ARGUMENT_PARSE_FAILURE_NO_INPUT_PROVIDED,
|
||||
(caption, sender) -> ARGUMENT_PARSE_FAILURE_NO_INPUT_PROVIDED
|
||||
);
|
||||
this.registerMessageFactory(
|
||||
StandardCaptionKeys.ARGUMENT_PARSE_FAILURE_BOOLEAN,
|
||||
(caption, sender) -> ARGUMENT_PARSE_FAILURE_BOOLEAN
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ public final class StandardCaptionKeys {
|
|||
|
||||
private static final Collection<Caption> RECOGNIZED_CAPTIONS = new LinkedList<>();
|
||||
|
||||
/**
|
||||
* Variables: None
|
||||
*/
|
||||
public static final Caption ARGUMENT_PARSE_FAILURE_NO_INPUT_PROVIDED = of("argument.parse.failure.no_input_was_provided");
|
||||
/**
|
||||
* Variables: {input}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
//
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2020 Alexander Söderberg & Contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
package cloud.commandframework.exceptions.parsing;
|
||||
|
||||
import cloud.commandframework.captions.StandardCaptionKeys;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* An exception which is thrown when an argument's input is unexpectedly null or empty
|
||||
*/
|
||||
public class NoInputProvidedException extends ParserException {
|
||||
|
||||
/**
|
||||
* Construct a new NoInputProvidedException
|
||||
*
|
||||
* @param argumentParser Argument parser class
|
||||
* @param context Command context
|
||||
*/
|
||||
public NoInputProvidedException(
|
||||
final Class<?> argumentParser,
|
||||
final @NonNull CommandContext<?> context
|
||||
) {
|
||||
super(
|
||||
argumentParser,
|
||||
context,
|
||||
StandardCaptionKeys.ARGUMENT_PARSE_FAILURE_NO_INPUT_PROVIDED
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
|
@ -152,7 +153,10 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
MessageParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
final MessageReceivedEvent event = commandContext.get("MessageReceivedEvent");
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -151,7 +152,10 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
UserParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
final JDA jda = commandContext.get("JDA");
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.bukkit.BukkitCaptionKeys;
|
||||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
|
@ -132,7 +133,10 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
EnchantmentParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
final NamespacedKey key;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.bukkit.BukkitCaptionKeys;
|
||||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.bukkit.Material;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -131,7 +132,10 @@ public class MaterialArgument<C> extends CommandArgument<C, Material> {
|
|||
) {
|
||||
String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
MaterialParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.bukkit.BukkitCaptionKeys;
|
||||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
|
@ -141,7 +142,10 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
OfflinePlayerParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
inputQueue.remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.bukkit.BukkitCaptionKeys;
|
||||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -135,7 +136,10 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
PlayerParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
inputQueue.remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.bukkit.BukkitCaptionKeys;
|
||||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
|
@ -128,7 +129,10 @@ public class WorldArgument<C> extends CommandArgument<C, World> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
WorldParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
|
||||
final World world = Bukkit.getWorld(input);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.bukkit.CloudBukkitCapabilities;
|
||||
import cloud.commandframework.bukkit.arguments.selector.MultipleEntitySelector;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -141,7 +142,10 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
|
|||
}
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
MultipleEntitySelectorParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
inputQueue.remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import cloud.commandframework.bukkit.CloudBukkitCapabilities;
|
|||
import cloud.commandframework.bukkit.arguments.selector.MultiplePlayerSelector;
|
||||
import cloud.commandframework.bukkit.parsers.PlayerArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
|
@ -136,7 +137,10 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
MultiplePlayerSelectorParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
inputQueue.remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.bukkit.CloudBukkitCapabilities;
|
||||
import cloud.commandframework.bukkit.arguments.selector.SingleEntitySelector;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -139,7 +140,10 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
|
|||
}
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
SingleEntitySelectorParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
inputQueue.remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import cloud.commandframework.bukkit.CloudBukkitCapabilities;
|
|||
import cloud.commandframework.bukkit.arguments.selector.SinglePlayerSelector;
|
||||
import cloud.commandframework.bukkit.parsers.PlayerArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
|
@ -134,7 +135,10 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
SinglePlayerSelectorParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
inputQueue.remove();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.captions.CaptionVariable;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import cloud.commandframework.velocity.VelocityCaptionKeys;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
|
@ -170,11 +171,10 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
|
|||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(
|
||||
new NullPointerException(
|
||||
"No input was provided"
|
||||
)
|
||||
);
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
PlayerParser.class,
|
||||
commandContext
|
||||
));
|
||||
}
|
||||
final Player player = this.proxyServer.getPlayer(input).orElse(null);
|
||||
if (player == null) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ package cloud.commandframework.examples.bukkit;
|
|||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.Description;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
||||
import cloud.commandframework.annotations.AnnotationParser;
|
||||
import cloud.commandframework.annotations.Argument;
|
||||
import cloud.commandframework.annotations.CommandDescription;
|
||||
|
|
@ -56,8 +58,6 @@ import cloud.commandframework.execution.CommandExecutionCoordinator;
|
|||
import cloud.commandframework.extra.confirmation.CommandConfirmationManager;
|
||||
import cloud.commandframework.meta.CommandMeta;
|
||||
import cloud.commandframework.minecraft.extras.ColorArgument;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
||||
import cloud.commandframework.paper.PaperCommandManager;
|
||||
import cloud.commandframework.types.tuples.Triplet;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue