Skip to content

Commit

Permalink
- Add error message for when a shop doesn't have enough stock.
Browse files Browse the repository at this point in the history
- Add localization key `error-message.shop-errors.not-enough-stock`
  • Loading branch information
Sven65 committed Feb 27, 2021
1 parent dcde180 commit c001588
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,19 @@ public void handleBuy (HumanEntity humanEntity) {

boolean isLimitedShop = shop.admin && shop.shopLimit != null && shop.shopLimit.enabled;


if (shop.stock <= 0 && !shop.admin) {
humanEntity.sendMessage(ChatColor.RED+LocaleManager.getString("error-message.shop-errors.out-of-stock"));
((Player) humanEntity).playSound(shop.location, slabboSound.getSoundByKey("BLOCKED"), 1, 1);
return;
}

if (shop.stock < shop.quantity) {
humanEntity.sendMessage(ChatColor.RED+LocaleManager.getString("error-message.shop-errors.not-enough-stock"));
((Player) humanEntity).playSound(shop.location, slabboSound.getSoundByKey("BLOCKED"), 1, 1);
return;
}

if (isLimitedShop) {
if (shop.shopLimit.buyStockLeft <= 0) {
humanEntity.sendMessage(ChatColor.RED+LocaleManager.getString("error-message.shop-errors.buy-limit-reached"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public BaseComponent getListComponent (Player player, List<String> rows, int pag
}

ISlabboSound slabboSound = Bukkit.getServicesManager().getRegistration(ISlabboSound.class).getProvider();
SlabboAPI slabboAPI = Bukkit.getServicesManager().getRegistration(SlabboAPI.class).getProvider();

@HelpCommand
@CatchUnknown
Expand Down Expand Up @@ -136,18 +135,6 @@ public void onReload (Player player) {
player.sendMessage("Slabbo "+LocaleManager.getString("general.general.reloaded")+"!");
}

@Subcommand("debug")
@Description("Debugs slabbo")
@CommandPermission("slabbo.info")
public void onDebug (Player player) {
ItemStack item = player.getInventory().getItemInMainHand();

String itemName = slabboAPI.getItemName(item);
int maxSize = slabboAPI.getMaxStack(item);

player.sendMessage(String.format("Max stack size of item %s is %d items.", itemName, maxSize));
}

@Subcommand("info")
@Description("Shows information about Slabbo")
@CommandPermission("slabbo.info")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void executeSellCommands (HashMap<String, Object> replacementMap) {


private static final long serialVersionUID = -1358999872552913870L;

public int buyPrice;
public int sellPrice;

Expand Down
1 change: 1 addition & 0 deletions modules/Plugin/src/main/resources/lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ error-message:
not-enough-inventory-space: You don't have enough inventory space!
buy-limit-reached: The shops buy limit has been reached!
sell-limit-reached: The shops sell limit has been reached!
not-enough-stock: The shop doesn't have enough stock left!

success-message:
chestlink:
Expand Down

0 comments on commit c001588

Please sign in to comment.