diff --git a/src/main/java/com/github/manolo8/darkbot/config/actions/values/StatTypeValue.java b/src/main/java/com/github/manolo8/darkbot/config/actions/values/StatTypeValue.java index 246bca870..4f8ba3c08 100644 --- a/src/main/java/com/github/manolo8/darkbot/config/actions/values/StatTypeValue.java +++ b/src/main/java/com/github/manolo8/darkbot/config/actions/values/StatTypeValue.java @@ -40,16 +40,16 @@ public class StatTypeValue implements Value, Parser { } private StatsAPI.Key getKeyFromString(String token) { - String[] tokenParts = token.split(":", 3); + String[] tokenParts = token.split(":"); - String statNamespace = tokenParts.length >= 2 ? tokenParts[0] : null; - String statCategory = tokenParts.length == 3 ? tokenParts[1] : null; + String statNamespace = tokenParts.length == 3 ? tokenParts[0] : null; + String statCategory = tokenParts.length >= 2 ? tokenParts[tokenParts.length - 2] : null; String statKey = tokenParts[tokenParts.length - 1]; return StatsManager.getStatKeys().stream() - .filter(s -> statNamespace == null || s.namespace().equals(statNamespace)) - .filter(s -> statCategory == null || s.category().equals(statCategory)) - .filter(s -> statKey == null || s.name().equals(statKey)) + .filter(s -> statNamespace == null || s.namespace().equalsIgnoreCase(statNamespace)) + .filter(s -> statCategory == null || s.category().equalsIgnoreCase(statCategory)) + .filter(s -> s.name().equalsIgnoreCase(statKey)) .findFirst().orElse(null); } @@ -77,12 +77,12 @@ public static StatData of(String sd) { @Override public String toString() { - return "stat-type(" + key.name().toLowerCase(Locale.ROOT) + "," + dataType + ")"; + return "stat-type(" + getKeyFormatted(key) + "," + dataType + ")"; } private String getKeyFormatted(Key keyToFormat) { - return (keyToFormat.namespace() != null ? keyToFormat.namespace() + ":" : "") + keyToFormat.category() + ":" - + keyToFormat.name(); + return ((keyToFormat.namespace() != null ? keyToFormat.namespace() + ":" : "") + keyToFormat.category() + ":" + + keyToFormat.name()).toLowerCase(Locale.ROOT); } @Override diff --git a/src/main/java/com/github/manolo8/darkbot/core/manager/StatsManager.java b/src/main/java/com/github/manolo8/darkbot/core/manager/StatsManager.java index 03137980a..7e39daadb 100644 --- a/src/main/java/com/github/manolo8/darkbot/core/manager/StatsManager.java +++ b/src/main/java/com/github/manolo8/darkbot/core/manager/StatsManager.java @@ -33,8 +33,6 @@ public class StatsManager implements Manager, StatsAPI, NativeUpdatable { private final Main main; private final EventBrokerAPI eventBroker; - private static StatsManager INSTANCE; - private long address; public int userId; @@ -53,7 +51,6 @@ public class StatsManager implements Manager, StatsAPI, NativeUpdatable { public StatsManager(Main main, EventBrokerAPI eventBroker) { this.main = main; this.eventBroker = eventBroker; - INSTANCE = this; registerImpl(Stats.Bot.RUNTIME, runtime = createStat()); @@ -129,11 +126,7 @@ private void registerImpl(Key key, StatImpl stat) { } public static Collection getStatKeys() { - return Collections.unmodifiableSet(getInstance().statistics.keySet()); - } - - public static StatsManager getInstance() { - return INSTANCE; + return Collections.unmodifiableSet(Main.INSTANCE.statsManager.statistics.keySet()); } @Override