Fix a dumb error

This commit is contained in:
Lucas
2019-05-20 13:12:38 +02:00
parent 97afe462c2
commit 4f203b6507
4 changed files with 45 additions and 23 deletions

View File

@@ -1,11 +1,13 @@
package net.runelite.client.menus; package net.runelite.client.menus;
import joptsimple.internal.Strings; import joptsimple.internal.Strings;
import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import static net.runelite.client.menus.MenuManager.LEVEL_PATTERN; import static net.runelite.client.menus.MenuManager.LEVEL_PATTERN;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@EqualsAndHashCode
public class AbstractMenuEntry public class AbstractMenuEntry
{ {
@Getter @Getter
@@ -88,7 +90,7 @@ public class AbstractMenuEntry
return true; return true;
} }
boolean equals(AbstractMenuEntry other) /*boolean equals(AbstractMenuEntry other)
{ {
return target.equals(other.getTarget()) return target.equals(other.getTarget())
&& option.equals(other.getOption()) && option.equals(other.getOption())
@@ -96,5 +98,5 @@ public class AbstractMenuEntry
&& type == other.getType() && type == other.getType()
&& strictOption == other.isStrictOption() && strictOption == other.isStrictOption()
&& strictTarget == other.isStrictTarget(); && strictTarget == other.isStrictTarget();
} }*/
} }

View File

@@ -418,6 +418,29 @@ public class MenuManager
priorityEntries.add(entry); priorityEntries.add(entry);
} }
public void removePriorityEntry(String option, String target)
{
option = Text.standardize(option);
target = Text.standardize(target);
AbstractMenuEntry entry = new AbstractMenuEntry(option, target);
Set<AbstractMenuEntry> toRemove = new HashSet<>();
for (AbstractMenuEntry priorityEntry : priorityEntries)
{
if (entry.equals(priorityEntry))
{
toRemove.add(entry);
}
}
for (AbstractMenuEntry e : toRemove)
{
priorityEntries.remove(e);
}
}
/** /**
* Adds to the set of menu entries which when present, will remove all entries except for this one * Adds to the set of menu entries which when present, will remove all entries except for this one
* This method will add one with strict option, but not-strict target (contains for target, equals for option) * This method will add one with strict option, but not-strict target (contains for target, equals for option)
@@ -431,35 +454,25 @@ public class MenuManager
priorityEntries.add(entry); priorityEntries.add(entry);
} }
public void removePriorityEntry(String option, String target)
{
option = Text.standardize(option);
target = Text.standardize(target);
AbstractMenuEntry entry = new AbstractMenuEntry(option, target);
for (AbstractMenuEntry priorityEntry : priorityEntries)
{
if (entry.equals(priorityEntry))
{
priorityEntries.remove(priorityEntry);
}
}
}
public void removePriorityEntry(String option) public void removePriorityEntry(String option)
{ {
option = Text.standardize(option); option = Text.standardize(option);
AbstractMenuEntry entry = new AbstractMenuEntry(option, "", false); AbstractMenuEntry entry = new AbstractMenuEntry(option, "", false);
Set<AbstractMenuEntry> toRemove = new HashSet<>();
for (AbstractMenuEntry priorityEntry : priorityEntries) for (AbstractMenuEntry priorityEntry : priorityEntries)
{ {
if (entry.equals(priorityEntry)) if (entry.equals(priorityEntry))
{ {
priorityEntries.remove(priorityEntry); toRemove.add(entry);
} }
} }
for (AbstractMenuEntry e : toRemove)
{
priorityEntries.remove(e);
}
} }
/** /**
@@ -515,12 +528,18 @@ public class MenuManager
public void removeSwap(AbstractMenuEntry swapFrom, AbstractMenuEntry swapTo) public void removeSwap(AbstractMenuEntry swapFrom, AbstractMenuEntry swapTo)
{ {
Set<AbstractMenuEntry> toRemove = new HashSet<>();
for (Map.Entry<AbstractMenuEntry, AbstractMenuEntry> e : swaps.entrySet()) for (Map.Entry<AbstractMenuEntry, AbstractMenuEntry> e : swaps.entrySet())
{ {
if (e.getKey().equals(swapFrom) && e.getValue().equals(swapTo)) if (e.getKey().equals(swapFrom) && e.getValue().equals(swapTo))
{ {
swaps.remove(e.getKey()); toRemove.add(e.getKey());
} }
} }
for (AbstractMenuEntry entry : toRemove)
{
swaps.remove(entry);
}
} }
} }

View File

@@ -48,7 +48,7 @@ import net.runelite.client.plugins.PluginType;
public class ShiftWalkerPlugin extends Plugin public class ShiftWalkerPlugin extends Plugin
{ {
private static final String WALK_HERE = "WALK HERE"; private static final String WALK_HERE = "Walk here";
@Inject @Inject
private ShiftWalkerConfig config; private ShiftWalkerConfig config;
@@ -91,11 +91,11 @@ public class ShiftWalkerPlugin extends Plugin
void startPrioritizing() void startPrioritizing()
{ {
menuManager.addPriorityEntry(WALK_HERE, ""); menuManager.addPriorityEntry(WALK_HERE);
} }
void stopPrioritizing() void stopPrioritizing()
{ {
menuManager.removePriorityEntry(WALK_HERE, ""); menuManager.removePriorityEntry(WALK_HERE);
} }
} }

View File

@@ -33,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
@Deprecated
@Slf4j @Slf4j
public class MenuUtil public class MenuUtil
{ {