Skip to content

Commit

Permalink
made incomplete args throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
ItziSpyder committed Jun 28, 2024
1 parent e992281 commit a7def5f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/io/github/itzispyder/pdk/commands/Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a7def5f

Please sign in to comment.