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:
zeruth
2021-01-29 21:19:28 -05:00
55 changed files with 1763 additions and 395 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;
/**

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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());

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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",

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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

View File

@@ -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.