1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 07:01:22 +01:00

Lets support Hex color codes in titles

This commit is contained in:
Zrips 2020-08-25 16:13:19 +03:00
parent 6dc5fb9ba1
commit dc85541107
14 changed files with 557 additions and 651 deletions

View File

@ -522,7 +522,6 @@ public class CMIChatColor {
if (or.contains(colorCodePrefix)) { if (or.contains(colorCodePrefix)) {
Matcher match = hexColorRegexPatternLast.matcher(or); Matcher match = hexColorRegexPatternLast.matcher(or);
if (match.find()) { if (match.find()) {
return new CMIChatColor(match.group(2)); return new CMIChatColor(match.group(2));
} }
match = hexColorNamePatternLast.matcher(or); match = hexColorNamePatternLast.matcher(or);

View File

@ -25,6 +25,7 @@ import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Title; import com.gamingmesh.jobs.container.Title;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.PageInfo; import com.gamingmesh.jobs.stuff.PageInfo;
import com.gamingmesh.jobs.stuff.Sorting; import com.gamingmesh.jobs.stuff.Sorting;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
@ -81,7 +82,7 @@ public class JobsCommands implements CommandExecutor {
if (!hasCommandPermission(sender, cmd)) { if (!hasCommandPermission(sender, cmd)) {
if (sender instanceof Player) { if (sender instanceof Player) {
new RawMessage().addText(Jobs.getLanguage().getMessage("general.error.permission")) new RawMessage().addText(Jobs.getLanguage().getMessage("general.error.permission"))
.addHover("&2" + label + ".command." + cmd).show(sender); .addHover("&2" + label + ".command." + cmd).show(sender);
} else } else
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission")); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
return true; return true;
@ -198,8 +199,7 @@ public class JobsCommands implements CommandExecutor {
break; break;
} }
} }
} }
private static Class<?> getClass(String cmd) { private static Class<?> getClass(String cmd) {

View File

@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.PlayerManager.BoostOf; import com.gamingmesh.jobs.PlayerManager.BoostOf;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.RawMessage; import com.gamingmesh.jobs.CMILib.RawMessage;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.commands.JobCommand;
@ -12,7 +13,6 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.stuff.ChatColor;
public class bonus implements Cmd { public class bonus implements Cmd {
@ -75,7 +75,7 @@ public class bonus implements Cmd {
} }
private static void printBoost(CommandSender sender, Boost boost, BoostOf type) { private static void printBoost(CommandSender sender, Boost boost, BoostOf type) {
String prefix = ChatColor.GOLD + "*"; String prefix = CMIChatColor.GOLD + "*";
if (type != BoostOf.NearSpawner && type != BoostOf.PetPay) if (type != BoostOf.NearSpawner && type != BoostOf.PetPay)
prefix = ""; prefix = "";

View File

@ -7,11 +7,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.RawMessage; import com.gamingmesh.jobs.CMILib.RawMessage;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.PageInfo; import com.gamingmesh.jobs.stuff.PageInfo;
public class browse implements Cmd { public class browse implements Cmd {
@ -201,7 +201,7 @@ public class browse implements Cmd {
builder.append(job.getChatColor().toString()); builder.append(job.getChatColor().toString());
builder.append(job.getName()); builder.append(job.getName());
if (job.getMaxLevel(sender) > 0) { if (job.getMaxLevel(sender) > 0) {
builder.append(ChatColor.WHITE.toString()); builder.append(CMIChatColor.WHITE.toString());
builder.append(Jobs.getLanguage().getMessage("command.info.help.max")); builder.append(Jobs.getLanguage().getMessage("command.info.help.max"));
builder.append(job.getMaxLevel(sender)); builder.append(job.getMaxLevel(sender));
} }

View File

@ -5,11 +5,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
public class demote implements Cmd { public class demote implements Cmd {
@ -42,7 +42,7 @@ public class demote implements Cmd {
Player player = Bukkit.getServer().getPlayer(jPlayer.getUniqueId()); Player player = Bukkit.getServer().getPlayer(jPlayer.getUniqueId());
if (player != null) { if (player != null) {
String message = Jobs.getLanguage().getMessage("command.demote.output.target", String message = Jobs.getLanguage().getMessage("command.demote.output.target",
"%jobname%", job.getNameWithColor() + ChatColor.WHITE, "%jobname%", job.getNameWithColor() + CMIChatColor.WHITE,
"%levelslost%", levelsLost); "%levelslost%", levelsLost);
player.sendMessage(message); player.sendMessage(message);
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack;
import com.gamingmesh.jobs.ItemBoostManager; import com.gamingmesh.jobs.ItemBoostManager;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.CMIReflections; import com.gamingmesh.jobs.CMILib.CMIReflections;
import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.commands.JobCommand;
@ -15,7 +16,6 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems; import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
public class edititembonus implements Cmd { public class edititembonus implements Cmd {
@ -103,9 +103,9 @@ public class edititembonus implements Cmd {
BoostMultiplier boost = item.getBoost(); BoostMultiplier boost = item.getBoost();
String mc = ChatColor.DARK_GREEN.toString(), String mc = CMIChatColor.DARK_GREEN.toString(),
pc = ChatColor.GOLD.toString(), pc = CMIChatColor.GOLD.toString(),
ec = ChatColor.YELLOW.toString(); ec = CMIChatColor.YELLOW.toString();
for (Job one : item.getJobs()) { for (Job one : item.getJobs()) {
String msg = Jobs.getLanguage().getMessage("command.itembonus.output.list", String msg = Jobs.getLanguage().getMessage("command.itembonus.output.list",

View File

@ -16,7 +16,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems; import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.CMIMaterial; import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.RawMessage; import com.gamingmesh.jobs.CMILib.RawMessage;
@ -68,9 +68,9 @@ public class itembonus implements Cmd {
if (!any) if (!any)
continue; continue;
String mc = ChatColor.DARK_GREEN.toString(), String mc = CMIChatColor.DARK_GREEN.toString(),
pc = ChatColor.GOLD.toString(), pc = CMIChatColor.GOLD.toString(),
ec = ChatColor.YELLOW.toString(), ec = CMIChatColor.YELLOW.toString(),
msg = null; msg = null;
if (jPlayer.isInJob(one)) if (jPlayer.isInJob(one))

View File

@ -61,8 +61,8 @@ public class limit implements Cmd {
continue; continue;
} }
if (limit.GetLeftTime(type) > 0) { if (limit.GetLeftTime(type) > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.GetLeftTime(type)))); sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.GetLeftTime(type))));
sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit", sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit",
"%current%", (int) (limit.GetAmount(type) * 100) / 100D, "%current%", (int) (limit.GetAmount(type) * 100) / 100D,
"%total%", JPlayer.getLimit(type))); "%total%", JPlayer.getLimit(type)));
} }

View File

@ -28,7 +28,6 @@ import com.gamingmesh.jobs.ItemBoostManager;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.*; import com.gamingmesh.jobs.container.*;
import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
@ -450,22 +449,22 @@ public class ConfigManager {
} }
break; break;
default: default:
break; break;
} }
if (actionType == ActionType.STRIPLOGS && Version.isCurrentLower(Version.v1_13_R1)) if (actionType == ActionType.STRIPLOGS && Version.isCurrentLower(Version.v1_13_R1))
return null; return null;
if (material != null && material.getMaterial() != null && material.isAir()) { if (material != null && material.getMaterial() != null && material.isAir()) {
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " can't recognize material! (" + myKey + ")"); Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " can't recognize material! (" + myKey + ")");
return null; return null;
} }
if (material != null && Version.isCurrentLower(Version.v1_13_R1) && meta.isEmpty()) if (material != null && Version.isCurrentLower(Version.v1_13_R1) && meta.isEmpty())
meta = String.valueOf(material.getData()); meta = String.valueOf(material.getData());
c: if (material != null && material != CMIMaterial.NONE && material.getMaterial() != null) { c: if (material != null && material != CMIMaterial.NONE && material.getMaterial() != null) {
// Need to include those ones and count as regular blocks // Need to include those ones and count as regular blocks
switch (myKey.replace("_", "").toLowerCase()) { switch (myKey.replace("_", "").toLowerCase()) {
case "itemframe": case "itemframe":
@ -490,9 +489,9 @@ public class ConfigManager {
// Break and Place actions MUST be blocks // Break and Place actions MUST be blocks
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE || actionType == ActionType.STRIPLOGS) { if (actionType == ActionType.BREAK || actionType == ActionType.PLACE || actionType == ActionType.STRIPLOGS) {
if (!material.isBlock()) { if (!material.isBlock()) {
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + material Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + material
+ " (" + myKey + ")! Material must be a block! Use \"/jobs blockinfo\" on a target block"); + " (" + myKey + ")! Material must be a block! Use \"/jobs blockinfo\" on a target block");
return null; return null;
} }
} }
@ -522,7 +521,7 @@ public class ConfigManager {
type = material.getMaterial().toString(); type = material.getMaterial().toString();
id = material.getId(); id = material.getId();
} else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) { } else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
// check entities // check entities
CMIEntityType entity = CMIEntityType.getByName(myKey); CMIEntityType entity = CMIEntityType.getByName(myKey);
@ -540,8 +539,8 @@ public class ConfigManager {
} }
} }
// Pre 1.13 checks for custom names // Pre 1.13 checks for custom names
if (entity == null) { if (entity == null) {
switch (myKey.toLowerCase()) { switch (myKey.toLowerCase()) {
case "skeletonwither": case "skeletonwither":
type = CMIEntityType.WITHER_SKELETON.name(); type = CMIEntityType.WITHER_SKELETON.name();
@ -741,16 +740,16 @@ public class ConfigManager {
} }
} }
ChatColor color = ChatColor.WHITE; CMIChatColor color = CMIChatColor.WHITE;
if (jobSection.contains("ChatColour")) { if (jobSection.contains("ChatColour")) {
String c = jobSection.getString("ChatColour", ""); String c = jobSection.getString("ChatColour", "");
color = ChatColor.matchColor(c); color = CMIChatColor.getColor(c);
if (color == null && !c.isEmpty()) if (color == null && !c.isEmpty())
color = ChatColor.matchColor(c.charAt(0)); color = CMIChatColor.getColor(String.valueOf("&" + c.charAt(0)));
if (color == null) { if (color == null) {
color = ChatColor.WHITE; color = CMIChatColor.WHITE;
log.warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!"); log.warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
} }
} }
@ -872,24 +871,24 @@ public class ConfigManager {
} else } else
log.warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!"); log.warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!");
if (guiSection.isList("Enchantments")) { if (guiSection.isList("Enchantments")) {
for (String str4 : guiSection.getStringList("Enchantments")) { for (String str4 : guiSection.getStringList("Enchantments")) {
String[] id = str4.split(":"); String[] id = str4.split(":");
if (GUIitem.getItemMeta() instanceof EnchantmentStorageMeta) { if (GUIitem.getItemMeta() instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta(); EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta();
enchantMeta.addStoredEnchant(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]), true); enchantMeta.addStoredEnchant(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]), true);
GUIitem.setItemMeta(enchantMeta); GUIitem.setItemMeta(enchantMeta);
} else } else
GUIitem.addUnsafeEnchantment(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1])); GUIitem.addUnsafeEnchantment(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]));
}
} }
}
if (guiSection.isString("CustomSkull")) { if (guiSection.isString("CustomSkull")) {
GUIitem = Util.getSkull(guiSection.getString("CustomSkull")); GUIitem = Util.getSkull(guiSection.getString("CustomSkull"));
} }
if (guiSection.getInt("slot", -1) >= 0) if (guiSection.getInt("slot", -1) >= 0)
guiSlot = guiSection.getInt("slot"); guiSlot = guiSection.getInt("slot");
} }
// Permissions // Permissions
@ -1205,8 +1204,8 @@ public class ConfigManager {
int id = keyValue.getId(); int id = keyValue.getId();
String type = keyValue.getType(), String type = keyValue.getType(),
subType = keyValue.getSubType(), subType = keyValue.getSubType(),
meta = keyValue.getMeta(); meta = keyValue.getMeta();
if (actionType == ActionType.TNTBREAK) if (actionType == ActionType.TNTBREAK)
Jobs.getGCManager().setTntFinder(true); Jobs.getGCManager().setTntFinder(true);

View File

@ -7,9 +7,9 @@ import java.util.List;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.ConfigReader; import com.gamingmesh.jobs.CMILib.ConfigReader;
import com.gamingmesh.jobs.container.Title; import com.gamingmesh.jobs.container.Title;
import com.gamingmesh.jobs.stuff.ChatColor;
public class TitleManager { public class TitleManager {
@ -55,12 +55,13 @@ public class TitleManager {
c.header(Arrays.asList( c.header(Arrays.asList(
"Title configuration", "Title configuration",
"Stores the titles people gain at certain levels.", "Stores the titles people gain at certain levels.",
"Each title requres to have a name, short name (used when the player has more than", "Each title requires to have a name, short name (used when the player has more than 1 job)",
"1 job) the colour of the title and the level requrirement to attain the title.", "the colour of the title and the level requirement to attain the title.",
"Colour can ether be a word like Brown, can be color character like &5 or hex color code like {#6600cc}",
"It is recommended but not required to have a title at level 0.", "It is recommended but not required to have a title at level 0.",
"Titles are completely optional.", "Titles are completely optional.",
"Posible variable are {level} to add current jobs level.", "Possible variable are {level} to add current jobs level.",
"Optionaly you can set different titles based by job.", "Optionally you can set different titles based by job.",
" JobName: Miner")); " JobName: Miner"));
ConfigurationSection titleSection = c.getC().getConfigurationSection("Titles"); ConfigurationSection titleSection = c.getC().getConfigurationSection("Titles");
@ -70,56 +71,56 @@ public class TitleManager {
titles.add(new Title( titles.add(new Title(
c.get("Titles.Novice.Name", "N"), c.get("Titles.Novice.Name", "N"),
c.get("Titles.Novice.ShortName", "N"), c.get("Titles.Novice.ShortName", "N"),
ChatColor.matchColor(c.get("Titles.Novice.ChatColour", "YELLOW")), CMIChatColor.getColor(c.get("Titles.Novice.ChatColour", "YELLOW")),
c.get("Titles.Novice.levelReq", 0), c.get("Titles.Novice.levelReq", 0),
null)); null));
titles.add(new Title( titles.add(new Title(
c.get("Titles.Apprentice.Name", "A"), c.get("Titles.Apprentice.Name", "A"),
c.get("Titles.Apprentice.ShortName", "A"), c.get("Titles.Apprentice.ShortName", "A"),
ChatColor.matchColor(c.get("Titles.Apprentice.ChatColour", "WHITE")), CMIChatColor.getColor(c.get("Titles.Apprentice.ChatColour", "WHITE")),
c.get("Titles.Apprentice.levelReq", 25), c.get("Titles.Apprentice.levelReq", 25),
null)); null));
titles.add(new Title( titles.add(new Title(
c.get("Titles.Initiate.Name", "I"), c.get("Titles.Initiate.Name", "I"),
c.get("Titles.Initiate.ShortName", "I"), c.get("Titles.Initiate.ShortName", "I"),
ChatColor.matchColor(c.get("Titles.Initiate.ChatColour", "GOLD")), CMIChatColor.getColor(c.get("Titles.Initiate.ChatColour", "GOLD")),
c.get("Titles.Initiate.levelReq", 50), c.get("Titles.Initiate.levelReq", 50),
null)); null));
titles.add(new Title( titles.add(new Title(
c.get("Titles.Journeyman.Name", "J"), c.get("Titles.Journeyman.Name", "J"),
c.get("Titles.Journeyman.ShortName", "J"), c.get("Titles.Journeyman.ShortName", "J"),
ChatColor.matchColor(c.get("Titles.Journeyman.ChatColour", "DARK_GREEN")), CMIChatColor.getColor(c.get("Titles.Journeyman.ChatColour", "DARK_GREEN")),
c.get("Titles.Journeyman.levelReq", 75), c.get("Titles.Journeyman.levelReq", 75),
null)); null));
titles.add(new Title( titles.add(new Title(
c.get("Titles.Adept.Name", "Ad"), c.get("Titles.Adept.Name", "Ad"),
c.get("Titles.Adept.ShortName", "Ad"), c.get("Titles.Adept.ShortName", "Ad"),
ChatColor.matchColor(c.get("Titles.Adept.ChatColour", "DARK_PURPLE")), CMIChatColor.getColor(c.get("Titles.Adept.ChatColour", "DARK_PURPLE")),
c.get("Titles.Adept.levelReq", 100), c.get("Titles.Adept.levelReq", 100),
null)); null));
titles.add(new Title( titles.add(new Title(
c.get("Titles.Master.Name", "M"), c.get("Titles.Master.Name", "M"),
c.get("Titles.Master.ShortName", "M"), c.get("Titles.Master.ShortName", "M"),
ChatColor.matchColor(c.get("Titles.Master.ChatColour", "GRAY")), CMIChatColor.getColor(c.get("Titles.Master.ChatColour", "GRAY")),
c.get("Titles.Master.levelReq", 125), c.get("Titles.Master.levelReq", 125),
null)); null));
titles.add(new Title( titles.add(new Title(
c.get("Titles.Grandmaster.Name", "GM"), c.get("Titles.Grandmaster.Name", "GM"),
c.get("Titles.Grandmaster.ShortName", "GM"), c.get("Titles.Grandmaster.ShortName", "GM"),
ChatColor.matchColor(c.get("Titles.Grandmaster.ChatColour", "DARK_GRAY")), CMIChatColor.getColor(c.get("Titles.Grandmaster.ChatColour", "DARK_GRAY")),
c.get("Titles.Grandmaster.levelReq", 150), c.get("Titles.Grandmaster.levelReq", 150),
null)); null));
titles.add(new Title( titles.add(new Title(
c.get("Titles.Legendary.Name", "L"), c.get("Titles.Legendary.Name", "L"),
c.get("Titles.Legendary.ShortName", "L"), c.get("Titles.Legendary.ShortName", "L"),
ChatColor.matchColor(c.get("Titles.Legendary.ChatColour", "BLACK")), CMIChatColor.getColor(c.get("Titles.Legendary.ChatColour", "BLACK")),
c.get("Titles.Legendary.levelReq", 200), c.get("Titles.Legendary.levelReq", 200),
null)); null));
c.save(); c.save();
@ -128,7 +129,7 @@ public class TitleManager {
String jobName = null; String jobName = null;
String titleName = titleSection.getString(titleKey + ".Name"); String titleName = titleSection.getString(titleKey + ".Name");
String titleShortName = titleSection.getString(titleKey + ".ShortName"); String titleShortName = titleSection.getString(titleKey + ".ShortName");
ChatColor titleColor = ChatColor.matchColor(titleSection.getString(titleKey + ".ChatColour", "")); CMIChatColor titleColor = CMIChatColor.getColor(titleSection.getString(titleKey + ".ChatColour", ""));
int levelReq = titleSection.getInt(titleKey + ".levelReq", -1); int levelReq = titleSection.getInt(titleKey + ".levelReq", -1);
if (titleSection.isString(titleKey + ".JobName")) if (titleSection.isString(titleKey + ".JobName"))

View File

@ -19,10 +19,10 @@
package com.gamingmesh.jobs.container; package com.gamingmesh.jobs.container;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.CMIMaterial; import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.actions.PotionItemActionInfo; import com.gamingmesh.jobs.actions.PotionItemActionInfo;
import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -51,7 +51,7 @@ public class Job {
private String jobShortName; private String jobShortName;
private String description; private String description;
private ChatColor jobColour; private CMIChatColor jobColour;
private Parser maxExpEquation; private Parser maxExpEquation;
private DisplayMethod displayMethod; private DisplayMethod displayMethod;
@ -85,7 +85,7 @@ public class Job {
private int id = 0; private int id = 0;
public Job(String jobName, String fullName, String jobShortName, String description, ChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel, public Job(String jobName, String fullName, String jobShortName, String description, CMIChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, HashMap<String, JobItems> jobItems, int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, HashMap<String, JobItems> jobItems,
HashMap<String, JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) { HashMap<String, JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem, int guiSlot, String bossbar, Long rejoinCD, List<String> worldBlacklist) {
this.jobName = jobName == null ? "" : jobName; this.jobName = jobName == null ? "" : jobName;
@ -294,7 +294,7 @@ public class Job {
* Get the Color of the job for chat * Get the Color of the job for chat
* @return the Color of the job for chat * @return the Color of the job for chat
*/ */
public ChatColor getChatColor() { public CMIChatColor getChatColor() {
return jobColour; return jobColour;
} }

View File

@ -38,7 +38,6 @@ import com.gamingmesh.jobs.Signs.SignTopType;
import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling; import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.TimeManage;
@ -678,7 +677,7 @@ public class JobsPlayer {
if (numJobs == 1) { if (numJobs == 1) {
if (method == DisplayMethod.FULL || method == DisplayMethod.TITLE) { if (method == DisplayMethod.FULL || method == DisplayMethod.TITLE) {
if (title != null) { if (title != null) {
String honorificpart = title.getChatColor() + title.getName() + ChatColor.WHITE; String honorificpart = title.getChatColor() + title.getName() + CMIChatColor.WHITE;
if (honorificpart.contains("{level}")) if (honorificpart.contains("{level}"))
honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel())); honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel()));
builder.append(honorificpart); builder.append(honorificpart);
@ -691,7 +690,7 @@ public class JobsPlayer {
builder.append(" "); builder.append(" ");
} }
String honorificpart = prog.getJob().getNameWithColor() + ChatColor.WHITE; String honorificpart = prog.getJob().getNameWithColor() + CMIChatColor.WHITE;
if (honorificpart.contains("{level}")) if (honorificpart.contains("{level}"))
honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel())); honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel()));
@ -703,7 +702,7 @@ public class JobsPlayer {
if (numJobs > 1 && (method == DisplayMethod.FULL) || method == DisplayMethod.TITLE || method == DisplayMethod.SHORT_FULL || method == DisplayMethod.SHORT_TITLE) { if (numJobs > 1 && (method == DisplayMethod.FULL) || method == DisplayMethod.TITLE || method == DisplayMethod.SHORT_FULL || method == DisplayMethod.SHORT_TITLE) {
// add title to honorific // add title to honorific
if (title != null) { if (title != null) {
String honorificpart = title.getChatColor() + title.getShortName() + ChatColor.WHITE; String honorificpart = title.getChatColor() + title.getShortName() + CMIChatColor.WHITE;
if (honorificpart.contains("{level}")) if (honorificpart.contains("{level}"))
honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel())); honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel()));
@ -712,9 +711,8 @@ public class JobsPlayer {
} }
} }
if (numJobs > 1 && (method == DisplayMethod.FULL) || method == DisplayMethod.JOB || method == DisplayMethod.SHORT_FULL || method == if (numJobs > 1 && (method == DisplayMethod.FULL) || method == DisplayMethod.JOB || method == DisplayMethod.SHORT_FULL || method == DisplayMethod.SHORT_JOB) {
DisplayMethod.SHORT_JOB) { String honorificpart = prog.getJob().getChatColor() + prog.getJob().getShortName() + CMIChatColor.WHITE;
String honorificpart = prog.getJob().getChatColor() + prog.getJob().getShortName() + ChatColor.WHITE;
if (honorificpart.contains("{level}")) if (honorificpart.contains("{level}"))
honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel())); honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel()));
@ -727,7 +725,7 @@ public class JobsPlayer {
if (nonejob != null) { if (nonejob != null) {
DisplayMethod metod = nonejob.getDisplayMethod(); DisplayMethod metod = nonejob.getDisplayMethod();
if (metod == DisplayMethod.FULL || metod == DisplayMethod.TITLE) { if (metod == DisplayMethod.FULL || metod == DisplayMethod.TITLE) {
String honorificpart = Jobs.getNoneJob().getChatColor() + Jobs.getNoneJob().getName() + ChatColor.WHITE; String honorificpart = Jobs.getNoneJob().getChatColor() + Jobs.getNoneJob().getName() + CMIChatColor.WHITE;
if (honorificpart.contains("{level}")) if (honorificpart.contains("{level}"))
honorificpart = honorificpart.replace("{level}", ""); honorificpart = honorificpart.replace("{level}", "");
@ -735,7 +733,7 @@ public class JobsPlayer {
} }
if (metod == DisplayMethod.SHORT_FULL || metod == DisplayMethod.SHORT_TITLE || metod == DisplayMethod.SHORT_JOB) { if (metod == DisplayMethod.SHORT_FULL || metod == DisplayMethod.SHORT_TITLE || metod == DisplayMethod.SHORT_JOB) {
String honorificpart = Jobs.getNoneJob().getChatColor() + Jobs.getNoneJob().getShortName() + ChatColor.WHITE; String honorificpart = Jobs.getNoneJob().getChatColor() + Jobs.getNoneJob().getShortName() + CMIChatColor.WHITE;
if (honorificpart.contains("{level}")) if (honorificpart.contains("{level}"))
honorificpart = honorificpart.replace("{level}", ""); honorificpart = honorificpart.replace("{level}", "");
@ -1225,7 +1223,7 @@ public class JobsPlayer {
public int getMaxFurnacesAllowed(CMIMaterial type) { public int getMaxFurnacesAllowed(CMIMaterial type) {
String perm = "jobs.max" + (type == CMIMaterial.FURNACE || type == CMIMaterial.LEGACY_BURNING_FURNACE String perm = "jobs.max" + (type == CMIMaterial.FURNACE || type == CMIMaterial.LEGACY_BURNING_FURNACE
? "furnaces" : type == CMIMaterial.BLAST_FURNACE ? "blastfurnaces" : type == CMIMaterial.SMOKER ? "smokers" : ""); ? "furnaces" : type == CMIMaterial.BLAST_FURNACE ? "blastfurnaces" : type == CMIMaterial.SMOKER ? "smokers" : "");
if (perm.isEmpty()) if (perm.isEmpty())
return 0; return 0;

View File

@ -1,89 +0,0 @@
/**
* Jobs Plugin for Bukkit
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.gamingmesh.jobs.stuff;
import java.util.HashMap;
import java.util.Map;
public enum ChatColor {
BLACK('0', 0),
DARK_BLUE('1', 1),
DARK_GREEN('2', 2),
DARK_AQUA('3', 3),
DARK_RED('4', 4),
DARK_PURPLE('5', 5),
GOLD('6', 6),
GRAY('7', 7),
DARK_GRAY('8', 8),
BLUE('9', 9),
GREEN('a', 10),
AQUA('b', 11),
RED('c', 12),
LIGHT_PURPLE('d', 13),
YELLOW('e', 14),
WHITE('f', 15),
BOLD('l', 16),
ITALIC('o', 17),
UNDERLINE('n', 18),
RESET('r', 19),
STRIKETHROUGH('m', 20);
private static final char COLOR_CHAR = '\u00A7';
private final char code;
private final int intCode;
private final String toString;
private final static Map<Integer, ChatColor> intMap = new HashMap<>();
private final static Map<Character, ChatColor> charMap = new HashMap<>();
private final static Map<String, ChatColor> stringMap = new HashMap<>();
private ChatColor(char code, int intCode) {
this.code = code;
this.intCode = intCode;
this.toString = new String(new char[] { COLOR_CHAR, code });
}
public char getChar() {
return code;
}
@Override
public String toString() {
return toString;
}
public static ChatColor matchColor(char code) {
return charMap.get(code);
}
public static ChatColor matchColor(int code) {
return intMap.get(code);
}
public static ChatColor matchColor(String name) {
return stringMap.get(name.toLowerCase());
}
static {
for (ChatColor color : values()) {
intMap.put(color.intCode, color);
charMap.put(color.code, color);
stringMap.put(color.name().toLowerCase(), color);
}
}
}