From 1504972e5152f38f15764c6c3c2c55446e3e9d54 Mon Sep 17 00:00:00 2001 From: extendedclip Date: Fri, 20 Apr 2018 21:03:00 -0400 Subject: [PATCH] Remove duplicate method. Make field modifiers consistent resolves #16, resolves #18 --- .../clip/placeholderapi/PlaceholderAPI.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java index 5d5079f..8b2b030 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java @@ -35,15 +35,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import static me.clip.placeholderapi.util.Msg.color; + public class PlaceholderAPI { private PlaceholderAPI() { } - private final static Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]"); - private final static Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]"); - private final static Pattern RELATIONAL_PLACEHOLDER_PATTERN = Pattern.compile("[%](rel_)([^%]+)[%]"); - private final static Map placeholders = new HashMap<>(); + private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]"); + private static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]"); + private static final Pattern RELATIONAL_PLACEHOLDER_PATTERN = Pattern.compile("[%](rel_)([^%]+)[%]"); + private static final Map placeholders = new HashMap<>(); /** * check if a specific placeholder identifier is currently registered @@ -188,7 +190,7 @@ public class PlaceholderAPI { */ public static String setPlaceholders(Player player, String text, Pattern placeholderPattern) { if (text == null) return null; - if (placeholders.isEmpty()) return colorize(text); + if (placeholders.isEmpty()) return color(text); Matcher m = placeholderPattern.matcher(text); Map hooks = getPlaceholders(); while (m.find()) { @@ -204,7 +206,7 @@ public class PlaceholderAPI { } } } - return colorize(text); + return color(text); } /** @@ -234,7 +236,7 @@ public class PlaceholderAPI { */ public static String setRelationalPlaceholders(Player one, Player two, String text) { if (text == null) return null; - if (placeholders.isEmpty()) return colorize(text); + if (placeholders.isEmpty()) return color(text); Matcher m = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text); Map hooks = getPlaceholders(); while (m.find()) { @@ -254,7 +256,7 @@ public class PlaceholderAPI { } } } - return colorize(text); + return color(text); } /** @@ -299,11 +301,7 @@ public class PlaceholderAPI { public static Pattern getRelationalPlaceholderPattern() { return RELATIONAL_PLACEHOLDER_PATTERN; } - - public static String colorize(String text) { - return ChatColor.translateAlternateColorCodes('&', text); - } - + @Deprecated public static Set getRegisteredPlaceholderPlugins() { return getRegisteredIdentifiers();