api: add player accessor to menuentry
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class MenuEntrySwapperPluginTest
|
||||
menuEntry.setTarget(target);
|
||||
menuEntry.setType(menuAction);
|
||||
menuEntry.setIdentifier(identifier);
|
||||
menuEntry.setNpc(npc);
|
||||
menuEntry.setActor(npc);
|
||||
return menuEntry;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user