MMOItems 5.5.1 - The Colorful Update

You can now use hex colors with most things!
The format is '<#xxxxxx>' and it works just like the old '&x' did.
The old format is still supported and sometimes they can even be mixed!

Requires MMOLib 1.2.3 or later
This commit is contained in:
ASangarin 2020-06-27 00:59:59 +02:00
parent 80b7652f12
commit 5dc5677030
36 changed files with 226 additions and 178 deletions

Binary file not shown.

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<artifactId>MMOItems</artifactId> <artifactId>MMOItems</artifactId>
<version>5.5</version> <version>5.5.1</version>
<name>MMOItems</name> <name>MMOItems</name>
<description>A great item solution for your RPG server.</description> <description>A great item solution for your RPG server.</description>

View File

@ -9,7 +9,6 @@ import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -19,6 +18,7 @@ import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.ParticleData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
public class ItemSet { public class ItemSet {
private final Map<Integer, SetBonuses> bonuses = new HashMap<>(); private final Map<Integer, SetBonuses> bonuses = new HashMap<>();
@ -30,7 +30,7 @@ public class ItemSet {
public ItemSet(ConfigurationSection config) { public ItemSet(ConfigurationSection config) {
this.id = config.getName().toUpperCase().replace("-", "_"); this.id = config.getName().toUpperCase().replace("-", "_");
this.loreTag = config.getStringList("lore-tag"); this.loreTag = config.getStringList("lore-tag");
this.name = ChatColor.translateAlternateColorCodes('&', config.getString("name")); this.name = new ColorParse('&', config.getString("name")).toChatColor();
Validate.isTrue(config.contains("bonuses"), "Could not find item set bonuses"); Validate.isTrue(config.contains("bonuses"), "Could not find item set bonuses");

View File

@ -5,12 +5,12 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.api.droptable.DropTable; import net.Indyuce.mmoitems.api.droptable.DropTable;
import net.Indyuce.mmoitems.comp.itemglow.TierColor; import net.Indyuce.mmoitems.comp.itemglow.TierColor;
import net.asangarin.hexcolors.ColorParse;
public class ItemTier { public class ItemTier {
private final String name, id; private final String name, id;
@ -29,7 +29,7 @@ public class ItemTier {
public ItemTier(ConfigurationSection config) { public ItemTier(ConfigurationSection config) {
id = config.getName().toUpperCase().replace("-", "_"); id = config.getName().toUpperCase().replace("-", "_");
name = ChatColor.translateAlternateColorCodes('&', config.getString("name")); name = new ColorParse('&', config.getString("name")).toChatColor();
deconstruct = config.contains("deconstruct-item") ? new DropTable(config.getConfigurationSection("deconstruct-item")) : null; deconstruct = config.contains("deconstruct-item") ? new DropTable(config.getConfigurationSection("deconstruct-item")) : null;
unidentificationInfo = new UnidentificationInfo(config.getConfigurationSection("unidentification")); unidentificationInfo = new UnidentificationInfo(config.getConfigurationSection("unidentification"));
@ -109,6 +109,6 @@ public class ItemTier {
} }
private String color(String str) { private String color(String str) {
return ChatColor.translateAlternateColorCodes('&', str); return new ColorParse('&', str).toChatColor();
} }
} }

View File

@ -14,6 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.util.MushroomState; import net.Indyuce.mmoitems.api.util.MushroomState;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
@ -32,10 +33,10 @@ public class CustomBlock {
Validate.notNull(config, "Could not read custom block config"); Validate.notNull(config, "Could not read custom block config");
blockName = ChatColor.translateAlternateColorCodes('&', config.getString("display-name", ChatColor.RESET + "Custom Block")); blockName = new ColorParse('&', config.getString("display-name", ChatColor.RESET + "Custom Block")).toChatColor();
if (config.contains("lore")) if (config.contains("lore"))
for (String s : config.getStringList("lore")) for (String s : config.getStringList("lore"))
lore.add(ChatColor.translateAlternateColorCodes('&', s)); lore.add(new ColorParse('&', s).toChatColor());
minExp = config.getInt("min-xp", 0); minExp = config.getInt("min-xp", 0);
maxExp = config.getInt("max-xp", 0); maxExp = config.getInt("max-xp", 0);
requiredPower = config.getInt("required-power", 0); requiredPower = config.getInt("required-power", 0);

View File

@ -8,7 +8,6 @@ import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -19,6 +18,7 @@ import net.Indyuce.mmoitems.api.crafting.recipe.Recipe.RecipeOption;
import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo; import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo;
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.PlayerData;
import net.asangarin.hexcolors.ColorParse;
public class CraftingStation { public class CraftingStation {
private final String id, name; private final String id, name;
@ -28,7 +28,7 @@ public class CraftingStation {
public CraftingStation(String id, FileConfiguration config) { public CraftingStation(String id, FileConfiguration config) {
this.id = id.toLowerCase().replace("_", "-").replace(" ", "-"); this.id = id.toLowerCase().replace("_", "-").replace(" ", "-");
this.name = ChatColor.translateAlternateColorCodes('&', config.getString("name")); this.name = new ColorParse('&', config.getString("name")).toChatColor();
for (String key : config.getConfigurationSection("recipes").getKeys(false)) for (String key : config.getConfigurationSection("recipes").getKeys(false))
try { try {
@ -46,7 +46,7 @@ public class CraftingStation {
Validate.notNull(name, "Crafting station name must not be null"); Validate.notNull(name, "Crafting station name must not be null");
this.id = id.toLowerCase().replace("_", "-").replace(" ", "-"); this.id = id.toLowerCase().replace("_", "-").replace(" ", "-");
this.name = ChatColor.translateAlternateColorCodes('&', name); this.name = new ColorParse('&', name).toChatColor();
this.itemOptions = itemOptions; this.itemOptions = itemOptions;
this.maxQueueSize = maxQueueSize; this.maxQueueSize = maxQueueSize;
} }

View File

@ -1,11 +1,11 @@
package net.Indyuce.mmoitems.api.crafting.ingredient; package net.Indyuce.mmoitems.api.crafting.ingredient;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.api.MMOLineConfig;
public class VanillaIngredient extends Ingredient { public class VanillaIngredient extends Ingredient {
@ -23,7 +23,7 @@ public class VanillaIngredient extends Ingredient {
config.validate("type"); config.validate("type");
material = Material.valueOf(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_")); material = Material.valueOf(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
displayName = config.contains("name") ? ChatColor.translateAlternateColorCodes('&', config.getString("name")) : null; displayName = config.contains("name") ? new ColorParse('&', config.getString("name")).toChatColor() : null;
display = config.contains("display") ? config.getString("display") : MMOUtils.caseOnWords(material.name().toLowerCase().replace("_", " ")); display = config.contains("display") ? config.getString("display") : MMOUtils.caseOnWords(material.name().toLowerCase().replace("_", " "));
} }

View File

@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.api.edition.process.AnvilGUI;
import net.Indyuce.mmoitems.api.edition.process.ChatEdition; import net.Indyuce.mmoitems.api.edition.process.ChatEdition;
import net.Indyuce.mmoitems.gui.PluginInventory; import net.Indyuce.mmoitems.gui.PluginInventory;
import net.Indyuce.mmoitems.gui.edition.BlockEdition.ConfigOptions; import net.Indyuce.mmoitems.gui.edition.BlockEdition.ConfigOptions;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
public class BlockChatEdition implements Edition { public class BlockChatEdition implements Edition {
@ -35,7 +36,7 @@ public class BlockChatEdition implements Edition {
inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------"); inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
for (String line : message) for (String line : message)
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.translateAlternateColorCodes('&', line)); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + new ColorParse('&', line).toChatColor());
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing."); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing.");
/* /*

View File

@ -27,7 +27,7 @@ public class NewItemEdition implements Edition {
inv.getPlayer().closeInventory(); inv.getPlayer().closeInventory();
inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------"); inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.translateAlternateColorCodes('&', "Write in the chat, the id of the new item.")); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Write in the chat, the id of the new item.");
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing."); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing.");
/* /*

View File

@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.api.edition.process.AnvilGUI;
import net.Indyuce.mmoitems.api.edition.process.ChatEdition; import net.Indyuce.mmoitems.api.edition.process.ChatEdition;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
public class StatEdition implements Edition { public class StatEdition implements Edition {
@ -39,7 +40,7 @@ public class StatEdition implements Edition {
inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------"); inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
for (String line : message) for (String line : message)
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.translateAlternateColorCodes('&', line)); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + new ColorParse('&', line).toChatColor());
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing."); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Type 'cancel' to abort editing.");
/* /*

View File

@ -25,6 +25,7 @@ import net.Indyuce.mmoitems.stat.data.PotionEffectListData;
import net.Indyuce.mmoitems.stat.data.SoulboundData; import net.Indyuce.mmoitems.stat.data.SoulboundData;
import net.Indyuce.mmoitems.stat.data.UpgradeData; import net.Indyuce.mmoitems.stat.data.UpgradeData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
@ -288,7 +289,7 @@ public class Consumable extends UseItem {
int maxConsume = (int) nbtItem.getStat("MAX_CONSUME"); int maxConsume = (int) nbtItem.getStat("MAX_CONSUME");
if (maxConsume > 1) { if (maxConsume > 1) {
ItemStack item = nbtItem.toItem().clone(); ItemStack item = nbtItem.toItem().clone();
String configMaxConsumeLore = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getLanguage().getStatFormat("max-consume")); String configMaxConsumeLore = new ColorParse('&', MMOItems.plugin.getLanguage().getStatFormat("max-consume")).toChatColor();
String maxConsumeLore = configMaxConsumeLore.replace("#", Integer.toString(maxConsume)); String maxConsumeLore = configMaxConsumeLore.replace("#", Integer.toString(maxConsume));
maxConsume -= 1; maxConsume -= 1;

View File

@ -2,11 +2,10 @@ package net.Indyuce.mmoitems.api.item.build;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.asangarin.hexcolors.ColorParse;
public class MMOItemLore { public class MMOItemLore {
private final List<String> lore = MMOItems.plugin.getLanguage().getDefaultLoreFormat(); private final List<String> lore = MMOItems.plugin.getLanguage().getDefaultLoreFormat();
@ -60,7 +59,7 @@ public class MMOItemLore {
* successfully calculated * successfully calculated
*/ */
for (int n = 0; n < lore.size(); n++) for (int n = 0; n < lore.size(); n++)
lore.set(n, ChatColor.translateAlternateColorCodes('&', lore.get(n).replace("{bar}", "").replace("{sbar}", ""))); lore.set(n, new ColorParse('&', lore.get(n).replace("{bar}", "").replace("{sbar}", "")).toChatColor());
return this; return this;
} }

View File

@ -15,6 +15,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.api.item.plugin.crafting.CraftingRecipeDisplay; import net.Indyuce.mmoitems.api.item.plugin.crafting.CraftingRecipeDisplay;
import net.Indyuce.mmoitems.api.item.plugin.crafting.QueueItemDisplay; import net.Indyuce.mmoitems.api.item.plugin.crafting.QueueItemDisplay;
import net.Indyuce.mmoitems.api.item.plugin.crafting.UpgradingRecipeDisplay; import net.Indyuce.mmoitems.api.item.plugin.crafting.UpgradingRecipeDisplay;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.version.VersionMaterial; import net.mmogroup.mmolib.version.VersionMaterial;
public class ConfigItem { public class ConfigItem {
@ -94,12 +95,12 @@ public class ConfigItem {
return; return;
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getName())); meta.setDisplayName(new ColorParse('&', getName()).toChatColor());
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
if (hasLore()) { if (hasLore()) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
getLore().forEach(str -> lore.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', str))); getLore().forEach(str -> lore.add(ChatColor.GRAY + new ColorParse('&', str).toChatColor()));
meta.setLore(lore); meta.setLore(lore);
} }

View File

@ -14,6 +14,7 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.version.VersionMaterial; import net.mmogroup.mmolib.version.VersionMaterial;
public class CustomSkull extends ConfigItem { public class CustomSkull extends ConfigItem {
@ -32,7 +33,7 @@ public class CustomSkull extends ConfigItem {
public void updateItem() { public void updateItem() {
setItem(VersionMaterial.PLAYER_HEAD.toItem()); setItem(VersionMaterial.PLAYER_HEAD.toItem());
ItemMeta meta = getItem().getItemMeta(); ItemMeta meta = getItem().getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getName())); meta.setDisplayName(new ColorParse('&', getName()).toChatColor());
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null); GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null);
@ -47,7 +48,7 @@ public class CustomSkull extends ConfigItem {
if (hasLore()) { if (hasLore()) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
getLore().forEach(str -> lore.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', str))); getLore().forEach(str -> lore.add(ChatColor.GRAY + new ColorParse('&', str).toChatColor()));
meta.setLore(lore); meta.setLore(lore);
} }

View File

@ -1,16 +1,17 @@
package net.Indyuce.mmoitems.api.item.plugin; package net.Indyuce.mmoitems.api.item.plugin;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import net.asangarin.hexcolors.ColorParse;
public class NamedItemStack extends ItemStack { public class NamedItemStack extends ItemStack {
public NamedItemStack(Material material, String name) { public NamedItemStack(Material material, String name) {
super(material); super(material);
ItemMeta meta = getItemMeta(); ItemMeta meta = getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); meta.setDisplayName(new ColorParse('&', name).toChatColor());
setItemMeta(meta); setItemMeta(meta);
} }
} }

View File

@ -20,6 +20,7 @@ import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe;
import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo; import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem; import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.api.util.message.Message;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
@ -108,7 +109,7 @@ public class CraftingRecipeDisplay extends ConfigItem {
* apply color to lore * apply color to lore
*/ */
for (int n = 0; n < lore.size(); n++) for (int n = 0; n < lore.size(); n++)
lore.set(n, ChatColor.translateAlternateColorCodes('&', lore.get(n))); lore.set(n, new ColorParse('&', lore.get(n)).toChatColor());
ItemStack item = craftingRecipe.getOutput().getPreview(); ItemStack item = craftingRecipe.getOutput().getPreview();
int amount = craftingRecipe.getOutput().getAmount(); int amount = craftingRecipe.getOutput().getAmount();
@ -120,7 +121,7 @@ public class CraftingRecipeDisplay extends ConfigItem {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name.replace("#name#", (amount > 1 ? (ChatColor.WHITE + "" + amount + " x ") : "") + MMOUtils.getDisplayName(item)))); meta.setDisplayName(new ColorParse('&', name.replace("#name#", (amount > 1 ? (ChatColor.WHITE + "" + amount + " x ") : "") + MMOUtils.getDisplayName(item))).toChatColor());
meta.setLore(lore); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);

View File

@ -6,7 +6,6 @@ import java.util.Iterator;
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.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -15,6 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue.CraftingInfo; import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue.CraftingInfo;
import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem; import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
@ -77,13 +77,13 @@ public class QueueItemDisplay extends ConfigItem {
* apply color to lore * apply color to lore
*/ */
for (int n = 0; n < lore.size(); n++) for (int n = 0; n < lore.size(); n++)
lore.set(n, ChatColor.translateAlternateColorCodes('&', lore.get(n))); lore.set(n, new ColorParse('&', lore.get(n)).toChatColor());
ItemStack item = ((CraftingRecipe) crafting.getRecipe()).getOutput().getPreview(); ItemStack item = ((CraftingRecipe) crafting.getRecipe()).getOutput().getPreview();
item.setAmount(position); item.setAmount(position);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name.replace("#name#", meta.getDisplayName()))); meta.setDisplayName(new ColorParse('&', name.replace("#name#", meta.getDisplayName())).toChatColor());
meta.setLore(lore); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);

View File

@ -6,7 +6,6 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -18,6 +17,7 @@ import net.Indyuce.mmoitems.api.crafting.condition.Condition.CheckedCondition;
import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo; import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo;
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem; import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
@ -85,12 +85,12 @@ public class UpgradingRecipeDisplay extends ConfigItem {
* apply color to lore * apply color to lore
*/ */
for (int n = 0; n < lore.size(); n++) for (int n = 0; n < lore.size(); n++)
lore.set(n, ChatColor.translateAlternateColorCodes('&', lore.get(n))); lore.set(n, new ColorParse('&', lore.get(n)).toChatColor());
ItemStack item = upgradingRecipe.getItem().getPreview(); ItemStack item = upgradingRecipe.getItem().getPreview();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name.replace("#name#", MMOUtils.getDisplayName(item)))); meta.setDisplayName(new ColorParse('&', name.replace("#name#", MMOUtils.getDisplayName(item))).toChatColor());
meta.setLore(lore); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);

View File

@ -8,7 +8,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -18,11 +17,12 @@ import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier; import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.MMOItem; import net.Indyuce.mmoitems.api.item.MMOItem;
import net.Indyuce.mmoitems.api.item.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem; import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
@ -96,7 +96,7 @@ public class UnidentifiedItem extends ConfigItem {
String str = lore.get(n); String str = lore.get(n);
for (String placeholder : placeholders.keySet()) for (String placeholder : placeholders.keySet())
str = str.replace("#" + placeholder + "#", placeholders.get(placeholder)); str = str.replace("#" + placeholder + "#", placeholders.get(placeholder));
lore.set(n, ChatColor.translateAlternateColorCodes('&', str.replace("{range}", "").replace("{tier}", ""))); lore.set(n, new ColorParse('&', str.replace("{range}", "").replace("{tier}", "")).toChatColor());
} }
/* /*
@ -106,7 +106,7 @@ public class UnidentifiedItem extends ConfigItem {
ItemMeta meta = unidentified.getItemMeta(); ItemMeta meta = unidentified.getItemMeta();
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
meta.setUnbreakable(true); meta.setUnbreakable(true);
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); meta.setDisplayName(new ColorParse('&', name).toChatColor());
meta.setLore(lore); meta.setLore(lore);
unidentified.setItemMeta(meta); unidentified.setItemMeta(meta);

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.api.itemgen; package net.Indyuce.mmoitems.api.itemgen;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.asangarin.hexcolors.ColorParse;
public class NameModifier { public class NameModifier {
private final ModifierType type; private final ModifierType type;
@ -24,7 +24,7 @@ public class NameModifier {
if (object instanceof ConfigurationSection) { if (object instanceof ConfigurationSection) {
ConfigurationSection config = (ConfigurationSection) object; ConfigurationSection config = (ConfigurationSection) object;
Validate.isTrue(config.contains("format"), MMOUtils.caseOnWords(type.name().toLowerCase()) + " format cannot be null"); Validate.isTrue(config.contains("format"), MMOUtils.caseOnWords(type.name().toLowerCase()) + " format cannot be null");
format = ChatColor.translateAlternateColorCodes('&', config.get("format").toString()); format = new ColorParse('&', config.get("format").toString()).toChatColor();
priority = config.getInt("priority"); priority = config.getInt("priority");
return; return;
} }
@ -35,7 +35,7 @@ public class NameModifier {
public NameModifier(ModifierType type, String format, int priority) { public NameModifier(ModifierType type, String format, int priority) {
Validate.notNull(format, "Format cannot be null"); Validate.notNull(format, "Format cannot be null");
this.type = type; this.type = type;
this.format = ChatColor.translateAlternateColorCodes('&', format); this.format = new ColorParse('&', format).toChatColor();
this.priority = priority; this.priority = priority;
Validate.notNull(type, "Type cannot be null"); Validate.notNull(type, "Type cannot be null");

View File

@ -54,6 +54,7 @@ import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit; import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
@ -222,7 +223,7 @@ public class MMOItemsCommand implements CommandExecutor {
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage(ChatColor.DARK_GRAY + "Description:"); sender.sendMessage(ChatColor.DARK_GRAY + "Description:");
for (String line : update.getDescription()) for (String line : update.getDescription())
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.translateAlternateColorCodes('&', line)); sender.sendMessage(ChatColor.GRAY + "- " + new ColorParse('&', line).toChatColor());
} }
sender.sendMessage(""); sender.sendMessage("");
@ -599,7 +600,7 @@ public class MMOItemsCommand implements CommandExecutor {
sender.sendMessage( sender.sendMessage(
"* " + ChatColor.GREEN + s "* " + ChatColor.GREEN + s
+ (config.getConfigurationSection(s).contains("name") + (config.getConfigurationSection(s).contains("name")
? " " + ChatColor.WHITE + "(" + ChatColor.translateAlternateColorCodes('&', config.getString(s + ".name")) ? " " + ChatColor.WHITE + "(" + new ColorParse('&', config.getString(s + ".name")).toChatColor()
+ ChatColor.WHITE + ")" + ChatColor.WHITE + ")"
: "")); : ""));
} }
@ -628,18 +629,18 @@ public class MMOItemsCommand implements CommandExecutor {
sender.sendMessage( sender.sendMessage(
"* " + ChatColor.GREEN + s "* " + ChatColor.GREEN + s
+ (config.getConfigurationSection(s).contains("name") + (config.getConfigurationSection(s).contains("name")
? " " + ChatColor.WHITE + "(" + ChatColor.translateAlternateColorCodes('&', config.getString(s + ".name")) ? " " + ChatColor.WHITE + "(" + new ColorParse('&', config.getString(s + ".name")).toChatColor()
+ ChatColor.WHITE + ")" + ChatColor.WHITE + ")"
: "")); : ""));
return true; return true;
} }
for (String s : config.getKeys(false)) { for (String s : config.getKeys(false)) {
String nameFormat = config.getConfigurationSection(s).contains("name") ? " " + ChatColor.WHITE + "(" String nameFormat = config.getConfigurationSection(s).contains("name") ? " " + ChatColor.WHITE + "("
+ ChatColor.translateAlternateColorCodes('&', config.getString(s + ".name")) + ChatColor.WHITE + ")" : ""; + new ColorParse('&', config.getString(s + ".name")).toChatColor() + ChatColor.WHITE + ")" : "";
MMOLib.plugin.getNMS().sendJson((Player) sender, MMOLib.plugin.getNMS().sendJson((Player) sender,
"{\"text\":\"* " + ChatColor.GREEN + s + nameFormat + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/mi edit " "{\"text\":\"* " + ChatColor.GREEN + s + nameFormat + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/mi edit "
+ type.getId() + " " + s + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to edit " + type.getId() + " " + s + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to edit "
+ (nameFormat.equals("") ? s : ChatColor.translateAlternateColorCodes('&', config.getString(s + ".name"))) + (nameFormat.equals("") ? s : new ColorParse('&', config.getString(s + ".name")).toChatColor())
+ ChatColor.WHITE + ".\",\"color\":\"white\"}}}"); + ChatColor.WHITE + ".\",\"color\":\"white\"}}}");
} }
} }

View File

@ -4,8 +4,9 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.mmogroup.mmolib.api.util.AltChar; import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.util.AltChar;
public class PluginHelp { public class PluginHelp {
private static final int commandsPerPage = 8; private static final int commandsPerPage = 8;
@ -102,7 +103,7 @@ public class PluginHelp {
private PluginCommand(String usage, String help) { private PluginCommand(String usage, String help) {
this.usage = usage; this.usage = usage;
this.help = help == null ? null : ChatColor.translateAlternateColorCodes('&', help); this.help = help == null ? null : new ColorParse('&', help).toChatColor();
} }
private boolean isCommand() { private boolean isCommand() {

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -18,6 +17,7 @@ import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe;
import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo; import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo;
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem; import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.asangarin.hexcolors.ColorParse;
public class CraftingStationPreview extends PluginInventory { public class CraftingStationPreview extends PluginInventory {
private final CraftingStationView previous; private final CraftingStationView previous;
@ -78,7 +78,7 @@ public class CraftingStationPreview extends PluginInventory {
if (recipe.getRecipe() instanceof UpgradingRecipe) { if (recipe.getRecipe() instanceof UpgradingRecipe) {
ItemStack stack = ((UpgradingRecipe) recipe.getRecipe()).getItem().getPreview(); ItemStack stack = ((UpgradingRecipe) recipe.getRecipe()).getItem().getPreview();
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.translateAlternateColorCodes('&', " &a+1!")); meta.setDisplayName(meta.getDisplayName() + new ColorParse('&', " &a+1!").toChatColor());
stack.setItemMeta(meta); stack.setItemMeta(meta);
inv.setItem(16, stack); inv.setItem(16, stack);
} }

View File

@ -22,9 +22,10 @@ import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.block.CustomBlock; import net.Indyuce.mmoitems.api.block.CustomBlock;
import net.Indyuce.mmoitems.api.edition.BlockChatEdition; import net.Indyuce.mmoitems.api.edition.BlockChatEdition;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem; import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.mmogroup.mmolib.api.util.AltChar;
import net.Indyuce.mmoitems.gui.BlockBrowser; import net.Indyuce.mmoitems.gui.BlockBrowser;
import net.Indyuce.mmoitems.gui.PluginInventory; import net.Indyuce.mmoitems.gui.PluginInventory;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.util.AltChar;
public class BlockEdition extends PluginInventory { public class BlockEdition extends PluginInventory {
private final ConfigFile config = new ConfigFile("custom-blocks"); private final ConfigFile config = new ConfigFile("custom-blocks");
@ -60,9 +61,17 @@ public class BlockEdition extends PluginInventory {
if (loreList.isEmpty()) if (loreList.isEmpty())
eventLore.add(ChatColor.RED + "No lore."); eventLore.add(ChatColor.RED + "No lore.");
for (String lore : loreList) for (String lore : loreList)
eventLore.add(ChatColor.GREEN + ChatColor.translateAlternateColorCodes('&', lore)); eventLore.add(ChatColor.GREEN + new ColorParse('&', lore).toChatColor());
} else } else
eventLore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN + (configOptions.format.equals("int") ? config.getConfig().contains(block.getId() + "." + configOptions.path) ? ChatColor.GREEN + config.getConfig().getString(block.getId() + "." + configOptions.path) : ChatColor.RED + "0" : ChatColor.translateAlternateColorCodes('&', config.getConfig().getString(block.getId() + "." + configOptions.path, ChatColor.RED + "Default")))); eventLore
.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN
+ (configOptions.format.equals("int")
? config.getConfig().contains(block.getId() + "." + configOptions.path)
? ChatColor.GREEN + config.getConfig()
.getString(block.getId() + "." + configOptions.path)
: ChatColor.RED + "0"
: new ColorParse('&', config.getConfig().getString(
block.getId() + "." + configOptions.path, ChatColor.RED + "Default")).toChatColor()));
eventLore.add(""); eventLore.add("");
eventLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); eventLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
@ -103,14 +112,15 @@ public class BlockEdition extends PluginInventory {
MMOItems.plugin.getCustomBlocks().reload(); MMOItems.plugin.getCustomBlocks().reload();
new BlockEdition(player, block).open(); new BlockEdition(player, block).open();
player.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(path.replace("-", " ")) + " Value" + ChatColor.GRAY + " successfully removed."); player.sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(path.replace("-", " "))
+ " Value" + ChatColor.GRAY + " successfully removed.");
} }
} }
} }
public enum ConfigOptions { public enum ConfigOptions {
DISPLAY_NAME("display-name", Material.WRITABLE_BOOK, 11, "string"), DISPLAY_NAME("display-name", Material.WRITABLE_BOOK, 11, "string"), LORE("lore", Material.MAP, 13, "line"),
LORE("lore", Material.MAP, 13, "line"),
REQUIRED_PICKAXE_POWER("required-power", Material.IRON_PICKAXE, 15, "int"), REQUIRED_PICKAXE_POWER("required-power", Material.IRON_PICKAXE, 15, "int"),
MIN_XP("min-xp", Material.EXPERIENCE_BOTTLE, 21, "int"), MIN_XP("min-xp", Material.EXPERIENCE_BOTTLE, 21, "int"),
MAX_XP("max-xp", Material.EXPERIENCE_BOTTLE, 23, "int"), MAX_XP("max-xp", Material.EXPERIENCE_BOTTLE, 23, "int"),
@ -161,22 +171,27 @@ public class BlockEdition extends PluginInventory {
try { try {
value = Integer.parseInt(message); value = Integer.parseInt(message);
} catch (Exception e1) { } catch (Exception e1) {
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + message + " is not a valid number."); inv.getPlayer().sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + message + " is not a valid number.");
return false; return false;
} }
setConfigValue(new ConfigFile("custom-blocks"), path, value); setConfigValue(new ConfigFile("custom-blocks"), path, value);
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + name().replace("_", " ") + " successfully changed to " + value + "."); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + name().replace("_", " ")
+ " successfully changed to " + value + ".");
break; break;
case "line": case "line":
ConfigFile config = new ConfigFile("custom-blocks"); ConfigFile config = new ConfigFile("custom-blocks");
List<String> lore = config.getConfig().contains(path) ? config.getConfig().getStringList(path) : new ArrayList<>(); List<String> lore = config.getConfig().contains(path) ? config.getConfig().getStringList(path)
: new ArrayList<>();
lore.add(message); lore.add(message);
setConfigValue(config, path, lore); setConfigValue(config, path, lore);
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully added to " + message + " to block lore."); inv.getPlayer().sendMessage(
MMOItems.plugin.getPrefix() + "Successfully added to " + message + " to block lore.");
break; break;
default: default:
setConfigValue(new ConfigFile("custom-blocks"), path, message); setConfigValue(new ConfigFile("custom-blocks"), path, message);
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully changed value to " + message + "."); inv.getPlayer().sendMessage(
MMOItems.plugin.getPrefix() + "Successfully changed value to " + message + ".");
break; break;
} }

View File

@ -18,6 +18,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.item.MMOItem; import net.Indyuce.mmoitems.api.item.MMOItem;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
@ -59,7 +60,7 @@ public class ItemEdition extends EditionInventory {
meta.setDisplayName(ChatColor.GREEN + stat.getName()); meta.setDisplayName(ChatColor.GREEN + stat.getName());
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
for (String s1 : stat.getLore()) for (String s1 : stat.getLore())
lore.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', s1)); lore.add(ChatColor.GRAY + new ColorParse('&', s1).toChatColor());
lore.add(""); lore.add("");
stat.whenDisplayed(lore, mmoitem); stat.whenDisplayed(lore, mmoitem);

View File

@ -24,6 +24,7 @@ import net.Indyuce.mmoitems.api.item.MMOItem;
import net.Indyuce.mmoitems.particle.api.ParticleType; import net.Indyuce.mmoitems.particle.api.ParticleType;
import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.ParticleData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
import net.mmogroup.mmolib.api.util.AltChar; import net.mmogroup.mmolib.api.util.AltChar;
@ -56,11 +57,12 @@ public class ParticlesEdition extends EditionInventory {
particleTypeItemLore.add(ChatColor.GRAY + "particles behave, what pattern they follow"); particleTypeItemLore.add(ChatColor.GRAY + "particles behave, what pattern they follow");
particleTypeItemLore.add(ChatColor.GRAY + "when displayed or what shape they form."); particleTypeItemLore.add(ChatColor.GRAY + "when displayed or what shape they form.");
particleTypeItemLore.add(""); particleTypeItemLore.add("");
particleTypeItemLore.add(ChatColor.GRAY + "Current Value: " particleTypeItemLore
+ (particleType == null ? ChatColor.RED + "No type selected." : ChatColor.GOLD + particleType.getDefaultName())); .add(ChatColor.GRAY + "Current Value: " + (particleType == null ? ChatColor.RED + "No type selected."
: ChatColor.GOLD + particleType.getDefaultName()));
if (particleType != null) { if (particleType != null) {
particleTypeItemLore particleTypeItemLore
.add("" + ChatColor.GRAY + ChatColor.ITALIC + ChatColor.translateAlternateColorCodes('&', particleType.getDescription())); .add("" + ChatColor.GRAY + ChatColor.ITALIC + new ColorParse('&', particleType.getDescription()).toChatColor());
} }
particleTypeItemLore.add(""); particleTypeItemLore.add("");
particleTypeItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); particleTypeItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
@ -81,7 +83,8 @@ public class ParticlesEdition extends EditionInventory {
particleItemLore.add(ChatColor.GRAY + "Defines what particle is used"); particleItemLore.add(ChatColor.GRAY + "Defines what particle is used");
particleItemLore.add(ChatColor.GRAY + "in the particle effect."); particleItemLore.add(ChatColor.GRAY + "in the particle effect.");
particleItemLore.add(""); particleItemLore.add("");
particleItemLore.add(ChatColor.GRAY + "Current Value: " + (particle == null ? ChatColor.RED + "No particle selected." particleItemLore
.add(ChatColor.GRAY + "Current Value: " + (particle == null ? ChatColor.RED + "No particle selected."
: ChatColor.GOLD + MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " ")))); : ChatColor.GOLD + MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " "))));
particleItemLore.add(""); particleItemLore.add("");
particleItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); particleItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
@ -94,14 +97,16 @@ public class ParticlesEdition extends EditionInventory {
for (String modifier : particleType.getModifiers()) { for (String modifier : particleType.getModifiers()) {
ItemStack modifierItem = VersionMaterial.GRAY_DYE.toItem(); ItemStack modifierItem = VersionMaterial.GRAY_DYE.toItem();
ItemMeta modifierItemMeta = modifierItem.getItemMeta(); ItemMeta modifierItemMeta = modifierItem.getItemMeta();
modifierItemMeta.setDisplayName(ChatColor.GREEN + MMOUtils.caseOnWords(modifier.toLowerCase().replace("-", " "))); modifierItemMeta.setDisplayName(
ChatColor.GREEN + MMOUtils.caseOnWords(modifier.toLowerCase().replace("-", " ")));
List<String> modifierItemLore = new ArrayList<String>(); List<String> modifierItemLore = new ArrayList<String>();
modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "This is a pattern modifier."); modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "This is a pattern modifier.");
modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "Changing this value will slightly"); modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "Changing this value will slightly");
modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "customize the particle pattern."); modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "customize the particle pattern.");
modifierItemLore.add(""); modifierItemLore.add("");
modifierItemLore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GOLD modifierItemLore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GOLD
+ (psection.contains(modifier) ? psection.getDouble(modifier) : particleType.getModifier(modifier))); + (psection.contains(modifier) ? psection.getDouble(modifier)
: particleType.getModifier(modifier)));
modifierItemMeta.setLore(modifierItemLore); modifierItemMeta.setLore(modifierItemLore);
modifierItem.setItemMeta(modifierItemMeta); modifierItem.setItemMeta(modifierItemMeta);
@ -123,8 +128,8 @@ public class ParticlesEdition extends EditionInventory {
colorItemLore.add(ChatColor.GRAY + "The RGB color of your particle."); colorItemLore.add(ChatColor.GRAY + "The RGB color of your particle.");
colorItemLore.add(""); colorItemLore.add("");
colorItemLore.add(ChatColor.GRAY + "Current Value (R-G-B):"); colorItemLore.add(ChatColor.GRAY + "Current Value (R-G-B):");
colorItemLore.add("" + ChatColor.RED + ChatColor.BOLD + red + ChatColor.GRAY + " - " + ChatColor.GREEN + ChatColor.BOLD + green colorItemLore.add("" + ChatColor.RED + ChatColor.BOLD + red + ChatColor.GRAY + " - " + ChatColor.GREEN
+ ChatColor.GRAY + " - " + ChatColor.BLUE + ChatColor.BOLD + blue); + ChatColor.BOLD + green + ChatColor.GRAY + " - " + ChatColor.BLUE + ChatColor.BOLD + blue);
colorItemLore.add(""); colorItemLore.add("");
colorItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); colorItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
colorItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to change this value."); colorItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to change this value.");
@ -159,12 +164,14 @@ public class ParticlesEdition extends EditionInventory {
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle")) { if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle")) {
if (event.getAction() == InventoryAction.PICKUP_ALL) if (event.getAction() == InventoryAction.PICKUP_ALL)
new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle").enable("Write in the chat the particle you want."); new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle")
.enable("Write in the chat the particle you want.");
if (event.getAction() == InventoryAction.PICKUP_HALF) { if (event.getAction() == InventoryAction.PICKUP_HALF) {
ConfigFile config = mmoitem.getType().getConfigFile(); ConfigFile config = mmoitem.getType().getConfigFile();
if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles") if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles")
&& config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("particle")) { && config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles")
.contains("particle")) {
config.getConfig().set(mmoitem.getId() + ".item-particles.particle", null); config.getConfig().set(mmoitem.getId() + ".item-particles.particle", null);
registerItemEdition(config); registerItemEdition(config);
open(); open();
@ -175,13 +182,13 @@ public class ParticlesEdition extends EditionInventory {
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle Color")) { if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle Color")) {
if (event.getAction() == InventoryAction.PICKUP_ALL) if (event.getAction() == InventoryAction.PICKUP_ALL)
new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle-color").enable("Write in the chat the RGB color you want.", new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle-color").enable(
ChatColor.AQUA + "Format: [RED] [GREEN] [BLUE]"); "Write in the chat the RGB color you want.", ChatColor.AQUA + "Format: [RED] [GREEN] [BLUE]");
if (event.getAction() == InventoryAction.PICKUP_HALF) { if (event.getAction() == InventoryAction.PICKUP_HALF) {
ConfigFile config = mmoitem.getType().getConfigFile(); ConfigFile config = mmoitem.getType().getConfigFile();
if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles") if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles") && config
&& config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("color")) { .getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("color")) {
config.getConfig().set(mmoitem.getId() + ".item-particles.color", null); config.getConfig().set(mmoitem.getId() + ".item-particles.color", null);
registerItemEdition(config); registerItemEdition(config);
open(); open();
@ -192,7 +199,8 @@ public class ParticlesEdition extends EditionInventory {
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle Pattern")) { if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle Pattern")) {
if (event.getAction() == InventoryAction.PICKUP_ALL) { if (event.getAction() == InventoryAction.PICKUP_ALL) {
new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle-type").enable("Write in the chat the particle type you want."); new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle-type")
.enable("Write in the chat the particle type you want.");
player.sendMessage(""); player.sendMessage("");
player.sendMessage("" + ChatColor.GREEN + ChatColor.BOLD + "Available Particles Patterns"); player.sendMessage("" + ChatColor.GREEN + ChatColor.BOLD + "Available Particles Patterns");
for (ParticleType type : ParticleType.values()) for (ParticleType type : ParticleType.values())
@ -201,12 +209,13 @@ public class ParticlesEdition extends EditionInventory {
if (event.getAction() == InventoryAction.PICKUP_HALF) { if (event.getAction() == InventoryAction.PICKUP_HALF) {
ConfigFile config = mmoitem.getType().getConfigFile(); ConfigFile config = mmoitem.getType().getConfigFile();
if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles") if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles") && config
&& config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("type")) { .getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("type")) {
config.getConfig().set(mmoitem.getId() + ".item-particles.type", null); config.getConfig().set(mmoitem.getId() + ".item-particles.type", null);
// reset other modifiers // reset other modifiers
for (String key : config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").getKeys(false)) for (String key : config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles")
.getKeys(false))
if (!key.equals("particle")) if (!key.equals("particle"))
config.getConfig().set(mmoitem.getId() + ".item-particles." + key, null); config.getConfig().set(mmoitem.getId() + ".item-particles." + key, null);
@ -231,7 +240,8 @@ public class ParticlesEdition extends EditionInventory {
config.getConfig().set(mmoitem.getId() + ".item-particles." + tag, null); config.getConfig().set(mmoitem.getId() + ".item-particles." + tag, null);
registerItemEdition(config); registerItemEdition(config);
open(); open();
player.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reset " + ChatColor.GOLD + tag + ChatColor.GRAY + "."); player.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reset " + ChatColor.GOLD + tag
+ ChatColor.GRAY + ".");
} }
} }
} }

View File

@ -12,7 +12,6 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.ChatColor;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
@ -21,10 +20,11 @@ import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.ability.Ability; import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.Ability.CastingMode; import net.Indyuce.mmoitems.api.ability.Ability.CastingMode;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem; import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.mmogroup.mmolib.api.util.AltChar;
import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect; import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit; import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.util.AltChar;
public class ConfigManager { public class ConfigManager {
@ -32,14 +32,16 @@ public class ConfigManager {
private ConfigFile abilities, items, loreFormat, messages, potionEffects, stats, attackEffects, namePlaceholders; private ConfigFile abilities, items, loreFormat, messages, potionEffects, stats, attackEffects, namePlaceholders;
// cached config options // cached config options
public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck; public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled,
upgradeRequirementsCheck;
public String healIndicatorFormat, damageIndicatorFormat, abilitySplitter; public String healIndicatorFormat, damageIndicatorFormat, abilitySplitter;
public DecimalFormat healIndicatorDecimalFormat, damageIndicatorDecimalFormat; public DecimalFormat healIndicatorDecimalFormat, damageIndicatorDecimalFormat;
public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage; public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage;
private static final Random random = new Random(); private static final Random random = new Random();
private static final String[] fileNames = { "abilities", "messages", "potion-effects", "stats", "items", "attack-effects" }; private static final String[] fileNames = { "abilities", "messages", "potion-effects", "stats", "items",
"attack-effects" };
private static final String[] languages = { "french", "chinese", "spanish", "russian", "polish" }; private static final String[] languages = { "french", "chinese", "spanish", "russian", "polish" };
// try to setup non existing languages // try to setup non existing languages
@ -69,9 +71,11 @@ public class ConfigManager {
JarFile jarFile = new JarFile(MMOItems.plugin.getJarFile()); JarFile jarFile = new JarFile(MMOItems.plugin.getJarFile());
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) { for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
String name = entries.nextElement().getName(); String name = entries.nextElement().getName();
if (name.startsWith("default/crafting-stations/") && name.length() > "default/crafting-stations/".length()) if (name.startsWith("default/crafting-stations/")
&& name.length() > "default/crafting-stations/".length())
Files.copy(MMOItems.plugin.getResource(name), Files.copy(MMOItems.plugin.getResource(name),
new File(MMOItems.plugin.getDataFolder() + "/crafting-stations", name.split("\\/")[2]).toPath()); new File(MMOItems.plugin.getDataFolder() + "/crafting-stations", name.split("\\/")[2])
.toPath());
} }
jarFile.close(); jarFile.close();
} catch (IOException exception) { } catch (IOException exception) {
@ -88,7 +92,8 @@ public class ConfigManager {
if (!new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").exists()) { if (!new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").exists()) {
try { try {
Files.copy(MMOItems.plugin.getResource("language/" + language + "/" + fileName + ".yml"), Files.copy(MMOItems.plugin.getResource("language/" + language + "/" + fileName + ".yml"),
new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").getAbsoluteFile().toPath(), new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml")
.getAbsoluteFile().toPath(),
StandardCopyOption.REPLACE_EXISTING); StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -102,8 +107,8 @@ public class ConfigManager {
file.checkFile(); file.checkFile();
/* /*
* setup /item files after generating the default /item files otherwise * setup /item files after generating the default /item files otherwise they
* they will be empty! * will be empty!
*/ */
MMOItems.plugin.getTypes().getAll().forEach(type -> type.getConfigFile().setup()); MMOItems.plugin.getTypes().getAll().forEach(type -> type.getConfigFile().setup());
@ -147,7 +152,8 @@ public class ConfigManager {
String path = effect.getName().toLowerCase().replace("_", "-"); String path = effect.getName().toLowerCase().replace("_", "-");
if (!potionEffects.getConfig().contains(path)) if (!potionEffects.getConfig().contains(path))
potionEffects.getConfig().set(path, MMOUtils.caseOnWords(effect.getName().toLowerCase().replace("_", " "))); potionEffects.getConfig().set(path,
MMOUtils.caseOnWords(effect.getName().toLowerCase().replace("_", " ")));
} }
potionEffects.save(); potionEffects.save();
@ -155,19 +161,21 @@ public class ConfigManager {
for (StaffSpirit spirit : StaffSpirit.values()) { for (StaffSpirit spirit : StaffSpirit.values()) {
String path = spirit.name().toLowerCase().replace("_", "-"); String path = spirit.name().toLowerCase().replace("_", "-");
if (!attackEffects.getConfig().contains("staff-spirit." + path)) if (!attackEffects.getConfig().contains("staff-spirit." + path))
attackEffects.getConfig().set("staff-spirit." + path, "&7" + AltChar.listSquare + " " + spirit.getDefaultName()); attackEffects.getConfig().set("staff-spirit." + path,
"&7" + AltChar.listSquare + " " + spirit.getDefaultName());
} }
for (LuteAttackEffect effect : LuteAttackEffect.values()) { for (LuteAttackEffect effect : LuteAttackEffect.values()) {
String path = effect.name().toLowerCase().replace("_", "-"); String path = effect.name().toLowerCase().replace("_", "-");
if (!attackEffects.getConfig().contains("lute-attack." + path)) if (!attackEffects.getConfig().contains("lute-attack." + path))
attackEffects.getConfig().set("lute-attack." + path, "&7" + AltChar.listSquare + " " + effect.getDefaultName() + " Attacks"); attackEffects.getConfig().set("lute-attack." + path,
"&7" + AltChar.listSquare + " " + effect.getDefaultName() + " Attacks");
} }
attackEffects.save(); attackEffects.save();
/* /*
* only load config files after they have been initialized (above) so * only load config files after they have been initialized (above) so they do
* they do not crash the first time they generate and so we do not have * not crash the first time they generate and so we do not have to restart the
* to restart the server * server
*/ */
reload(); reload();
} }
@ -185,16 +193,20 @@ public class ConfigManager {
namePlaceholders = new ConfigFile("name-placeholders"); namePlaceholders = new ConfigFile("name-placeholders");
/* /*
* reload cached config options for quicker access - these options are * reload cached config options for quicker access - these options are used in
* used in runnables, it is thus better to cache them * runnables, it is thus better to cache them
*/ */
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops"); replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen"); worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
abilityPlayerDamage = MMOItems.plugin.getConfig().getBoolean("ability-player-damage"); abilityPlayerDamage = MMOItems.plugin.getConfig().getBoolean("ability-player-damage");
healIndicatorFormat = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getConfig().getString("game-indicators.heal.format")); healIndicatorFormat = new ColorParse('&', MMOItems.plugin.getConfig().getString("game-indicators.heal.format"))
damageIndicatorFormat = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getConfig().getString("game-indicators.damage.format")); .toChatColor();
healIndicatorDecimalFormat = new DecimalFormat(MMOItems.plugin.getConfig().getString("game-indicators.heal.decimal-format")); damageIndicatorFormat = new ColorParse('&',
damageIndicatorDecimalFormat = new DecimalFormat(MMOItems.plugin.getConfig().getString("game-indicators.damage.decimal-format")); MMOItems.plugin.getConfig().getString("game-indicators.damage.format")).toChatColor();
healIndicatorDecimalFormat = new DecimalFormat(
MMOItems.plugin.getConfig().getString("game-indicators.heal.decimal-format"));
damageIndicatorDecimalFormat = new DecimalFormat(
MMOItems.plugin.getConfig().getString("game-indicators.damage.decimal-format"));
abilitySplitter = getStatFormat("ability-splitter"); abilitySplitter = getStatFormat("ability-splitter");
dodgeKnockbackForce = MMOItems.plugin.getConfig().getDouble("mitigation.dodge.knockback.force"); dodgeKnockbackForce = MMOItems.plugin.getConfig().getDouble("mitigation.dodge.knockback.force");
dodgeKnockbackEnabled = MMOItems.plugin.getConfig().getBoolean("mitigation.dodge.knockback.enabled"); dodgeKnockbackEnabled = MMOItems.plugin.getConfig().getBoolean("mitigation.dodge.knockback.enabled");
@ -212,7 +224,7 @@ public class ConfigManager {
public String getMessage(String path) { public String getMessage(String path) {
String found = messages.getConfig().getString(path); String found = messages.getConfig().getString(path);
return ChatColor.translateAlternateColorCodes('&', found == null ? "<MessageNotFound:" + path + ">" : found); return new ColorParse('&', found == null ? "<MessageNotFound:" + path + ">" : found).toChatColor();
} }
public String getAbilityName(Ability ability) { public String getAbilityName(Ability ability) {
@ -244,27 +256,27 @@ public class ConfigManager {
} }
public String getLuteAttackEffectName(LuteAttackEffect effect) { public String getLuteAttackEffectName(LuteAttackEffect effect) {
return ChatColor.translateAlternateColorCodes('&', return new ColorParse('&',
attackEffects.getConfig().getString("lute-attack." + effect.name().toLowerCase().replace("_", "-"))); attackEffects.getConfig().getString("lute-attack." + effect.name().toLowerCase().replace("_", "-")))
.toChatColor();
} }
public String getStaffSpiritName(StaffSpirit spirit) { public String getStaffSpiritName(StaffSpirit spirit) {
return ChatColor.translateAlternateColorCodes('&', return new ColorParse('&',
attackEffects.getConfig().getString("staff-spirit." + spirit.name().toLowerCase().replace("_", "-"))); attackEffects.getConfig().getString("staff-spirit." + spirit.name().toLowerCase().replace("_", "-")))
.toChatColor();
} }
/* /*
* all config files that have a default configuration are stored here, they * all config files that have a default configuration are stored here, they get
* get copied into the plugin folder when the plugin enables * copied into the plugin folder when the plugin enables
*/ */
public enum DefaultFile { public enum DefaultFile {
// default general config files -> /MMOItems // default general config files -> /MMOItems
ITEM_TIERS("item-tiers.yml", "", "item-tiers.yml"), ITEM_TIERS("item-tiers.yml", "", "item-tiers.yml"), ITEM_TYPES("item-types.yml", "", "item-types.yml", true),
ITEM_TYPES("item-types.yml", "", "item-types.yml", true),
CUSTOM_BLOCKS("custom-blocks.yml", "", "custom-blocks.yml"), CUSTOM_BLOCKS("custom-blocks.yml", "", "custom-blocks.yml"),
GEN_TEMPLATES("gen-templates.yml", "", "gen-templates.yml"), GEN_TEMPLATES("gen-templates.yml", "", "gen-templates.yml"), DROPS("drops.yml", "", "drops.yml"),
DROPS("drops.yml", "", "drops.yml"),
ITEM_SETS("item-sets.yml", "", "item-sets.yml"), ITEM_SETS("item-sets.yml", "", "item-sets.yml"),
NAME_PLACEHOLDERS("name-placeholders.yml", "", "name-placeholders.yml"), NAME_PLACEHOLDERS("name-placeholders.yml", "", "name-placeholders.yml"),
UPGRADE_TEMPLATES("upgrade-templates.yml", "", "upgrade-templates.yml"), UPGRADE_TEMPLATES("upgrade-templates.yml", "", "upgrade-templates.yml"),
@ -273,41 +285,34 @@ public class ConfigManager {
// Not included in the jar anymore // Not included in the jar anymore
// default language files -> /MMOItems/language // default language files -> /MMOItems/language
LORE_FORMAT("lore-format.yml", "language", "lore-format.yml"), LORE_FORMAT("lore-format.yml", "language", "lore-format.yml"), STATS("stats.yml", "language", "stats.yml"),
STATS("stats.yml", "language", "stats.yml"),
// item generator // item generator
EXAMPLE_GEN_TEMPLATES("generator/templates/example-templates.yml", "generator/templates", "example-templates.yml"), EXAMPLE_GEN_TEMPLATES("generator/templates/example-templates.yml", "generator/templates",
EXAMPLE_GEN_MODIFIERS("generator/modifiers/example-modifiers.yml", "generator/modifiers", "example-modifiers.yml"), "example-templates.yml"),
EXAMPLE_GEN_MODIFIERS("generator/modifiers/example-modifiers.yml", "generator/modifiers",
"example-modifiers.yml"),
ITEM_GEN_CONFIG("generator/config.yml", "generator", "config.yml"), ITEM_GEN_CONFIG("generator/config.yml", "generator", "config.yml"),
// default item config files -> /MMOItems/item // default item config files -> /MMOItems/item
ARMOR("item/armor.yml", "item", "armor.yml"), ARMOR("item/armor.yml", "item", "armor.yml"), AXE("item/axe.yml", "item", "axe.yml"),
AXE("item/axe.yml", "item", "axe.yml"), BOW("item/bow.yml", "item", "bow.yml"), CATALYST("item/catalyst.yml", "item", "catalyst.yml"),
BOW("item/bow.yml", "item", "bow.yml"), CONSUMABLE("item/consumable.yml", "item", "consumable.yml"), DAGGER("item/dagger.yml", "item", "dagger.yml"),
CATALYST("item/catalyst.yml", "item", "catalyst.yml"),
CONSUMABLE("item/consumable.yml", "item", "consumable.yml"),
DAGGER("item/dagger.yml", "item", "dagger.yml"),
GEM_STONE("item/gem_stone.yml", "item", "gem_stone.yml"), GEM_STONE("item/gem_stone.yml", "item", "gem_stone.yml"),
GREATSTAFF("item/greatstaff.yml", "item", "greatstaff.yml"), GREATSTAFF("item/greatstaff.yml", "item", "greatstaff.yml"),
GREATSWORD("item/greatsword.yml", "item", "greatsword.yml"), GREATSWORD("item/greatsword.yml", "item", "greatsword.yml"), HALBERD("item/halberd.yml", "item", "halberd.yml"),
HALBERD("item/halberd.yml", "item", "halberd.yml"), HAMMER("item/hammer.yml", "item", "hammer.yml"), LANCE("item/lance.yml", "item", "lance.yml"),
HAMMER("item/hammer.yml", "item", "hammer.yml"),
LANCE("item/lance.yml", "item", "lance.yml"),
MATERIAL("item/material.yml", "item", "material.yml"), MATERIAL("item/material.yml", "item", "material.yml"),
MISCELLANEOUS("item/miscellaneous.yml", "item", "miscellaneous.yml"), MISCELLANEOUS("item/miscellaneous.yml", "item", "miscellaneous.yml"),
SHIELD("item/shield.yml", "item", "shield.yml"), SHIELD("item/shield.yml", "item", "shield.yml"), STAFF("item/staff.yml", "item", "staff.yml"),
STAFF("item/staff.yml", "item", "staff.yml"), SWORD("item/sword.yml", "item", "sword.yml"), TOME("item/tome.yml", "item", "tome.yml"),
SWORD("item/sword.yml", "item", "sword.yml"), TOOL("item/tool.yml", "item", "tool.yml"), WAND("item/wand.yml", "item", "wand.yml");
TOME("item/tome.yml", "item", "tome.yml"),
TOOL("item/tool.yml", "item", "tool.yml"),
WAND("item/wand.yml", "item", "wand.yml");
private final String folderPath, fileName, resourceName; private final String folderPath, fileName, resourceName;
/* /*
* allows to use the checkFile() method while not loading it * allows to use the checkFile() method while not loading it automatically e.g
* automatically e.g item-types.yml * item-types.yml
*/ */
private final boolean manual; private final boolean manual;
@ -327,7 +332,8 @@ public class ConfigManager {
} }
public File getFile() { public File getFile() {
return new File(MMOItems.plugin.getDataFolder() + (folderPath.equals("") ? "" : "/" + folderPath), fileName); return new File(MMOItems.plugin.getDataFolder() + (folderPath.equals("") ? "" : "/" + folderPath),
fileName);
} }
public void checkFile() { public void checkFile() {

View File

@ -5,7 +5,6 @@ import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -23,6 +22,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.recipe.MMORecipeChoice; import net.Indyuce.mmoitems.api.recipe.MMORecipeChoice;
import net.asangarin.hexcolors.ColorParse;
public class RecipeManagerDefault extends RecipeManager { public class RecipeManagerDefault extends RecipeManager {
@ -183,7 +183,7 @@ public class RecipeManagerDefault extends RecipeManager {
item.setAmount(amount); item.setAmount(amount);
if (!name.isEmpty()) { if (!name.isEmpty()) {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); meta.setDisplayName(new ColorParse('&', name).toChatColor());
item.setItemMeta(meta); item.setItemMeta(meta);
} }
recipe.setIngredient(character, new RecipeChoice.ExactChoice(item)); recipe.setIngredient(character, new RecipeChoice.ExactChoice(item));

View File

@ -25,6 +25,7 @@ import net.Indyuce.mmoitems.stat.data.ArrowParticlesData;
import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.ParticleData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar; import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial; import net.mmogroup.mmolib.version.VersionMaterial;
@ -113,7 +114,7 @@ public class ArrowParticles extends ItemStat {
inv.registerItemEdition(config); inv.registerItemEdition(config);
inv.open(); inv.open();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Particle color successfully set to " inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Particle color successfully set to "
+ ChatColor.translateAlternateColorCodes('&', "&c&l" + red + "&7 - &a&l" + green + "&7 - &9&l" + blue)); + new ColorParse('&', "&c&l" + red + "&7 - &a&l" + green + "&7 - &9&l" + blue).toChatColor());
return true; return true;
} }
@ -186,8 +187,8 @@ public class ArrowParticles extends ItemStat {
lore.add(""); lore.add("");
if (ParticleData.isColorable(data.getParticle())) if (ParticleData.isColorable(data.getParticle()))
lore.add(ChatColor.translateAlternateColorCodes('&', lore.add(new ColorParse('&',
"&7* Color: &c&l" + data.getRed() + "&7 - &a&l" + data.getGreen() + "&7 - &9&l" + data.getBlue())); "&7* Color: &c&l" + data.getRed() + "&7 - &a&l" + data.getGreen() + "&7 - &9&l" + data.getBlue()).toChatColor());
else else
lore.add(ChatColor.GRAY + "* Speed: " + ChatColor.WHITE + data.getSpeed()); lore.add(ChatColor.GRAY + "* Speed: " + ChatColor.WHITE + data.getSpeed());
} }

View File

@ -23,6 +23,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.StringListData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar; import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial; import net.mmogroup.mmolib.version.VersionMaterial;
@ -62,7 +63,7 @@ public class CompatibleTypes extends ItemStat {
config.getConfig().set(inv.getEdited().getId() + ".compatible-types", lore); config.getConfig().set(inv.getEdited().getId() + ".compatible-types", lore);
inv.registerItemEdition(config); inv.registerItemEdition(config);
inv.open(); inv.open();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + ChatColor.translateAlternateColorCodes('&', last) inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + new ColorParse('&', last).toChatColor()
+ ChatColor.GRAY + "'."); + ChatColor.GRAY + "'.");
} }
} }
@ -88,7 +89,7 @@ public class CompatibleTypes extends ItemStat {
if (mmoitem.hasData(this)) { if (mmoitem.hasData(this)) {
lore.add(ChatColor.GRAY + "Current Value:"); lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) mmoitem.getData(this); StringListData data = (StringListData) mmoitem.getData(this);
data.getList().forEach(str -> lore.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', str))); data.getList().forEach(str -> lore.add(ChatColor.GRAY + new ColorParse('&', str).toChatColor()));
} else } else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "Compatible with any item."); lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "Compatible with any item.");
@ -103,7 +104,7 @@ public class CompatibleTypes extends ItemStat {
List<String> compatibleTypes = new ArrayList<>(); List<String> compatibleTypes = new ArrayList<>();
JsonArray array = new JsonArray(); JsonArray array = new JsonArray();
((StringListData) data).getList().forEach(line -> { ((StringListData) data).getList().forEach(line -> {
line = ChatColor.translateAlternateColorCodes('&', line); line = new ColorParse('&', line).toChatColor();
array.add(line); array.add(line);
compatibleTypes.add(line); compatibleTypes.add(line);
}); });

View File

@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.stat.data.StringData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.StringStat; import net.Indyuce.mmoitems.stat.type.StringStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.version.VersionMaterial; import net.mmogroup.mmolib.version.VersionMaterial;
public class DisplayName extends StringStat { public class DisplayName extends StringStat {
@ -20,7 +21,7 @@ public class DisplayName extends StringStat {
@Override @Override
public void whenApplied(MMOItemBuilder item, StatData data) { public void whenApplied(MMOItemBuilder item, StatData data) {
item.getMeta().setDisplayName(fix(ChatColor.translateAlternateColorCodes('&', getDisplayName(data)))); item.getMeta().setDisplayName(fix(new ColorParse('&', getDisplayName(data)).toChatColor()));
} }
@Override @Override

View File

@ -27,6 +27,7 @@ import net.Indyuce.mmoitems.stat.data.GemSocketsData;
import net.Indyuce.mmoitems.stat.data.GemstoneData; import net.Indyuce.mmoitems.stat.data.GemstoneData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar; import net.mmogroup.mmolib.api.util.AltChar;
@ -101,7 +102,7 @@ public class GemSockets extends ItemStat {
config.getConfig().set(inv.getEdited().getId() + "." + getPath(), lore); config.getConfig().set(inv.getEdited().getId() + "." + getPath(), lore);
inv.registerItemEdition(config); inv.registerItemEdition(config);
inv.open(); inv.open();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + ChatColor.translateAlternateColorCodes('&', last) inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + new ColorParse('&', last).toChatColor()
+ ChatColor.GRAY + "'."); + ChatColor.GRAY + "'.");
} }
} }

View File

@ -24,6 +24,7 @@ import net.Indyuce.mmoitems.stat.data.StringListData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.ProperStat; import net.Indyuce.mmoitems.stat.type.ProperStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar; import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial; import net.mmogroup.mmolib.version.VersionMaterial;
@ -62,7 +63,7 @@ public class Lore extends ItemStat implements ProperStat {
config.getConfig().set(inv.getEdited().getId() + ".lore", lore); config.getConfig().set(inv.getEdited().getId() + ".lore", lore);
inv.registerItemEdition(config); inv.registerItemEdition(config);
inv.open(); inv.open();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + ChatColor.translateAlternateColorCodes('&', last) inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + new ColorParse('&', last).toChatColor()
+ ChatColor.GRAY + "'."); + ChatColor.GRAY + "'.");
} }
} }
@ -88,7 +89,7 @@ public class Lore extends ItemStat implements ProperStat {
if (mmoitem.hasData(this)) { if (mmoitem.hasData(this)) {
lore.add(ChatColor.GRAY + "Current Value:"); lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) mmoitem.getData(this); StringListData data = (StringListData) mmoitem.getData(this);
data.getList().forEach(el -> lore.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', el))); data.getList().forEach(el -> lore.add(ChatColor.GRAY + new ColorParse('&', el).toChatColor()));
} else } else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None"); lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
@ -103,7 +104,7 @@ public class Lore extends ItemStat implements ProperStat {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
JsonArray array = new JsonArray(); JsonArray array = new JsonArray();
((StringListData) data).getList().forEach(line -> { ((StringListData) data).getList().forEach(line -> {
line = ChatColor.translateAlternateColorCodes('&', line); line = new ColorParse('&', line).toChatColor();
array.add(line); array.add(line);
lore.add(line); lore.add(line);
}); });

View File

@ -24,6 +24,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.StringListData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar; import net.mmogroup.mmolib.api.util.AltChar;
@ -62,7 +63,7 @@ public class NBTTags extends ItemStat {
config.getConfig().set(inv.getEdited().getId() + ".custom-nbt", nbtTags); config.getConfig().set(inv.getEdited().getId() + ".custom-nbt", nbtTags);
inv.registerItemEdition(config); inv.registerItemEdition(config);
inv.open(); inv.open();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + ChatColor.translateAlternateColorCodes('&', last) inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + new ColorParse('&', last).toChatColor()
+ ChatColor.GRAY + "'."); + ChatColor.GRAY + "'.");
} }
} }
@ -93,7 +94,7 @@ public class NBTTags extends ItemStat {
if (mmoitem.hasData(this)) { if (mmoitem.hasData(this)) {
lore.add(ChatColor.GRAY + "Current Value:"); lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) mmoitem.getData(this); StringListData data = (StringListData) mmoitem.getData(this);
data.getList().forEach(str -> lore.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', str))); data.getList().forEach(str -> lore.add(ChatColor.GRAY + new ColorParse('&', str).toChatColor()));
} else } else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None"); lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");

