forked from Upstream/mmocore
MMOCore 1.4.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
ed0c72c8da
commit
4d78a3a245
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.Indyuce</groupId>
|
<groupId>net.Indyuce</groupId>
|
||||||
<artifactId>MMOCore</artifactId>
|
<artifactId>MMOCore</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4.1</version>
|
||||||
<description>Offer your players a brand new RPG experience.</description>
|
<description>Offer your players a brand new RPG experience.</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -3,11 +3,11 @@ package net.Indyuce.mmocore.api;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
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.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
import net.mmogroup.mmolib.MMOLib;
|
||||||
|
|
||||||
public class ConfigMessage {
|
public class ConfigMessage {
|
||||||
@ -31,14 +31,14 @@ public class ConfigMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void send(CommandSender sender) {
|
public void send(CommandSender sender) {
|
||||||
messages.forEach(line -> sender.sendMessage(ChatColor.translateAlternateColorCodes('&', line)));
|
messages.forEach(line -> sender.sendMessage(new ColorParse('&', line).toChatColor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(Collection<? extends Player> players) {
|
public void send(Collection<? extends Player> players) {
|
||||||
players.forEach(player -> messages.forEach(line -> player.sendMessage(ChatColor.translateAlternateColorCodes('&', MMOCore.plugin.placeholderParser.parse(player, line)))));
|
players.forEach(player -> messages.forEach(line -> player.sendMessage(new ColorParse('&', MMOCore.plugin.placeholderParser.parse(player, line)).toChatColor())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendAsJSon(Player player) {
|
public void sendAsJSon(Player player) {
|
||||||
messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, ChatColor.translateAlternateColorCodes('&', line)));
|
messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, new ColorParse('&', line).toChatColor()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.api;
|
|||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -10,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public class PlayerActionBar extends BukkitRunnable {
|
|||||||
for (PlayerData data : PlayerData.getAll())
|
for (PlayerData data : PlayerData.getAll())
|
||||||
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.canSeeActionBar()) {
|
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.canSeeActionBar()) {
|
||||||
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(data.getPlayer(),
|
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(data.getPlayer(),
|
||||||
ChatColor.translateAlternateColorCodes('&', new String(format)
|
new ColorParse('&', new String(format)
|
||||||
.replace("{health}", digit.format(data.getPlayer().getHealth()))
|
.replace("{health}", digit.format(data.getPlayer().getHealth()))
|
||||||
.replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
|
.replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
|
||||||
.replace("{mana_icon}", data.getProfess().getManaDisplay().getIcon())
|
.replace("{mana_icon}", data.getProfess().getManaDisplay().getIcon())
|
||||||
@ -45,7 +45,7 @@ public class PlayerActionBar extends BukkitRunnable {
|
|||||||
.replace("{xp}", "" + data.getExperience())
|
.replace("{xp}", "" + data.getExperience())
|
||||||
.replace("{armor}", "" + StatType.ARMOR.format(data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue()))
|
.replace("{armor}", "" + StatType.ARMOR.format(data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue()))
|
||||||
.replace("{level}", "" + data.getLevel())
|
.replace("{level}", "" + data.getLevel())
|
||||||
.replace("{name}", data.getPlayer().getDisplayName())))));
|
.replace("{name}", data.getPlayer().getDisplayName())).toChatColor())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ 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 net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
|
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
|
||||||
|
|
||||||
public class PlayerAttribute {
|
public class PlayerAttribute {
|
||||||
@ -48,7 +48,7 @@ public class PlayerAttribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return ChatColor.translateAlternateColorCodes('&', name);
|
return new ColorParse('&', name).toChatColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMax() {
|
public boolean hasMax() {
|
||||||
|
@ -13,7 +13,6 @@ import java.util.UUID;
|
|||||||
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.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -38,6 +37,8 @@ import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
|||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||||
import net.Indyuce.mmocore.api.util.math.particle.CastingParticle;
|
import net.Indyuce.mmocore.api.util.math.particle.CastingParticle;
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ public class PlayerClass extends PostLoadObject {
|
|||||||
|
|
||||||
this.id = id.toUpperCase().replace("-", "_").replace(" ", "_");
|
this.id = id.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||||
|
|
||||||
name = ChatColor.translateAlternateColorCodes('&', config.getString("display.name"));
|
name = new ColorParse('&', config.getString("display.name")).toChatColor();
|
||||||
icon = MMOCoreUtils.readIcon(config.getString("display.item", "BARRIER"));
|
icon = MMOCoreUtils.readIcon(config.getString("display.item", "BARRIER"));
|
||||||
|
|
||||||
if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial())
|
if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial())
|
||||||
@ -76,20 +77,23 @@ public class PlayerClass extends PostLoadObject {
|
|||||||
gp.getProperties().put("textures", new Property("textures", config.getString("display.texture")));
|
gp.getProperties().put("textures", new Property("textures", config.getString("display.texture")));
|
||||||
profileField.set(meta, gp);
|
profileField.set(meta, gp);
|
||||||
icon.setItemMeta(meta);
|
icon.setItemMeta(meta);
|
||||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException exception) {
|
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
|
||||||
|
| SecurityException exception) {
|
||||||
throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage());
|
throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String string : config.getStringList("display.lore"))
|
for (String string : config.getStringList("display.lore"))
|
||||||
description.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', string));
|
description.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor());
|
||||||
for (String string : config.getStringList("display.attribute-lore"))
|
for (String string : config.getStringList("display.attribute-lore"))
|
||||||
attrDescription.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', string));
|
attrDescription.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor());
|
||||||
manaDisplay = config.contains("mana") ? new ManaDisplayOptions(config.getConfigurationSection("mana")) : ManaDisplayOptions.DEFAULT;
|
manaDisplay = config.contains("mana") ? new ManaDisplayOptions(config.getConfigurationSection("mana"))
|
||||||
|
: ManaDisplayOptions.DEFAULT;
|
||||||
maxLevel = config.getInt("max-level");
|
maxLevel = config.getInt("max-level");
|
||||||
displayOrder = config.getInt("display.order");
|
displayOrder = config.getInt("display.order");
|
||||||
|
|
||||||
expCurve = config.contains("exp-curve")
|
expCurve = config.contains("exp-curve")
|
||||||
? MMOCore.plugin.experience.getOrThrow(config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
? MMOCore.plugin.experience.getOrThrow(
|
||||||
|
config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
||||||
: ExpCurve.DEFAULT;
|
: ExpCurve.DEFAULT;
|
||||||
|
|
||||||
if (config.contains("attributes"))
|
if (config.contains("attributes"))
|
||||||
@ -98,27 +102,30 @@ public class PlayerClass extends PostLoadObject {
|
|||||||
stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")),
|
stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")),
|
||||||
new LinearValue(config.getConfigurationSection("attributes." + key)));
|
new LinearValue(config.getConfigurationSection("attributes." + key)));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load stat info '" + key + "' from class '"
|
||||||
"Could not load stat info '" + key + "' from class '" + id + "': " + exception.getMessage());
|
+ id + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("skills"))
|
if (config.contains("skills"))
|
||||||
for (String key : config.getConfigurationSection("skills").getKeys(false))
|
for (String key : config.getConfigurationSection("skills").getKeys(false))
|
||||||
try {
|
try {
|
||||||
Validate.isTrue(MMOCore.plugin.skillManager.has(key), "Could not find skill " + key);
|
Validate.isTrue(MMOCore.plugin.skillManager.has(key), "Could not find skill " + key);
|
||||||
skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key).newSkillInfo(config.getConfigurationSection("skills." + key)));
|
skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key)
|
||||||
|
.newSkillInfo(config.getConfigurationSection("skills." + key)));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill info '" + key + "' from class '"
|
||||||
"Could not load skill info '" + key + "' from class '" + id + "': " + exception.getMessage());
|
+ id + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle"))
|
castParticle = config.contains("cast-particle")
|
||||||
|
? new CastingParticle(config.getConfigurationSection("cast-particle"))
|
||||||
: new CastingParticle(Particle.SPELL_INSTANT);
|
: new CastingParticle(Particle.SPELL_INSTANT);
|
||||||
|
|
||||||
if (config.contains("options"))
|
if (config.contains("options"))
|
||||||
for (String key : config.getConfigurationSection("options").getKeys(false))
|
for (String key : config.getConfigurationSection("options").getKeys(false))
|
||||||
try {
|
try {
|
||||||
setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")), config.getBoolean("options." + key));
|
setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")),
|
||||||
|
config.getBoolean("options." + key));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||||
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
|
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
|
||||||
@ -127,12 +134,13 @@ public class PlayerClass extends PostLoadObject {
|
|||||||
if (config.contains("main-exp-sources"))
|
if (config.contains("main-exp-sources"))
|
||||||
for (String key : config.getStringList("main-exp-sources"))
|
for (String key : config.getStringList("main-exp-sources"))
|
||||||
try {
|
try {
|
||||||
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), null);
|
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key),
|
||||||
|
null);
|
||||||
source.setClass(this);
|
source.setClass(this);
|
||||||
MMOCore.plugin.professionManager.registerExpSource(source);
|
MMOCore.plugin.professionManager.registerExpSource(source);
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp source '" + key + "' from class '"
|
||||||
"Could not load exp source '" + key + "' from class '" + id + "': " + exception.getMessage());
|
+ id + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("triggers"))
|
if (config.contains("triggers"))
|
||||||
@ -146,17 +154,17 @@ public class PlayerClass extends PostLoadObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* must make sure all the resourceHandlers are registered when the
|
* must make sure all the resourceHandlers are registered when the placer class
|
||||||
* placer class is initialized.
|
* is initialized.
|
||||||
*/
|
*/
|
||||||
for (PlayerResource resource : PlayerResource.values()) {
|
for (PlayerResource resource : PlayerResource.values()) {
|
||||||
if (config.isConfigurationSection("resource." + resource.name().toLowerCase()))
|
if (config.isConfigurationSection("resource." + resource.name().toLowerCase()))
|
||||||
try {
|
try {
|
||||||
resourceHandlers.put(resource,
|
resourceHandlers.put(resource, new ResourceHandler(resource,
|
||||||
new ResourceHandler(resource, config.getConfigurationSection("resource." + resource.name().toLowerCase())));
|
config.getConfigurationSection("resource." + resource.name().toLowerCase())));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load special resource regen for " + resource.name() + ": "
|
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load special resource regen for "
|
||||||
+ exception.getMessage());
|
+ resource.name() + ": " + exception.getMessage());
|
||||||
resourceHandlers.put(resource, new ResourceHandler(resource));
|
resourceHandlers.put(resource, new ResourceHandler(resource));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -191,11 +199,13 @@ public class PlayerClass extends PostLoadObject {
|
|||||||
if (config.contains("subclasses"))
|
if (config.contains("subclasses"))
|
||||||
for (String key : config.getConfigurationSection("subclasses").getKeys(false))
|
for (String key : config.getConfigurationSection("subclasses").getKeys(false))
|
||||||
try {
|
try {
|
||||||
subclasses.add(new Subclass(MMOCore.plugin.classManager.getOrThrow(key.toUpperCase().replace("-", "_").replace(" ", "_")),
|
subclasses.add(new Subclass(
|
||||||
|
MMOCore.plugin.classManager
|
||||||
|
.getOrThrow(key.toUpperCase().replace("-", "_").replace(" ", "_")),
|
||||||
config.getInt("subclasses." + key)));
|
config.getInt("subclasses." + key)));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load subclass '" + key + "' from class '"
|
||||||
"Could not load subclass '" + key + "' from class '" + getId() + "': " + exception.getMessage());
|
+ getId() + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package net.Indyuce.mmocore.api.player.profess.resource;
|
package net.Indyuce.mmocore.api.player.profess.resource;
|
||||||
|
|
||||||
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.asangarin.hexcolors.ColorParse;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.mmogroup.mmolib.api.util.AltChar;
|
import net.mmogroup.mmolib.api.util.AltChar;
|
||||||
|
|
||||||
public class ManaDisplayOptions {
|
public class ManaDisplayOptions {
|
||||||
@ -21,15 +22,15 @@ public class ManaDisplayOptions {
|
|||||||
Validate.notNull(name, "Could not load mana name");
|
Validate.notNull(name, "Could not load mana name");
|
||||||
|
|
||||||
Validate.notNull(config.getConfigurationSection("color"), "Could not find mana color config");
|
Validate.notNull(config.getConfigurationSection("color"), "Could not find mana color config");
|
||||||
full = ChatColor.valueOf(config.getString("color.full", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_"));
|
full = ColorParse.getColor(config.getString("color.full", "NO_INPUT"));
|
||||||
half = ChatColor.valueOf(config.getString("color.half", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_"));
|
half = ColorParse.getColor(config.getString("color.half", "NO_INPUT"));
|
||||||
empty = ChatColor.valueOf(config.getString("color.empty", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_"));
|
empty = ColorParse.getColor(config.getString("color.empty", "NO_INPUT"));
|
||||||
|
|
||||||
String format = config.getString("char", "");
|
String format = config.getString("char", "");
|
||||||
Validate.notEmpty(format, "Could not load mana bar character");
|
Validate.notEmpty(format, "Could not load mana bar character");
|
||||||
barCharacter = format.charAt(0);
|
barCharacter = format.charAt(0);
|
||||||
|
|
||||||
icon = ChatColor.translateAlternateColorCodes('&', config.getString("icon", ""));
|
icon = new ColorParse('&', config.getString("icon", "")).toChatColor();
|
||||||
Validate.notEmpty(format, "Could not load mana action bar icon");
|
Validate.notEmpty(format, "Could not load mana action bar icon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package net.Indyuce.mmocore.api.quest;
|
package net.Indyuce.mmocore.api.quest;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
|
|
||||||
public class QuestProgress {
|
public class QuestProgress {
|
||||||
private final Quest quest;
|
private final Quest quest;
|
||||||
@ -65,6 +64,6 @@ public class QuestProgress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFormattedLore() {
|
public String getFormattedLore() {
|
||||||
return ChatColor.translateAlternateColorCodes('&', objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore()));
|
return new ColorParse('&', objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore())).toChatColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,6 @@ import java.util.UUID;
|
|||||||
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.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
@ -20,6 +19,7 @@ import com.mojang.authlib.GameProfile;
|
|||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
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;
|
||||||
@ -138,6 +138,6 @@ public class ConfigItem {
|
|||||||
for (String placeholder : placeholders.keySet())
|
for (String placeholder : placeholders.keySet())
|
||||||
if (string.contains("{" + placeholder + "}"))
|
if (string.contains("{" + placeholder + "}"))
|
||||||
string = string.replace("{" + placeholder + "}", "" + placeholders.get(placeholder));
|
string = string.replace("{" + placeholder + "}", "" + placeholders.get(placeholder));
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return new ColorParse('&', string).toChatColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package net.Indyuce.mmocore.api.util.item;
|
package net.Indyuce.mmocore.api.util.item;
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package net.Indyuce.mmocore.comp.placeholder;
|
package net.Indyuce.mmocore.comp.placeholder;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
|
|
||||||
public class DefaultParser implements PlaceholderParser {
|
public class DefaultParser implements PlaceholderParser {
|
||||||
@Override
|
@Override
|
||||||
public String parse(OfflinePlayer player, String string) {
|
public String parse(OfflinePlayer player, String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string.replace("%player%", player.getName()));
|
return new ColorParse('&', string.replace("%player%", player.getName())).toChatColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -24,6 +23,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
|||||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class ClassSelect extends EditableInventory {
|
|||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (hideFlags())
|
if (hideFlags())
|
||||||
meta.addItemFlags(ItemFlag.values());
|
meta.addItemFlags(ItemFlag.values());
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name).replace("{name}", profess.getName()));
|
meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName()));
|
||||||
List<String> lore = new ArrayList<>(this.lore);
|
List<String> lore = new ArrayList<>(this.lore);
|
||||||
|
|
||||||
int index = lore.indexOf("{lore}");
|
int index = lore.indexOf("{lore}");
|
||||||
|
@ -27,6 +27,7 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
|||||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public class SkillList extends EditableInventory {
|
|||||||
|
|
||||||
if (function.equals("slot"))
|
if (function.equals("slot"))
|
||||||
return new InventoryPlaceholderItem(config) {
|
return new InventoryPlaceholderItem(config) {
|
||||||
private final String none = ChatColor.translateAlternateColorCodes('&', config.getString("no-skill"));
|
private final String none = new ColorParse('&', config.getString("no-skill")).toChatColor();
|
||||||
private final Material emptyMaterial = Material
|
private final Material emptyMaterial = Material
|
||||||
.valueOf(config.getString("empty-item").toUpperCase().replace("-", "_").replace(" ", "_"));
|
.valueOf(config.getString("empty-item").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
|
|
||||||
@ -169,12 +170,12 @@ public class SkillList extends EditableInventory {
|
|||||||
lore.add(index + j, skillLore.get(j));
|
lore.add(index + j, skillLore.get(j));
|
||||||
|
|
||||||
for (int j = 0; j < lore.size(); j++)
|
for (int j = 0; j < lore.size(); j++)
|
||||||
lore.set(j, ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', lore.get(j)));
|
lore.set(j, ChatColor.GRAY + new ColorParse('&', lore.get(j)).toChatColor());
|
||||||
|
|
||||||
ItemStack item = cloneItem();
|
ItemStack item = cloneItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getName().replace("{skill}", skill.getSkill().getName())
|
meta.setDisplayName(new ColorParse('&', getName().replace("{skill}", skill.getSkill().getName())
|
||||||
.replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel)));
|
.replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel)).toChatColor());
|
||||||
meta.addItemFlags(ItemFlag.values());
|
meta.addItemFlags(ItemFlag.values());
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
@ -21,6 +20,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
|||||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class SubclassSelect extends EditableInventory {
|
|||||||
|
|
||||||
ItemStack item = profess.getIcon();
|
ItemStack item = profess.getIcon();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name).replace("{name}", profess.getName()));
|
meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName()));
|
||||||
List<String> lore = new ArrayList<>(this.lore);
|
List<String> lore = new ArrayList<>(this.lore);
|
||||||
|
|
||||||
int index = lore.indexOf("{lore}");
|
int index = lore.indexOf("{lore}");
|
||||||
|
@ -4,13 +4,13 @@ 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.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.TriggerItem;
|
import net.Indyuce.mmocore.gui.api.item.TriggerItem;
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
|
|
||||||
public abstract class GeneratedInventory extends PluginInventory {
|
public abstract class GeneratedInventory extends PluginInventory {
|
||||||
private final EditableInventory editable;
|
private final EditableInventory editable;
|
||||||
@ -54,7 +54,7 @@ public abstract class GeneratedInventory extends PluginInventory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
Inventory inv = Bukkit.createInventory(this, editable.getSlots(), ChatColor.translateAlternateColorCodes('&', calculateName()));
|
Inventory inv = Bukkit.createInventory(this, editable.getSlots(), new ColorParse('&', calculateName()).toChatColor());
|
||||||
|
|
||||||
for (InventoryItem item : editable.getItems())
|
for (InventoryItem item : editable.getItems())
|
||||||
if (item.canDisplay(this))
|
if (item.canDisplay(this))
|
||||||
|
@ -20,6 +20,7 @@ import net.Indyuce.mmocore.api.util.input.AnvilGUI;
|
|||||||
import net.Indyuce.mmocore.api.util.input.ChatInput;
|
import net.Indyuce.mmocore.api.util.input.ChatInput;
|
||||||
import net.Indyuce.mmocore.api.util.input.PlayerInput;
|
import net.Indyuce.mmocore.api.util.input.PlayerInput;
|
||||||
import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType;
|
import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType;
|
||||||
|
import net.asangarin.hexcolors.ColorParse;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
|
||||||
@ -155,7 +156,7 @@ public class ConfigManager {
|
|||||||
String format = messages.getString(key, "");
|
String format = messages.getString(key, "");
|
||||||
for (int j = 0; j < placeholders.length - 1; j += 2)
|
for (int j = 0; j < placeholders.length - 1; j += 2)
|
||||||
format = format.replace("{" + placeholders[j] + "}", placeholders[j + 1]);
|
format = format.replace("{" + placeholders[j] + "}", placeholders[j + 1]);
|
||||||
return new SimpleMessage(ChatColor.translateAlternateColorCodes('&', format));
|
return new SimpleMessage(new ColorParse('&', format).toChatColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SimpleMessage {
|
public class SimpleMessage {
|
||||||
|
Loading…
Reference in New Issue
Block a user