menumanager: fix swaps with high ids
This commit is contained in:
@@ -64,8 +64,8 @@ public class ComparableEntry
|
||||
|
||||
public ComparableEntry(String option, String target, int id, int type, boolean strictOption, boolean strictTarget)
|
||||
{
|
||||
this.option = option;
|
||||
this.target = target;
|
||||
this.option = Text.standardize(option);
|
||||
this.target = Text.standardize(target);
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.strictOption = strictOption;
|
||||
@@ -76,12 +76,11 @@ public class ComparableEntry
|
||||
// target sometimes changes to option.
|
||||
public ComparableEntry(MenuEntry e)
|
||||
{
|
||||
this.option = e.getOption();
|
||||
this.option = Text.standardize(e.getOption());
|
||||
this.id = e.getIdentifier();
|
||||
this.type = e.getType();
|
||||
this.strictOption = true;
|
||||
}
|
||||
|
||||
boolean matches(MenuEntry entry)
|
||||
{
|
||||
String opt = Text.standardize(entry.getOption());
|
||||
|
||||
@@ -750,7 +750,7 @@ public class MenuManager
|
||||
{
|
||||
MenuEntry entry = event.getMenuEntry();
|
||||
|
||||
if (!entry.getTarget().equals(entry.getOption()) && !comparable.matches(entry))
|
||||
if (event.getTarget().equals("do not edit") || !comparable.matches(entry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -873,57 +873,29 @@ public interface MenuEntrySwapperConfig extends Config
|
||||
return "";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------//
|
||||
|
||||
/* @ConfigItem(
|
||||
keyName = "easyConstruction",
|
||||
name = "Easy Construction",
|
||||
description = "Makes 'Remove'/'Build' the default option for listed item ID's in build mode.<br>Tip: Use dev tools \"'Game Objects\" to find out the ID!",
|
||||
position = 59,
|
||||
group = "Skilling"
|
||||
)
|
||||
default boolean getEasyConstruction()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "constructionItems",
|
||||
name = "Construction Items",
|
||||
description = "Makes 'Remove'/'Build' the default option for listed item ID's in build mode.<br>Tip: Use dev tools \"Game Objects\" to find out the ID, and separate values with a ','",
|
||||
position = 60,
|
||||
group = "Skilling",
|
||||
hidden = true,
|
||||
unhide = "easyConstruction"
|
||||
)
|
||||
default String getConstructionItems()
|
||||
{
|
||||
return "";
|
||||
}*/
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "getTempConstruction",
|
||||
keyName = "getEasyConstruction",
|
||||
name = "Easy Construction",
|
||||
description = "Makes 'Remove'/'Build' the default option for listed items.",
|
||||
position = 64,
|
||||
group = "Skilling"
|
||||
)
|
||||
|
||||
default boolean getTempConstruction()
|
||||
default boolean getEasyConstruction()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "getTempConstructionItems",
|
||||
keyName = "getEasyConstructionItems",
|
||||
name = "Build Items",
|
||||
description = "",
|
||||
position = 65,
|
||||
group = "Skilling",
|
||||
hidden = true,
|
||||
unhide = "getTempConstruction"
|
||||
unhide = "getEasyConstruction"
|
||||
)
|
||||
default String getTempConstructionItems()
|
||||
default String getEasyConstructionItems()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
private static final int PURO_PURO_REGION_ID = 10307;
|
||||
|
||||
private MenuEntry[] entries;
|
||||
private final Set<Integer> leftClickConstructionIDs = new HashSet<>();
|
||||
private final Set<String> leftClickConstructionItems = new HashSet<>();
|
||||
private boolean buildingMode;
|
||||
|
||||
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
|
||||
@@ -183,8 +183,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
public void startUp()
|
||||
{
|
||||
addSwaps();
|
||||
//todo re-enable when fixed.
|
||||
/*loadConstructionIDs(config.getConstructionItems());*/
|
||||
loadConstructionItems(config.getEasyConstructionItems());
|
||||
|
||||
if (config.shiftClickCustomization())
|
||||
{
|
||||
@@ -198,8 +197,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
public void shutDown()
|
||||
{
|
||||
disableCustomization();
|
||||
//todo re-enable when fixed.
|
||||
/*loadConstructionIDs("");*/
|
||||
loadConstructionItems("");
|
||||
loadCustomSwaps(""); // Removes all custom swaps
|
||||
removeSwaps();
|
||||
}
|
||||
@@ -211,9 +209,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
//todo re-enable when fixed.
|
||||
|
||||
/*loadConstructionIDs(config.getConstructionItems());*/
|
||||
loadConstructionItems(config.getEasyConstructionItems());
|
||||
removeSwaps();
|
||||
addSwaps();
|
||||
|
||||
@@ -308,9 +305,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
//todo re-enable when fixed.
|
||||
|
||||
/*loadConstructionIDs(config.getConstructionItems());*/
|
||||
loadConstructionItems(config.getEasyConstructionItems());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -1208,37 +1204,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
{
|
||||
swap(client, "teleport menu", option, target, true);
|
||||
}
|
||||
|
||||
if (config.getTempConstruction() && buildingMode && !Strings.isNullOrEmpty(config.getTempConstructionItems()))
|
||||
{
|
||||
if (event.getType() == WALK.getId())
|
||||
{
|
||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||
MenuEntry menuEntry = menuEntries[menuEntries.length - 1];
|
||||
menuEntry.setType(MenuAction.WALK.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET);
|
||||
client.setMenuEntries(menuEntries);
|
||||
}
|
||||
|
||||
swap(client, "Build", option, target);
|
||||
|
||||
MenuEntry[] entries = client.getMenuEntries();
|
||||
for (int i = entries.length - 1; i >= 0; i--)
|
||||
{
|
||||
for (String temp : config.getTempConstructionItems().split(","))
|
||||
{
|
||||
if (temp.equalsIgnoreCase(Text.removeTags(entries[i].getTarget())))
|
||||
{
|
||||
if (!entries[i].getOption().equalsIgnoreCase("remove"))
|
||||
{
|
||||
entries = ArrayUtils.remove(entries, i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client.setMenuEntries(entries);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -1482,25 +1447,24 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
return location.getRegionID() == PURO_PURO_REGION_ID;
|
||||
}
|
||||
}
|
||||
//todo re-enable when fixed.
|
||||
|
||||
/* private void loadConstructionIDs(String from)
|
||||
private void loadConstructionItems(String from)
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN
|
||||
|| Strings.isNullOrEmpty(from) && leftClickConstructionIDs.isEmpty())
|
||||
|| Strings.isNullOrEmpty(from) && leftClickConstructionItems.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!leftClickConstructionIDs.isEmpty())
|
||||
if (!leftClickConstructionItems.isEmpty())
|
||||
{
|
||||
for (int i : leftClickConstructionIDs)
|
||||
for (String s : leftClickConstructionItems)
|
||||
{
|
||||
menuManager.toggleLeftClick("build", i, true);
|
||||
menuManager.toggleLeftClick("remove", i, true);
|
||||
menuManager.removePriorityEntry("build", s);
|
||||
menuManager.removePriorityEntry("remove", s);
|
||||
}
|
||||
|
||||
leftClickConstructionIDs.clear();
|
||||
leftClickConstructionItems.clear();
|
||||
}
|
||||
|
||||
if (config.getEasyConstruction() &&
|
||||
@@ -1509,21 +1473,18 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
{
|
||||
for (String s : Text.fromCSV(from))
|
||||
{
|
||||
int id = Integer.parseInt(s.replaceAll("[^0-9]", ""));
|
||||
|
||||
if (leftClickConstructionIDs.contains(id))
|
||||
if (leftClickConstructionItems.contains(s))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (menuManager.toggleLeftClick("build", id, false)
|
||||
|| menuManager.toggleLeftClick("remove", id, false))
|
||||
{
|
||||
leftClickConstructionIDs.add(id);
|
||||
}
|
||||
menuManager.addPriorityEntry("build", s);
|
||||
menuManager.addPriorityEntry("remove", s);
|
||||
|
||||
leftClickConstructionItems.add(s);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void startShift()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user