Merge branch 'upstream-master' into runelite
# Conflicts: # cache-client/pom.xml # cache-updater/pom.xml # cache/pom.xml # http-api/pom.xml # http-service/pom.xml # pom.xml # runelite-api/pom.xml # runelite-api/src/main/java/net/runelite/api/Client.java # runelite-api/src/main/java/net/runelite/api/events/MenuEntryAdded.java # runelite-api/src/main/java/net/runelite/api/events/NpcActionChanged.java # runelite-api/src/main/java/net/runelite/api/events/PlayerMenuOptionClicked.java # runelite-client/pom.xml # runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java # runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java # runelite-script-assembler-plugin/pom.xml
This commit is contained in:
@@ -237,7 +237,7 @@ public enum AgilityShortcut
|
||||
@Getter
|
||||
private final int level;
|
||||
/**
|
||||
* Brief description of the shortcut (e.g. 'Rocks', 'Stepping Stones', 'Jump')
|
||||
* Brief description of the shortcut. (e.g. 'Rocks', 'Stepping Stones', 'Jump')
|
||||
*/
|
||||
@Getter
|
||||
private final String description;
|
||||
|
||||
@@ -26,33 +26,25 @@ package net.runelite.client.menus;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.IconID;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.NPCComposition;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.events.NpcActionChanged;
|
||||
import net.runelite.api.events.PlayerMenuOptionClicked;
|
||||
import net.runelite.api.events.PlayerMenuOptionsChanged;
|
||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -64,16 +56,13 @@ public class MenuManager
|
||||
private static final int IDX_LOWER = 4;
|
||||
private static final int IDX_UPPER = 8;
|
||||
|
||||
private static final Pattern BOUNTY_EMBLEM_TAG_AND_TIER_REGEXP = Pattern.compile(String.format("%s[1-9]0?", IconID.BOUNTY_HUNTER_EMBLEM.toString()));
|
||||
|
||||
private final Client client;
|
||||
private final EventBus eventBus;
|
||||
|
||||
//Maps the indexes that are being used to the menu option.
|
||||
private final Map<Integer, String> playerMenuIndexMap = new HashMap<>();
|
||||
//Used to manage custom non-player menu options
|
||||
private final Multimap<Integer, WidgetMenuOption> managedMenuOptions = HashMultimap.create();
|
||||
private final Set<String> npcMenuOptions = new HashSet<>();
|
||||
private final Multimap<Integer, WidgetMenuOption> managedMenuOptions = LinkedHashMultimap.create();
|
||||
|
||||
@Inject
|
||||
@VisibleForTesting
|
||||
@@ -123,7 +112,7 @@ public class MenuManager
|
||||
@Subscribe
|
||||
public void onMenuEntryAdded(MenuEntryAdded event)
|
||||
{
|
||||
if (client.getSpellSelected())
|
||||
if (client.getSpellSelected() || event.getType() != MenuAction.CC_OP.getId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -200,45 +189,12 @@ public class MenuManager
|
||||
addPlayerMenuItem(newIdx, menuText);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onNpcActionChanged(NpcActionChanged event)
|
||||
{
|
||||
NPCComposition composition = event.getNpcComposition();
|
||||
for (String npcOption : npcMenuOptions)
|
||||
{
|
||||
addNpcOption(composition, npcOption);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNpcOption(NPCComposition composition, String npcOption)
|
||||
{
|
||||
String[] actions = composition.getActions();
|
||||
int unused = -1;
|
||||
for (int i = 0; i < actions.length; ++i)
|
||||
{
|
||||
if (actions[i] == null && unused == -1)
|
||||
{
|
||||
unused = i;
|
||||
}
|
||||
else if (actions[i] != null && actions[i].equals(npcOption))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (unused == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
actions[unused] = npcOption;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||
{
|
||||
if (event.getMenuAction() != MenuAction.RUNELITE
|
||||
&& event.getMenuAction() != MenuAction.RUNELITE_PLAYER)
|
||||
if (event.getMenuAction() != MenuAction.RUNELITE)
|
||||
{
|
||||
return; // not a managed widget option or custom player option
|
||||
return;
|
||||
}
|
||||
|
||||
int widgetId = event.getWidgetId();
|
||||
@@ -254,23 +210,9 @@ public class MenuManager
|
||||
customMenu.setMenuTarget(event.getMenuTarget());
|
||||
customMenu.setWidget(curMenuOption.getWidget());
|
||||
eventBus.post(customMenu);
|
||||
return; // don't continue because it's not a player option
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// removes bounty hunter emblem tag and tier from player name, e.g:
|
||||
// "username<img=20>5<col=40ff00> (level-42)" -> "username<col=40ff00> (level-42)"
|
||||
String target = BOUNTY_EMBLEM_TAG_AND_TIER_REGEXP.matcher(event.getMenuTarget()).replaceAll("");
|
||||
|
||||
// removes tags and level from player names for example:
|
||||
// <col=ffffff>username<col=40ff00> (level-42) or <col=ffffff><img=2>username</col>
|
||||
String username = Text.removeTags(target).split("[(]")[0].trim();
|
||||
|
||||
PlayerMenuOptionClicked playerMenuOptionClicked = new PlayerMenuOptionClicked();
|
||||
playerMenuOptionClicked.setMenuOption(event.getMenuOption());
|
||||
playerMenuOptionClicked.setMenuTarget(username);
|
||||
|
||||
eventBus.post(playerMenuOptionClicked);
|
||||
}
|
||||
|
||||
private void addPlayerMenuItem(int playerOptionIndex, String menuText)
|
||||
|
||||
@@ -33,11 +33,11 @@ import net.runelite.client.util.ColorUtil;
|
||||
public final class WidgetMenuOption
|
||||
{
|
||||
/**
|
||||
* The left hand text to be displayed on the menu option. Ex. the menuOption of "Drop Bones" is "Drop"
|
||||
* The left hand text to be displayed on the menu option. (ex. the menuOption of "Drop Bones" is "Drop")
|
||||
*/
|
||||
private String menuOption;
|
||||
/**
|
||||
* The right hand text to be displayed on the menu option Ex. the menuTarget of "Drop Bones" is "Bones"
|
||||
* The right hand text to be displayed on the menu option. (ex. the menuTarget of "Drop Bones" is "Bones")
|
||||
*/
|
||||
private String menuTarget;
|
||||
/**
|
||||
|
||||
@@ -470,7 +470,7 @@ enum DiscordGameEventType
|
||||
private int priority;
|
||||
|
||||
/**
|
||||
* Marks this event as root event, e.g event that should be used for total time tracking
|
||||
* Marks this event as root event. (eg. event that should be used for total time tracking)
|
||||
*/
|
||||
private boolean root;
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -98,7 +99,13 @@ public class GroundMarkerPlugin extends Plugin
|
||||
@Inject
|
||||
private ChatboxPanelManager chatboxPanelManager;
|
||||
|
||||
private void savePoints(int regionId, Collection<GroundMarkerPoint> points)
|
||||
@Inject
|
||||
private EventBus eventBus;
|
||||
|
||||
@Inject
|
||||
private GroundMarkerSharingManager sharingManager;
|
||||
|
||||
void savePoints(int regionId, Collection<GroundMarkerPoint> points)
|
||||
{
|
||||
if (points == null || points.isEmpty())
|
||||
{
|
||||
@@ -110,7 +117,7 @@ public class GroundMarkerPlugin extends Plugin
|
||||
configManager.setConfiguration(CONFIG_GROUP, REGION_PREFIX + regionId, json);
|
||||
}
|
||||
|
||||
private Collection<GroundMarkerPoint> getPoints(int regionId)
|
||||
Collection<GroundMarkerPoint> getPoints(int regionId)
|
||||
{
|
||||
String json = configManager.getConfiguration(CONFIG_GROUP, REGION_PREFIX + regionId);
|
||||
if (Strings.isNullOrEmpty(json))
|
||||
@@ -129,7 +136,7 @@ public class GroundMarkerPlugin extends Plugin
|
||||
return configManager.getConfig(GroundMarkerConfig.class);
|
||||
}
|
||||
|
||||
private void loadPoints()
|
||||
void loadPoints()
|
||||
{
|
||||
points.clear();
|
||||
|
||||
@@ -181,14 +188,18 @@ public class GroundMarkerPlugin extends Plugin
|
||||
{
|
||||
overlayManager.add(overlay);
|
||||
overlayManager.add(minimapOverlay);
|
||||
sharingManager.addMenuOptions();
|
||||
loadPoints();
|
||||
eventBus.register(sharingManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown()
|
||||
{
|
||||
eventBus.unregister(sharingManager);
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.remove(minimapOverlay);
|
||||
sharingManager.removeMenuOptions();
|
||||
points.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.groundmarkers;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_OPTION;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.chat.QueuedMessage;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.menus.WidgetMenuOption;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
|
||||
@Slf4j
|
||||
class GroundMarkerSharingManager
|
||||
{
|
||||
private static final WidgetMenuOption EXPORT_MARKERS_OPTION = new WidgetMenuOption("Export", "Ground Markers", WORLD_MAP_OPTION);
|
||||
private static final WidgetMenuOption IMPORT_MARKERS_OPTION = new WidgetMenuOption("Import", "Ground Markers", WORLD_MAP_OPTION);
|
||||
|
||||
private static final Gson GSON = RuneLiteAPI.GSON;
|
||||
|
||||
private final GroundMarkerPlugin plugin;
|
||||
private final Client client;
|
||||
private final MenuManager menuManager;
|
||||
private final ChatMessageManager chatMessageManager;
|
||||
private final ChatboxPanelManager chatboxPanelManager;
|
||||
|
||||
@Inject
|
||||
private GroundMarkerSharingManager(GroundMarkerPlugin plugin, Client client, MenuManager menuManager, ChatMessageManager chatMessageManager, ChatboxPanelManager chatboxPanelManager)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.client = client;
|
||||
this.menuManager = menuManager;
|
||||
this.chatMessageManager = chatMessageManager;
|
||||
this.chatboxPanelManager = chatboxPanelManager;
|
||||
}
|
||||
|
||||
void addMenuOptions()
|
||||
{
|
||||
menuManager.addManagedCustomMenu(EXPORT_MARKERS_OPTION);
|
||||
menuManager.addManagedCustomMenu(IMPORT_MARKERS_OPTION);
|
||||
}
|
||||
|
||||
void removeMenuOptions()
|
||||
{
|
||||
menuManager.removeManagedCustomMenu(EXPORT_MARKERS_OPTION);
|
||||
menuManager.removeManagedCustomMenu(IMPORT_MARKERS_OPTION);
|
||||
}
|
||||
|
||||
private boolean widgetMenuClickedEquals(final WidgetMenuOptionClicked event, final WidgetMenuOption target)
|
||||
{
|
||||
return event.getMenuTarget().equals(target.getMenuTarget()) &&
|
||||
event.getMenuOption().equals(target.getMenuOption());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event)
|
||||
{
|
||||
// ensure that the option clicked is the export markers option
|
||||
if (event.getWidget() != WORLD_MAP_OPTION)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (widgetMenuClickedEquals(event, EXPORT_MARKERS_OPTION))
|
||||
{
|
||||
exportGroundMarkers();
|
||||
}
|
||||
else if (widgetMenuClickedEquals(event, IMPORT_MARKERS_OPTION))
|
||||
{
|
||||
promptForImport();
|
||||
}
|
||||
}
|
||||
|
||||
private void exportGroundMarkers()
|
||||
{
|
||||
int[] regions = client.getMapRegions();
|
||||
if (regions == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<GroundMarkerPoint> activePoints = Arrays.stream(regions)
|
||||
.mapToObj(regionId -> plugin.getPoints(regionId).stream())
|
||||
.flatMap(Function.identity())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (activePoints.isEmpty())
|
||||
{
|
||||
sendChatMessage("You have no ground markers to export.");
|
||||
return;
|
||||
}
|
||||
|
||||
final String exportDump = GSON.toJson(activePoints);
|
||||
|
||||
log.debug("Exported ground markers: {}", exportDump);
|
||||
|
||||
Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard()
|
||||
.setContents(new StringSelection(exportDump), null);
|
||||
sendChatMessage(activePoints.size() + " ground markers were copied to your clipboard.");
|
||||
}
|
||||
|
||||
private void promptForImport()
|
||||
{
|
||||
final String clipboardText;
|
||||
try
|
||||
{
|
||||
clipboardText = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard()
|
||||
.getData(DataFlavor.stringFlavor)
|
||||
.toString();
|
||||
}
|
||||
catch (IOException | UnsupportedFlavorException ex)
|
||||
{
|
||||
sendChatMessage("Unable to read system clipboard.");
|
||||
log.warn("error reading clipboard", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Clipboard contents: {}", clipboardText);
|
||||
if (Strings.isNullOrEmpty(clipboardText))
|
||||
{
|
||||
sendChatMessage("You do not have any ground markers copied in your clipboard.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<GroundMarkerPoint> importPoints;
|
||||
try
|
||||
{
|
||||
// CHECKSTYLE:OFF
|
||||
importPoints = GSON.fromJson(clipboardText, new TypeToken<List<GroundMarkerPoint>>(){}.getType());
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
catch (JsonSyntaxException e)
|
||||
{
|
||||
log.debug("Malformed JSON for clipboard import", e);
|
||||
sendChatMessage("You do not have any ground markers copied in your clipboard.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (importPoints.isEmpty())
|
||||
{
|
||||
sendChatMessage("You do not have any ground markers copied in your clipboard.");
|
||||
return;
|
||||
}
|
||||
|
||||
chatboxPanelManager.openTextMenuInput("Are you sure you want to import " + importPoints.size() + " ground markers?")
|
||||
.option("Yes", () -> importGroundMarkers(importPoints))
|
||||
.option("No", Runnables::doNothing)
|
||||
.build();
|
||||
}
|
||||
|
||||
private void importGroundMarkers(Collection<GroundMarkerPoint> importPoints)
|
||||
{
|
||||
// regions being imported may not be loaded on client,
|
||||
// so need to import each bunch directly into the config
|
||||
// first, collate the list of unique region ids in the import
|
||||
Map<Integer, List<GroundMarkerPoint>> regionGroupedPoints = importPoints.stream()
|
||||
.collect(Collectors.groupingBy(GroundMarkerPoint::getRegionId));
|
||||
|
||||
// now import each region into the config
|
||||
regionGroupedPoints.forEach((regionId, groupedPoints) ->
|
||||
{
|
||||
// combine imported points with existing region points
|
||||
log.debug("Importing {} points to region {}", groupedPoints.size(), regionId);
|
||||
Collection<GroundMarkerPoint> regionPoints = plugin.getPoints(regionId);
|
||||
|
||||
List<GroundMarkerPoint> mergedList = new ArrayList<>(regionPoints.size() + groupedPoints.size());
|
||||
// add existing points
|
||||
mergedList.addAll(regionPoints);
|
||||
|
||||
// add new points
|
||||
for (GroundMarkerPoint point : groupedPoints)
|
||||
{
|
||||
// filter out duplicates
|
||||
if (!mergedList.contains(point))
|
||||
{
|
||||
mergedList.add(point);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.savePoints(regionId, mergedList);
|
||||
});
|
||||
|
||||
// reload points from config
|
||||
log.debug("Reloading points after import");
|
||||
plugin.loadPoints();
|
||||
sendChatMessage(importPoints.size() + " ground markers were imported from the clipboard.");
|
||||
}
|
||||
|
||||
private void sendChatMessage(final String message)
|
||||
{
|
||||
chatMessageManager.queue(QueuedMessage.builder()
|
||||
.type(ChatMessageType.CONSOLE)
|
||||
.runeLiteFormattedMessage(message)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -38,9 +38,10 @@ import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.PlayerMenuOptionClicked;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
@@ -174,11 +175,30 @@ public class HiscorePlugin extends Plugin
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerMenuOptionClicked(PlayerMenuOptionClicked event)
|
||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||
{
|
||||
if (event.getMenuOption().equals(LOOKUP))
|
||||
if ((event.getMenuAction() == MenuAction.RUNELITE || event.getMenuAction() == MenuAction.RUNELITE_PLAYER)
|
||||
&& event.getMenuOption().equals(LOOKUP))
|
||||
{
|
||||
lookupPlayer(Text.removeTags(event.getMenuTarget()));
|
||||
final String target;
|
||||
if (event.getMenuAction() == MenuAction.RUNELITE_PLAYER)
|
||||
{
|
||||
// The player id is included in the event, so we can use that to get the player name,
|
||||
// which avoids having to parse out the combat level and any icons preceding the name.
|
||||
Player player = client.getCachedPlayers()[event.getId()];
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
target = player.getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
target = Text.removeTags(event.getMenuTarget());
|
||||
}
|
||||
|
||||
lookupPlayer(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.idlenotifier;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.Range;
|
||||
import net.runelite.client.config.Units;
|
||||
|
||||
@ConfigGroup("idlenotifier")
|
||||
@@ -110,10 +111,36 @@ public interface IdleNotifierConfig extends Config
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "lowEnergy",
|
||||
name = "Low Energy Threshold",
|
||||
description = "The amount of energy points remaining to send a notification at. A value of 100 will disable notification.",
|
||||
position = 8
|
||||
)
|
||||
@Units(Units.PERCENT)
|
||||
@Range(max = 100)
|
||||
default int getLowEnergyThreshold()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "highEnergy",
|
||||
name = "High Energy Threshold",
|
||||
description = "The amount of energy points reached to send a notification. A value of 0 will disable notification.",
|
||||
position = 9
|
||||
)
|
||||
@Units(Units.PERCENT)
|
||||
@Range(max = 100)
|
||||
default int getHighEnergyThreshold()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "oxygen",
|
||||
name = "Oxygen Threshold",
|
||||
position = 8,
|
||||
position = 10,
|
||||
description = "The amount of remaining oxygen to send a notification at. A value of 0 will disable notification."
|
||||
)
|
||||
@Units(Units.PERCENT)
|
||||
@@ -125,7 +152,7 @@ public interface IdleNotifierConfig extends Config
|
||||
@ConfigItem(
|
||||
keyName = "spec",
|
||||
name = "Spec Threshold",
|
||||
position = 9,
|
||||
position = 11,
|
||||
description = "The amount of special attack energy reached to send a notification at. A value of 0 will disable notification."
|
||||
)
|
||||
@Units(Units.PERCENT)
|
||||
|
||||
@@ -93,6 +93,8 @@ public class IdleNotifierPlugin extends Plugin
|
||||
private boolean notifyPosition = false;
|
||||
private boolean notifyHitpoints = true;
|
||||
private boolean notifyPrayer = true;
|
||||
private boolean shouldNotifyLowEnergy = false;
|
||||
private boolean shouldNotifyHighEnergy = false;
|
||||
private boolean notifyOxygen = true;
|
||||
private boolean notifyIdleLogout = true;
|
||||
private boolean notify6HourLogout = true;
|
||||
@@ -471,6 +473,16 @@ public class IdleNotifierPlugin extends Plugin
|
||||
notifier.notify("[" + local.getName() + "] has low prayer!");
|
||||
}
|
||||
|
||||
if (checkLowEnergy())
|
||||
{
|
||||
notifier.notify("[" + local.getName() + "] has low run energy!");
|
||||
}
|
||||
|
||||
if (checkHighEnergy())
|
||||
{
|
||||
notifier.notify("[" + local.getName() + "] has restored run energy!");
|
||||
}
|
||||
|
||||
if (checkLowOxygen())
|
||||
{
|
||||
notifier.notify("[" + local.getName() + "] has low oxygen!");
|
||||
@@ -572,6 +584,52 @@ public class IdleNotifierPlugin extends Plugin
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkLowEnergy()
|
||||
{
|
||||
if (config.getLowEnergyThreshold() >= 100)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (client.getEnergy() <= config.getLowEnergyThreshold())
|
||||
{
|
||||
if (shouldNotifyLowEnergy)
|
||||
{
|
||||
shouldNotifyLowEnergy = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldNotifyLowEnergy = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkHighEnergy()
|
||||
{
|
||||
if (config.getHighEnergyThreshold() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (client.getEnergy() >= config.getHighEnergyThreshold())
|
||||
{
|
||||
if (shouldNotifyHighEnergy)
|
||||
{
|
||||
shouldNotifyHighEnergy = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldNotifyHighEnergy = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkInteractionIdle(Duration waitDuration, Player local)
|
||||
{
|
||||
if (lastInteract == null)
|
||||
|
||||
@@ -215,7 +215,7 @@ public class ItemStatChanges
|
||||
add(new GauntletPotion(), EGNIOL_POTION_1, EGNIOL_POTION_2, EGNIOL_POTION_3, EGNIOL_POTION_4);
|
||||
|
||||
// Soul Wars
|
||||
add(combo(2, heal(HITPOINTS, perc(.20, 2)), heal(RUN_ENERGY, 100)), BANDAGES_25202);
|
||||
add(combo(2, heal(HITPOINTS, perc(.15, 1)), heal(RUN_ENERGY, 100)), BANDAGES_25202);
|
||||
add(combo(6, boost(ATTACK, perc(.15, 5)), boost(STRENGTH, perc(.15, 5)), boost(DEFENCE, perc(.15, 5)), boost(RANGED, perc(.15, 5)), boost(MAGIC, perc(.15, 5)), heal(PRAYER, perc(.25, 8))), POTION_OF_POWER1, POTION_OF_POWER2, POTION_OF_POWER3, POTION_OF_POWER4);
|
||||
|
||||
log.debug("{} items; {} behaviours loaded", effects.size(), new HashSet<>(effects.values()).size());
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class Stat
|
||||
public abstract int getValue(Client client);
|
||||
|
||||
/**
|
||||
* Get the base stat maximum, ie. the bottom half of the stat fraction.
|
||||
* Get the base stat maximum. (ie. the bottom half of the stat fraction)
|
||||
*/
|
||||
public abstract int getMaximum(Client client);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
public class NpcMinimapOverlay extends Overlay
|
||||
{
|
||||
@@ -56,7 +57,7 @@ public class NpcMinimapOverlay extends Overlay
|
||||
{
|
||||
for (NPC npc : plugin.getHighlightedNpcs())
|
||||
{
|
||||
renderNpcOverlay(graphics, npc, npc.getName(), config.getHighlightColor());
|
||||
renderNpcOverlay(graphics, npc, Text.removeTags(npc.getName()), config.getHighlightColor());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SlayerPlugin extends Plugin
|
||||
//Chat messages
|
||||
private static final Pattern CHAT_GEM_PROGRESS_MESSAGE = Pattern.compile("^(?:You're assigned to kill|You have received a new Slayer assignment from .*:) (?:[Tt]he )?(?<name>.+?)(?: (?:in|on|south of) (?:the )?(?<location>[^;]+))?(?:; only | \\()(?<amount>\\d+)(?: more to go\\.|\\))$");
|
||||
private static final String CHAT_GEM_COMPLETE_MESSAGE = "You need something new to hunt.";
|
||||
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("(?:\\d+,)*\\d+");
|
||||
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("You've completed (?:at least )?(?<tasks>[\\d,]+) (?:Wilderness )?tasks?(?: and received \\d+ points, giving you a total of (?<points>[\\d,]+)| and reached the maximum amount of Slayer points \\((?<points2>[\\d,]+)\\))?");
|
||||
private static final String CHAT_CANCEL_MESSAGE = "Your task has been cancelled.";
|
||||
private static final String CHAT_CANCEL_MESSAGE_JAD = "You no longer have a slayer task as you left the fight cave.";
|
||||
private static final String CHAT_CANCEL_MESSAGE_ZUK = "You no longer have a slayer task as you left the Inferno.";
|
||||
@@ -450,6 +450,7 @@ public class SlayerPlugin extends Plugin
|
||||
expeditiousChargeCount = Integer.parseInt(mExpeditious.group(1));
|
||||
config.expeditious(expeditiousChargeCount);
|
||||
}
|
||||
|
||||
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE))
|
||||
{
|
||||
Matcher mSlaughter = CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX.matcher(chatMsg);
|
||||
@@ -466,35 +467,25 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
Matcher mComplete = CHAT_COMPLETE_MESSAGE.matcher(chatMsg);
|
||||
|
||||
List<String> matches = new ArrayList<>();
|
||||
while (mComplete.find())
|
||||
if (mComplete.find())
|
||||
{
|
||||
matches.add(mComplete.group(0).replaceAll(",", ""));
|
||||
}
|
||||
String mTasks = mComplete.group("tasks");
|
||||
String mPoints = mComplete.group("points");
|
||||
if (mPoints == null)
|
||||
{
|
||||
mPoints = mComplete.group("points2");
|
||||
}
|
||||
|
||||
int streak = -1, points = -1;
|
||||
switch (matches.size())
|
||||
{
|
||||
case 0:
|
||||
streak = 1;
|
||||
break;
|
||||
case 1:
|
||||
streak = Integer.parseInt(matches.get(0));
|
||||
break;
|
||||
case 3:
|
||||
streak = Integer.parseInt(matches.get(0));
|
||||
points = Integer.parseInt(matches.get(2));
|
||||
break;
|
||||
default:
|
||||
log.warn("Unreachable default case for message ending in '; return to Slayer master'");
|
||||
}
|
||||
if (streak != -1)
|
||||
{
|
||||
config.streak(streak);
|
||||
}
|
||||
if (points != -1)
|
||||
{
|
||||
config.points(points);
|
||||
if (mTasks != null)
|
||||
{
|
||||
int streak = Integer.parseInt(mTasks.replace(",", ""));
|
||||
config.streak(streak);
|
||||
}
|
||||
if (mPoints != null)
|
||||
{
|
||||
int points = Integer.parseInt(mPoints.replace(",", ""));
|
||||
config.points(points);
|
||||
}
|
||||
}
|
||||
|
||||
setTask("", 0, 0);
|
||||
|
||||
@@ -40,6 +40,7 @@ public interface TimeTrackingConfig extends Config
|
||||
String BOTANIST = "botanist";
|
||||
String TIMERS = "timers";
|
||||
String STOPWATCHES = "stopwatches";
|
||||
String PREFER_SOONEST = "preferSoonest";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "timeFormatMode",
|
||||
@@ -120,6 +121,17 @@ public interface TimeTrackingConfig extends Config
|
||||
return 10;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = PREFER_SOONEST,
|
||||
name = "Prefer soonest completion",
|
||||
description = "When displaying completion times on the overview, prefer showing the soonest any patch will complete.",
|
||||
position = 7
|
||||
)
|
||||
default boolean preferSoonest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "activeTab",
|
||||
name = "Active Tab",
|
||||
|
||||
@@ -51,6 +51,7 @@ import net.runelite.client.events.RuneScapeProfileChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.CONFIG_GROUP;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.PREFER_SOONEST;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.STOPWATCHES;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.TIMERS;
|
||||
import net.runelite.client.plugins.timetracking.clocks.ClockManager;
|
||||
@@ -173,6 +174,10 @@ public class TimeTrackingPlugin extends Plugin
|
||||
{
|
||||
clockManager.loadStopwatches();
|
||||
}
|
||||
else if (e.getKey().equals(PREFER_SOONEST))
|
||||
{
|
||||
farmingTracker.loadCompletionTimes();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -407,7 +407,7 @@ public class FarmingTracker
|
||||
{
|
||||
for (Map.Entry<Tab, Set<FarmingPatch>> tab : farmingWorld.getTabs().entrySet())
|
||||
{
|
||||
long maxCompletionTime = 0;
|
||||
long extremumCompletionTime = config.preferSoonest() ? Long.MAX_VALUE : 0;
|
||||
boolean allUnknown = true;
|
||||
boolean allEmpty = true;
|
||||
|
||||
@@ -426,7 +426,15 @@ public class FarmingTracker
|
||||
allEmpty = false;
|
||||
|
||||
// update max duration if this patch takes longer to grow
|
||||
maxCompletionTime = Math.max(maxCompletionTime, prediction.getDoneEstimate());
|
||||
if (config.preferSoonest())
|
||||
{
|
||||
extremumCompletionTime = Math.min(extremumCompletionTime, prediction.getDoneEstimate());
|
||||
}
|
||||
else
|
||||
{
|
||||
extremumCompletionTime = Math.max(extremumCompletionTime, prediction.getDoneEstimate());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +451,7 @@ public class FarmingTracker
|
||||
state = SummaryState.EMPTY;
|
||||
completionTime = -1L;
|
||||
}
|
||||
else if (maxCompletionTime <= Instant.now().getEpochSecond())
|
||||
else if (extremumCompletionTime <= Instant.now().getEpochSecond())
|
||||
{
|
||||
state = SummaryState.COMPLETED;
|
||||
completionTime = 0;
|
||||
@@ -451,7 +459,7 @@ public class FarmingTracker
|
||||
else
|
||||
{
|
||||
state = SummaryState.IN_PROGRESS;
|
||||
completionTime = maxCompletionTime;
|
||||
completionTime = extremumCompletionTime;
|
||||
}
|
||||
summaries.put(tab.getKey(), state);
|
||||
completionTimes.put(tab.getKey(), completionTime);
|
||||
|
||||
@@ -47,10 +47,10 @@ import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.ChatPlayer;
|
||||
import net.runelite.api.FriendsChatMember;
|
||||
import net.runelite.api.FriendsChatManager;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Friend;
|
||||
import net.runelite.api.FriendsChatManager;
|
||||
import net.runelite.api.FriendsChatMember;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
@@ -60,10 +60,11 @@ import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.PlayerMenuOptionClicked;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.events.WorldListLoad;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.chat.ChatColorType;
|
||||
import net.runelite.client.chat.ChatMessageBuilder;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
@@ -111,6 +112,9 @@ public class WorldHopperPlugin extends Plugin
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
@@ -162,7 +166,7 @@ public class WorldHopperPlugin extends Plugin
|
||||
@Override
|
||||
public void hotkeyPressed()
|
||||
{
|
||||
hop(true);
|
||||
clientThread.invoke(() -> hop(true));
|
||||
}
|
||||
};
|
||||
private final HotkeyListener nextKeyListener = new HotkeyListener(() -> config.nextKey())
|
||||
@@ -170,7 +174,7 @@ public class WorldHopperPlugin extends Plugin
|
||||
@Override
|
||||
public void hotkeyPressed()
|
||||
{
|
||||
hop(false);
|
||||
clientThread.invoke(() -> hop(false));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -304,7 +308,7 @@ public class WorldHopperPlugin extends Plugin
|
||||
|
||||
void hopTo(World world)
|
||||
{
|
||||
hop(world.getId());
|
||||
clientThread.invoke(() -> hop(world.getId()));
|
||||
}
|
||||
|
||||
void addToFavorites(World world)
|
||||
@@ -408,9 +412,9 @@ public class WorldHopperPlugin extends Plugin
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerMenuOptionClicked(PlayerMenuOptionClicked event)
|
||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||
{
|
||||
if (!event.getMenuOption().equals(HOP_TO))
|
||||
if (event.getMenuAction() != MenuAction.RUNELITE || !event.getMenuOption().equals(HOP_TO))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -613,6 +617,8 @@ public class WorldHopperPlugin extends Plugin
|
||||
|
||||
private void hop(int worldId)
|
||||
{
|
||||
assert client.isClientThread();
|
||||
|
||||
WorldResult worldResult = worldService.getWorlds();
|
||||
// Don't try to hop if the world doesn't exist
|
||||
World world = worldResult.findWorld(worldId);
|
||||
|
||||
@@ -370,10 +370,7 @@ class WorldSwitcherPanel extends PluginPanel
|
||||
private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite)
|
||||
{
|
||||
WorldTableRow row = new WorldTableRow(world, current, favorite, plugin.getStoredPing(world),
|
||||
world1 ->
|
||||
{
|
||||
plugin.hopTo(world1);
|
||||
},
|
||||
plugin::hopTo,
|
||||
(world12, add) ->
|
||||
{
|
||||
if (add)
|
||||
|
||||
@@ -159,8 +159,8 @@ class XpState
|
||||
}
|
||||
|
||||
/**
|
||||
* Update number of actions performed for skill (e.g amount of kills in this case) if last interacted
|
||||
* NPC died
|
||||
* Update number of actions performed for skill if last interacted NPC died.
|
||||
* (eg. amount of kills in this case)
|
||||
* @param skill skill to update actions for
|
||||
* @param npc npc that just died
|
||||
* @param npcHealth max health of npc that just died
|
||||
|
||||
@@ -182,7 +182,7 @@ public class QuantityFormatter
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates, given a string with a value denominator (ex. 20K)
|
||||
* Calculates, given a string with a value denominator (for example, 20K)
|
||||
* the multiplier that the denominator represents (in this case 1000).
|
||||
*
|
||||
* @param string The string to check.
|
||||
|
||||
@@ -2727,6 +2727,10 @@
|
||||
2464,
|
||||
8936
|
||||
],
|
||||
"black dhide vambraces": [
|
||||
2491,
|
||||
25494
|
||||
],
|
||||
"blue dhide chaps": [
|
||||
2493,
|
||||
7382,
|
||||
@@ -2743,7 +2747,8 @@
|
||||
2497,
|
||||
12383,
|
||||
12387,
|
||||
20424
|
||||
20424,
|
||||
25493
|
||||
],
|
||||
"blue dhide body": [
|
||||
2499,
|
||||
@@ -2761,7 +2766,8 @@
|
||||
2503,
|
||||
12381,
|
||||
12385,
|
||||
20423
|
||||
20423,
|
||||
25492
|
||||
],
|
||||
"dragon chainbody": [
|
||||
2513,
|
||||
@@ -7760,7 +7766,15 @@
|
||||
],
|
||||
"toxic blowpipe": [
|
||||
12924,
|
||||
12926
|
||||
12926,
|
||||
25484,
|
||||
25485,
|
||||
25486,
|
||||
25487,
|
||||
25488,
|
||||
25489,
|
||||
25490,
|
||||
25491
|
||||
],
|
||||
"serpentine helm": [
|
||||
12929,
|
||||
@@ -9240,21 +9254,24 @@
|
||||
23887,
|
||||
23888,
|
||||
23971,
|
||||
23973
|
||||
23973,
|
||||
25495
|
||||
],
|
||||
"crystal body": [
|
||||
23889,
|
||||
23890,
|
||||
23891,
|
||||
23975,
|
||||
23977
|
||||
23977,
|
||||
25496
|
||||
],
|
||||
"crystal legs": [
|
||||
23892,
|
||||
23893,
|
||||
23894,
|
||||
23979,
|
||||
23981
|
||||
23981,
|
||||
25497
|
||||
],
|
||||
"crystal staff": [
|
||||
23898,
|
||||
@@ -9623,10 +9640,6 @@
|
||||
25319,
|
||||
25338
|
||||
],
|
||||
"gnome child": [
|
||||
25320,
|
||||
25321
|
||||
],
|
||||
"soul cape": [
|
||||
25344,
|
||||
25346
|
||||
@@ -9635,5 +9648,25 @@
|
||||
25380,
|
||||
25383,
|
||||
25386
|
||||
],
|
||||
"bronze coffin": [
|
||||
25459,
|
||||
25469
|
||||
],
|
||||
"steel coffin": [
|
||||
25461,
|
||||
25470
|
||||
],
|
||||
"black coffin": [
|
||||
25463,
|
||||
25471
|
||||
],
|
||||
"silver coffin": [
|
||||
25465,
|
||||
25472
|
||||
],
|
||||
"gold coffin": [
|
||||
25467,
|
||||
25473
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,997 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import static net.runelite.api.ChatMessageType.GAMEMESSAGE;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Hitsplat;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NPCComposition;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.ActorDeath;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.HitsplatApplied;
|
||||
import net.runelite.api.events.StatChanged;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.chat.ChatCommandManager;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.http.api.chat.ChatClient;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SlayerPluginTest
|
||||
{
|
||||
private static final String TASK_NEW = "Your new task is to kill 231 Suqahs.";
|
||||
private static final String TASK_NEW_KONAR = "You are to bring balance to 147 Wyrms in the Karuulm Slayer Dungeon.";
|
||||
private static final String TASK_NEW_KONAR_2 = "You are to bring balance to 142 Hellhounds in Witchhaven Dungeon.";
|
||||
private static final String TASK_NEW_KONAR_3 = "You are to bring balance to 135 Trolls south of Mount Quidamortem.";
|
||||
private static final String TASK_NEW_FIRST = "We'll start you off hunting goblins, you'll need to kill 17 of them.";
|
||||
private static final String TASK_NEW_FIRST_KONAR = "We'll start you off bringing balance to cows, you'll need to kill 44 of them.";
|
||||
private static final String TASK_NEW_NPC_CONTACT = "Excellent, you're doing great. Your new task is to kill<br>211 Suqahs.";
|
||||
private static final String TASK_NEW_FROM_PARTNER = "You have received a new Slayer assignment from breaklulz: Dust Devils (377)";
|
||||
private static final String TASK_CHECKSLAYERGEM = "You're assigned to kill Suqahs; only 211 more to go.";
|
||||
private static final String TASK_CHECKSLAYERGEM_WILDERNESS = "You're assigned to kill Suqahs in the Wilderness; only 211 more to go.";
|
||||
private static final String TASK_CHECKSLAYERGEM_KONAR = "You're assigned to kill Blue dragons in the Ogre Enclave; only 122 more to go.";
|
||||
private static final String TASK_UPDATE_COMBAT_BRACELET = "You still need to kill 30 monsters to complete your current Slayer assignment";
|
||||
|
||||
private static final String TASK_BOSS_NEW = "Excellent. You're now assigned to kill Vet'ion 3 times.<br>Your reward point tally is 914.";
|
||||
private static final String TASK_BOSS_NEW_THE = "Excellent. You're now assigned to kill the Chaos <br>Elemental 3 times. Your reward point tally is 914.";
|
||||
private static final String TASK_KONAR_BOSS = "You're now assigned to bring balance to the Alchemical<br>Hydra 35 times. Your reward point tally is 724.";
|
||||
|
||||
private static final String TASK_EXISTING = "You're still hunting suqahs; you have 222 to go. Come<br>back when you've finished your task.";
|
||||
private static final String TASK_EXISTING_KONAR = "You're still bringing balance to adamant dragons in the Lithkren Vault, with 3 to go. Come back when you're finished.";
|
||||
private static final String TASK_EXISTING_WILDERNESS = "You're still meant to be slaying bandits in the Wilderness; you have 99 to go. Come back when you've finished your task.";
|
||||
|
||||
private static final String TASK_ACTIVATESLAYERGEM = "You're currently assigned to kill fossil island wyverns; only 23 more to go. Your reward point tally is 46.";
|
||||
private static final String TASK_ACTIVATESLAYERGEM_KONAR = "You're currently assigned to bring balance to adamant dragons in the Lithkren Vault; you have 3 more to go. Your reward point tally is 16.";
|
||||
private static final String TASK_ACTIVATESLAYERGEM_WILDERNESS = "You're currently assigned to kill bandits in the Wilderness; only 99 more to go. Your reward point tally is 34.";
|
||||
|
||||
private static final String REWARD_POINTS = "Reward points: 17,566";
|
||||
|
||||
private static final String TASK_ONE = "<col=ef1020>You've completed </col>1 task<col=ef1020> and will need</col> 4 more <col=ef1020>before you start receiving Slayer points; return to a Slayer master.</col>";
|
||||
private static final String TASK_COMPLETE_NO_POINTS = "<col=ef1020>You've completed </col>3 tasks<col=ef1020> and will need </col>2 more<col=ef1020> before you start receiving Slayer points; return to a Slayer master.";
|
||||
private static final String TASK_POINTS = "<col=ef1020>You've completed </col>9 tasks <col=ef1020>and received </col>10 points<col=ef1020>, giving you a total of </col>18,000<col=ef1020>; return to a Slayer master.";
|
||||
private static final String TASK_LARGE_STREAK = "<col=ef1020>You've completed </col>2,465 tasks <col=ef1020>and received </col>15 points<col=ef1020>, giving you a total of </col>131,071<col=ef1020>; return to a Slayer master.";
|
||||
private static final String TASK_COMPETE_TURAEL = "<col=ef1020>You've completed </col>104 tasks <col=ef1020>. You'll be eligible to earn reward points if you complete tasks from a more advanced Slayer Master.";
|
||||
private static final String TASK_MAX_STREAK = "<col=ef1020>You've completed at least </col>16,000 tasks <col=ef1020>and received </col>15 points<col=ef1020>, giving you a total of </col>131,071<col=ef1020>; return to a Slayer master.";
|
||||
private static final String TASK_MAX_POINTS = "<col=ef1020>You've completed </col>9 tasks <col=ef1020>and reached the maximum amount of Slayer points </col>(131,071)<col=ef1020>; return to a Slayer master.";
|
||||
private static final String TASK_WILDERNESS = "<col=ef1020>You've completed </col>9 Wilderness tasks <col=ef1020>and received </col>10 points<col=ef1020>, giving you a total of </col>18,000<col=ef1020>; return to a Slayer master.";
|
||||
|
||||
private static final String TASK_COMPLETE = "You need something new to hunt.";
|
||||
private static final String TASK_CANCELED = "Your task has been cancelled.";
|
||||
|
||||
private static final String SUPERIOR_MESSAGE = "A superior foe has appeared...";
|
||||
|
||||
private static final String BRACLET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 9 charges left.";
|
||||
private static final String BRACLET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your slayer task faster. It has 9 charges left.";
|
||||
|
||||
private static final String BRACLET_SLAUGHTER_V2 = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 1 charge left.";
|
||||
private static final String BRACLET_EXPEDITIOUS_V2 = "Your expeditious bracelet helps you progress your slayer faster. It has 1 charge left.";
|
||||
|
||||
private static final String BRACLET_SLAUGHTER_V3 = "Your bracelet of slaughter prevents your slayer count from decreasing. It then crumbles to dust.";
|
||||
private static final String BRACLET_EXPEDITIOUS_V3 = "Your expeditious bracelet helps you progress your slayer faster. It then crumbles to dust.";
|
||||
|
||||
private static final String CHAT_BRACELET_SLAUGHTER_CHARGE = "Your bracelet of slaughter has 12 charges left.";
|
||||
private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE = "Your expeditious bracelet has 12 charges left.";
|
||||
|
||||
private static final String CHAT_BRACELET_SLAUGHTER_CHARGE_ONE = "Your bracelet of slaughter has 1 charge left.";
|
||||
private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE_ONE = "Your expeditious bracelet has 1 charge left.";
|
||||
|
||||
private static final String BREAK_SLAUGHTER = "The bracelet shatters. Your next bracelet of slaughter<br>will start afresh from 30 charges.";
|
||||
private static final String BREAK_EXPEDITIOUS = "The bracelet shatters. Your next expeditious bracelet<br>will start afresh from 30 charges.";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
SlayerConfig slayerConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
SlayerOverlay overlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
InfoBoxManager infoBoxManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ItemManager itemManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Notifier notifier;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatMessageManager chatMessageManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatCommandManager chatCommandManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ScheduledExecutorService executor;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatClient chatClient;
|
||||
|
||||
@Inject
|
||||
SlayerPlugin slayerPlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(231, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewKonarTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Wyrms", slayerPlugin.getTaskName());
|
||||
assertEquals(147, slayerPlugin.getAmount());
|
||||
assertEquals("Karuulm Slayer Dungeon", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewKonarTask2()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_2);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Hellhounds", slayerPlugin.getTaskName());
|
||||
assertEquals(142, slayerPlugin.getAmount());
|
||||
assertEquals("Witchhaven Dungeon", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewKonarTask3()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_3);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Trolls", slayerPlugin.getTaskName());
|
||||
assertEquals(135, slayerPlugin.getAmount());
|
||||
assertEquals("Mount Quidamortem", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("goblins", slayerPlugin.getTaskName());
|
||||
assertEquals(17, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstTaskKonar()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST_KONAR);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("cows", slayerPlugin.getTaskName());
|
||||
assertEquals(44, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewNpcContactTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_NPC_CONTACT);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(211, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBossTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Vet'ion", slayerPlugin.getTaskName());
|
||||
assertEquals(3, slayerPlugin.getAmount());
|
||||
verify(slayerConfig).points(914);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBossTaskThe()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW_THE);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Chaos Elemental", slayerPlugin.getTaskName());
|
||||
assertEquals(3, slayerPlugin.getAmount());
|
||||
verify(slayerConfig).points(914);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKonarBossTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_KONAR_BOSS);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Alchemical Hydra", slayerPlugin.getTaskName());
|
||||
assertEquals(35, slayerPlugin.getAmount());
|
||||
verify(slayerConfig).points(724);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartnerTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_NEW_FROM_PARTNER, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("Dust Devils", slayerPlugin.getTaskName());
|
||||
assertEquals(377, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckSlayerGem()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_CHECKSLAYERGEM, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(211, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckSlayerGemWildernessTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_CHECKSLAYERGEM_WILDERNESS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(211, slayerPlugin.getAmount());
|
||||
assertEquals("Wilderness", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckSlayerGemKonarTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_CHECKSLAYERGEM_KONAR, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("Blue dragons", slayerPlugin.getTaskName());
|
||||
assertEquals(122, slayerPlugin.getAmount());
|
||||
assertEquals("Ogre Enclave", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_EXISTING);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(222, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingTaskKonar()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_EXISTING_KONAR);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("adamant dragons", slayerPlugin.getTaskName());
|
||||
assertEquals(3, slayerPlugin.getAmount());
|
||||
assertEquals("Lithkren Vault", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingTaskWilderness()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_EXISTING_WILDERNESS);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("bandits", slayerPlugin.getTaskName());
|
||||
assertEquals(99, slayerPlugin.getAmount());
|
||||
assertEquals("Wilderness", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSlayergemActivate()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_ACTIVATESLAYERGEM);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("fossil island wyverns", slayerPlugin.getTaskName());
|
||||
assertEquals(23, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSlayergemActivateKonar()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_ACTIVATESLAYERGEM_KONAR);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("adamant dragons", slayerPlugin.getTaskName());
|
||||
assertEquals(3, slayerPlugin.getAmount());
|
||||
assertEquals("Lithkren Vault", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSlayergemActivateWilderness()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_ACTIVATESLAYERGEM_WILDERNESS);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("bandits", slayerPlugin.getTaskName());
|
||||
assertEquals(99, slayerPlugin.getAmount());
|
||||
assertEquals("Wilderness", slayerPlugin.getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRewardPointsWidget()
|
||||
{
|
||||
Widget rewardBar = mock(Widget.class);
|
||||
Widget rewardBarText = mock(Widget.class);
|
||||
Widget[] rewardBarChildren = new Widget[]{rewardBarText};
|
||||
|
||||
when(rewardBar.getDynamicChildren()).thenReturn(rewardBarChildren);
|
||||
when(rewardBarText.getText()).thenReturn(REWARD_POINTS);
|
||||
when(client.getWidget(WidgetInfo.SLAYER_REWARDS_TOPBAR)).thenReturn(rewardBar);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
verify(slayerConfig).points(17566);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_ONE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(1);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoPoints()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE_NO_POINTS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(3);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPoints()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_POINTS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(9);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
verify(slayerConfig).points(18_000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLargeStreak()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_LARGE_STREAK, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(2465);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
verify(slayerConfig).points(131_071);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskCompleteTurael()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPETE_TURAEL, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(104);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskMaxStreak()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_MAX_STREAK, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(16_000);
|
||||
verify(slayerConfig).points(131_071);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskMaxPoints()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_MAX_POINTS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(9);
|
||||
verify(slayerConfig).points(131_071);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskWilderness()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_WILDERNESS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(slayerConfig).streak(9);
|
||||
verify(slayerConfig).points(18_000);
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplete()
|
||||
{
|
||||
slayerPlugin.setTaskName("cows");
|
||||
slayerPlugin.setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelled()
|
||||
{
|
||||
slayerPlugin.setTaskName("cows");
|
||||
slayerPlugin.setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_CANCELED, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperiorNotification()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Superior", SUPERIOR_MESSAGE, null, 0);
|
||||
|
||||
when(slayerConfig.showSuperiorNotification()).thenReturn(true);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
verify(notifier).notify(SUPERIOR_MESSAGE);
|
||||
|
||||
when(slayerConfig.showSuperiorNotification()).thenReturn(false);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
verifyNoMoreInteractions(notifier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorrectlyCapturedTaskKill()
|
||||
{
|
||||
final Player player = mock(Player.class);
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
StatChanged statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
100,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
slayerPlugin.setTaskName("Dagannoth");
|
||||
slayerPlugin.setAmount(143);
|
||||
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
110,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals(142, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncorrectlyCapturedTaskKill()
|
||||
{
|
||||
final Player player = mock(Player.class);
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
StatChanged statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
100,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
slayerPlugin.setTaskName("Monster");
|
||||
slayerPlugin.setAmount(98);
|
||||
|
||||
assert Task.getTask("Monster") == null;
|
||||
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
110,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals(97, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJadTaskKill()
|
||||
{
|
||||
final Player player = mock(Player.class);
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
StatChanged statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
100,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
slayerPlugin.setTaskName("TzTok-Jad");
|
||||
slayerPlugin.setAmount(1);
|
||||
|
||||
// One bat kill
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
110,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals(1, slayerPlugin.getAmount());
|
||||
|
||||
// One Jad kill
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
25360,
|
||||
-1,
|
||||
-1
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZukTaskKill()
|
||||
{
|
||||
final Player player = mock(Player.class);
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
StatChanged statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
110,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
slayerPlugin.setTaskName("TzKal-Zuk");
|
||||
slayerPlugin.setAmount(1);
|
||||
|
||||
// One bat kill
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
125,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals(1, slayerPlugin.getAmount());
|
||||
|
||||
// One Zuk kill
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
102_015,
|
||||
-1,
|
||||
-1
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBraceletSlaughter()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.setSlaughterChargeCount(10);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(9, slayerPlugin.getSlaughterChargeCount());
|
||||
assertEquals(43, slayerPlugin.getAmount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_SLAUGHTER_CHARGE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(12, slayerPlugin.getSlaughterChargeCount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_SLAUGHTER_CHARGE_ONE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(1, slayerPlugin.getSlaughterChargeCount());
|
||||
|
||||
slayerPlugin.setSlaughterChargeCount(1);
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER_V3, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(30, slayerPlugin.getSlaughterChargeCount());
|
||||
|
||||
Widget braceletBreakWidget = mock(Widget.class);
|
||||
when(braceletBreakWidget.getText()).thenReturn(BREAK_SLAUGHTER);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT)).thenReturn(braceletBreakWidget);
|
||||
|
||||
slayerPlugin.setSlaughterChargeCount(-1);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
assertEquals(30, slayerPlugin.getSlaughterChargeCount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER_V2, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.setSlaughterChargeCount(2);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(1, slayerPlugin.getSlaughterChargeCount());
|
||||
assertEquals(43, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBraceletExpeditious()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.setExpeditiousChargeCount(10);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(41, slayerPlugin.getAmount());
|
||||
assertEquals(9, slayerPlugin.getExpeditiousChargeCount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_EXPEDITIOUS_CHARGE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(12, slayerPlugin.getExpeditiousChargeCount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_EXPEDITIOUS_CHARGE_ONE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(1, slayerPlugin.getExpeditiousChargeCount());
|
||||
|
||||
slayerPlugin.setExpeditiousChargeCount(1);
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS_V3, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(30, slayerPlugin.getExpeditiousChargeCount());
|
||||
|
||||
Widget braceletBreakWidget = mock(Widget.class);
|
||||
when(braceletBreakWidget.getText()).thenReturn(BREAK_EXPEDITIOUS);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT)).thenReturn(braceletBreakWidget);
|
||||
|
||||
slayerPlugin.setExpeditiousChargeCount(-1);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
assertEquals(30, slayerPlugin.getExpeditiousChargeCount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS_V2, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.setExpeditiousChargeCount(2);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(41, slayerPlugin.getAmount());
|
||||
assertEquals(1, slayerPlugin.getExpeditiousChargeCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCombatBraceletUpdate()
|
||||
{
|
||||
final Player player = mock(Player.class);
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
slayerPlugin.setTaskName("Suqahs");
|
||||
slayerPlugin.setAmount(231);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", TASK_UPDATE_COMBAT_BRACELET, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessage);
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
slayerPlugin.killed(1);
|
||||
assertEquals(30, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateInitialAmount()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_EXISTING);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals(222, slayerPlugin.getInitialAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskLookup() throws IOException
|
||||
{
|
||||
net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task();
|
||||
task.setTask("Abyssal demons");
|
||||
task.setLocation("Abyss");
|
||||
task.setAmount(42);
|
||||
task.setInitialAmount(42);
|
||||
|
||||
when(slayerConfig.taskCommand()).thenReturn(true);
|
||||
when(chatClient.getTask(anyString())).thenReturn(task);
|
||||
|
||||
ChatMessage setMessage = new ChatMessage();
|
||||
setMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||
setMessage.setName("Adam");
|
||||
setMessage.setMessageNode(mock(MessageNode.class));
|
||||
|
||||
slayerPlugin.taskLookup(setMessage, "!task");
|
||||
|
||||
verify(chatMessageManager).update(any(MessageNode.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskLookupInvalid() throws IOException
|
||||
{
|
||||
net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task();
|
||||
task.setTask("task<");
|
||||
task.setLocation("loc");
|
||||
task.setAmount(42);
|
||||
task.setInitialAmount(42);
|
||||
|
||||
when(slayerConfig.taskCommand()).thenReturn(true);
|
||||
when(chatClient.getTask(anyString())).thenReturn(task);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage();
|
||||
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||
chatMessage.setName("Adam");
|
||||
chatMessage.setMessageNode(mock(MessageNode.class));
|
||||
|
||||
slayerPlugin.taskLookup(chatMessage, "!task");
|
||||
|
||||
verify(chatMessageManager, never()).update(any(MessageNode.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewAccountSlayerKill()
|
||||
{
|
||||
final Player player = mock(Player.class);
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
slayerPlugin.setTaskName("Bears");
|
||||
slayerPlugin.setAmount(35);
|
||||
|
||||
StatChanged statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
27,
|
||||
1,
|
||||
1
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals(34, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void infoboxNotAddedOnLogin()
|
||||
{
|
||||
when(slayerConfig.taskName()).thenReturn(Task.BLOODVELD.getName());
|
||||
|
||||
GameStateChanged loggingIn = new GameStateChanged();
|
||||
loggingIn.setGameState(GameState.LOGGING_IN);
|
||||
slayerPlugin.onGameStateChanged(loggingIn);
|
||||
|
||||
GameStateChanged loggedIn = new GameStateChanged();
|
||||
loggedIn.setGameState(GameState.LOGGED_IN);
|
||||
slayerPlugin.onGameStateChanged(loggedIn);
|
||||
|
||||
verify(infoBoxManager, never()).addInfoBox(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultikill()
|
||||
{
|
||||
final Player player = mock(Player.class);
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
// Setup xp cache
|
||||
StatChanged statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
NPCComposition npcComposition = mock(NPCComposition.class);
|
||||
when(npcComposition.getActions()).thenReturn(new String[]{"Attack"});
|
||||
|
||||
NPC npc1 = mock(NPC.class);
|
||||
when(npc1.getName()).thenReturn("Suqah");
|
||||
when(npc1.getTransformedComposition()).thenReturn(npcComposition);
|
||||
|
||||
NPC npc2 = mock(NPC.class);
|
||||
when(npc2.getName()).thenReturn("Suqah");
|
||||
when(npc2.getTransformedComposition()).thenReturn(npcComposition);
|
||||
|
||||
when(client.getNpcs()).thenReturn(Arrays.asList(npc1, npc2));
|
||||
|
||||
// Set task
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
// Damage both npcs
|
||||
Hitsplat hitsplat = new Hitsplat(Hitsplat.HitsplatType.DAMAGE_ME, 1, 1);
|
||||
HitsplatApplied hitsplatApplied = new HitsplatApplied();
|
||||
hitsplatApplied.setHitsplat(hitsplat);
|
||||
hitsplatApplied.setActor(npc1);
|
||||
slayerPlugin.onHitsplatApplied(hitsplatApplied);
|
||||
|
||||
hitsplatApplied.setActor(npc2);
|
||||
slayerPlugin.onHitsplatApplied(hitsplatApplied);
|
||||
|
||||
// Kill both npcs
|
||||
slayerPlugin.onActorDeath(new ActorDeath(npc1));
|
||||
slayerPlugin.onActorDeath(new ActorDeath(npc2));
|
||||
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
statChanged = new StatChanged(
|
||||
Skill.SLAYER,
|
||||
105,
|
||||
2,
|
||||
2
|
||||
);
|
||||
slayerPlugin.onStatChanged(statChanged);
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(229, slayerPlugin.getAmount()); // 2 kills
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user