Added messages/placeholders for failed transactions
This commit is contained in:
parent
fe82ccfa43
commit
09c3349048
|
|
@ -59,11 +59,15 @@ public class ShopTypeConfig {
|
|||
public String shopSold = "<white><user> bought <amount> <item>(s) from you for <price>.";
|
||||
public String shopInventoryFull = "<red>This shop does not have enough space in its inventory.";
|
||||
public String shopNoStock = "<red>This shop is out of stock.";
|
||||
public String yourShopNoFunds = "<red>Your <item> shop at <location> is out of funds";
|
||||
public String yourShopNoStock = "<red>Your <item> shop at <location> is out of stock";
|
||||
private void transactionMessages() {
|
||||
playerInventoryFull = getString("transaction.player-inventory-full", playerInventoryFull);
|
||||
playerNoFunds = getString("transaction.player-no-funds", playerNoFunds);
|
||||
shopInventoryFull = getString("transaction.shop-inventory-full", shopInventoryFull);
|
||||
shopNoStock = getString("transaction.shop-no-stock", shopNoStock);
|
||||
yourShopNoFunds = getString("transaction.your-shop-no-funds", yourShopNoFunds);
|
||||
yourShopNoStock = getString("transaction.your-shop-no-stock", yourShopNoStock);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ import com.alttd.playershops.handler.ShopHandler;
|
|||
import com.alttd.playershops.hook.WorldGuardHook;
|
||||
import com.alttd.playershops.shop.PlayerShop;
|
||||
import com.alttd.playershops.shop.TransactionError;
|
||||
import com.alttd.playershops.storage.database.DatabaseHelper;
|
||||
import com.alttd.playershops.utils.Logger;
|
||||
import com.alttd.playershops.utils.ShopUtil;
|
||||
import com.alttd.playershops.utils.Util;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -106,7 +105,9 @@ public class TransactionListener extends EventListener {
|
|||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.unparsed("ownername", shop.getOwnerName()),
|
||||
Placeholder.unparsed("price", shop.getPrice() + ""),
|
||||
Placeholder.unparsed("amount", shop.getAmount() + "")
|
||||
Placeholder.unparsed("amount", shop.getAmount() + ""),
|
||||
Placeholder.unparsed("item", Util.capitalize(shop.getItemStack().getType().toString())),
|
||||
Placeholder.unparsed("location", formatLocation(shop.getShopLocation()))
|
||||
);
|
||||
if (transactionError != TransactionError.NONE) {
|
||||
switch (transactionError) {
|
||||
|
|
@ -114,7 +115,7 @@ public class TransactionListener extends EventListener {
|
|||
Player shopOwner = Bukkit.getPlayer(shop.getOwnerUUID());
|
||||
if (shopOwner != null && notifyOwner(shop)) {
|
||||
// TODO notify shopowner in game if not on cooldown and once per day on discord if linked and enabled
|
||||
shopOwner.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().shopSold, null));
|
||||
shopOwner.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().yourShopNoFunds, placeholders));
|
||||
}
|
||||
player.sendMiniMessage(shop.getType().getShopTypeConfig().shopNoStock, placeholders);
|
||||
}
|
||||
|
|
@ -124,6 +125,7 @@ public class TransactionListener extends EventListener {
|
|||
case INVENTORY_FULL_SHOP -> {
|
||||
Player shopOwner = Bukkit.getPlayer(shop.getOwnerUUID());
|
||||
if (shopOwner != null && notifyOwner(shop)) {
|
||||
shopOwner.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().yourShopNoStock, placeholders));
|
||||
// TODO notify shopowner in game if not on cooldown and once per day on discord if linked and enabled
|
||||
}
|
||||
player.sendMiniMessage(shop.getType().getShopTypeConfig().shopInventoryFull, placeholders);
|
||||
|
|
@ -138,6 +140,13 @@ public class TransactionListener extends EventListener {
|
|||
plugin.getDatabaseHelper().logTransaction(player, shop, orders);
|
||||
}
|
||||
|
||||
private String formatLocation(Location location) {
|
||||
return Util.capitalize(location.getWorld().getName()) + ": " +
|
||||
" " + (int) location.getX() +
|
||||
", " + (int) location.getY() +
|
||||
", " + (int) location.getZ();
|
||||
}
|
||||
|
||||
private boolean notifyOwner(PlayerShop playerShop) {
|
||||
// TODO notify shopowner in game if not on cooldown and once per day on discord if linked and enabled
|
||||
return playerShop.isNotifiedOwner();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user