Skip to content

Commit

Permalink
✨ Make shopcommands work
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven65 committed Jul 11, 2021
1 parent 6c7039d commit 1b701a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class ShopCreationGUI implements Listener {
private int quantity = 0;
private int stock = 0;

public String linkedChestLocation = "";
private String linkedChestLocation = "";

private Shop.CommandList commandList;

private String sellersNote;

Expand Down Expand Up @@ -72,6 +74,9 @@ public ShopCreationGUI (Location slabLocation, Shop shop) {

sellersNote = shop.note;

commandList = shop.commandList;


initializeStage2();
}

Expand All @@ -97,6 +102,7 @@ public void resetGUI () {

sellersNote = "";
linkedChestLocation = "";
commandList = null;
}

public boolean getIsStage2 () {
Expand Down Expand Up @@ -215,6 +221,7 @@ public void onInventoryClick(final InventoryClickEvent e) {

Shop shop = new Shop(buyPrice, sellPrice, quantity, slabLocation, shopItem);


shop.ownerId = e.getWhoClicked().getUniqueId();

shop.admin = isAdmin;
Expand All @@ -223,6 +230,8 @@ public void onInventoryClick(final InventoryClickEvent e) {
shop.note = sellersNote;
shop.linkedChestLocation = linkedChestLocation;

shop.commandList = commandList;


ShopManager.put(ShopManager.locationToString(slabLocation), shop);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public void onAddBuyCommand(Player player, SlabboContextResolver slabboContextRe
lookingAtShop.commandList = new Shop.CommandList();
}

player.sendMessage(ChatColor.GREEN+LocaleManager.getString("success-message.general.shop-commands.added-command"));
player.sendMessage(ChatColor.GREEN+LocaleManager.replaceSingleKey("success-message.general.shop-commands.added-command", "command", command));

lookingAtShop.commandList.buyCommands.add(command);

Expand All @@ -741,7 +741,7 @@ public void onAddSellCommand(Player player, SlabboContextResolver slabboContextR

Shop lookingAtShop = slabboContextResolver.shop;

player.sendMessage(ChatColor.GREEN+LocaleManager.getString("success-message.general.shop-commands.added-command"));
player.sendMessage(ChatColor.GREEN+LocaleManager.replaceSingleKey("success-message.general.shop-commands.removed-command", "command", command));

lookingAtShop.commandList.sellCommands.add(command);

Expand Down Expand Up @@ -781,7 +781,7 @@ public void onRemoveBuyCommand(Player player, SlabboContextResolver slabboContex
return;
}

if (lookingAtShop.commandList.buyCommands.size() < newIndex) {
if (lookingAtShop.commandList.buyCommands.size() <= newIndex) {
player.sendMessage(ChatColor.RED+LocaleManager.getString("error-message.general.invalid-index"));
return;
}
Expand Down Expand Up @@ -814,7 +814,7 @@ public void onRemoveSellCommand(Player player, SlabboContextResolver slabboConte
return;
}

if (lookingAtShop.commandList.sellCommands.size() < newIndex) {
if (lookingAtShop.commandList.sellCommands.size() <= newIndex) {
player.sendMessage(ChatColor.RED+LocaleManager.getString("error-message.general.invalid-index"));
return;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/Plugin/src/main/resources/lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ success-message:
set-sell-stock: Selling stock has been set to {stock}!
set-buy-stock: Buying stock has been set to {stock}!
shop-commands:
added-command: The command has been added.
removed-command: The command has been removed.
added-command: The command {command} has been added.
removed-command: The command {command} has been removed.
import:
importing: Importing shops!
success: Imported {count} shops. Skipped {skipped} as shops already exist at their locations.
Expand Down

0 comments on commit 1b701a1

Please sign in to comment.