fix args parser?
totally didn't ask chatgpt but idk i only stole part of the fix cuz it added random shits
This commit is contained in:
parent
824697879d
commit
7c15ea84a2
2 changed files with 9 additions and 3 deletions
|
@ -34,7 +34,7 @@ public class CommandContext {
|
|||
|
||||
public String getString (boolean greedy, boolean required) throws CommandException { return getString(greedy, required, "string"); }
|
||||
private String getString (boolean greedy, boolean required, String type) throws CommandException {
|
||||
if (args.length == 0 || args[Math.min(argsPosition, args.length - 1)] == null) {
|
||||
if (argsPosition >= args.length || args[argsPosition] == null) {
|
||||
if (required) {
|
||||
throw new CommandException(
|
||||
Component.translatable(
|
||||
|
@ -47,7 +47,13 @@ public class CommandContext {
|
|||
}
|
||||
}
|
||||
|
||||
return greedy ? String.join(" ", Arrays.copyOfRange(args, argsPosition++, args.length)) : args[Math.min(argsPosition++, args.length - 1)];
|
||||
final String string = greedy ?
|
||||
String.join(" ", Arrays.copyOfRange(args, argsPosition, args.length)) :
|
||||
args[argsPosition];
|
||||
|
||||
argsPosition++;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
public Integer getInteger (boolean required) throws CommandException {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class MailCommand extends Command {
|
|||
bot.mail.send(
|
||||
new Mail(
|
||||
sender.profile.getName(),
|
||||
context.getString(true, true),
|
||||
context.getString(false, true),
|
||||
Instant.now().toEpochMilli(),
|
||||
bot.host + ":" + bot.port,
|
||||
context.getString(true, true)
|
||||
|
|
Loading…
Reference in a new issue