From a7def5f7ebb386e95ad9ac606fc13dd7286d3229 Mon Sep 17 00:00:00 2001 From: ImproperIssues <114215797+ItziSpyder@users.noreply.github.com> Date: Thu, 27 Jun 2024 20:10:19 -0700 Subject: [PATCH] made incomplete args throw error --- .../java/io/github/itzispyder/pdk/commands/Args.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/itzispyder/pdk/commands/Args.java b/src/main/java/io/github/itzispyder/pdk/commands/Args.java index 9bd75e2..1aa54ee 100644 --- a/src/main/java/io/github/itzispyder/pdk/commands/Args.java +++ b/src/main/java/io/github/itzispyder/pdk/commands/Args.java @@ -17,10 +17,11 @@ public Arg getAll(int beginIndex) { } public Arg get(int index) { - if (args.length == 0) { - return new Arg(""); - } - return new Arg(args[Math.min(Math.max(index, 0), args.length - 1)]); + if (args.length == 0) + throw new IllegalArgumentException("not enough arguments: arguments are empty"); + if (index < 0 || index >= args.length) + throw new IllegalArgumentException("not enough arguments: argument %s is missing".formatted(index + 1)); + return new Arg(args[index]); } public Arg first() {