/**
* Loads an ItemMeta from a ConfigurationSection.
*
* @param itemSection the parent section of the meta section
* @param is the ItemStack to complete
*
* @throws InventoryUtilException if something goes wrong
*/
public static void loadFromConfigSection(final ConfigurationSection itemSection, final ItemStack is) throws InventoryUtilException {
if (itemSection.isConfigurationSection("meta")) {
final ItemMeta meta = is.getItemMeta();
final ConfigurationSection metaSection = itemSection.getConfigurationSection("meta");
if (meta instanceof BookMeta) {
loadBookMetaFromConfigSection(metaSection, (BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
loadEnchantmentStorageMetaFromConfigSection(metaSection, (EnchantmentStorageMeta)meta);
} else if (meta instanceof FireworkEffectMeta) {
loadFireworkEffectMetaFromConfigSection(metaSection, (FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
loadFireworkMetaFromConfigSection(metaSection, (FireworkMeta)meta);
} else if (meta instanceof LeatherArmorMeta) {
loadLeatherArmorMetaFromConfigSection(metaSection, (LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
loadMapMetaFromConfigSection(metaSection, (MapMeta)meta);
} else if (meta instanceof PotionMeta) {
loadPotionMetaFromConfigSection(metaSection, (PotionMeta)meta);
} else if (meta instanceof SkullMeta) {
loadSkullMetaFromConfigSection(metaSection, (SkullMeta)meta);
}
final String displayName = metaSection.getString("name", "");
if (!displayName.isEmpty()) {
meta.setDisplayName(ColorUtil.colorize(displayName));
}
final List<String> lore = metaSection.getStringList("lore");
if (!lore.isEmpty()) {
meta.setLore(ColorUtil.colorize(lore));
}
is.setItemMeta(meta);
}
}
ItemMetaUtil.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:NPlugins
作者:
评论列表
文章目录