Fixed anvil names not being saved to loadout.

I also fixed "lore" too, but I do not know what it is.
This commit is contained in:
cmastudios 2013-01-29 22:21:41 -06:00
parent c3d7b74109
commit 9ca2ed1f46
1 changed files with 21 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
public class LoadoutYmlMapper {
@ -58,6 +59,18 @@ public class LoadoutYmlMapper {
meta.setColor(clr);
stack.setItemMeta(meta);
}
if (config.contains(prefix + "name")) {
String itemName = config.getString(prefix + "name");
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(itemName);
stack.setItemMeta(meta);
}
if (config.contains(prefix + "lore")) {
List<String> itemLore = config.getStringList(prefix + "lore");
ItemMeta meta = stack.getItemMeta();
meta.setLore(itemLore);
stack.setItemMeta(meta);
}
loadout.put(slot, stack);
}
@ -125,6 +138,14 @@ public class LoadoutYmlMapper {
int rgb = meta.getColor().asRGB();
slotSection.set("armorcolor", rgb);
}
if (stack.hasItemMeta() && stack.getItemMeta().hasDisplayName()) {
ItemMeta meta = stack.getItemMeta();
slotSection.set("name", meta.getDisplayName());
}
if (stack.hasItemMeta() && stack.getItemMeta().hasLore()) {
ItemMeta meta = stack.getItemMeta();
slotSection.set("lore", meta.getLore());
}
}
}
}