diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java index cc8560ba..102b946a 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java @@ -11,7 +11,7 @@ public class WorldRegexMatcher { private final Map mPatterns = new HashMap<>(); - private final Map> mWorldPatternMatches = new HashMap<>(); + private final Map> mWorldPatternMatches = new HashMap<>(); public WorldRegexMatcher(Set worldRegexes) throws PatternSyntaxException { for (String worldRegexStr : worldRegexes) { @@ -25,7 +25,7 @@ public WorldRegexMatcher(Set worldRegexes) throws PatternSyntaxException public void onLoadWorld(World world) { Set matchingPatterns = new HashSet<>(); - mWorldPatternMatches.put(world, matchingPatterns); + mWorldPatternMatches.put(world.getName(), matchingPatterns); String worldName = world.getName(); for (Map.Entry entry : mPatterns.entrySet()) { @@ -42,14 +42,17 @@ public void onLoadWorld(World world) { } public void onUnloadWorld(World world) { - mWorldPatternMatches.remove(world); + mWorldPatternMatches.remove(world.getName()); } // Only works for the patterns provided at matcher instantiation public boolean matches(World world, String worldRegex) { - Set matches = mWorldPatternMatches.get(world); + Set matches = mWorldPatternMatches.get(world.getName()); if (matches == null) { - MMLog.warning("Falling back to slow regex .matches() to test world: '" + world.getName() + "' against unregistered regex: '" + worldRegex + "'"); + MMLog.severe( + "Falling back to slow regex .matches() to test unloaded world: '" + world.getName() + "' against regex: '" + worldRegex + "'", + new IllegalStateException("WorldRegexMatcher testing against an unloaded world") + ); try { return world.getName().matches(worldRegex); } catch (PatternSyntaxException e) {