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

@@ -84,6 +84,7 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.Player;
@@ -445,7 +446,7 @@ public class ConfigManager
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))
{
@@ -565,6 +566,7 @@ public class ConfigManager
ConfigChanged configChanged = new ConfigChanged();
configChanged.setGroup(groupName);
configChanged.setProfile(profile);
configChanged.setKey(key);
configChanged.setOldValue(oldValue);

View File

@@ -381,17 +381,6 @@ public interface RuneLiteConfig extends Config
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(
keyName = "sidebarToggleKey",
name = "Sidebar Toggle Key",
@@ -415,4 +404,26 @@ public interface RuneLiteConfig extends Config
{
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.PostItemComposition;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.util.AsyncBufferedImage;
@@ -87,6 +88,7 @@ public class ItemManager
private final Client client;
private final ClientThread clientThread;
private final ItemClient itemClient;
private final RuneLiteConfig runeLiteConfig;
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
@@ -171,11 +173,12 @@ public class ItemManager
@Inject
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
OkHttpClient okHttpClient, EventBus eventBus)
OkHttpClient okHttpClient, EventBus eventBus, RuneLiteConfig runeLiteConfig)
{
this.client = client;
this.clientThread = clientThread;
this.itemClient = new ItemClient(okHttpClient);
this.runeLiteConfig = runeLiteConfig;
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
scheduledExecutorService.submit(this::loadStats);
@@ -293,17 +296,36 @@ public class ItemManager
*/
public int getItemPrice(int itemID)
{
return getItemPrice(itemID, false);
return getItemPriceWithSource(itemID, runeLiteConfig.useWikiItemPrices());
}
/**
* Look up an item's price
*
* @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
*/
@Deprecated(since = "4.1.0", forRemoval = true)
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)
{
@@ -331,7 +353,7 @@ public class ItemManager
if (ip != null)
{
price += ip.getPrice();
price = useWikiPrice && ip.getWikiPrice() > 0 ? ip.getWikiPrice() : ip.getPrice();
}
}
else
@@ -343,7 +365,7 @@ public class ItemManager
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 LoopTimer barrowsPrayerDrainTimer;
private boolean wasInCrypt = false;
@Getter
private Widget puzzleAnswer;
@@ -128,7 +127,6 @@ public class BarrowsPlugin extends Plugin
overlayManager.remove(barrowsOverlay);
overlayManager.remove(brotherOverlay);
puzzleAnswer = null;
wasInCrypt = false;
stopPrayerDrainTimer();
// Restore widgets
@@ -157,18 +155,14 @@ public class BarrowsPlugin extends Plugin
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState() == GameState.LOADING)
{
wasInCrypt = isInCrypt();
}
else if (event.getGameState() == GameState.LOGGED_IN)
if (event.getGameState() == GameState.LOGGED_IN)
{
boolean isInCrypt = isInCrypt();
if (wasInCrypt && !isInCrypt)
if (!isInCrypt && barrowsPrayerDrainTimer != null)
{
stopPrayerDrainTimer();
}
else if (!wasInCrypt && isInCrypt)
else if (isInCrypt && barrowsPrayerDrainTimer == null)
{
startPrayerDrainTimer();
}
@@ -233,6 +227,7 @@ public class BarrowsPlugin extends Plugin
{
if (config.showPrayerDrainTimer())
{
assert barrowsPrayerDrainTimer == null;
final LoopTimer loopTimer = new LoopTimer(
PRAYER_DRAIN_INTERVAL_MS,
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.ChatMessageManager;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ChatInput;
import net.runelite.client.game.ItemManager;
@@ -177,6 +178,9 @@ public class ChatCommandsPlugin extends Plugin
@Inject
private ChatClient chatClient;
@Inject
private RuneLiteConfig runeLiteConfig;
@Override
public void startUp()
{
@@ -996,7 +1000,7 @@ public class ChatCommandsPlugin extends Plugin
ItemPrice item = retrieveFromList(results, search);
int itemId = item.getId();
int itemPrice = item.getPrice();
int itemPrice = runeLiteConfig.useWikiItemPrices() && item.getWikiPrice() > 0 ? item.getWikiPrice() : item.getPrice();
final ChatMessageBuilder builder = new ChatMessageBuilder()
.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 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)),
// 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_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_T), 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("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 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("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)),

View File

@@ -57,13 +57,13 @@ public interface GrandExchangeConfig extends Config
@ConfigItem(
position = 3,
keyName = "enableOsbPrices",
name = "Enable OSB actively traded prices",
description = "Shows the OSBuddy actively traded price on the GE buy interface"
keyName = "showActivelyTradedPrice",
name = "Enable actively traded prices",
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(

View File

@@ -38,7 +38,7 @@ import net.runelite.api.ItemComposition;
import net.runelite.client.ui.ColorScheme;
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 OFFERS_PANEL = "OFFERS_PANEL";

View File

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

View File

@@ -36,7 +36,6 @@ import com.google.gson.Gson;
import com.google.inject.Provides;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.time.Duration;
@@ -48,7 +47,6 @@ import java.util.EnumSet;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.ToIntFunction;
import java.util.stream.Collectors;
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.item.ItemStats;
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
import net.runelite.http.api.osbuddy.OSBGrandExchangeResult;
import net.runelite.http.api.worlds.WorldType;
import okhttp3.OkHttpClient;
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 OFFER_CONTAINER_ITEM = 21;
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_KEY = "buylimit";
@@ -173,9 +169,6 @@ public class GrandExchangePlugin extends Plugin
@Inject
private Notifier notifier;
@Inject
private ScheduledExecutorService executorService;
@Inject
private SessionManager sessionManager;
@@ -189,16 +182,10 @@ public class GrandExchangePlugin extends Plugin
private Widget grandExchangeItem;
private String grandExchangeExamine;
private int osbItem;
private OSBGrandExchangeResult osbGrandExchangeResult;
@Inject
private GrandExchangeClient grandExchangeClient;
private int lastLoginTick;
@Inject
private OSBGrandExchangeClient osbGrandExchangeClient;
private boolean wasFuzzySearch;
private String machineUuid;
@@ -318,9 +305,6 @@ public class GrandExchangePlugin extends Plugin
grandExchangeClient.setUuid(null);
}
osbItem = -1;
osbGrandExchangeResult = null;
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;
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)

View File

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

View File

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

View File

@@ -316,7 +316,14 @@ public class SlayerPlugin extends Plugin
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()