Merge remote-tracking branch 'origin/dev/rewrite' into dev/rewrite

# Conflicts:
#	src/main/java/com/alttd/playershops/listener/TransactionListener.java
This commit is contained in:
Teriuihi 2022-08-28 20:51:54 +02:00
commit 4ad7d4995e
4 changed files with 24 additions and 8 deletions

View File

@ -55,7 +55,7 @@ public class ShopTypeConfig {
public String playerInventoryFull = "<red>You do not have enough space in your inventory to buy from this shop.";
public String playerNoFunds = "<red>You do not have sufficient funds to trade with this shop.";
public String playerBought = "<white>You bought <amount> <item>(s) from <shopownername> for <price>.";
public String playerBought = "<white>You bought <amount> <item>(s) from <ownername> for <price>.";
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.";

View File

@ -17,11 +17,13 @@ public class ConversationManager implements ConversationAbandonedListener {
Conversation conversation;
public ConversationManager(JavaPlugin plugin, Player player, ConversationType conversationType, PlayerShop playerShop) {
if (player.isConversing()) return;
this.player = player;
this.playerShop = playerShop;
ConversationFactory conversationFactory = new ConversationFactory(plugin)
.withModality(true)
.withFirstPrompt(getPrompt(conversationType))
.addConversationAbandonedListener(this)
.withEscapeSequence("cancel");
conversation = conversationFactory.buildConversation(player);
conversation.begin();

View File

@ -4,9 +4,12 @@ import com.alttd.playershops.PlayerShops;
import com.alttd.playershops.conversation.ConversationManager;
import com.alttd.playershops.conversation.ConversationType;
import com.alttd.playershops.shop.PlayerShop;
import com.alttd.playershops.utils.EconomyUtils;
import com.alttd.playershops.utils.ShopUtil;
import com.alttd.playershops.utils.Util;
import net.kyori.adventure.text.Component;
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.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -35,11 +38,18 @@ public class ShopManagementGui extends AbstractGui {
ItemStack shopIcon = GuiIcon.MANAGE_SHOP.getItemStack();
ItemMeta meta = shopIcon.getItemMeta();
List<Component> lore = new ArrayList<>();
lore.add(Util.parseMiniMessage("Balance: " + shop.getBalance(), null));
lore.add(Util.parseMiniMessage("item: " + ShopUtil.itemNameComponent(shop.getItemStack()), null));
lore.add(Util.parseMiniMessage("amount: " + shop.getAmount(), null));
lore.add(Util.parseMiniMessage("Type: " + shop.getType(), null));
lore.add(Util.parseMiniMessage("Price: " + shop.getPrice(), null));
TagResolver placeholders = TagResolver.resolver(
Placeholder.unparsed("balance", shop.getBalance() + ""),
Placeholder.unparsed("price", shop.getPrice() + ""),
Placeholder.unparsed("amount", shop.getAmount() + ""),
Placeholder.unparsed("shoptype", shop.getType().toString()),
Placeholder.component("itemname", ShopUtil.itemNameComponent(shop.getItemStack()))
);
lore.add(Util.parseMiniMessage("Balance: <balance>", placeholders));
lore.add(Util.parseMiniMessage("item: <itemname>", placeholders));
lore.add(Util.parseMiniMessage("amount: <amount>", placeholders));
lore.add(Util.parseMiniMessage("Type: <shoptype>", placeholders));
lore.add(Util.parseMiniMessage("Price: <price>", placeholders));
meta.lore(lore);
shopIcon.setItemMeta(meta);
@ -65,7 +75,11 @@ public class ShopManagementGui extends AbstractGui {
if (slot == GuiIcon.MANAGE_SHOP.getSlot() && GuiIcon.MANAGE_SHOP.getItemStack().equals(item)) {
} else if (slot == GuiIcon.MANAGE_SHOP_BALANCE_ADD.getSlot() && GuiIcon.MANAGE_SHOP_BALANCE_ADD.getItemStack().equals(item)) {
openChangePrompt(ConversationType.ADD_BALANCE);
if (EconomyUtils.getFunds(getPlayer()) > 0) {
openChangePrompt(ConversationType.ADD_BALANCE);
} else {
getPlayer().sendMiniMessage("<red>You do not have money to add to this shop", null);
}
} else if (slot == GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getSlot() && GuiIcon.MANAGE_SHOP_BALANCE_REMOVE.getItemStack().equals(item)) {
if (shop.getBalance() > 0) {
openChangePrompt(ConversationType.WITHDRAW_BALANCE);

View File

@ -106,7 +106,7 @@ public class TransactionListener extends EventListener {
Placeholder.unparsed("ownername", shop.getOwnerName()),
Placeholder.unparsed("price", shop.getPrice() + ""),
Placeholder.unparsed("amount", shop.getAmount() + ""),
Placeholder.unparsed("item", Util.capitalize(shop.getItemStack().getType().toString())),
Placeholder.component("item", ShopUtil.itemNameComponent(shop.getItemStack())),
Placeholder.unparsed("location", formatLocation(shop.getShopLocation()))
);
if (transactionError != TransactionError.NONE) {