From f52be003ab2f8ca1c44aecde21c560ab4de6ec74 Mon Sep 17 00:00:00 2001 From: Eric Biedert Date: Tue, 28 Jun 2016 21:27:51 +0200 Subject: [PATCH] ItemMeta of shop item should be applied + Remove Items with "shopItem" metadata on disable --- src/de/epiceric/shopchest/ShopChest.java | 10 ++++++++++ src/de/epiceric/shopchest/shop/Shop.java | 7 ++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/de/epiceric/shopchest/ShopChest.java b/src/de/epiceric/shopchest/ShopChest.java index 01c35d5..154f94d 100644 --- a/src/de/epiceric/shopchest/ShopChest.java +++ b/src/de/epiceric/shopchest/ShopChest.java @@ -23,7 +23,9 @@ import de.epiceric.shopchest.utils.Utils; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; @@ -340,6 +342,14 @@ public class ShopChest extends JavaPlugin { for (Shop shop : ShopUtils.getShops()) { ShopUtils.removeShop(shop, false); } + + for (World world : Bukkit.getWorlds()) { + for (Item item : world.getEntitiesByClass(Item.class)) { + if (item.hasMetadata("shopItem")) { + item.remove(); + } + } + } } private void initializeShops() { diff --git a/src/de/epiceric/shopchest/shop/Shop.java b/src/de/epiceric/shopchest/shop/Shop.java index 507f750..16a2379 100644 --- a/src/de/epiceric/shopchest/shop/Shop.java +++ b/src/de/epiceric/shopchest/shop/Shop.java @@ -84,16 +84,13 @@ public class Shop { Item item; Location itemLocation; ItemStack itemStack; - ItemMeta itemMeta = product.getItemMeta().clone(); + ItemMeta itemMeta = product.getItemMeta(); itemMeta.setDisplayName(UUID.randomUUID().toString()); - ArrayList lore = new ArrayList<>(); - lore.add("Shop Item"); - itemMeta.setLore(lore); - itemLocation = new Location(location.getWorld(), hologram.getLocation().getX(), location.getY() + 1, hologram.getLocation().getZ()); itemStack = new ItemStack(product); itemStack.setAmount(1); + itemStack.setItemMeta(itemMeta); item = location.getWorld().dropItem(itemLocation, itemStack); item.setVelocity(new Vector(0, 0, 0));