diff --git a/runelite-client/src/main/java/net/runelite/client/menus/AbstractMenuEntry.java b/runelite-client/src/main/java/net/runelite/client/menus/ComparableEntry.java similarity index 83% rename from runelite-client/src/main/java/net/runelite/client/menus/AbstractMenuEntry.java rename to runelite-client/src/main/java/net/runelite/client/menus/ComparableEntry.java index 521f3c2645..29efd58742 100644 --- a/runelite-client/src/main/java/net/runelite/client/menus/AbstractMenuEntry.java +++ b/runelite-client/src/main/java/net/runelite/client/menus/ComparableEntry.java @@ -32,7 +32,7 @@ import static net.runelite.client.menus.MenuManager.LEVEL_PATTERN; import net.runelite.client.util.Text; @EqualsAndHashCode -public class AbstractMenuEntry +public class ComparableEntry { @Getter private String option; @@ -52,17 +52,17 @@ public class AbstractMenuEntry @Getter private boolean strictTarget; - public AbstractMenuEntry(String option, String target) + public ComparableEntry(String option, String target) { this(option, target, -1, -1, true, true); } - public AbstractMenuEntry(String option, String target, boolean strictTarget) + public ComparableEntry(String option, String target, boolean strictTarget) { this(option, target, -1, -1, true, strictTarget); } - public AbstractMenuEntry(String option, String target, int id, int type, boolean strictOption, boolean strictTarget) + public ComparableEntry(String option, String target, int id, int type, boolean strictOption, boolean strictTarget) { this.option = option; this.target = target; @@ -113,14 +113,4 @@ public class AbstractMenuEntry return true; } - - /*boolean equals(AbstractMenuEntry other) - { - return target.equals(other.getTarget()) - && option.equals(other.getOption()) - && id == other.getId() - && type == other.getType() - && strictOption == other.isStrictOption() - && strictTarget == other.isStrictTarget(); - }*/ } diff --git a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java index 81c7b4d868..d95127eaa5 100644 --- a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java +++ b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java @@ -91,10 +91,10 @@ public class MenuManager private final Multimap managedMenuOptions = HashMultimap.create(); private final Set npcMenuOptions = new HashSet<>(); - private final Set priorityEntries = new HashSet<>(); + private final Set priorityEntries = new HashSet<>(); private final Set currentPriorityEntries = new HashSet<>(); - private final Map swaps = new HashMap<>(); + private final Map swaps = new HashMap<>(); private final Set originalTypes = new HashSet<>(); private final Set leftClickObjects = new HashSet<>(); @@ -176,7 +176,7 @@ public class MenuManager final MenuEntry newestEntry = menuEntries[menuEntries.length - 1]; boolean isPrio = false; - for (AbstractMenuEntry p : priorityEntries) + for (ComparableEntry p : priorityEntries) { if (p.matches(newestEntry)) { @@ -203,8 +203,8 @@ public class MenuManager } // Find the current entry in the swaps map - AbstractMenuEntry swapEntry = null; - for (AbstractMenuEntry e : swaps.keySet()) + ComparableEntry swapEntry = null; + for (ComparableEntry e : swaps.keySet()) { if (e.matches(newestEntry)) { @@ -215,7 +215,7 @@ public class MenuManager if (swapEntry != null) { - AbstractMenuEntry swapTarget = swaps.get(swapEntry); + ComparableEntry swapTarget = swaps.get(swapEntry); // Find the target for the swap in current menu entries MenuEntry foundSwap = null; @@ -587,7 +587,7 @@ public class MenuManager option = Text.standardize(option); target = Text.standardize(target); - AbstractMenuEntry entry = new AbstractMenuEntry(option, target); + ComparableEntry entry = new ComparableEntry(option, target); priorityEntries.add(entry); } @@ -597,10 +597,10 @@ public class MenuManager option = Text.standardize(option); target = Text.standardize(target); - AbstractMenuEntry entry = new AbstractMenuEntry(option, target); + ComparableEntry entry = new ComparableEntry(option, target); - Set toRemove = new HashSet<>(); - for (AbstractMenuEntry priorityEntry : priorityEntries) + Set toRemove = new HashSet<>(); + for (ComparableEntry priorityEntry : priorityEntries) { if (entry.equals(priorityEntry)) { @@ -608,7 +608,7 @@ public class MenuManager } } - for (AbstractMenuEntry e : toRemove) + for (ComparableEntry e : toRemove) { priorityEntries.remove(e); } @@ -623,7 +623,7 @@ public class MenuManager { option = Text.standardize(option); - AbstractMenuEntry entry = new AbstractMenuEntry(option, "", false); + ComparableEntry entry = new ComparableEntry(option, "", false); priorityEntries.add(entry); } @@ -632,10 +632,10 @@ public class MenuManager { option = Text.standardize(option); - AbstractMenuEntry entry = new AbstractMenuEntry(option, "", false); + ComparableEntry entry = new ComparableEntry(option, "", false); - Set toRemove = new HashSet<>(); - for (AbstractMenuEntry priorityEntry : priorityEntries) + Set toRemove = new HashSet<>(); + for (ComparableEntry priorityEntry : priorityEntries) { if (entry.equals(priorityEntry)) { @@ -643,7 +643,7 @@ public class MenuManager } } - for (AbstractMenuEntry e : toRemove) + for (ComparableEntry e : toRemove) { priorityEntries.remove(e); } @@ -660,8 +660,8 @@ public class MenuManager option2 = Text.standardize(option2); target2 = Text.standardize(target2); - AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, -1, -1, strictOption, strictTarget); - AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, -1, -1, strictOption, strictTarget); + ComparableEntry swapFrom = new ComparableEntry(option, target, -1, -1, strictOption, strictTarget); + ComparableEntry swapTo = new ComparableEntry(option2, target2, -1, -1, strictOption, strictTarget); if (swapTo.equals(swapFrom)) { @@ -681,8 +681,8 @@ public class MenuManager option2 = Text.standardize(option2); target2 = Text.standardize(target2); - AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, -1, -1, strictOption, strictTarget); - AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, -1, -1, strictOption, strictTarget); + ComparableEntry swapFrom = new ComparableEntry(option, target, -1, -1, strictOption, strictTarget); + ComparableEntry swapTo = new ComparableEntry(option2, target2, -1, -1, strictOption, strictTarget); removeSwap(swapFrom, swapTo); } @@ -703,7 +703,7 @@ public class MenuManager /** * Adds to the map of swaps - Pre-baked Abstract entry */ - public void addSwap(AbstractMenuEntry swapFrom, AbstractMenuEntry swapTo) + public void addSwap(ComparableEntry swapFrom, ComparableEntry swapTo) { if (swapTo.equals(swapFrom)) { @@ -726,8 +726,8 @@ public class MenuManager option2 = Text.standardize(option2); target2 = Text.standardize(target2); - AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, id, type, false, false); - AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, id2, type2, false, false); + ComparableEntry swapFrom = new ComparableEntry(option, target, id, type, false, false); + ComparableEntry swapTo = new ComparableEntry(option2, target2, id2, type2, false, false); if (swapTo.equals(swapFrom)) { @@ -746,11 +746,11 @@ public class MenuManager option2 = Text.standardize(option2); target2 = Text.standardize(target2); - AbstractMenuEntry swapFrom = new AbstractMenuEntry(option, target, id, type, false, false); - AbstractMenuEntry swapTo = new AbstractMenuEntry(option2, target2, id2, type2, false, false); + ComparableEntry swapFrom = new ComparableEntry(option, target, id, type, false, false); + ComparableEntry swapTo = new ComparableEntry(option2, target2, id2, type2, false, false); - Set toRemove = new HashSet<>(); - for (Map.Entry e : swaps.entrySet()) + Set toRemove = new HashSet<>(); + for (Map.Entry e : swaps.entrySet()) { if (e.getKey().equals(swapFrom) && e.getValue().equals(swapTo)) { @@ -758,16 +758,16 @@ public class MenuManager } } - for (AbstractMenuEntry entry : toRemove) + for (ComparableEntry entry : toRemove) { swaps.remove(entry); } } - public void removeSwap(AbstractMenuEntry swapFrom, AbstractMenuEntry swapTo) + public void removeSwap(ComparableEntry swapFrom, ComparableEntry swapTo) { - Set toRemove = new HashSet<>(); - for (Map.Entry e : swaps.entrySet()) + Set toRemove = new HashSet<>(); + for (Map.Entry e : swaps.entrySet()) { if (e.getKey().equals(swapFrom) && e.getValue().equals(swapTo)) { @@ -775,7 +775,7 @@ public class MenuManager } } - for (AbstractMenuEntry entry : toRemove) + for (ComparableEntry entry : toRemove) { swaps.remove(entry); } @@ -788,9 +788,9 @@ public class MenuManager { withTarget = Text.standardize(withTarget); - Set toRemove = new HashSet<>(); + Set toRemove = new HashSet<>(); - for (AbstractMenuEntry e : swaps.keySet()) + for (ComparableEntry e : swaps.keySet()) { if (e.getTarget().equals(withTarget)) { @@ -798,7 +798,7 @@ public class MenuManager } } - for (AbstractMenuEntry entry : toRemove) + for (ComparableEntry entry : toRemove) { swaps.remove(entry); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index f7359bd6b7..ca79318593 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -55,7 +55,7 @@ import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemVariationMapping; import net.runelite.client.input.KeyManager; -import net.runelite.client.menus.AbstractMenuEntry; +import net.runelite.client.menus.ComparableEntry; import net.runelite.client.menus.MenuManager; import net.runelite.client.menus.WidgetMenuOption; import net.runelite.client.plugins.Plugin; @@ -110,7 +110,7 @@ public class MenuEntrySwapperPlugin extends Plugin .omitEmptyStrings() .trimResults(); - private final Map customSwaps = new HashMap<>(); + private final Map customSwaps = new HashMap<>(); @Inject private Client client; @@ -762,7 +762,7 @@ else if (config.swapOccult() != OccultAltarMode.VENERATE && option.equals("vener private void loadCustomSwaps(String config) { - Map tmp = new HashMap<>(); + Map tmp = new HashMap<>(); if (!Strings.isNullOrEmpty(config)) { @@ -784,7 +784,7 @@ else if (config.swapOccult() != OccultAltarMode.VENERATE && option.equals("vener targetFrom = splitFrom[1].trim(); } - AbstractMenuEntry fromEntry = new AbstractMenuEntry(optionFrom, targetFrom); + ComparableEntry fromEntry = new ComparableEntry(optionFrom, targetFrom); String[] splitTo = Text.standardize(to).split(","); String optionTo = splitTo[0].trim(); @@ -798,26 +798,26 @@ else if (config.swapOccult() != OccultAltarMode.VENERATE && option.equals("vener targetTo = splitTo[1].trim(); } - AbstractMenuEntry toEntry = new AbstractMenuEntry(optionTo, targetTo); + ComparableEntry toEntry = new ComparableEntry(optionTo, targetTo); tmp.put(fromEntry, toEntry); } } - for (Map.Entry e : customSwaps.entrySet()) + for (Map.Entry e : customSwaps.entrySet()) { - AbstractMenuEntry key = e.getKey(); - AbstractMenuEntry value = e.getValue(); + ComparableEntry key = e.getKey(); + ComparableEntry value = e.getValue(); menuManager.removeSwap(key, value); } customSwaps.clear(); customSwaps.putAll(tmp); - for (Map.Entry entry : customSwaps.entrySet()) + for (Map.Entry entry : customSwaps.entrySet()) { - AbstractMenuEntry a1 = entry.getKey(); - AbstractMenuEntry a2 = entry.getValue(); + ComparableEntry a1 = entry.getKey(); + ComparableEntry a2 = entry.getValue(); menuManager.addSwap(a1, a2); } }