Merge remote-tracking branch 'upstream/master' into hi-phil-swift-here-for-flex-tape-the-super-strong-waterproof-tape

This commit is contained in:
ThatGamerBlue
2021-03-10 16:32:29 +00:00
22 changed files with 313 additions and 125 deletions

View File

@@ -25,9 +25,9 @@
object ProjectVersions { object ProjectVersions {
const val launcherVersion = "2.2.0" const val launcherVersion = "2.2.0"
const val rlVersion = "1.7.2" const val rlVersion = "1.7.2.2"
const val openosrsVersion = "4.0.1" const val openosrsVersion = "4.1.0"
const val rsversion = 194 const val rsversion = 194
const val cacheversion = 165 const val cacheversion = 165

View File

@@ -43,10 +43,7 @@ public class ColorTypeAdapter extends TypeAdapter<Color>
} }
int rgba = value.getRGB(); int rgba = value.getRGB();
out.beginObject() out.value(String.format("#%08X", rgba));
.name("value")
.value(rgba)
.endObject();
} }
@Override @Override
@@ -57,7 +54,18 @@ public class ColorTypeAdapter extends TypeAdapter<Color>
case NULL: case NULL:
in.nextNull(); in.nextNull();
return null; return null;
case STRING:
{
String value = in.nextString();
if (value.charAt(0) == '#')
{
value = value.substring(1);
}
int intValue = Integer.parseUnsignedInt(value, 16);
return new Color(intValue, true);
}
case BEGIN_OBJECT: case BEGIN_OBJECT:
{
in.beginObject(); in.beginObject();
double value = 0; double value = 0;
while (in.peek() != JsonToken.END_OBJECT) while (in.peek() != JsonToken.END_OBJECT)
@@ -74,6 +82,7 @@ public class ColorTypeAdapter extends TypeAdapter<Color>
} }
in.endObject(); in.endObject();
return new Color((int) value, true); return new Color((int) value, true);
}
} }
return null; // throws return null; // throws
} }

View File

@@ -43,12 +43,7 @@ public class InstantTypeAdapter extends TypeAdapter<Instant>
return; return;
} }
out.beginObject() out.value(value.toEpochMilli());
.name("seconds")
.value(value.getEpochSecond())
.name("nanos")
.value(value.getNano())
.endObject();
} }
@Override @Override
@@ -60,6 +55,12 @@ public class InstantTypeAdapter extends TypeAdapter<Instant>
return null; return null;
} }
if (in.peek() == JsonToken.NUMBER)
{
long jsTime = in.nextLong();
return Instant.ofEpochMilli(jsTime);
}
long seconds = 0; long seconds = 0;
int nanos = 0; int nanos = 0;
in.beginObject(); in.beginObject();

View File

@@ -24,7 +24,6 @@
*/ */
package net.runelite.http.api.item; package net.runelite.http.api.item;
import java.time.Instant;
import lombok.Data; import lombok.Data;
@Data @Data
@@ -33,5 +32,5 @@ public class ItemPrice
private int id; private int id;
private String name; private String name;
private int price; private int price;
private Instant time; private int wikiPrice;
} }

View File

