diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java index 397b4d83..2d585508 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/CommandContext.java @@ -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 { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java index aeaae8ce..4435f687 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java @@ -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)