Skip to content

Commit

Permalink
Fix bad input parsing in the region parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
md5sha256 committed Mar 2, 2024
1 parent 8cc497d commit d445c6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.context.CommandInput;
Expand All @@ -20,12 +21,13 @@ public BuyRegionParser(@NonNull IFileManager fileManager) {
@Override
public @NonNull ArgumentParseResult<@NonNull BuyRegion> parse(@NonNull CommandContext<@NonNull C> commandContext,
@NonNull CommandInput commandInput) {
String input = commandInput.readInput();
String input = commandInput.peekString();
BuyRegion region = this.fileManager.getBuy(input);
if (region != null) {
commandInput.readString();
return ArgumentParseResult.success(region);
}
AreaShopCommandException exception = new AreaShopCommandException("buy-notBuyable");
AreaShopCommandException exception = new AreaShopCommandException("buy-noBuyable", input);
return ArgumentParseResult.failure(exception);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ public GeneralRegionParser(@NonNull IFileManager fileManager) {
@Override
public @NonNull ArgumentParseResult<@NonNull GeneralRegion> parse(@NonNull CommandContext<@NonNull C> commandContext,
@NonNull CommandInput commandInput) {
String input = commandInput.readInput();
String input = commandInput.peekString();
GeneralRegion region = this.fileManager.getRegion(input);
if (region != null) {
commandInput.readString();
return ArgumentParseResult.success(region);
}
AreaShopCommandException exception = new AreaShopCommandException("cmd-notRegistered");
AreaShopCommandException exception = new AreaShopCommandException("cmd-notRegistered", input);
return ArgumentParseResult.failure(exception);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ public RentRegionParser(@NonNull IFileManager fileManager) {
@Override
public @NonNull ArgumentParseResult<@NonNull RentRegion> parse(@NonNull CommandContext<@NonNull C> commandContext,
@NonNull CommandInput commandInput) {
String input = commandInput.readInput();
String input = commandInput.peekString();
RentRegion region = this.fileManager.getRent(input);
if (region != null) {
commandInput.readString();
return ArgumentParseResult.success(region);
}
AreaShopCommandException exception = new AreaShopCommandException("buy-notBuyable");
AreaShopCommandException exception = new AreaShopCommandException("buy-notBuyable", input);
return ArgumentParseResult.failure(exception);
}

Expand Down

0 comments on commit d445c6d

Please sign in to comment.