mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Add ChatColor support for lore and custom item names. Add lore and custom item name support for potions and dyes.
This commit is contained in:
parent
bfff5682b5
commit
e71eff852c
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -116,12 +117,12 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
try {
|
try {
|
||||||
short dataValue = Short.parseShort(potion_section.getName());
|
short dataValue = Short.parseShort(potion_section.getName());
|
||||||
|
|
||||||
String name = potion_section.getString("Name");
|
String name = ChatColor.translateAlternateColorCodes('&', potion_section.getString("Name"));
|
||||||
|
|
||||||
List<String> lore = new ArrayList<String>();
|
List<String> lore = new ArrayList<String>();
|
||||||
if (potion_section.contains("Lore")) {
|
if (potion_section.contains("Lore")) {
|
||||||
for (String line : potion_section.getStringList("Lore")) {
|
for (String line : potion_section.getStringList("Lore")) {
|
||||||
lore.add(line);
|
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -236,6 +237,22 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
||||||
|
|
||||||
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
List<String> lore = new ArrayList<String>();
|
||||||
|
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||||
|
}
|
||||||
|
itemMeta.setLore(lore);
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
reason.add("Invalid Potion_Type: " + potionType);
|
reason.add("Invalid Potion_Type: " + potionType);
|
||||||
@ -249,6 +266,22 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
||||||
|
|
||||||
item = dye.toItemStack(amount);
|
item = dye.toItemStack(amount);
|
||||||
|
|
||||||
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
List<String> lore = new ArrayList<String>();
|
||||||
|
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||||
|
}
|
||||||
|
itemMeta.setLore(lore);
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
reason.add("Invalid Dye_Color: " + color);
|
reason.add("Invalid Dye_Color: " + color);
|
||||||
@ -259,13 +292,17 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
itemMeta.setDisplayName(config.getString(type + "." + treasureName + ".Custom_Name"));
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
itemMeta.setLore(config.getStringList(type + "." + treasureName + ".Lore"));
|
List<String> lore = new ArrayList<String>();
|
||||||
|
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||||
|
}
|
||||||
|
itemMeta.setLore(lore);
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user