ItemMeta of shop item should be applied + Remove Items with "shopItem" metadata on disable

This commit is contained in:
Eric Biedert 2016-06-28 21:27:51 +02:00
parent 3b734ac429
commit f52be003ab
2 changed files with 12 additions and 5 deletions

View File

@ -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() {

View File

@ -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<String> 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));