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)
|
public ComparableEntry(String option, String target, int id, int type, boolean strictOption, boolean strictTarget)
|
||||||
{
|
{
|
||||||
this.option = option;
|
this.option = Text.standardize(option);
|
||||||
this.target = target;
|
this.target = Text.standardize(target);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.strictOption = strictOption;
|
this.strictOption = strictOption;
|
||||||
@@ -76,12 +76,11 @@ public class ComparableEntry
|
|||||||
// target sometimes changes to option.
|
// target sometimes changes to option.
|
||||||
public ComparableEntry(MenuEntry e)
|
public ComparableEntry(MenuEntry e)
|
||||||
{
|
{
|
||||||
this.option = e.getOption();
|
this.option = Text.standardize(e.getOption());
|
||||||
this.id = e.getIdentifier();
|
this.id = e.getIdentifier();
|
||||||
this.type = e.getType();
|
this.type = e.getType();
|
||||||
this.strictOption = true;
|
this.strictOption = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean matches(MenuEntry entry)
|
boolean matches(MenuEntry entry)
|
||||||
{
|
{
|
||||||
String opt = Text.standardize(entry.getOption());
|
String opt = Text.standardize(entry.getOption());
|
||||||
|
|||||||
@@ -750,7 +750,7 @@ public class MenuManager
|
|||||||
{
|
{
|
||||||
MenuEntry entry = event.getMenuEntry();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -873,57 +873,29 @@ public interface MenuEntrySwapperConfig extends Config
|
|||||||
return "";
|
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(
|
@ConfigItem(
|
||||||
keyName = "constructionItems",
|
keyName = "getEasyConstruction",
|
||||||
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",
|
|
||||||
name = "Easy Construction",
|
name = "Easy Construction",
|
||||||
description = "Makes 'Remove'/'Build' the default option for listed items.",
|
description = "Makes 'Remove'/'Build' the default option for listed items.",
|
||||||
position = 64,
|
position = 64,
|
||||||
group = "Skilling"
|
group = "Skilling"
|
||||||
)
|
)
|
||||||
|
|
||||||
default boolean getTempConstruction()
|
default boolean getEasyConstruction()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "getTempConstructionItems",
|
keyName = "getEasyConstructionItems",
|
||||||
name = "Build Items",
|
name = "Build Items",
|
||||||
description = "",
|
description = "",
|
||||||
position = 65,
|
position = 65,
|
||||||
group = "Skilling",
|
group = "Skilling",
|
||||||
hidden = true,
|
hidden = true,
|
||||||
unhide = "getTempConstruction"
|
unhide = "getEasyConstruction"
|
||||||
)
|
)
|
||||||
default String getTempConstructionItems()
|
default String getEasyConstructionItems()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
private static final int PURO_PURO_REGION_ID = 10307;
|
private static final int PURO_PURO_REGION_ID = 10307;
|
||||||
|
|
||||||
private MenuEntry[] entries;
|
private MenuEntry[] entries;
|
||||||
private final Set<Integer> leftClickConstructionIDs = new HashSet<>();
|
private final Set<String> leftClickConstructionItems = new HashSet<>();
|
||||||
private boolean buildingMode;
|
private boolean buildingMode;
|
||||||
|
|
||||||
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
|
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
|
||||||
@@ -183,8 +183,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
public void startUp()
|
public void startUp()
|
||||||
{
|
{
|
||||||
addSwaps();
|
addSwaps();
|
||||||
//todo re-enable when fixed.
|
loadConstructionItems(config.getEasyConstructionItems());
|
||||||
/*loadConstructionIDs(config.getConstructionItems());*/
|
|
||||||
|
|
||||||
if (config.shiftClickCustomization())
|
if (config.shiftClickCustomization())
|
||||||
{
|
{
|
||||||
@@ -198,8 +197,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
public void shutDown()
|
public void shutDown()
|
||||||
{
|
{
|
||||||
disableCustomization();
|
disableCustomization();
|
||||||
//todo re-enable when fixed.
|
loadConstructionItems("");
|
||||||
/*loadConstructionIDs("");*/
|
|
||||||
loadCustomSwaps(""); // Removes all custom swaps
|
loadCustomSwaps(""); // Removes all custom swaps
|
||||||
removeSwaps();
|
removeSwaps();
|
||||||
}
|
}
|
||||||
@@ -211,9 +209,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//todo re-enable when fixed.
|
|
||||||
|
|
||||||
/*loadConstructionIDs(config.getConstructionItems());*/
|
loadConstructionItems(config.getEasyConstructionItems());
|
||||||
removeSwaps();
|
removeSwaps();
|
||||||
addSwaps();
|
addSwaps();
|
||||||
|
|
||||||
@@ -308,9 +305,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//todo re-enable when fixed.
|
|
||||||
|
|
||||||
/*loadConstructionIDs(config.getConstructionItems());*/
|
loadConstructionItems(config.getEasyConstructionItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -1208,37 +1204,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
swap(client, "teleport menu", option, target, true);
|
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
|
@Subscribe
|
||||||
@@ -1482,25 +1447,24 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
return location.getRegionID() == PURO_PURO_REGION_ID;
|
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
|
if (client.getGameState() != GameState.LOGGED_IN
|
||||||
|| Strings.isNullOrEmpty(from) && leftClickConstructionIDs.isEmpty())
|
|| Strings.isNullOrEmpty(from) && leftClickConstructionItems.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!leftClickConstructionIDs.isEmpty())
|
if (!leftClickConstructionItems.isEmpty())
|
||||||
{
|
{
|
||||||
for (int i : leftClickConstructionIDs)
|
for (String s : leftClickConstructionItems)
|
||||||
{
|
{
|
||||||
menuManager.toggleLeftClick("build", i, true);
|
menuManager.removePriorityEntry("build", s);
|
||||||
menuManager.toggleLeftClick("remove", i, true);
|
menuManager.removePriorityEntry("remove", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
leftClickConstructionIDs.clear();
|
leftClickConstructionItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getEasyConstruction() &&
|
if (config.getEasyConstruction() &&
|
||||||
@@ -1509,21 +1473,18 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
for (String s : Text.fromCSV(from))
|
for (String s : Text.fromCSV(from))
|
||||||
{
|
{
|
||||||
int id = Integer.parseInt(s.replaceAll("[^0-9]", ""));
|
if (leftClickConstructionItems.contains(s))
|
||||||
|
|
||||||
if (leftClickConstructionIDs.contains(id))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menuManager.toggleLeftClick("build", id, false)
|
menuManager.addPriorityEntry("build", s);
|
||||||
|| menuManager.toggleLeftClick("remove", id, false))
|
menuManager.addPriorityEntry("remove", s);
|
||||||
{
|
|
||||||
leftClickConstructionIDs.add(id);
|
leftClickConstructionItems.add(s);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
void startShift()
|
void startShift()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user