View File

@ -1,6 +1,5 @@
package net.Indyuce.mmoitems.stat.data; package net.Indyuce.mmoitems.stat.data;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@ -12,6 +11,7 @@ import net.Indyuce.mmoitems.api.itemgen.GeneratedItemBuilder;
import net.Indyuce.mmoitems.api.itemgen.RandomStatData; import net.Indyuce.mmoitems.api.itemgen.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.asangarin.hexcolors.ColorParse;
public class UpgradeData implements StatData, RandomStatData { public class UpgradeData implements StatData, RandomStatData {
private final String reference, template; private final String reference, template;
@ -73,7 +73,7 @@ public class UpgradeData implements StatData, RandomStatData {
public void upgrade(MMOItem mmoitem) { public void upgrade(MMOItem mmoitem) {
// change display name // change display name
String suffix = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getConfig().getString("item-upgrading.name-suffix")); String suffix = new ColorParse('&', MMOItems.plugin.getConfig().getString("item-upgrading.name-suffix")).toChatColor();
if (MMOItems.plugin.getConfig().getBoolean("item-upgrading.display-in-name")) if (MMOItems.plugin.getConfig().getBoolean("item-upgrading.display-in-name"))
if (mmoitem.hasData(ItemStat.NAME)) { if (mmoitem.hasData(ItemStat.NAME)) {
StringData nameData = (StringData) mmoitem.getData(ItemStat.NAME); StringData nameData = (StringData) mmoitem.getData(ItemStat.NAME);

View File

@ -18,6 +18,7 @@ import net.Indyuce.mmoitems.api.itemgen.RandomStatData;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.data.StringData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.asangarin.hexcolors.ColorParse;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar; import net.mmogroup.mmolib.api.util.AltChar;
@ -70,7 +71,7 @@ public class StringStat extends ItemStat {
public void whenDisplayed(List<String> lore, MMOItem mmoitem) { public void whenDisplayed(List<String> lore, MMOItem mmoitem) {
if (mmoitem.hasData(this)) { if (mmoitem.hasData(this)) {
String value = ChatColor.translateAlternateColorCodes('&', mmoitem.getData(this).toString()); String value = new ColorParse('&', mmoitem.getData(this).toString()).toChatColor();
value = value.length() > 40 ? value.substring(0, 40) + "..." : value; value = value.length() > 40 ? value.substring(0, 40) + "..." : value;
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN + value); lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN + value);