diff --git a/src/main/java/us/ajg0702/leaderboards/formatting/formats/Time.java b/src/main/java/us/ajg0702/leaderboards/formatting/formats/Time.java index 670dda6c..2d80ec64 100644 --- a/src/main/java/us/ajg0702/leaderboards/formatting/formats/Time.java +++ b/src/main/java/us/ajg0702/leaderboards/formatting/formats/Time.java @@ -38,12 +38,27 @@ public class Time extends Format { private static final List knownTimePlaceholders = Arrays.asList( "statistic_time_played", "statistic_time_since_death", - "mbedwars_stats-play_time" + "mbedwars_stats-play_time", + "formatter_number_time_*" ); + private boolean isKnownTimePlaceholder(String placeholder) { + boolean is = false; + for (String knownTimePlaceholder : knownTimePlaceholders) { + if(knownTimePlaceholder.endsWith("*")) { + is = placeholder.startsWith(knownTimePlaceholder.substring(0, knownTimePlaceholder.length() - 1)); + } else { + is = placeholder.equals(knownTimePlaceholder); + } + if(is) break; + } + + return is; + } + @Override public boolean matches(String output, String placeholder) { - if(knownTimePlaceholders.contains(placeholder.toLowerCase(Locale.ROOT))) { + if(isKnownTimePlaceholder(placeholder.toLowerCase(Locale.ROOT))) { // don't bother with more expensive checks below if we know it's a time placeholder // let me know about any other placeholders that should be here! return true; diff --git a/src/test/java/us/ajg0702/leaderboards/formatting/formats/TimeTest.java b/src/test/java/us/ajg0702/leaderboards/formatting/formats/TimeTest.java index 78888989..970cdf3f 100644 --- a/src/test/java/us/ajg0702/leaderboards/formatting/formats/TimeTest.java +++ b/src/test/java/us/ajg0702/leaderboards/formatting/formats/TimeTest.java @@ -14,7 +14,8 @@ public void testMatches() throws Exception { "31m", "13 hours 21 minutes 15 seconds", "6d 15h 46m 8s", - "9h 21m 44s" + "9h 21m 44s", + "2s" ); List shouldNotMatch = Arrays.asList( "hello there",