api: add player accessor to menuentry

This commit is contained in:
Adam
2022-05-23 17:42:14 -04:00
parent 7a1d958ee0
commit 5367d225bf
6 changed files with 36 additions and 9 deletions

View File

@@ -28,9 +28,11 @@ import java.util.function.Consumer;
import javax.annotation.Nullable;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import net.runelite.api.Actor;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.api.widgets.Widget;
@EqualsAndHashCode
@@ -50,7 +52,7 @@ public class TestMenuEntry implements MenuEntry
@Setter
private Widget widget;
@Setter
private NPC npc;
private Actor actor;
@Override
public String getOption()
@@ -205,6 +207,20 @@ public class TestMenuEntry implements MenuEntry
@Override
public NPC getNpc()
{
return npc;
return actor instanceof NPC ? (NPC) actor : null;
}
@Nullable
@Override
public Player getPlayer()
{
return actor instanceof Player ? (Player) actor : null;
}
@Nullable
@Override
public Actor getActor()
{
return actor;
}
}

View File

@@ -129,7 +129,7 @@ public class MenuEntrySwapperPluginTest
menuEntry.setTarget(target);
menuEntry.setType(menuAction);
menuEntry.setIdentifier(identifier);
menuEntry.setNpc(npc);
menuEntry.setActor(npc);
return menuEntry;
}

View File

@@ -109,7 +109,7 @@ public class NpcIndicatorsPluginTest
TestMenuEntry entry = new TestMenuEntry();
entry.setTarget("Goblin");
entry.setIdentifier(MenuAction.NPC_FIRST_OPTION.getId());
entry.setNpc(npc);
entry.setActor(npc);
MenuEntryAdded menuEntryAdded = new MenuEntryAdded(entry);
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
@@ -133,7 +133,7 @@ public class NpcIndicatorsPluginTest
TestMenuEntry entry = new TestMenuEntry();
entry.setTarget("Goblin");
entry.setIdentifier(MenuAction.NPC_FIRST_OPTION.getId());
entry.setNpc(npc);
entry.setActor(npc);
MenuEntryAdded menuEntryAdded = new MenuEntryAdded(entry);
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);