Fix incorrect number of arguments in command
Fix check stock command checking total items left, not total amount of purchases left
This commit is contained in:
parent
d3ba5be040
commit
da5e514422
|
|
@ -48,14 +48,14 @@ public class CheckStockCommand implements Subcommand {
|
||||||
sender.sendMessage(Util.parseMiniMessage("<red>Only players can use this command."));
|
sender.sendMessage(Util.parseMiniMessage("<red>Only players can use this command."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 2 && args.length != 3) {
|
if (args.length != 1 && args.length != 2) {
|
||||||
player.sendMessage(Util.parseMiniMessage("<red>Invalid command syntax, use /checkstock <radius> [minimum stock]"));
|
player.sendMessage(Util.parseMiniMessage("<red>Invalid command syntax, use /checkstock <radius> [minimum stock]"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radius;
|
int radius;
|
||||||
try {
|
try {
|
||||||
radius = Integer.parseInt(args[1]);
|
radius = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
player.sendMessage(Util.parseMiniMessage("<red>radius has to be a valid number, use /checkstock <radius> [minimum stock]"));
|
player.sendMessage(Util.parseMiniMessage("<red>radius has to be a valid number, use /checkstock <radius> [minimum stock]"));
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -66,9 +66,9 @@ public class CheckStockCommand implements Subcommand {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 3) {
|
if (args.length == 2) {
|
||||||
try {
|
try {
|
||||||
minimumStock = Integer.parseInt(args[2]);
|
minimumStock = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
player.sendMessage(Util.parseMiniMessage("<red>minimum stock has to be a valid number, use /checkstock <radius> [minimum stock]"));
|
player.sendMessage(Util.parseMiniMessage("<red>minimum stock has to be a valid number, use /checkstock <radius> [minimum stock]"));
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -90,12 +90,12 @@ public class CheckStockCommand implements Subcommand {
|
||||||
List<PlayerShop> shops = PlayerShops.getInstance().getShopHandler().getShopsInRadius(x, z, radius);
|
List<PlayerShop> shops = PlayerShops.getInstance().getShopHandler().getShopsInRadius(x, z, radius);
|
||||||
Stream<PlayerShop> playerShopStream = shops.stream();
|
Stream<PlayerShop> playerShopStream = shops.stream();
|
||||||
if (minimumStock != -1)
|
if (minimumStock != -1)
|
||||||
playerShopStream = playerShopStream.filter(shop -> shop.getRemainingStock() < minimumStock);
|
playerShopStream = playerShopStream.filter(shop -> shop.getRemainingStock() / shop.getAmount() < minimumStock);
|
||||||
if (!caller.hasPermission(PlayerShopCommand.BASE_PERM + ".checkstock.any"))
|
if (!caller.hasPermission(PlayerShopCommand.BASE_PERM + ".checkstock.any"))
|
||||||
playerShopStream = playerShopStream.filter(shop -> shop.getOwnerUUID().equals(caller.getUniqueId()));
|
playerShopStream = playerShopStream.filter(shop -> shop.getOwnerUUID().equals(caller.getUniqueId()));
|
||||||
return playerShopStream.map(shop -> {
|
return playerShopStream.map(shop -> {
|
||||||
Location signLocation = shop.getSignLocation();
|
Location signLocation = shop.getSignLocation();
|
||||||
return new Stock(shop.getRemainingStock(),
|
return new Stock(shop.getRemainingStock() / shop.getAmount(),
|
||||||
signLocation.getBlockX(),
|
signLocation.getBlockX(),
|
||||||
signLocation.getBlockY(),
|
signLocation.getBlockY(),
|
||||||
signLocation.getBlockZ(),
|
signLocation.getBlockZ(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user