diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/StaticArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/StaticArgument.java index f2d979a1..ec99dcbb 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/StaticArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/StaticArgument.java @@ -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 extends CommandArgument { ) { 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(); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/preprocessor/RegexPreprocessor.java b/cloud-core/src/main/java/cloud/commandframework/arguments/preprocessor/RegexPreprocessor.java index e68c0e0d..a3d60251 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/preprocessor/RegexPreprocessor.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/preprocessor/RegexPreprocessor.java @@ -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 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); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/BooleanArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/BooleanArgument.java index 4b05935f..86ff7f1f 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/BooleanArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/BooleanArgument.java @@ -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 extends CommandArgument { ) { 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(); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ByteArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ByteArgument.java index ab75c8aa..890ac484 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ByteArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ByteArgument.java @@ -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 extends CommandArgument { ) { 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); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/CharArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/CharArgument.java index c82a5eb8..328caf89 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/CharArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/CharArgument.java @@ -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 extends CommandArgument { ) { 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) { diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/DoubleArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/DoubleArgument.java index bb1c5dbb..42969ce6 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/DoubleArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/DoubleArgument.java @@ -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 extends CommandArgument { ) { 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); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/EnumArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/EnumArgument.java index 2c136a3e..f9470cad 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/EnumArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/EnumArgument.java @@ -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> extends CommandArgument { ) { 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) { diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/FloatArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/FloatArgument.java index da75face..b06a9934 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/FloatArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/FloatArgument.java @@ -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 extends CommandArgument { ) { 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); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/IntegerArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/IntegerArgument.java index 286556eb..7d2e9bc1 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/IntegerArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/IntegerArgument.java @@ -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 extends CommandArgument { ) { 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); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/LongArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/LongArgument.java index 04d44fb6..4c4e0225 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/LongArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/LongArgument.java @@ -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 extends CommandArgument { ) { 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); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ShortArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ShortArgument.java index 21e5cd2a..ef810026 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ShortArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/ShortArgument.java @@ -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 extends CommandArgument { ) { 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); diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/StringArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/StringArgument.java index 7a4adab6..43fec66e 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/StringArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/StringArgument.java @@ -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 extends CommandArgument { ) { 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) { diff --git a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/UUIDArgument.java b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/UUIDArgument.java index cd66c230..87100b5f 100644 --- a/cloud-core/src/main/java/cloud/commandframework/arguments/standard/UUIDArgument.java +++ b/cloud-core/src/main/java/cloud/commandframework/arguments/standard/UUIDArgument.java @@ -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 extends CommandArgument { ) { 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 { diff --git a/cloud-core/src/main/java/cloud/commandframework/captions/SimpleCaptionRegistry.java b/cloud-core/src/main/java/cloud/commandframework/captions/SimpleCaptionRegistry.java index 9d83d2c5..a7bed067 100644 --- a/cloud-core/src/main/java/cloud/commandframework/captions/SimpleCaptionRegistry.java +++ b/cloud-core/src/main/java/cloud/commandframework/captions/SimpleCaptionRegistry.java @@ -36,6 +36,10 @@ import java.util.function.BiFunction; */ public class SimpleCaptionRegistry implements FactoryDelegatingCaptionRegistry { + /** + * 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 implements FactoryDelegatingCaptionRegistr private final Map> 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 diff --git a/cloud-core/src/main/java/cloud/commandframework/captions/StandardCaptionKeys.java b/cloud-core/src/main/java/cloud/commandframework/captions/StandardCaptionKeys.java index 77f91ff4..e5bcd042 100644 --- a/cloud-core/src/main/java/cloud/commandframework/captions/StandardCaptionKeys.java +++ b/cloud-core/src/main/java/cloud/commandframework/captions/StandardCaptionKeys.java @@ -36,6 +36,10 @@ public final class StandardCaptionKeys { private static final Collection 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} */ diff --git a/cloud-core/src/main/java/cloud/commandframework/exceptions/parsing/NoInputProvidedException.java b/cloud-core/src/main/java/cloud/commandframework/exceptions/parsing/NoInputProvidedException.java new file mode 100644 index 00000000..e6fd1358 --- /dev/null +++ b/cloud-core/src/main/java/cloud/commandframework/exceptions/parsing/NoInputProvidedException.java @@ -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 + ); + } + +} diff --git a/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/ChannelArgument.java b/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/ChannelArgument.java index 0942972c..4079f146 100644 --- a/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/ChannelArgument.java +++ b/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/ChannelArgument.java @@ -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 extends CommandArgument ) { 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"); diff --git a/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/UserArgument.java b/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/UserArgument.java index 6ff192ca..3d5851dc 100644 --- a/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/UserArgument.java +++ b/cloud-discord/cloud-jda/src/main/java/cloud/commandframework/jda/parsers/UserArgument.java @@ -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 extends CommandArgument { ) { 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"); diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java index 7a94a8f6..13fd8535 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java @@ -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 extends CommandArgument { ) { 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; diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/MaterialArgument.java b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/MaterialArgument.java index 4e20b00a..8d8ab2c2 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/MaterialArgument.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/MaterialArgument.java @@ -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 extends CommandArgument { ) { 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 { diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/OfflinePlayerArgument.java b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/OfflinePlayerArgument.java index a96b511d..82136070 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/OfflinePlayerArgument.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/OfflinePlayerArgument.java @@ -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 extends CommandArgument extends CommandArgument { ) { 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(); diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/WorldArgument.java b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/WorldArgument.java index ddf2c9cc..32ae489d 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/WorldArgument.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/WorldArgument.java @@ -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 extends CommandArgument { ) { 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); diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/selector/MultipleEntitySelectorArgument.java b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/selector/MultipleEntitySelectorArgument.java index bc1eedaf..a046ad30 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/selector/MultipleEntitySelectorArgument.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/selector/MultipleEntitySelectorArgument.java @@ -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 extends CommandArgument extends CommandArgument extends CommandArgument extends CommandArgument extends CommandArgument { ) { 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) { diff --git a/examples/example-bukkit/src/main/java/cloud/commandframework/examples/bukkit/ExamplePlugin.java b/examples/example-bukkit/src/main/java/cloud/commandframework/examples/bukkit/ExamplePlugin.java index 4037ca08..e637d095 100644 --- a/examples/example-bukkit/src/main/java/cloud/commandframework/examples/bukkit/ExamplePlugin.java +++ b/examples/example-bukkit/src/main/java/cloud/commandframework/examples/bukkit/ExamplePlugin.java @@ -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;