@@ -84,6 +84,7 @@ import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Player; import net.runelite.api.Player;
@@ -445,7 +446,7 @@ public class ConfigManager
setConfiguration(groupName, null, key, value); setConfiguration(groupName, null, key, value);
} }
public void setConfiguration(String groupName, String profile, String key, String value) public void setConfiguration(String groupName, String profile, String key, @NonNull String value)
{ {
if (Strings.isNullOrEmpty(groupName) || Strings.isNullOrEmpty(key)) if (Strings.isNullOrEmpty(groupName) || Strings.isNullOrEmpty(key))
{ {
@@ -565,6 +566,7 @@ public class ConfigManager
ConfigChanged configChanged = new ConfigChanged(); ConfigChanged configChanged = new ConfigChanged();
configChanged.setGroup(groupName); configChanged.setGroup(groupName);
configChanged.setProfile(profile);
configChanged.setKey(key); configChanged.setKey(key);
configChanged.setOldValue(oldValue); configChanged.setOldValue(oldValue);

View File

@@ -381,17 +381,6 @@ public interface RuneLiteConfig extends Config
return ComponentConstants.STANDARD_BACKGROUND_COLOR; return ComponentConstants.STANDARD_BACKGROUND_COLOR;
} }
@ConfigItem(
keyName = "blockExtraMouseButtons",
name = "Block Extra Mouse Buttons",
description = "Blocks extra mouse buttons (4 and above)",
position = 44
)
default boolean blockExtraMouseButtons()
{
return true;
}
@ConfigItem( @ConfigItem(
keyName = "sidebarToggleKey", keyName = "sidebarToggleKey",
name = "Sidebar Toggle Key", name = "Sidebar Toggle Key",
@@ -415,4 +404,26 @@ public interface RuneLiteConfig extends Config
{ {
return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK); return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK);
} }
@ConfigItem(
keyName = "blockExtraMouseButtons",
name = "Block extra mouse buttons",
description = "Blocks extra mouse buttons (4 and above)",
position = 50
)
default boolean blockExtraMouseButtons()
{
return true;
}
@ConfigItem(
keyName = "useWikiItemPrices",
name = "Use actively traded price",
description = "Use actively traded prices, sourced from the RuneScape wiki, for item prices",
position = 51
)
default boolean useWikiItemPrices()
{
return true;
}
} }

View File

@@ -56,6 +56,7 @@ import net.runelite.api.SpritePixels;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.PostItemComposition; import net.runelite.api.events.PostItemComposition;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.util.AsyncBufferedImage; import net.runelite.client.util.AsyncBufferedImage;
@@ -87,6 +88,7 @@ public class ItemManager
private final Client client; private final Client client;
private final ClientThread clientThread; private final ClientThread clientThread;
private final ItemClient itemClient; private final ItemClient itemClient;
private final RuneLiteConfig runeLiteConfig;
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap(); private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
private Map<Integer, ItemStats> itemStats = Collections.emptyMap(); private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
@@ -171,11 +173,12 @@ public class ItemManager
@Inject @Inject
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread, public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
OkHttpClient okHttpClient, EventBus eventBus) OkHttpClient okHttpClient, EventBus eventBus, RuneLiteConfig runeLiteConfig)
{ {
this.client = client; this.client = client;
this.clientThread = clientThread; this.clientThread = clientThread;
this.itemClient = new ItemClient(okHttpClient); this.itemClient = new ItemClient(okHttpClient);
this.runeLiteConfig = runeLiteConfig;
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES); scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
scheduledExecutorService.submit(this::loadStats); scheduledExecutorService.submit(this::loadStats);
@@ -293,17 +296,36 @@ public class ItemManager
*/ */
public int getItemPrice(int itemID) public int getItemPrice(int itemID)
{ {
return getItemPrice(itemID, false); return getItemPriceWithSource(itemID, runeLiteConfig.useWikiItemPrices());
} }
/** /**
* Look up an item's price * Look up an item's price
* *
* @param itemID item id * @param itemID item id
* @param ignoreUntradeableMap should the price returned ignore items that are not tradeable for coins in regular way * @param ignoreUntradeableMap skip untradeables
* @return item price * @return item price
*/ */
@Deprecated(since = "4.1.0", forRemoval = true)
public int getItemPrice(int itemID, boolean ignoreUntradeableMap) public int getItemPrice(int itemID, boolean ignoreUntradeableMap)
{
return getItemPriceWithSource(itemID, runeLiteConfig.useWikiItemPrices(), ignoreUntradeableMap);
}
/**
* Look up an item's price
*
* @param itemID item id
* @param useWikiPrice use the actively traded/wiki price
* @return item price
*/
public int getItemPriceWithSource(int itemID, boolean useWikiPrice)
{
return getItemPriceWithSource(itemID, useWikiPrice, false);
}
// TODO: inline this back to getItemPriceWithSource(int, boolean) next minor ver
private int getItemPriceWithSource(int itemID, boolean useWikiPrice, boolean ignoreUntradeableMap)
{ {
if (itemID == COINS_995) if (itemID == COINS_995)
{ {
@@ -331,7 +353,7 @@ public class ItemManager
if (ip != null) if (ip != null)
{ {
price += ip.getPrice(); price = useWikiPrice && ip.getWikiPrice() > 0 ? ip.getWikiPrice() : ip.getPrice();
} }
} }
else else
@@ -343,7 +365,7 @@ public class ItemManager
continue; continue;
} }
price += getItemPrice(mappedItem.getTradeableItem(), ignoreUntradeableMap) * mappedItem.getQuantity(); price += getItemPriceWithSource(mappedItem.getTradeableItem(), useWikiPrice) * mappedItem.getQuantity();
} }
} }

