diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java index 1a47110f61..9bc8e243f9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java @@ -78,8 +78,8 @@ public interface SpellbookConfig extends Config @ConfigItem( keyName = "filter", name = "Unfiltered spells", - description = "Spells you don't want to filter, seperated with a comma" - ) + description = "Spells you don't want to filter, seperated with a comma.
\"'s can be used in front and behind spells (eg: '\"c' matches all spells starting with a c" + ) // ^ JAJAJJAJAJAJAJA BRAZIL default String filter() { return ""; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java index 82181d6911..8175c05f3f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java @@ -81,6 +81,13 @@ public class SpellbookPlugin extends Plugin private static final WidgetMenuOption RESIZABLE_MAGIC_TAB_UNLOCK = new WidgetMenuOption(UNLOCK, MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_MAGIC_TAB); private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_MAGIC_TAB_LOCK = new WidgetMenuOption(LOCK, MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_MAGIC_TAB); private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_MAGIC_TAB_UNLOCK = new WidgetMenuOption(UNLOCK, MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_MAGIC_TAB); + private enum WordFilterMode + { + CONTAINS, + EQUALS, + STARTSWITH, + ENDSWITH + } @Inject private Client client; @@ -143,9 +150,7 @@ public class SpellbookPlugin extends Plugin saveSpells(); config.canDrag(false); mouseManager.unregisterMouseListener(mouseListener); - mouseManager.unregisterMouseWheelListener(mouseListener); - mouseListener = null; } @@ -168,16 +173,13 @@ public class SpellbookPlugin extends Plugin String key = event.getKey(); - if ("canDrag".equals(key)) - { - refreshMagicTabOption(); - } - else if ("filter".equals(key)) + if ("filter".equals(key)) { loadFilter(); } clientThread.invokeLater(this::runRebuild); + refreshMagicTabOption(); } @Subscribe @@ -241,7 +243,46 @@ public class SpellbookPlugin extends Plugin return; } - iStack[iStackSize - 2] = notFilteredSpells.stream().anyMatch(spell::contains) ? 1 : 0; + for (String str : notFilteredSpells) + { + WordFilterMode mode = getFilterMode(str); + str = str.replaceAll("\"", ""); + + if (mode == WordFilterMode.CONTAINS) + { + if (spell.contains(str)) + { + iStack[iStackSize - 2] = 1; + break; + } + } + else if (mode == WordFilterMode.STARTSWITH) + { + if (spell.startsWith(str)) + { + iStack[iStackSize - 2] = 1; + break; + } + } + else if (mode == WordFilterMode.ENDSWITH) + { + if (spell.endsWith(str)) + { + iStack[iStackSize - 2] = 1; + break; + } + } + else if (mode == WordFilterMode.EQUALS) + { + if (spell.equals(str)) + { + iStack[iStackSize - 2] = 1; + break; + } + } + + iStack[iStackSize - 2] = 0; + } } else if ("isMobileSpellbookEnabled".equals(event.getEventName())) { @@ -273,7 +314,7 @@ public class SpellbookPlugin extends Plugin .map(Spell::getName) .filter(s -> notFilteredSpells .stream() - .anyMatch(s::contains)) + .anyMatch(s.replaceAll("\"", "" )::contains)) .count(); @@ -436,6 +477,24 @@ public class SpellbookPlugin extends Plugin ); } + private static WordFilterMode getFilterMode(String s) + { + if (!s.contains("\"")) + { + return WordFilterMode.CONTAINS; + } + if (s.startsWith("\"")) + { + return s.endsWith("\"") ? WordFilterMode.EQUALS : WordFilterMode.STARTSWITH; + } + else if (s.endsWith("\"")) + { + return WordFilterMode.ENDSWITH; + } + + return WordFilterMode.CONTAINS; // but probably null soz + } + boolean isOnSpellWidget(java.awt.Point point) { Widget boundsWidget = client.getWidget(WidgetInfo.SPELLBOOK_FILTERED_BOUNDS);