Add a way to display ShopTransaction.java
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package com.alttd.playershops.utils;
|
||||
|
||||
import com.alttd.playershops.gui.GuiIcon;
|
||||
import com.alttd.playershops.shop.PlayerShop;
|
||||
import com.alttd.playershops.shop.ShopTransaction;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
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.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -12,8 +16,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -150,6 +157,27 @@ public class ShopUtil {
|
||||
return skull;
|
||||
}
|
||||
|
||||
public static ItemStack getShopTransactionItem(ShopTransaction shopTransaction) {
|
||||
ItemStack itemStack = new ItemStack(Material.ENCHANTED_BOOK);
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
List<Component> lore = new ArrayList<>();
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.unparsed("name", shopTransaction.Name()),
|
||||
Placeholder.unparsed("amount", shopTransaction.transactions() + ""),
|
||||
Placeholder.unparsed("value", shopTransaction.value() + ""),
|
||||
Placeholder.unparsed("action", shopTransaction.shopAction().name() + "")
|
||||
);
|
||||
lore.add(Util.parseMiniMessage("PlayerName: <name>", placeholders));
|
||||
lore.add(Util.parseMiniMessage("Amount: <amount>", placeholders));
|
||||
lore.add(Util.parseMiniMessage("Value: <value>", placeholders));
|
||||
lore.add(Util.parseMiniMessage("Action: <action>", placeholders));
|
||||
|
||||
meta.lore(lore);
|
||||
itemStack.setItemMeta(meta);
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
// TODO upgrade this to an util method check if owner/trusted and open management interface
|
||||
public static boolean canManageShop(Player player, PlayerShop playerShop) {
|
||||
if (playerShop.getOwnerUUID().equals(player.getUniqueId())) {
|
||||
|
||||
Reference in New Issue
Block a user