View File

@@ -77,7 +77,6 @@ public class BarrowsPlugin extends Plugin
private static final int CRYPT_REGION_ID = 14231; private static final int CRYPT_REGION_ID = 14231;
private LoopTimer barrowsPrayerDrainTimer; private LoopTimer barrowsPrayerDrainTimer;
private boolean wasInCrypt = false;
@Getter @Getter
private Widget puzzleAnswer; private Widget puzzleAnswer;
@@ -128,7 +127,6 @@ public class BarrowsPlugin extends Plugin
overlayManager.remove(barrowsOverlay); overlayManager.remove(barrowsOverlay);
overlayManager.remove(brotherOverlay); overlayManager.remove(brotherOverlay);
puzzleAnswer = null; puzzleAnswer = null;
wasInCrypt = false;
stopPrayerDrainTimer(); stopPrayerDrainTimer();
// Restore widgets // Restore widgets
@@ -157,18 +155,14 @@ public class BarrowsPlugin extends Plugin
@Subscribe @Subscribe
public void onGameStateChanged(GameStateChanged event) public void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOADING) if (event.getGameState() == GameState.LOGGED_IN)
{
wasInCrypt = isInCrypt();
}
else if (event.getGameState() == GameState.LOGGED_IN)
{ {
boolean isInCrypt = isInCrypt(); boolean isInCrypt = isInCrypt();
if (wasInCrypt && !isInCrypt) if (!isInCrypt && barrowsPrayerDrainTimer != null)
{ {
stopPrayerDrainTimer(); stopPrayerDrainTimer();
} }
else if (!wasInCrypt && isInCrypt) else if (isInCrypt && barrowsPrayerDrainTimer == null)
{ {
startPrayerDrainTimer(); startPrayerDrainTimer();
} }
@@ -233,6 +227,7 @@ public class BarrowsPlugin extends Plugin
{ {
if (config.showPrayerDrainTimer()) if (config.showPrayerDrainTimer())
{ {
assert barrowsPrayerDrainTimer == null;
final LoopTimer loopTimer = new LoopTimer( final LoopTimer loopTimer = new LoopTimer(
PRAYER_DRAIN_INTERVAL_MS, PRAYER_DRAIN_INTERVAL_MS,
ChronoUnit.MILLIS, ChronoUnit.MILLIS,

View File

@@ -65,6 +65,7 @@ import net.runelite.client.chat.ChatCommandManager;
import net.runelite.client.chat.ChatMessageBuilder; import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ChatInput; import net.runelite.client.events.ChatInput;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
@@ -177,6 +178,9 @@ public class ChatCommandsPlugin extends Plugin
@Inject @Inject
private ChatClient chatClient; private ChatClient chatClient;
@Inject
private RuneLiteConfig runeLiteConfig;
@Override @Override
public void startUp() public void startUp()
{ {
@@ -996,7 +1000,7 @@ public class ChatCommandsPlugin extends Plugin
ItemPrice item = retrieveFromList(results, search); ItemPrice item = retrieveFromList(results, search);
int itemId = item.getId(); int itemId = item.getId();
int itemPrice = item.getPrice(); int itemPrice = runeLiteConfig.useWikiItemPrices() && item.getWikiPrice() > 0 ? item.getWikiPrice() : item.getPrice();
final ChatMessageBuilder builder = new ChatMessageBuilder() final ChatMessageBuilder builder = new ChatMessageBuilder()
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)

View File

@@ -58,13 +58,12 @@ public class FaloTheBardClue extends ClueScroll implements TextClueScroll, NpcCl
new FaloTheBardClue("A mark used to increase one's grace, found atop a seer's place.", item(MARK_OF_GRACE)), new FaloTheBardClue("A mark used to increase one's grace, found atop a seer's place.", item(MARK_OF_GRACE)),
new FaloTheBardClue("A molten beast with fiery breath, you acquire these with its death.", item(LAVA_DRAGON_BONES)), new FaloTheBardClue("A molten beast with fiery breath, you acquire these with its death.", item(LAVA_DRAGON_BONES)),
new FaloTheBardClue("A shiny helmet of flight, to obtain this with melee, struggle you might.", item(ARMADYL_HELMET)), new FaloTheBardClue("A shiny helmet of flight, to obtain this with melee, struggle you might.", item(ARMADYL_HELMET)),
// The wiki doesn't specify whether the trimmed dragon defender will work so I've assumed that it doesn't new FaloTheBardClue("A sword held in the other hand, red its colour, Cyclops strength you must withstand.", any("Dragon or Avernic Defender", item(DRAGON_DEFENDER), item(DRAGON_DEFENDER_T), item(DRAGON_DEFENDER_L), item(AVERNIC_DEFENDER), item(AVERNIC_DEFENDER_L))),
new FaloTheBardClue("A sword held in the other hand, red its colour, Cyclops strength you must withstand.", any("Dragon or Avernic Defender", item(DRAGON_DEFENDER), item(DRAGON_DEFENDER_L), item(AVERNIC_DEFENDER), item(AVERNIC_DEFENDER_L))),
new FaloTheBardClue("A token used to kill mythical beasts, in hopes of a blade or just for an xp feast.", item(WARRIOR_GUILD_TOKEN)), new FaloTheBardClue("A token used to kill mythical beasts, in hopes of a blade or just for an xp feast.", item(WARRIOR_GUILD_TOKEN)),
new FaloTheBardClue("Green is my favourite, mature ale I do love, this takes your herblore above.", item(GREENMANS_ALEM)), new FaloTheBardClue("Green is my favourite, mature ale I do love, this takes your herblore above.", item(GREENMANS_ALEM)),
new FaloTheBardClue("It can hold down a boat or crush a goat, this object, you see, is quite heavy.", item(BARRELCHEST_ANCHOR)), new FaloTheBardClue("It can hold down a boat or crush a goat, this object, you see, is quite heavy.", item(BARRELCHEST_ANCHOR)),
new FaloTheBardClue("It comes from the ground, underneath the snowy plain. Trolls aplenty, with what looks like a mane.", item(BASALT)), new FaloTheBardClue("It comes from the ground, underneath the snowy plain. Trolls aplenty, with what looks like a mane.", item(BASALT)),
new FaloTheBardClue("No attack to wield, only strength is required, made of obsidian, but with no room for a shield.", item(TZHAARKETOM)), new FaloTheBardClue("No attack to wield, only strength is required, made of obsidian, but with no room for a shield.", any("Tzhaar-ket-om", item(TZHAARKETOM), item(TZHAARKETOM_T))),
new FaloTheBardClue("Penance healers runners and more, obtaining this body often gives much deplore.", any("Fighter Torso", item(FIGHTER_TORSO), item(FIGHTER_TORSO_L))), new FaloTheBardClue("Penance healers runners and more, obtaining this body often gives much deplore.", any("Fighter Torso", item(FIGHTER_TORSO), item(FIGHTER_TORSO_L))),
new FaloTheBardClue("Strangely found in a chest, many believe these gloves are the best.", item(BARROWS_GLOVES)), new FaloTheBardClue("Strangely found in a chest, many believe these gloves are the best.", item(BARROWS_GLOVES)),
new FaloTheBardClue("These gloves of white won't help you fight, but aid in cooking, they just might.", item(COOKING_GAUNTLETS)), new FaloTheBardClue("These gloves of white won't help you fight, but aid in cooking, they just might.", item(COOKING_GAUNTLETS)),

View File

@@ -57,13 +57,13 @@ public interface GrandExchangeConfig extends Config
@ConfigItem( @ConfigItem(
position = 3, position = 3,
keyName = "enableOsbPrices", keyName = "showActivelyTradedPrice",
name = "Enable OSB actively traded prices", name = "Enable actively traded prices",
description = "Shows the OSBuddy actively traded price on the GE buy interface" description = "Shows the actively traded price on the GE buy interface, sourced from the RuneScape wiki"
) )
default boolean enableOsbPrices() default boolean showActivelyTradedPrice()
{ {
return false; return true;
} }
@ConfigItem( @ConfigItem(

View File

@@ -38,7 +38,7 @@ import net.runelite.api.ItemComposition;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.components.PluginErrorPanel; import net.runelite.client.ui.components.PluginErrorPanel;
public class GrandExchangeOffersPanel extends JPanel class GrandExchangeOffersPanel extends JPanel
{ {
private static final String ERROR_PANEL = "ERROR_PANEL"; private static final String ERROR_PANEL = "ERROR_PANEL";
private static final String OFFERS_PANEL = "OFFERS_PANEL"; private static final String OFFERS_PANEL = "OFFERS_PANEL";

View File

@@ -27,13 +27,10 @@
package net.runelite.client.plugins.grandexchange; package net.runelite.client.plugins.grandexchange;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import lombok.Getter; import lombok.Getter;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.materialtabs.MaterialTab; import net.runelite.client.ui.components.materialtabs.MaterialTab;
@@ -49,21 +46,20 @@ class GrandExchangePanel extends PluginPanel
private final MaterialTab searchTab; private final MaterialTab searchTab;
@Getter @Getter
private GrandExchangeSearchPanel searchPanel; private final GrandExchangeSearchPanel searchPanel;
@Getter @Getter
private GrandExchangeOffersPanel offersPanel; private GrandExchangeOffersPanel offersPanel;
@Inject @Inject
private GrandExchangePanel(ClientThread clientThread, ItemManager itemManager, ScheduledExecutorService executor) private GrandExchangePanel(GrandExchangeSearchPanel searchPanel)
{ {
super(false); super(false);
this.searchPanel = searchPanel;
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
// Search Panel
searchPanel = new GrandExchangeSearchPanel(clientThread, itemManager, executor);
//Offers Panel //Offers Panel
offersPanel = new GrandExchangeOffersPanel(); offersPanel = new GrandExchangeOffersPanel();

View File

@@ -36,7 +36,6 @@ import com.google.gson.Gson;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Color; import java.awt.Color;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
import java.time.Duration; import java.time.Duration;
@@ -48,7 +47,6 @@ import java.util.EnumSet;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.ToIntFunction; import java.util.function.ToIntFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
@@ -105,7 +103,6 @@ import net.runelite.http.api.ge.GrandExchangeClient;
import net.runelite.http.api.ge.GrandExchangeTrade; import net.runelite.http.api.ge.GrandExchangeTrade;
import net.runelite.http.api.item.ItemStats; import net.runelite.http.api.item.ItemStats;
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient; import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
import net.runelite.http.api.osbuddy.OSBGrandExchangeResult;
import net.runelite.http.api.worlds.WorldType; import net.runelite.http.api.worlds.WorldType;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.commons.lang3.time.DurationFormatUtils;
@@ -124,7 +121,6 @@ public class GrandExchangePlugin extends Plugin
private static final int GE_LOGIN_BURST_WINDOW = 2; // ticks private static final int GE_LOGIN_BURST_WINDOW = 2; // ticks
private static final int OFFER_CONTAINER_ITEM = 21; private static final int OFFER_CONTAINER_ITEM = 21;
private static final int OFFER_DEFAULT_ITEM_ID = 6512; private static final int OFFER_DEFAULT_ITEM_ID = 6512;
private static final String OSB_GE_TEXT = "<br>OSBuddy Actively traded price: ";
private static final String BUY_LIMIT_GE_TEXT = "<br>Buy limit: "; private static final String BUY_LIMIT_GE_TEXT = "<br>Buy limit: ";
private static final String BUY_LIMIT_KEY = "buylimit"; private static final String BUY_LIMIT_KEY = "buylimit";
@@ -173,9 +169,6 @@ public class GrandExchangePlugin extends Plugin
@Inject @Inject
private Notifier notifier; private Notifier notifier;
@Inject
private ScheduledExecutorService executorService;
@Inject @Inject
private SessionManager sessionManager; private SessionManager sessionManager;
@@ -189,16 +182,10 @@ public class GrandExchangePlugin extends Plugin
private Widget grandExchangeItem; private Widget grandExchangeItem;
private String grandExchangeExamine; private String grandExchangeExamine;
private int osbItem;
private OSBGrandExchangeResult osbGrandExchangeResult;
@Inject @Inject
private GrandExchangeClient grandExchangeClient; private GrandExchangeClient grandExchangeClient;
private int lastLoginTick; private int lastLoginTick;
@Inject
private OSBGrandExchangeClient osbGrandExchangeClient;
private boolean wasFuzzySearch; private boolean wasFuzzySearch;
private String machineUuid; private String machineUuid;
@@ -318,9 +305,6 @@ public class GrandExchangePlugin extends Plugin
grandExchangeClient.setUuid(null); grandExchangeClient.setUuid(null);
} }
osbItem = -1;
osbGrandExchangeResult = null;
lastLoginTick = -1; lastLoginTick = -1;
} }
@@ -880,50 +864,17 @@ public class GrandExchangePlugin extends Plugin
} }
} }
if (config.showActivelyTradedPrice())
{
final int price = itemManager.getItemPriceWithSource(itemId, true);
if (price > 0)
{
text += "<br>Actively traded price: " + QuantityFormatter.formatNumber(price);
}
}
grandExchangeExamine = text; grandExchangeExamine = text;
geText.setText(text); geText.setText(text);
if (!config.enableOsbPrices())
{
return;
}
// If we already have the result, use it
if (osbGrandExchangeResult != null && osbGrandExchangeResult.getItem_id() == itemId && osbGrandExchangeResult.getOverall_average() > 0)
{
grandExchangeExamine = text + OSB_GE_TEXT + QuantityFormatter.formatNumber(osbGrandExchangeResult.getOverall_average());
geText.setText(grandExchangeExamine);
}
if (osbItem == itemId)
{
// avoid starting duplicate lookups
return;
}
osbItem = itemId;
log.debug("Looking up OSB item price {}", itemId);
final String start = text;
executorService.submit(() ->
{
try
{
final OSBGrandExchangeResult result = osbGrandExchangeClient.lookupItem(itemId);
if (result != null && result.getOverall_average() > 0)
{
osbGrandExchangeResult = result;
// Update the text on the widget too
grandExchangeExamine = start + OSB_GE_TEXT + QuantityFormatter.formatNumber(result.getOverall_average());
geText.setText(grandExchangeExamine);
}
}
catch (IOException e)
{
log.debug("Error getting price of item {}", itemId, e);
}
});
} }
static void openGeLink(String name, int itemId) static void openGeLink(String name, int itemId)

View File

@@ -34,12 +34,14 @@ import java.awt.GridBagLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.components.IconTextField; import net.runelite.client.ui.components.IconTextField;
@@ -64,6 +66,7 @@ class GrandExchangeSearchPanel extends JPanel
private final ClientThread clientThread; private final ClientThread clientThread;
private final ItemManager itemManager; private final ItemManager itemManager;
private final ScheduledExecutorService executor; private final ScheduledExecutorService executor;
private final RuneLiteConfig runeLiteConfig;
private final IconTextField searchBar = new IconTextField(); private final IconTextField searchBar = new IconTextField();
@@ -78,11 +81,14 @@ class GrandExchangeSearchPanel extends JPanel
private final List<GrandExchangeItems> itemsList = new ArrayList<>(); private final List<GrandExchangeItems> itemsList = new ArrayList<>();
GrandExchangeSearchPanel(ClientThread clientThread, ItemManager itemManager, ScheduledExecutorService executor) @Inject
private GrandExchangeSearchPanel(ClientThread clientThread, ItemManager itemManager,
ScheduledExecutorService executor, RuneLiteConfig runeLiteConfig)
{ {
this.clientThread = clientThread; this.clientThread = clientThread;
this.itemManager = itemManager; this.itemManager = itemManager;
this.executor = executor; this.executor = executor;
this.runeLiteConfig = runeLiteConfig;
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -192,6 +198,7 @@ class GrandExchangeSearchPanel extends JPanel
cardLayout.show(centerPanel, RESULTS_PANEL); cardLayout.show(centerPanel, RESULTS_PANEL);
int count = 0; int count = 0;
boolean useActivelyTradedPrice = runeLiteConfig.useWikiItemPrices();
for (ItemPrice item : result) for (ItemPrice item : result)
{ {
@@ -206,7 +213,7 @@ class GrandExchangeSearchPanel extends JPanel
ItemComposition itemComp = itemManager.getItemComposition(itemId); ItemComposition itemComp = itemManager.getItemComposition(itemId);
ItemStats itemStats = itemManager.getItemStats(itemId, false); ItemStats itemStats = itemManager.getItemStats(itemId, false);
int itemPrice = item.getPrice(); int itemPrice = useActivelyTradedPrice && item.getWikiPrice() > 0 ? item.getWikiPrice() : item.getPrice();
int itemLimit = itemStats != null ? itemStats.getGeLimit() : 0; int itemLimit = itemStats != null ? itemStats.getGeLimit() : 0;
AsyncBufferedImage itemImage = itemManager.getImage(itemId); AsyncBufferedImage itemImage = itemManager.getImage(itemId);

View File

@@ -208,7 +208,7 @@ public class ObjectIndicatorsPlugin extends Plugin
} }
} }
if (gameStateChanged.getGameState() != GameState.LOGGED_IN) if (gameStateChanged.getGameState() != GameState.LOGGED_IN && gameStateChanged.getGameState() != GameState.CONNECTION_LOST)
{ {
objects.clear(); objects.clear();
} }

View File

@@ -25,6 +25,7 @@
*/ */
package net.runelite.client.plugins.opponentinfo; package net.runelite.client.plugins.opponentinfo;
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
@@ -80,6 +81,8 @@ public class OpponentInfoPlugin extends Plugin
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Actor lastOpponent; private Actor lastOpponent;
@Getter(AccessLevel.PACKAGE)
@VisibleForTesting
private Instant lastTime; private Instant lastTime;
@Provides @Provides

View File

@@ -316,7 +316,14 @@ public class SlayerPlugin extends Plugin
private void setProfileConfig(String key, Object value) private void setProfileConfig(String key, Object value)
{ {
configManager.setRSProfileConfiguration(SlayerConfig.GROUP_NAME, key, value); if (value != null)
{
configManager.setRSProfileConfiguration(SlayerConfig.GROUP_NAME, key, value);
}
else
{
configManager.unsetRSProfileConfiguration(SlayerConfig.GROUP_NAME, key);
}
} }
private void save() private void save()

View File

@@ -49,6 +49,7 @@ import net.runelite.client.chat.ChatCommandManager;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.http.api.chat.ChatClient; import net.runelite.http.api.chat.ChatClient;
import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreSkill; import net.runelite.http.api.hiscore.HiscoreSkill;
@@ -106,6 +107,10 @@ public class ChatCommandsPluginTest
@Bind @Bind
ChatClient chatClient; ChatClient chatClient;
@Mock
@Bind
RuneLiteConfig runeLiteConfig;
@Mock @Mock
@Bind @Bind
ChatCommandsConfig chatCommandsConfig; ChatCommandsConfig chatCommandsConfig;

View File

@@ -32,7 +32,6 @@ import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
@@ -109,10 +108,6 @@ public class GrandExchangePluginTest
@Bind @Bind
private MouseManager mouseManager; private MouseManager mouseManager;
@Mock
@Bind
private ScheduledExecutorService scheduledExecutorService;
@Mock @Mock
@Bind @Bind
private GrandExchangeClient grandExchangeClient; private GrandExchangeClient grandExchangeClient;

View File

@@ -0,0 +1,180 @@
/*
* Copyright (c) 2021, Jordan Atwood <jordan.atwood423@gmail.com>
* 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.opponentinfo;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.testing.fieldbinder.Bind;
import com.google.inject.testing.fieldbinder.BoundFieldModule;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.Test;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.Mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class OpponentInfoPluginTest
{
@Mock
@Bind
Client client;
@Mock
@Bind
OverlayManager overlayManager;
@Mock
@Bind
OpponentInfoConfig config;
@Mock
@Bind
OpponentInfoOverlay opponentInfoOverlay;
@Mock
@Bind
PlayerComparisonOverlay playerComparisonOverlay;
@Inject
OpponentInfoPlugin plugin;
private final Player localPlayer = mock(Player.class);
@Before
public void before()
{
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
when(client.getLocalPlayer()).thenReturn(localPlayer);
}
@Test
public void testNpcInteractions()
{
final NPC npc = mock(NPC.class);
interactingChanged(npc, localPlayer);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(npc, null);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(localPlayer, npc);
assertSame(npc, plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(npc, localPlayer);
assertSame(npc, plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(localPlayer, null);
// last opponent is remembered for 5 seconds
assertSame(npc, plugin.getLastOpponent());
assertNotNull(plugin.getLastTime());
}
@Test
public void testOtherPlayerInteractions()
{
final Player otherPlayer = mock(Player.class);
interactingChanged(otherPlayer, localPlayer);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(otherPlayer, null);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(localPlayer, otherPlayer);
assertSame(otherPlayer, plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(otherPlayer, localPlayer);
assertSame(otherPlayer, plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(localPlayer, null);
// last opponent is remembered for 5 seconds
assertSame(otherPlayer, plugin.getLastOpponent());
assertNotNull(plugin.getLastTime());
}
@Test
public void testNonLocalPlayerInteractions()
{
final Player otherPlayer = mock(Player.class);
final NPC npc = mock(NPC.class);
interactingChanged(otherPlayer, npc);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(npc, otherPlayer);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(otherPlayer, null);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
interactingChanged(npc, null);
assertNull(plugin.getLastOpponent());
assertNull(plugin.getLastTime());
}
private void interactingChanged(final Actor source, final Actor target)
{
when(source.getInteracting()).thenReturn(target);
plugin.onInteractingChanged(new InteractingChanged(source, target));
}
}

View File

@@ -553,6 +553,8 @@ public class SlayerPluginTest
assertEquals("", slayerPlugin.getTaskName()); assertEquals("", slayerPlugin.getTaskName());
assertEquals(0, slayerPlugin.getAmount()); assertEquals(0, slayerPlugin.getAmount());
verify(configManager).unsetRSProfileConfiguration(SlayerConfig.GROUP_NAME, SlayerConfig.TASK_LOC_KEY);
} }
@Test @Test