mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
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:
parent
80b7652f12
commit
5dc5677030
BIN
lib/MMOLib.jar
BIN
lib/MMOLib.jar
Binary file not shown.
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOItems</artifactId>
|
||||
<version>5.5</version>
|
||||
<version>5.5.1</version>
|
||||
<name>MMOItems</name>
|
||||
<description>A great item solution for your RPG server.</description>
|
||||
|
||||
|
@ -9,7 +9,6 @@ import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
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.ParticleData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class ItemSet {
|
||||
private final Map<Integer, SetBonuses> bonuses = new HashMap<>();
|
||||
@ -30,7 +30,7 @@ public class ItemSet {
|
||||
public ItemSet(ConfigurationSection config) {
|
||||
this.id = config.getName().toUpperCase().replace("-", "_");
|
||||
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");
|
||||
|
||||
|
@ -5,12 +5,12 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.api.droptable.DropTable;
|
||||
import net.Indyuce.mmoitems.comp.itemglow.TierColor;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class ItemTier {
|
||||
private final String name, id;
|
||||
@ -29,7 +29,7 @@ public class ItemTier {
|
||||
|
||||
public ItemTier(ConfigurationSection config) {
|
||||
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;
|
||||
unidentificationInfo = new UnidentificationInfo(config.getConfigurationSection("unidentification"));
|
||||
|
||||
@ -109,6 +109,6 @@ public class ItemTier {
|
||||
}
|
||||
|
||||
private String color(String str) {
|
||||
return ChatColor.translateAlternateColorCodes('&', str);
|
||||
return new ColorParse('&', str).toChatColor();
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.util.MushroomState;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
|
||||
@ -32,10 +33,10 @@ public class CustomBlock {
|
||||
|
||||
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"))
|
||||
for (String s : config.getStringList("lore"))
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
lore.add(new ColorParse('&', s).toChatColor());
|
||||
minExp = config.getInt("min-xp", 0);
|
||||
maxExp = config.getInt("max-xp", 0);
|
||||
requiredPower = config.getInt("required-power", 0);
|
||||
|
@ -8,7 +8,6 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
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.UpgradingRecipe;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class CraftingStation {
|
||||
private final String id, name;
|
||||
@ -28,7 +28,7 @@ public class CraftingStation {
|
||||
|
||||
public CraftingStation(String id, FileConfiguration config) {
|
||||
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))
|
||||
try {
|
||||
@ -46,7 +46,7 @@ public class CraftingStation {
|
||||
Validate.notNull(name, "Crafting station name must not be null");
|
||||
|
||||
this.id = id.toLowerCase().replace("_", "-").replace(" ", "-");
|
||||
this.name = ChatColor.translateAlternateColorCodes('&', name);
|
||||
this.name = new ColorParse('&', name).toChatColor();
|
||||
this.itemOptions = itemOptions;
|
||||
this.maxQueueSize = maxQueueSize;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package net.Indyuce.mmoitems.api.crafting.ingredient;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
|
||||
public class VanillaIngredient extends Ingredient {
|
||||
@ -23,7 +23,7 @@ public class VanillaIngredient extends Ingredient {
|
||||
config.validate("type");
|
||||
|
||||
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("_", " "));
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.api.edition.process.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.process.ChatEdition;
|
||||
import net.Indyuce.mmoitems.gui.PluginInventory;
|
||||
import net.Indyuce.mmoitems.gui.edition.BlockEdition.ConfigOptions;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class BlockChatEdition implements Edition {
|
||||
@ -35,7 +36,7 @@ public class BlockChatEdition implements Edition {
|
||||
|
||||
inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
|
||||
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.");
|
||||
|
||||
/*
|
||||
|
@ -27,7 +27,7 @@ public class NewItemEdition implements Edition {
|
||||
inv.getPlayer().closeInventory();
|
||||
|
||||
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.");
|
||||
|
||||
/*
|
||||
|
@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.api.edition.process.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.process.ChatEdition;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class StatEdition implements Edition {
|
||||
@ -39,7 +40,7 @@ public class StatEdition implements Edition {
|
||||
|
||||
inv.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
|
||||
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.");
|
||||
|
||||
/*
|
||||
|
@ -25,6 +25,7 @@ import net.Indyuce.mmoitems.stat.data.PotionEffectListData;
|
||||
import net.Indyuce.mmoitems.stat.data.SoulboundData;
|
||||
import net.Indyuce.mmoitems.stat.data.UpgradeData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
@ -288,7 +289,7 @@ public class Consumable extends UseItem {
|
||||
int maxConsume = (int) nbtItem.getStat("MAX_CONSUME");
|
||||
if (maxConsume > 1) {
|
||||
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));
|
||||
|
||||
maxConsume -= 1;
|
||||
|
@ -2,11 +2,10 @@ package net.Indyuce.mmoitems.api.item.build;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class MMOItemLore {
|
||||
private final List<String> lore = MMOItems.plugin.getLanguage().getDefaultLoreFormat();
|
||||
@ -60,7 +59,7 @@ public class MMOItemLore {
|
||||
* successfully calculated
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -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.QueueItemDisplay;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.crafting.UpgradingRecipeDisplay;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class ConfigItem {
|
||||
@ -94,12 +95,12 @@ public class ConfigItem {
|
||||
return;
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getName()));
|
||||
meta.setDisplayName(new ColorParse('&', getName()).toChatColor());
|
||||
meta.addItemFlags(ItemFlag.values());
|
||||
|
||||
if (hasLore()) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class CustomSkull extends ConfigItem {
|
||||
@ -32,7 +33,7 @@ public class CustomSkull extends ConfigItem {
|
||||
public void updateItem() {
|
||||
setItem(VersionMaterial.PLAYER_HEAD.toItem());
|
||||
ItemMeta meta = getItem().getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getName()));
|
||||
meta.setDisplayName(new ColorParse('&', getName()).toChatColor());
|
||||
meta.addItemFlags(ItemFlag.values());
|
||||
|
||||
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null);
|
||||
@ -47,7 +48,7 @@ public class CustomSkull extends ConfigItem {
|
||||
|
||||
if (hasLore()) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
package net.Indyuce.mmoitems.api.item.plugin;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class NamedItemStack extends ItemStack {
|
||||
public NamedItemStack(Material material, String name) {
|
||||
super(material);
|
||||
|
||||
ItemMeta meta = getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
meta.setDisplayName(new ColorParse('&', name).toChatColor());
|
||||
setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
|
@ -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.item.plugin.ConfigItem;
|
||||
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.NBTItem;
|
||||
|
||||
@ -108,7 +109,7 @@ public class CraftingRecipeDisplay extends ConfigItem {
|
||||
* apply color to lore
|
||||
*/
|
||||
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();
|
||||
int amount = craftingRecipe.getOutput().getAmount();
|
||||
@ -120,7 +121,7 @@ public class CraftingRecipeDisplay extends ConfigItem {
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
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);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
|
@ -6,7 +6,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
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.recipe.CraftingRecipe;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
|
||||
@ -77,13 +77,13 @@ public class QueueItemDisplay extends ConfigItem {
|
||||
* apply color to lore
|
||||
*/
|
||||
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();
|
||||
item.setAmount(position);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
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);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
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.UpgradingRecipe;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
|
||||
@ -85,12 +85,12 @@ public class UpgradingRecipeDisplay extends ConfigItem {
|
||||
* apply color to lore
|
||||
*/
|
||||
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();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
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);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
|
@ -8,7 +8,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
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.api.ItemTier;
|
||||
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.VolatileMMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
@ -96,7 +96,7 @@ public class UnidentifiedItem extends ConfigItem {
|
||||
String str = lore.get(n);
|
||||
for (String placeholder : placeholders.keySet())
|
||||
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();
|
||||
meta.addItemFlags(ItemFlag.values());
|
||||
meta.setUnbreakable(true);
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
meta.setDisplayName(new ColorParse('&', name).toChatColor());
|
||||
meta.setLore(lore);
|
||||
unidentified.setItemMeta(meta);
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.Indyuce.mmoitems.api.itemgen;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class NameModifier {
|
||||
private final ModifierType type;
|
||||
@ -24,7 +24,7 @@ public class NameModifier {
|
||||
if (object instanceof ConfigurationSection) {
|
||||
ConfigurationSection config = (ConfigurationSection) object;
|
||||
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");
|
||||
return;
|
||||
}
|
||||
@ -35,7 +35,7 @@ public class NameModifier {
|
||||
public NameModifier(ModifierType type, String format, int priority) {
|
||||
Validate.notNull(format, "Format cannot be null");
|
||||
this.type = type;
|
||||
this.format = ChatColor.translateAlternateColorCodes('&', format);
|
||||
this.format = new ColorParse('&', format).toChatColor();
|
||||
this.priority = priority;
|
||||
|
||||
Validate.notNull(type, "Type cannot be null");
|
||||
|
@ -54,6 +54,7 @@ import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
|
||||
import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
@ -222,7 +223,7 @@ public class MMOItemsCommand implements CommandExecutor {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "Description:");
|
||||
for (String line : update.getDescription())
|
||||
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.translateAlternateColorCodes('&', line));
|
||||
sender.sendMessage(ChatColor.GRAY + "- " + new ColorParse('&', line).toChatColor());
|
||||
}
|
||||
|
||||
sender.sendMessage("");
|
||||
@ -599,7 +600,7 @@ public class MMOItemsCommand implements CommandExecutor {
|
||||
sender.sendMessage(
|
||||
"* " + ChatColor.GREEN + s
|
||||
+ (config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + ChatColor.translateAlternateColorCodes('&', config.getString(s + ".name"))
|
||||
? " " + ChatColor.WHITE + "(" + new ColorParse('&', config.getString(s + ".name")).toChatColor()
|
||||
+ ChatColor.WHITE + ")"
|
||||
: ""));
|
||||
}
|
||||
@ -628,18 +629,18 @@ public class MMOItemsCommand implements CommandExecutor {
|
||||
sender.sendMessage(
|
||||
"* " + ChatColor.GREEN + s
|
||||
+ (config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + ChatColor.translateAlternateColorCodes('&', config.getString(s + ".name"))
|
||||
? " " + ChatColor.WHITE + "(" + new ColorParse('&', config.getString(s + ".name")).toChatColor()
|
||||
+ ChatColor.WHITE + ")"
|
||||
: ""));
|
||||
return true;
|
||||
}
|
||||
for (String s : config.getKeys(false)) {
|
||||
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,
|
||||
"{\"text\":\"* " + ChatColor.GREEN + s + nameFormat + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/mi 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\"}}}");
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.api.util.AltChar;
|
||||
|
||||
public class PluginHelp {
|
||||
private static final int commandsPerPage = 8;
|
||||
@ -102,7 +103,7 @@ public class PluginHelp {
|
||||
|
||||
private PluginCommand(String usage, String help) {
|
||||
this.usage = usage;
|
||||
this.help = help == null ? null : ChatColor.translateAlternateColorCodes('&', help);
|
||||
this.help = help == null ? null : new ColorParse('&', help).toChatColor();
|
||||
}
|
||||
|
||||
private boolean isCommand() {
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
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.UpgradingRecipe;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class CraftingStationPreview extends PluginInventory {
|
||||
private final CraftingStationView previous;
|
||||
@ -78,7 +78,7 @@ public class CraftingStationPreview extends PluginInventory {
|
||||
if (recipe.getRecipe() instanceof UpgradingRecipe) {
|
||||
ItemStack stack = ((UpgradingRecipe) recipe.getRecipe()).getItem().getPreview();
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(meta.getDisplayName() + ChatColor.translateAlternateColorCodes('&', " &a+1!"));
|
||||
meta.setDisplayName(meta.getDisplayName() + new ColorParse('&', " &a+1!").toChatColor());
|
||||
stack.setItemMeta(meta);
|
||||
inv.setItem(16, stack);
|
||||
}
|
||||
|
@ -22,9 +22,10 @@ import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.block.CustomBlock;
|
||||
import net.Indyuce.mmoitems.api.edition.BlockChatEdition;
|
||||
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.PluginInventory;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
|
||||
public class BlockEdition extends PluginInventory {
|
||||
private final ConfigFile config = new ConfigFile("custom-blocks");
|
||||
@ -60,9 +61,17 @@ public class BlockEdition extends PluginInventory {
|
||||
if (loreList.isEmpty())
|
||||
eventLore.add(ChatColor.RED + "No lore.");
|
||||
for (String lore : loreList)
|
||||
eventLore.add(ChatColor.GREEN + ChatColor.translateAlternateColorCodes('&', lore));
|
||||
eventLore.add(ChatColor.GREEN + new ColorParse('&', lore).toChatColor());
|
||||
} 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(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
|
||||
@ -103,14 +112,15 @@ public class BlockEdition extends PluginInventory {
|
||||
MMOItems.plugin.getCustomBlocks().reload();
|
||||
|
||||
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 {
|
||||
DISPLAY_NAME("display-name", Material.WRITABLE_BOOK, 11, "string"),
|
||||
LORE("lore", Material.MAP, 13, "line"),
|
||||
DISPLAY_NAME("display-name", Material.WRITABLE_BOOK, 11, "string"), LORE("lore", Material.MAP, 13, "line"),
|
||||
REQUIRED_PICKAXE_POWER("required-power", Material.IRON_PICKAXE, 15, "int"),
|
||||
MIN_XP("min-xp", Material.EXPERIENCE_BOTTLE, 21, "int"),
|
||||
MAX_XP("max-xp", Material.EXPERIENCE_BOTTLE, 23, "int"),
|
||||
@ -161,22 +171,27 @@ public class BlockEdition extends PluginInventory {
|
||||
try {
|
||||
value = Integer.parseInt(message);
|
||||
} 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;
|
||||
}
|
||||
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;
|
||||
case "line":
|
||||
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);
|
||||
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;
|
||||
default:
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.item.MMOItem;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
@ -59,7 +60,7 @@ public class ItemEdition extends EditionInventory {
|
||||
meta.setDisplayName(ChatColor.GREEN + stat.getName());
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String s1 : stat.getLore())
|
||||
lore.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', s1));
|
||||
lore.add(ChatColor.GRAY + new ColorParse('&', s1).toChatColor());
|
||||
lore.add("");
|
||||
|
||||
stat.whenDisplayed(lore, mmoitem);
|
||||
|
@ -24,6 +24,7 @@ import net.Indyuce.mmoitems.api.item.MMOItem;
|
||||
import net.Indyuce.mmoitems.particle.api.ParticleType;
|
||||
import net.Indyuce.mmoitems.stat.data.ParticleData;
|
||||
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.NBTItem;
|
||||
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 + "when displayed or what shape they form.");
|
||||
particleTypeItemLore.add("");
|
||||
particleTypeItemLore.add(ChatColor.GRAY + "Current Value: "
|
||||
+ (particleType == null ? ChatColor.RED + "No type selected." : ChatColor.GOLD + particleType.getDefaultName()));
|
||||
particleTypeItemLore
|
||||
.add(ChatColor.GRAY + "Current Value: " + (particleType == null ? ChatColor.RED + "No type selected."
|
||||
: ChatColor.GOLD + particleType.getDefaultName()));
|
||||
if (particleType != null) {
|
||||
particleTypeItemLore
|
||||
.add("" + ChatColor.GRAY + ChatColor.ITALIC + ChatColor.translateAlternateColorCodes('&', particleType.getDescription()));
|
||||
.add("" + ChatColor.GRAY + ChatColor.ITALIC + new ColorParse('&', particleType.getDescription()).toChatColor());
|
||||
}
|
||||
particleTypeItemLore.add("");
|
||||
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 + "in the particle effect.");
|
||||
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("_", " "))));
|
||||
particleItemLore.add("");
|
||||
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()) {
|
||||
ItemStack modifierItem = VersionMaterial.GRAY_DYE.toItem();
|
||||
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>();
|
||||
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 + "customize the particle pattern.");
|
||||
modifierItemLore.add("");
|
||||
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);
|
||||
modifierItem.setItemMeta(modifierItemMeta);
|
||||
|
||||
@ -123,8 +128,8 @@ public class ParticlesEdition extends EditionInventory {
|
||||
colorItemLore.add(ChatColor.GRAY + "The RGB color of your particle.");
|
||||
colorItemLore.add("");
|
||||
colorItemLore.add(ChatColor.GRAY + "Current Value (R-G-B):");
|
||||
colorItemLore.add("" + ChatColor.RED + ChatColor.BOLD + red + ChatColor.GRAY + " - " + ChatColor.GREEN + ChatColor.BOLD + green
|
||||
+ ChatColor.GRAY + " - " + ChatColor.BLUE + ChatColor.BOLD + blue);
|
||||
colorItemLore.add("" + ChatColor.RED + ChatColor.BOLD + red + ChatColor.GRAY + " - " + ChatColor.GREEN
|
||||
+ ChatColor.BOLD + green + ChatColor.GRAY + " - " + ChatColor.BLUE + ChatColor.BOLD + blue);
|
||||
colorItemLore.add("");
|
||||
colorItemLore.add(ChatColor.YELLOW + AltChar.listDash + " 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 (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) {
|
||||
ConfigFile config = mmoitem.getType().getConfigFile();
|
||||
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);
|
||||
registerItemEdition(config);
|
||||
open();
|
||||
@ -175,13 +182,13 @@ public class ParticlesEdition extends EditionInventory {
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle Color")) {
|
||||
if (event.getAction() == InventoryAction.PICKUP_ALL)
|
||||
new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle-color").enable("Write in the chat the RGB color you want.",
|
||||
ChatColor.AQUA + "Format: [RED] [GREEN] [BLUE]");
|
||||
new StatEdition(this, ItemStat.ITEM_PARTICLES, "particle-color").enable(
|
||||
"Write in the chat the RGB color you want.", ChatColor.AQUA + "Format: [RED] [GREEN] [BLUE]");
|
||||
|
||||
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
||||
ConfigFile config = mmoitem.getType().getConfigFile();
|
||||
if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles")
|
||||
&& config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("color")) {
|
||||
if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles") && config
|
||||
.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("color")) {
|
||||
config.getConfig().set(mmoitem.getId() + ".item-particles.color", null);
|
||||
registerItemEdition(config);
|
||||
open();
|
||||
@ -192,7 +199,8 @@ public class ParticlesEdition extends EditionInventory {
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Particle Pattern")) {
|
||||
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("" + ChatColor.GREEN + ChatColor.BOLD + "Available Particles Patterns");
|
||||
for (ParticleType type : ParticleType.values())
|
||||
@ -201,12 +209,13 @@ public class ParticlesEdition extends EditionInventory {
|
||||
|
||||
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
||||
ConfigFile config = mmoitem.getType().getConfigFile();
|
||||
if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles")
|
||||
&& config.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("type")) {
|
||||
if (config.getConfig().getConfigurationSection(mmoitem.getId()).contains("item-particles") && config
|
||||
.getConfig().getConfigurationSection(mmoitem.getId() + ".item-particles").contains("type")) {
|
||||
config.getConfig().set(mmoitem.getId() + ".item-particles.type", null);
|
||||
|
||||
// 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"))
|
||||
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);
|
||||
registerItemEdition(config);
|
||||
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 + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
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.CastingMode;
|
||||
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.stat.LuteAttackEffectStat.LuteAttackEffect;
|
||||
import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
@ -32,14 +32,16 @@ public class ConfigManager {
|
||||
private ConfigFile abilities, items, loreFormat, messages, potionEffects, stats, attackEffects, namePlaceholders;
|
||||
|
||||
// cached config options
|
||||
public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck;
|
||||
public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled,
|
||||
upgradeRequirementsCheck;
|
||||
public String healIndicatorFormat, damageIndicatorFormat, abilitySplitter;
|
||||
public DecimalFormat healIndicatorDecimalFormat, damageIndicatorDecimalFormat;
|
||||
|
||||
public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage;
|
||||
|
||||
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" };
|
||||
|
||||
// try to setup non existing languages
|
||||
@ -69,9 +71,11 @@ public class ConfigManager {
|
||||
JarFile jarFile = new JarFile(MMOItems.plugin.getJarFile());
|
||||
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
|
||||
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),
|
||||
new File(MMOItems.plugin.getDataFolder() + "/crafting-stations", name.split("\\/")[2]).toPath());
|
||||
new File(MMOItems.plugin.getDataFolder() + "/crafting-stations", name.split("\\/")[2])
|
||||
.toPath());
|
||||
}
|
||||
jarFile.close();
|
||||
} catch (IOException exception) {
|
||||
@ -88,7 +92,8 @@ public class ConfigManager {
|
||||
if (!new File(MMOItems.plugin.getDataFolder() + "/language/" + language, fileName + ".yml").exists()) {
|
||||
try {
|
||||
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);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -102,8 +107,8 @@ public class ConfigManager {
|
||||
file.checkFile();
|
||||
|
||||
/*
|
||||
* setup /item files after generating the default /item files otherwise
|
||||
* they will be empty!
|
||||
* setup /item files after generating the default /item files otherwise they
|
||||
* will be empty!
|
||||
*/
|
||||
MMOItems.plugin.getTypes().getAll().forEach(type -> type.getConfigFile().setup());
|
||||
|
||||
@ -147,7 +152,8 @@ public class ConfigManager {
|
||||
|
||||
String path = effect.getName().toLowerCase().replace("_", "-");
|
||||
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();
|
||||
|
||||
@ -155,19 +161,21 @@ public class ConfigManager {
|
||||
for (StaffSpirit spirit : StaffSpirit.values()) {
|
||||
String path = spirit.name().toLowerCase().replace("_", "-");
|
||||
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()) {
|
||||
String path = effect.name().toLowerCase().replace("_", "-");
|
||||
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();
|
||||
|
||||
/*
|
||||
* only load config files after they have been initialized (above) so
|
||||
* they do not crash the first time they generate and so we do not have
|
||||
* to restart the server
|
||||
* only load config files after they have been initialized (above) so they do
|
||||
* not crash the first time they generate and so we do not have to restart the
|
||||
* server
|
||||
*/
|
||||
reload();
|
||||
}
|
||||
@ -185,16 +193,20 @@ public class ConfigManager {
|
||||
namePlaceholders = new ConfigFile("name-placeholders");
|
||||
|
||||
/*
|
||||
* reload cached config options for quicker access - these options are
|
||||
* used in runnables, it is thus better to cache them
|
||||
* reload cached config options for quicker access - these options are used in
|
||||
* runnables, it is thus better to cache them
|
||||
*/
|
||||
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
|
||||
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
|
||||
abilityPlayerDamage = MMOItems.plugin.getConfig().getBoolean("ability-player-damage");
|
||||
healIndicatorFormat = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getConfig().getString("game-indicators.heal.format"));
|
||||
damageIndicatorFormat = ChatColor.translateAlternateColorCodes('&', MMOItems.plugin.getConfig().getString("game-indicators.damage.format"));
|
||||
healIndicatorDecimalFormat = new DecimalFormat(MMOItems.plugin.getConfig().getString("game-indicators.heal.decimal-format"));
|
||||
damageIndicatorDecimalFormat = new DecimalFormat(MMOItems.plugin.getConfig().getString("game-indicators.damage.decimal-format"));
|
||||
healIndicatorFormat = new ColorParse('&', MMOItems.plugin.getConfig().getString("game-indicators.heal.format"))
|
||||
.toChatColor();
|
||||
damageIndicatorFormat = new ColorParse('&',
|
||||
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");
|
||||
dodgeKnockbackForce = MMOItems.plugin.getConfig().getDouble("mitigation.dodge.knockback.force");
|
||||
dodgeKnockbackEnabled = MMOItems.plugin.getConfig().getBoolean("mitigation.dodge.knockback.enabled");
|
||||
@ -212,7 +224,7 @@ public class ConfigManager {
|
||||
|
||||
public String getMessage(String 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) {
|
||||
@ -244,27 +256,27 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public String getLuteAttackEffectName(LuteAttackEffect effect) {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
attackEffects.getConfig().getString("lute-attack." + effect.name().toLowerCase().replace("_", "-")));
|
||||
return new ColorParse('&',
|
||||
attackEffects.getConfig().getString("lute-attack." + effect.name().toLowerCase().replace("_", "-")))
|
||||
.toChatColor();
|
||||
}
|
||||
|
||||
public String getStaffSpiritName(StaffSpirit spirit) {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
attackEffects.getConfig().getString("staff-spirit." + spirit.name().toLowerCase().replace("_", "-")));
|
||||
return new ColorParse('&',
|
||||
attackEffects.getConfig().getString("staff-spirit." + spirit.name().toLowerCase().replace("_", "-")))
|
||||
.toChatColor();
|
||||
}
|
||||
|
||||
/*
|
||||
* all config files that have a default configuration are stored here, they
|
||||
* get copied into the plugin folder when the plugin enables
|
||||
* all config files that have a default configuration are stored here, they get
|
||||
* copied into the plugin folder when the plugin enables
|
||||
*/
|
||||
public enum DefaultFile {
|
||||
|
||||
// default general config files -> /MMOItems
|
||||
ITEM_TIERS("item-tiers.yml", "", "item-tiers.yml"),
|
||||
ITEM_TYPES("item-types.yml", "", "item-types.yml", true),
|
||||
ITEM_TIERS("item-tiers.yml", "", "item-tiers.yml"), ITEM_TYPES("item-types.yml", "", "item-types.yml", true),
|
||||
CUSTOM_BLOCKS("custom-blocks.yml", "", "custom-blocks.yml"),
|
||||
GEN_TEMPLATES("gen-templates.yml", "", "gen-templates.yml"),
|
||||
DROPS("drops.yml", "", "drops.yml"),
|
||||
GEN_TEMPLATES("gen-templates.yml", "", "gen-templates.yml"), DROPS("drops.yml", "", "drops.yml"),
|
||||
ITEM_SETS("item-sets.yml", "", "item-sets.yml"),
|
||||
NAME_PLACEHOLDERS("name-placeholders.yml", "", "name-placeholders.yml"),
|
||||
UPGRADE_TEMPLATES("upgrade-templates.yml", "", "upgrade-templates.yml"),
|
||||
@ -273,41 +285,34 @@ public class ConfigManager {
|
||||
// Not included in the jar anymore
|
||||
|
||||
// default language files -> /MMOItems/language
|
||||
LORE_FORMAT("lore-format.yml", "language", "lore-format.yml"),
|
||||
STATS("stats.yml", "language", "stats.yml"),
|
||||
LORE_FORMAT("lore-format.yml", "language", "lore-format.yml"), STATS("stats.yml", "language", "stats.yml"),
|
||||
|
||||
// item generator
|
||||
EXAMPLE_GEN_TEMPLATES("generator/templates/example-templates.yml", "generator/templates", "example-templates.yml"),
|
||||
EXAMPLE_GEN_MODIFIERS("generator/modifiers/example-modifiers.yml", "generator/modifiers", "example-modifiers.yml"),
|
||||
EXAMPLE_GEN_TEMPLATES("generator/templates/example-templates.yml", "generator/templates",
|
||||
"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"),
|
||||
|
||||
// default item config files -> /MMOItems/item
|
||||
ARMOR("item/armor.yml", "item", "armor.yml"),
|
||||
AXE("item/axe.yml", "item", "axe.yml"),
|
||||
BOW("item/bow.yml", "item", "bow.yml"),
|
||||
CATALYST("item/catalyst.yml", "item", "catalyst.yml"),
|
||||
CONSUMABLE("item/consumable.yml", "item", "consumable.yml"),
|
||||
DAGGER("item/dagger.yml", "item", "dagger.yml"),
|
||||
ARMOR("item/armor.yml", "item", "armor.yml"), AXE("item/axe.yml", "item", "axe.yml"),
|
||||
BOW("item/bow.yml", "item", "bow.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"),
|
||||
GREATSTAFF("item/greatstaff.yml", "item", "greatstaff.yml"),
|
||||
GREATSWORD("item/greatsword.yml", "item", "greatsword.yml"),
|
||||
HALBERD("item/halberd.yml", "item", "halberd.yml"),
|
||||
HAMMER("item/hammer.yml", "item", "hammer.yml"),
|
||||
LANCE("item/lance.yml", "item", "lance.yml"),
|
||||
GREATSWORD("item/greatsword.yml", "item", "greatsword.yml"), HALBERD("item/halberd.yml", "item", "halberd.yml"),
|
||||
HAMMER("item/hammer.yml", "item", "hammer.yml"), LANCE("item/lance.yml", "item", "lance.yml"),
|
||||
MATERIAL("item/material.yml", "item", "material.yml"),
|
||||
MISCELLANEOUS("item/miscellaneous.yml", "item", "miscellaneous.yml"),
|
||||
SHIELD("item/shield.yml", "item", "shield.yml"),
|
||||
STAFF("item/staff.yml", "item", "staff.yml"),
|
||||
SWORD("item/sword.yml", "item", "sword.yml"),
|
||||
TOME("item/tome.yml", "item", "tome.yml"),
|
||||
TOOL("item/tool.yml", "item", "tool.yml"),
|
||||
WAND("item/wand.yml", "item", "wand.yml");
|
||||
SHIELD("item/shield.yml", "item", "shield.yml"), STAFF("item/staff.yml", "item", "staff.yml"),
|
||||
SWORD("item/sword.yml", "item", "sword.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;
|
||||
|
||||
/*
|
||||
* allows to use the checkFile() method while not loading it
|
||||
* automatically e.g item-types.yml
|
||||
* allows to use the checkFile() method while not loading it automatically e.g
|
||||
* item-types.yml
|
||||
*/
|
||||
private final boolean manual;
|
||||
|
||||
@ -327,7 +332,8 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -5,7 +5,6 @@ import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -23,6 +22,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.recipe.MMORecipeChoice;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class RecipeManagerDefault extends RecipeManager {
|
||||
|
||||
@ -183,7 +183,7 @@ public class RecipeManagerDefault extends RecipeManager {
|
||||
item.setAmount(amount);
|
||||
if (!name.isEmpty()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
meta.setDisplayName(new ColorParse('&', name).toChatColor());
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
recipe.setIngredient(character, new RecipeChoice.ExactChoice(item));
|
||||
|
@ -25,6 +25,7 @@ import net.Indyuce.mmoitems.stat.data.ArrowParticlesData;
|
||||
import net.Indyuce.mmoitems.stat.data.ParticleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
@ -113,7 +114,7 @@ public class ArrowParticles extends ItemStat {
|
||||
inv.registerItemEdition(config);
|
||||
inv.open();
|
||||
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;
|
||||
}
|
||||
|
||||
@ -186,8 +187,8 @@ public class ArrowParticles extends ItemStat {
|
||||
lore.add("");
|
||||
|
||||
if (ParticleData.isColorable(data.getParticle()))
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&',
|
||||
"&7* Color: &c&l" + data.getRed() + "&7 - &a&l" + data.getGreen() + "&7 - &9&l" + data.getBlue()));
|
||||
lore.add(new ColorParse('&',
|
||||
"&7* Color: &c&l" + data.getRed() + "&7 - &a&l" + data.getGreen() + "&7 - &9&l" + data.getBlue()).toChatColor());
|
||||
else
|
||||
lore.add(ChatColor.GRAY + "* Speed: " + ChatColor.WHITE + data.getSpeed());
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
@ -62,7 +63,7 @@ public class CompatibleTypes extends ItemStat {
|
||||
config.getConfig().set(inv.getEdited().getId() + ".compatible-types", lore);
|
||||
inv.registerItemEdition(config);
|
||||
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 + "'.");
|
||||
}
|
||||
}
|
||||
@ -88,7 +89,7 @@ public class CompatibleTypes extends ItemStat {
|
||||
if (mmoitem.hasData(this)) {
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
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
|
||||
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<>();
|
||||
JsonArray array = new JsonArray();
|
||||
((StringListData) data).getList().forEach(line -> {
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
line = new ColorParse('&', line).toChatColor();
|
||||
array.add(line);
|
||||
compatibleTypes.add(line);
|
||||
});
|
||||
|
@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.stat.type.StringStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class DisplayName extends StringStat {
|
||||
@ -20,7 +21,7 @@ public class DisplayName extends StringStat {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -27,6 +27,7 @@ import net.Indyuce.mmoitems.stat.data.GemSocketsData;
|
||||
import net.Indyuce.mmoitems.stat.data.GemstoneData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
|
||||
@ -101,7 +102,7 @@ public class GemSockets extends ItemStat {
|
||||
config.getConfig().set(inv.getEdited().getId() + "." + getPath(), lore);
|
||||
inv.registerItemEdition(config);
|
||||
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 + "'.");
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ProperStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
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);
|
||||
inv.registerItemEdition(config);
|
||||
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 + "'.");
|
||||
}
|
||||
}
|
||||
@ -88,7 +89,7 @@ public class Lore extends ItemStat implements ProperStat {
|
||||
if (mmoitem.hasData(this)) {
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
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
|
||||
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<>();
|
||||
JsonArray array = new JsonArray();
|
||||
((StringListData) data).getList().forEach(line -> {
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
line = new ColorParse('&', line).toChatColor();
|
||||
array.add(line);
|
||||
lore.add(line);
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
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);
|
||||
inv.registerItemEdition(config);
|
||||
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 + "'.");
|
||||
}
|
||||
}
|
||||
@ -93,7 +94,7 @@ public class NBTTags extends ItemStat {
|
||||
if (mmoitem.hasData(this)) {
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
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
|
||||
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.Indyuce.mmoitems.stat.data;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
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.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class UpgradeData implements StatData, RandomStatData {
|
||||
private final String reference, template;
|
||||
@ -73,7 +73,7 @@ public class UpgradeData implements StatData, RandomStatData {
|
||||
|
||||
public void upgrade(MMOItem mmoitem) {
|
||||
// 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 (mmoitem.hasData(ItemStat.NAME)) {
|
||||
StringData nameData = (StringData) mmoitem.getData(ItemStat.NAME);
|
||||
|
@ -18,6 +18,7 @@ import net.Indyuce.mmoitems.api.itemgen.RandomStatData;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
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.util.AltChar;
|
||||
|
||||
@ -70,7 +71,7 @@ public class StringStat extends ItemStat {
|
||||
public void whenDisplayed(List<String> lore, MMOItem mmoitem) {
|
||||
|
||||
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;
|
||||
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN + value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user