Support Unbreakable NBT tag for items loaded from hand, fixes #591

This commit is contained in:
BuildTools 2018-12-27 01:10:10 -05:00
parent fe92c86584
commit c07e361ec7

View File

@ -247,6 +247,16 @@ public class ItemUtil {
} }
} }
extra.put(key, nested); extra.put(key, nested);
} else if (value.equals("true")) {
// For some NBT tags
try {
if (key.equalsIgnoreCase("unbreakable")) {
meta.setUnbreakable(true);
}
} catch (Throwable tr) {
Bukkit.getLogger().info("You are running a version of CraftBukkit"
+ " for which Quests cannot set the NBT tag " + key);
}
} else { } else {
extra.put(key, value); extra.put(key, value);
} }
@ -260,7 +270,11 @@ public class ItemUtil {
} }
meta = stack.getItemMeta(); meta = stack.getItemMeta();
if (!extra.isEmpty()) { if (!extra.isEmpty()) {
meta = ItemUtil.deserializeItemMeta(meta.getClass(), (Map<String, Object>) extra); ItemMeta toLoad = null;
toLoad = ItemUtil.deserializeItemMeta(meta.getClass(), (Map<String, Object>) extra);
if (toLoad != null) {
meta = toLoad;
}
} }
if (!enchs.isEmpty()) { if (!enchs.isEmpty()) {
for (Enchantment e : enchs.keySet()) { for (Enchantment e : enchs.keySet()) {