From 8febbeb89e3aa63ea27219138524460edfbed09f Mon Sep 17 00:00:00 2001 From: Nathan Thor Date: Sat, 20 Nov 2021 11:46:36 -0800 Subject: [PATCH] More Unification of message sending --- .../listeners/ShopTradeListener.java | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/shanerx/tradeshop/listeners/ShopTradeListener.java b/src/main/java/org/shanerx/tradeshop/listeners/ShopTradeListener.java index af04baea..d77e9154 100644 --- a/src/main/java/org/shanerx/tradeshop/listeners/ShopTradeListener.java +++ b/src/main/java/org/shanerx/tradeshop/listeners/ShopTradeListener.java @@ -86,7 +86,7 @@ public void onBlockInteract(PlayerInteractEvent e) { } if (!shop.getShopType().equals(ShopType.ITRADE) && shop.getUsersUUID().contains(buyer.getUniqueId()) && !Setting.ALLOW_USER_PURCHASING.getBoolean()) { - buyer.sendMessage(Message.SELF_OWNED.getPrefixed()); + Message.SELF_OWNED.sendMessage(buyer); return; } @@ -96,13 +96,13 @@ public void onBlockInteract(PlayerInteractEvent e) { chestState = shop.getStorage(); if (!shop.getShopType().equals(ShopType.ITRADE) && chestState == null) { - buyer.sendMessage(Message.MISSING_CHEST.getPrefixed()); + Message.MISSING_CHEST.sendMessage(buyer); shop.updateStatus(); return; } if (!(shop.areProductsValid() && shop.areCostsValid())) { - buyer.sendMessage(Message.ILLEGAL_ITEM.getPrefixed()); + Message.ILLEGAL_ITEM.sendMessage(buyer); return; } @@ -129,10 +129,10 @@ public void onBlockInteract(PlayerInteractEvent e) { switch (shop.getStatus()) { case CLOSED: - buyer.sendMessage(Message.SHOP_CLOSED.getPrefixed()); + Message.SHOP_CLOSED.sendMessage(buyer); return; case INCOMPLETE: - buyer.sendMessage(Message.SHOP_EMPTY.getPrefixed()); + Message.SHOP_EMPTY.sendMessage(buyer); case OUT_OF_STOCK: if (shop.getShopType() == ShopType.BITRADE && e.getAction() == Action.LEFT_CLICK_BLOCK) { Message.SHOP_INSUFFICIENT_ITEMS.sendMessage(buyer, new Tuple<>("{ITEM}", costName), new Tuple<>("{AMOUNT}", String.valueOf(amountCost))); @@ -191,12 +191,12 @@ public void onBlockInteract(PlayerInteractEvent e) { owner = "-Unknown-"; if (tradeAllItems(shop, multiplier, e, buyer)) { - buyer.sendMessage(Message.ON_TRADE.getPrefixed() - .replace("{AMOUNT1}", String.valueOf(amountProduct)) - .replace("{AMOUNT2}", String.valueOf(amountCost)) - .replace("{ITEM1}", productName.toLowerCase()) - .replace("{ITEM2}", costName.toLowerCase()) - .replace("{SELLER}", shop.getShopType().isITrade() ? Setting.ITRADESHOP_OWNER.getString() : owner)); + Message.ON_TRADE.sendMessage(buyer, + new Tuple<>("{AMOUNT1}", String.valueOf(amountProduct)), + new Tuple<>("{AMOUNT2}", String.valueOf(amountCost)), + new Tuple<>("{ITEM1}", productName.toLowerCase()), + new Tuple<>("{ITEM2}", costName.toLowerCase()), + new Tuple<>("{SELLER}", shop.getShopType().isITrade() ? Setting.ITRADESHOP_OWNER.getString() : owner)); } shop.updateSign(); @@ -215,9 +215,9 @@ private boolean tradeAllItems(Shop shop, int multiplier, PlayerInteractEvent eve costItems = getItems(playerInventory, shop.getCost(), multiplier); if (costItems.get(0) == null) { ItemStack item = costItems.get(1); - buyer.sendMessage(Message.INSUFFICIENT_ITEMS.getPrefixed() - .replace("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()) - .replace("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); + Message.INSUFFICIENT_ITEMS.sendMessage(buyer, + new Tuple<>("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()), + new Tuple<>("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); return false; } @@ -238,9 +238,9 @@ private boolean tradeAllItems(Shop shop, int multiplier, PlayerInteractEvent eve costItems = getItems(playerInventory, shop.getProduct(), multiplier); //Reverse BiTrade, Product is Cost if (costItems.get(0) == null) { ItemStack item = costItems.get(1); - buyer.sendMessage(Message.INSUFFICIENT_ITEMS.getPrefixed() - .replace("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()) - .replace("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); + Message.INSUFFICIENT_ITEMS.sendMessage(buyer, + new Tuple<>("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()), + new Tuple<>("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); return false; } @@ -249,9 +249,9 @@ private boolean tradeAllItems(Shop shop, int multiplier, PlayerInteractEvent eve if (productItems.get(0) == null) { ItemStack item = productItems.get(1); shop.updateStatus(); - buyer.sendMessage(Message.SHOP_INSUFFICIENT_ITEMS.getPrefixed() - .replace("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()) - .replace("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); + Message.SHOP_INSUFFICIENT_ITEMS.sendMessage(buyer, + new Tuple<>("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()), + new Tuple<>("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); return false; } } else if (action.equals(Action.RIGHT_CLICK_BLOCK)) { // Normal Trade @@ -260,9 +260,9 @@ private boolean tradeAllItems(Shop shop, int multiplier, PlayerInteractEvent eve costItems = getItems(playerInventory, shop.getCost(), multiplier); if (costItems.get(0) == null) { ItemStack item = costItems.get(1); - buyer.sendMessage(Message.INSUFFICIENT_ITEMS.getPrefixed() - .replace("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()) - .replace("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); + Message.INSUFFICIENT_ITEMS.sendMessage(buyer, + new Tuple<>("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()), + new Tuple<>("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); return false; } @@ -271,9 +271,9 @@ private boolean tradeAllItems(Shop shop, int multiplier, PlayerInteractEvent eve if (productItems.get(0) == null) { ItemStack item = productItems.get(1); shop.updateStatus(); - buyer.sendMessage(Message.SHOP_INSUFFICIENT_ITEMS.getPrefixed() - .replace("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()) - .replace("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); + Message.SHOP_INSUFFICIENT_ITEMS.sendMessage(buyer, + new Tuple<>("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()), + new Tuple<>("{AMOUNT}", String.valueOf(item.getAmount() * multiplier))); return false; }