From fd3b47d5c588f85fbc334400c9dab8ce28ead1a1 Mon Sep 17 00:00:00 2001 From: GeekFrog Date: Sun, 16 Jul 2017 17:46:57 +0800 Subject: [PATCH] fix bug --- .../gg/frog/mc/permissionstime/config/PackagesCfg.java | 8 +++++++- .../frog/mc/permissionstime/gui/PlayerPermissionShow.java | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/gg/frog/mc/permissionstime/config/PackagesCfg.java b/src/main/gg/frog/mc/permissionstime/config/PackagesCfg.java index 5c53bfe..456e4eb 100644 --- a/src/main/gg/frog/mc/permissionstime/config/PackagesCfg.java +++ b/src/main/gg/frog/mc/permissionstime/config/PackagesCfg.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -50,7 +51,12 @@ public class PackagesCfg extends PluginConfig { } PACKAGE_ITEMS.clear(); for (Entry e : PACKAGES.entrySet()) { - PACKAGE_ITEMS.put(e.getKey(), getPackageItem(e.getKey(), e.getValue())); + ItemStack item = getPackageItem(e.getKey(), e.getValue()); + if (item != null) { + PACKAGE_ITEMS.put(e.getKey(), item); + } else { + PluginMain.LOG.log(Level.SEVERE, "Packages of " + e.getKey() + " has problem."); + } allPermissions.addAll(e.getValue().getPermissions()); allGroups.addAll(e.getValue().getGroups()); } diff --git a/src/main/gg/frog/mc/permissionstime/gui/PlayerPermissionShow.java b/src/main/gg/frog/mc/permissionstime/gui/PlayerPermissionShow.java index 6f9bd6f..1510d8f 100644 --- a/src/main/gg/frog/mc/permissionstime/gui/PlayerPermissionShow.java +++ b/src/main/gg/frog/mc/permissionstime/gui/PlayerPermissionShow.java @@ -20,12 +20,13 @@ public class PlayerPermissionShow { for (PlayerDataBean pdb : pdbList) { ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName()); if (item != null) { - ItemMeta meta = item.getItemMeta(); + ItemStack tItem = item.clone(); + ItemMeta meta = tItem.getItemMeta(); List lores = meta.getLore(); lores.add(StrUtil.messageFormat(LangCfg.EXPIRATION_DATE, StrUtil.timestampToString(pdb.getExpire()))); meta.setLore(lores); - item.setItemMeta(meta); - inventory.addItem(item); + tItem.setItemMeta(meta); + inventory.addItem(tItem); } } p.openInventory(inventory);