Fix shift walk under bug (#740)

This commit is contained in:
Lucwousin
2019-06-25 07:31:48 +02:00
committed by James
parent d793312cf4
commit 2006f52219
7 changed files with 82 additions and 41 deletions

View File

@@ -570,6 +570,11 @@ public interface Client extends GameShell
*/
MenuEntry[] getMenuEntries();
/**
* @return amount of menu entries the client has (same as client.getMenuEntries().size())
*/
int getMenuOptionCount();
/**
* Sets the array of open menu entries.
* <p>

View File

@@ -55,4 +55,5 @@ public class GraphicID
public static final int OLM_HEAL = 1363;
public static final int OLM_CRYSTAL = 1447;
public static final int XERIC_TELEPORT = 1612;
public static final int HYDRA_LIGHTNING = 1666;
}

View File

@@ -24,12 +24,16 @@
*/
package net.runelite.api;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/**
* A menu entry in a right-click menu.
*/
@Data
@AllArgsConstructor
@RequiredArgsConstructor
public class MenuEntry
{
/**

View File

@@ -26,6 +26,7 @@ package net.runelite.api.events;
import lombok.AllArgsConstructor;
import lombok.Data;
import net.runelite.api.MenuEntry;
/**
* An event when a new entry is added to a right-click menu.
@@ -35,30 +36,42 @@ import lombok.Data;
public class MenuEntryAdded
{
/**
* The option text added to the menu (ie. "Walk here", "Use").
* The MenuEntry object that was actually added
*/
private final String option;
/**
* The target of the action (ie. Item or Actor name).
* <p>
* If the option does not apply to any target, this field
* will be set to empty string.
*/
private final String target;
/**
* The action type that will be triggered.
*/
private final int type;
/**
* An identifier value for the target of the action
*/
private final int identifier;
/**
* An additional parameter for the action.
*/
private final int actionParam0;
/**
* A second additional parameter for the action.
*/
private final int actionParam1;
private final MenuEntry menuEntry;
public String getOption()
{
return menuEntry.getOption();
}
public String getTarget()
{
return menuEntry.getTarget();
}
public int getType()
{
return menuEntry.getType();
}
public int getIdentifier()
{
return menuEntry.getIdentifier();
}
public int getActionParam0()
{
return menuEntry.getParam0();
}
public int getActionParam1()
{
return menuEntry.getParam1();
}
public boolean isForceLeftClick()
{
return menuEntry.isForceLeftClick();
}
}

View File

@@ -173,22 +173,14 @@ public class MenuManager
final MenuEntry newestEntry = menuEntries[menuEntries.length - 1];
boolean isPrio = false;
for (ComparableEntry p : priorityEntries)
{
if (p.matches(newestEntry))
{
isPrio = true;
break;
currentPriorityEntries.add(newestEntry);
}
}
// If the last entry was a priority entry, keep track of it
if (isPrio)
{
currentPriorityEntries.add(newestEntry);
}
// Make a copy of the menu entries, cause you can't remove from Arrays.asList()
List<MenuEntry> copy = Lists.newArrayList(menuEntries);
@@ -197,7 +189,29 @@ public class MenuManager
{
copy.retainAll(currentPriorityEntries);
copy.add(0, CANCEL());
// This is because players existing changes walk-here target
// so without this we lose track of em
if (copy.size() != currentPriorityEntries.size())
{
for (MenuEntry e : currentPriorityEntries)
{
if (copy.contains(e))
{
continue;
}
for (MenuEntry e2 : client.getMenuEntries())
{
if (e.getType() == e2.getType())
{
e.setTarget(e2.getTarget());
copy.add(e);
}
}
}
}
copy.add(CANCEL());
}
// Find the current entry in the swaps map

View File

@@ -645,12 +645,15 @@ public abstract class RSClientMixin implements RSClient
if (newCount == oldCount + 1)
{
MenuEntryAdded event = new MenuEntryAdded(
client.getMenuOptions()[newCount - 1],
client.getMenuTargets()[newCount - 1],
client.getMenuTypes()[newCount - 1],
client.getMenuIdentifiers()[newCount - 1],
client.getMenuActionParams0()[newCount - 1],
client.getMenuActionParams1()[newCount - 1]
new MenuEntry(
client.getMenuOptions()[oldCount],
client.getMenuTargets()[oldCount],
client.getMenuTypes()[oldCount],
client.getMenuIdentifiers()[oldCount],
client.getMenuActionParams0()[oldCount],
client.getMenuActionParams1()[oldCount],
client.getMenuForceLeftClick()[oldCount]
)
);
client.getCallbacks().post(event);

View File

@@ -298,6 +298,7 @@ public interface RSClient extends RSGameShell, Client
boolean isCheckClick();
@Import("menuOptionsCount")
@Override
int getMenuOptionCount();
@Import("menuOptionsCount")