diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/CMIChatColor.java b/src/main/java/com/gamingmesh/jobs/CMILib/CMIChatColor.java index 1698dc7c..da188e72 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/CMIChatColor.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/CMIChatColor.java @@ -54,52 +54,6 @@ public class CMIChatColor { public static final String colorCodePrefix = "{#"; public static final String colorCodeSuffix = "}"; - private static String charEscape(String s) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - - switch (ch) { - case '"': - sb.append("\\\""); - break; - case '\n': - sb.append("\\n"); - break; - case '\\': - sb.append("\\\\"); - break; - case '\b': - sb.append("\\b"); - break; - case '\f': - sb.append("\\f"); - break; - case '\r': - sb.append("\\r"); - break; - case '\t': - sb.append("\\t"); - break; - case '/': - sb.append("/"); - break; - default: - if ((ch >= '\u0000' && ch <= '\u001F') || (ch >= '\u007F' && ch <= '\u009F') || (ch >= '\u2000' && ch <= '\u20FF')) { - String ss = Integer.toHexString(ch); - sb.append("\\u"); - for (int k = 0; k < 4 - ss.length(); k++) { - sb.append('0'); - } - sb.append(ss.toUpperCase()); - } else { - sb.append(ch); - } - } - } - return sb.toString(); - } - private static String escape(String text) { return text.replace("#", "\\#").replace("{", "\\{").replace("}", "\\}"); } @@ -557,11 +511,11 @@ public class CMIChatColor { } public static CMIChatColor getRandomColor() { - List ls = new ArrayList(); - for (Entry one : BY_NAME.entrySet()) { - if (!one.getValue().isColor()) + List ls = new ArrayList<>(); + for (CMIChatColor one : BY_NAME.values()) { + if (!one.isColor()) continue; - ls.add(one.getValue()); + ls.add(one); } Collections.shuffle(ls); return ls.get(0); @@ -599,7 +553,7 @@ public class CMIChatColor { public static CMIChatColor getByCustomName(String name) { if (name.equalsIgnoreCase("random")) { - List valuesList = new ArrayList(CUSTOM_BY_NAME.values()); + List valuesList = new ArrayList<>(CUSTOM_BY_NAME.values()); int randomIndex = new Random().nextInt(valuesList.size()); return valuesList.get(randomIndex); } @@ -678,12 +632,12 @@ public class CMIChatColor { return null; } double distance = Double.MAX_VALUE; - for (Entry one : CUSTOM_BY_HEX.entrySet()) { + for (CMIChatColor one : CUSTOM_BY_HEX.values()) { java.awt.Color c1 = new java.awt.Color( - Integer.valueOf(one.getValue().hex.substring(0, 2), 16), - Integer.valueOf(one.getValue().hex.substring(2, 4), 16), - Integer.valueOf(one.getValue().hex.substring(4, 6), 16)); + Integer.valueOf(one.hex.substring(0, 2), 16), + Integer.valueOf(one.hex.substring(2, 4), 16), + Integer.valueOf(one.hex.substring(4, 6), 16)); int red1 = c1.getRed(); int red2 = c2.getRed(); @@ -693,7 +647,7 @@ public class CMIChatColor { int b = c1.getBlue() - c2.getBlue(); double dist = Math.sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8)); if (dist < distance) { - closest = one.getValue(); + closest = one; distance = dist; } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index 35130131..9d4b11e7 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -25,7 +25,6 @@ import com.gamingmesh.jobs.container.JobInfo; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.Title; -import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.PageInfo; import com.gamingmesh.jobs.stuff.Sorting; import com.gamingmesh.jobs.stuff.Util; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java b/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java index 98fae315..7280ac1d 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java @@ -14,7 +14,6 @@ import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.Quest; import com.gamingmesh.jobs.container.QuestProgression; import com.gamingmesh.jobs.economy.BufferedEconomy; -import com.gamingmesh.jobs.stuff.Debug; public class skipquest implements Cmd { diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 08e0ff0b..3581ff1c 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -38,7 +38,6 @@ import com.gamingmesh.jobs.Signs.SignTopType; import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.resources.jfep.Parser; -import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling; import com.gamingmesh.jobs.stuff.TimeManage; diff --git a/src/main/java/com/gamingmesh/jobs/container/Title.java b/src/main/java/com/gamingmesh/jobs/container/Title.java index b85670c8..afc6e391 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Title.java +++ b/src/main/java/com/gamingmesh/jobs/container/Title.java @@ -18,7 +18,9 @@ package com.gamingmesh.jobs.container; -import com.gamingmesh.jobs.stuff.ChatColor; +import org.bukkit.ChatColor; + +import com.gamingmesh.jobs.CMILib.CMIChatColor; /** * Container class for titles @@ -28,7 +30,7 @@ import com.gamingmesh.jobs.stuff.ChatColor; public class Title { private String name = null; private String shortName = null; - private ChatColor color = ChatColor.WHITE; + private CMIChatColor color = CMIChatColor.WHITE; private int levelReq = 0; private String jobName = null; @@ -40,12 +42,24 @@ public class Title { * @param levelReq - the level requirement of the title * @param jobName - Job this title is made for */ + @Deprecated public Title(String name, String shortName, ChatColor color, int levelReq, String jobName){ - this.name = name; - this.color = color; - this.levelReq = levelReq; - this.shortName = shortName; - this.jobName = jobName; + this(jobName, jobName, CMIChatColor.WHITE, levelReq, jobName); + } + + /** + * @param name The long name of the title + * @param shortName the short name of the title + * @param color {@link CMIChatColor} + * @param levelReq the level requirement of the title + * @param jobName Job this title is made for + */ + public Title(String name, String shortName, CMIChatColor color, int levelReq, String jobName) { + this.name = name; + this.color = color; + this.levelReq = levelReq; + this.shortName = shortName; + this.jobName = jobName; } /** @@ -65,11 +79,11 @@ public class Title { } /** - * Function to get the ChatColor of the title - * @return the chat colour o the title + * Returns the color of the title + * @return {@link CMIChatColor} */ - public ChatColor getChatColor() { - return color; + public CMIChatColor getChatColor() { + return color; } /** diff --git a/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java b/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java index f3dd1934..ec61fca6 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java @@ -12,7 +12,6 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.stuff.Debug; public class PistonProtectionListener implements Listener {