Merge remote-tracking branch 'upstream/master' into master

This commit is contained in:
ThatGamerBlue
2021-04-14 13:20:19 +01:00
24 changed files with 612 additions and 129 deletions

View File

@@ -42,8 +42,6 @@ public class ArdougneDiaryRequirement extends GenericDiaryRequirement
new SkillRequirement(Skill.THIEVING, 5));
add("Enter the Combat Training Camp north of W. Ardougne.",
new QuestRequirement(Quest.BIOHAZARD));
add("Go out fishing on the Fishing Trawler.",
new SkillRequirement(Skill.FISHING, 15));
// MEDIUM
add("Enter the Unicorn pen in Ardougne zoo using Fairy rings.",

View File

@@ -38,7 +38,6 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -53,7 +52,6 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.Experience;
import net.runelite.api.Player;
import net.runelite.api.WorldType;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel;
@@ -118,7 +116,7 @@ public class HiscorePanel extends PluginPanel
HiscoreEndpoint.NORMAL, HiscoreEndpoint.IRONMAN, HiscoreEndpoint.HARDCORE_IRONMAN, HiscoreEndpoint.ULTIMATE_IRONMAN, HiscoreEndpoint.DEADMAN, HiscoreEndpoint.LEAGUE
};
private final Client client;
private final HiscorePlugin plugin;
private final HiscoreConfig config;
private final NameAutocompleter nameAutocompleter;
private final HiscoreClient hiscoreClient;
@@ -138,10 +136,10 @@ public class HiscorePanel extends PluginPanel
private boolean loading = false;
@Inject
public HiscorePanel(@Nullable Client client,
HiscoreConfig config, NameAutocompleter nameAutocompleter, OkHttpClient okHttpClient)
public HiscorePanel(@Nullable Client client, HiscorePlugin plugin, HiscoreConfig config,
NameAutocompleter nameAutocompleter, OkHttpClient okHttpClient)
{
this.client = client;
this.plugin = plugin;
this.config = config;
this.nameAutocompleter = nameAutocompleter;
this.hiscoreClient = new HiscoreClient(okHttpClient);
@@ -187,7 +185,7 @@ public class HiscorePanel extends PluginPanel
if (localPlayer != null)
{
lookup(localPlayer.getName());
lookup(localPlayer.getName(), plugin.getLocalHiscoreEndpoint());
}
}
});
@@ -360,10 +358,10 @@ public class HiscorePanel extends PluginPanel
return skillPanel;
}
public void lookup(String username)
public void lookup(String username, HiscoreEndpoint endpoint)
{
searchBar.setText(username);
resetEndpoints();
tabGroup.select(tabGroup.getTab(ArrayUtils.indexOf(ENDPOINTS, endpoint)));
lookup();
}
@@ -720,33 +718,11 @@ public class HiscorePanel extends PluginPanel
private void resetEndpoints()
{
// Select the correct tab based on the world type.
HiscoreEndpoint endpoint = selectWorldEndpoint();
HiscoreEndpoint endpoint = plugin.getWorldEndpoint();
int idx = ArrayUtils.indexOf(ENDPOINTS, endpoint);
tabGroup.select(tabGroup.getTab(idx));
}
private HiscoreEndpoint selectWorldEndpoint()
{
if (client != null)
{
EnumSet<WorldType> wTypes = client.getWorldType();
if (wTypes.contains(WorldType.DEADMAN_TOURNAMENT))
{
return HiscoreEndpoint.TOURNAMENT;
}
else if (wTypes.contains(WorldType.DEADMAN))
{
return HiscoreEndpoint.DEADMAN;
}
else if (wTypes.contains(WorldType.LEAGUE))
{
return HiscoreEndpoint.LEAGUE;
}
}
return HiscoreEndpoint.NORMAL;
}
@VisibleForTesting
static String formatLevel(int level)
{

View File

@@ -28,20 +28,25 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ObjectArrays;
import com.google.inject.Provides;
import java.awt.image.BufferedImage;
import java.util.EnumSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.swing.SwingUtilities;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.IconID;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.Player;
import net.runelite.api.WorldType;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
@@ -53,6 +58,7 @@ import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor(
@@ -84,6 +90,9 @@ public class HiscorePlugin extends Plugin
private NavigationButton navButton;
private HiscorePanel hiscorePanel;
@Getter
private HiscoreEndpoint localHiscoreEndpoint;
@Provides
HiscoreConfig provideConfig(ConfigManager configManager)
{
@@ -181,6 +190,7 @@ public class HiscorePlugin extends Plugin
&& event.getMenuOption().equals(LOOKUP))
{
final String target;
HiscoreEndpoint endpoint = HiscoreEndpoint.NORMAL;
if (event.getMenuAction() == MenuAction.RUNELITE_PLAYER)
{
// The player id is included in the event, so we can use that to get the player name,
@@ -195,10 +205,13 @@ public class HiscorePlugin extends Plugin
}
else
{
// Determine proper endpoint from player name.
// TODO: look at target's world and determine if tournament/dmm endpoint should be used instead.
endpoint = findHiscoreEndpointFromPlayerName(event.getMenuTarget());
target = Text.removeTags(event.getMenuTarget());
}
lookupPlayer(target);
lookupPlayer(target, endpoint);
}
}
@@ -214,10 +227,16 @@ public class HiscorePlugin extends Plugin
Matcher m = BOUNTY_PATTERN.matcher(message);
if (m.matches())
{
lookupPlayer(m.group(1));
lookupPlayer(m.group(1), HiscoreEndpoint.NORMAL);
}
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
localHiscoreEndpoint = findHiscoreEndpointFromLocalPlayer();
}
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries)
{
MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry);
@@ -226,7 +245,7 @@ public class HiscorePlugin extends Plugin
client.setMenuEntries(newMenu);
}
private void lookupPlayer(String playerName)
private void lookupPlayer(String playerName, HiscoreEndpoint endpoint)
{
SwingUtilities.invokeLater(() ->
{
@@ -234,7 +253,73 @@ public class HiscorePlugin extends Plugin
{
navButton.getOnSelect().run();
}
hiscorePanel.lookup(playerName);
hiscorePanel.lookup(playerName, endpoint);
});
}
HiscoreEndpoint getWorldEndpoint()
{
if (client != null)
{
EnumSet<WorldType> wTypes = client.getWorldType();
if (wTypes.contains(WorldType.DEADMAN_TOURNAMENT))
{
return HiscoreEndpoint.TOURNAMENT;
}
else if (wTypes.contains(WorldType.DEADMAN))
{
return HiscoreEndpoint.DEADMAN;
}
else if (wTypes.contains(WorldType.LEAGUE))
{
return HiscoreEndpoint.LEAGUE;
}
}
return HiscoreEndpoint.NORMAL;
}
private HiscoreEndpoint findHiscoreEndpointFromLocalPlayer()
{
final HiscoreEndpoint profile = getWorldEndpoint();
if (profile != HiscoreEndpoint.NORMAL)
{
return profile;
}
if (client != null)
{
switch (client.getAccountType())
{
case IRONMAN:
return HiscoreEndpoint.IRONMAN;
case ULTIMATE_IRONMAN:
return HiscoreEndpoint.ULTIMATE_IRONMAN;
case HARDCORE_IRONMAN:
return HiscoreEndpoint.HARDCORE_IRONMAN;
}
}
return HiscoreEndpoint.NORMAL;
}
private HiscoreEndpoint findHiscoreEndpointFromPlayerName(String name)
{
if (name.contains(IconID.IRONMAN.toString()))
{
return HiscoreEndpoint.IRONMAN;
}
if (name.contains(IconID.ULTIMATE_IRONMAN.toString()))
{
return HiscoreEndpoint.ULTIMATE_IRONMAN;
}
if (name.contains(IconID.HARDCORE_IRONMAN.toString()))
{
return HiscoreEndpoint.HARDCORE_IRONMAN;
}
if (name.contains(IconID.LEAGUE.toString()))
{
return HiscoreEndpoint.LEAGUE;
}
return HiscoreEndpoint.NORMAL;
}
}

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.specialcounter;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -314,7 +315,7 @@ public class SpecialCounterPlugin extends Plugin
for (SpecialWeapon specialWeapon : SpecialWeapon.values())
{
if (specialWeapon.getItemID() == weapon.getId())
if (Arrays.stream(specialWeapon.getItemID()).anyMatch(id -> id == weapon.getId()))
{
return specialWeapon;
}
@@ -328,7 +329,7 @@ public class SpecialCounterPlugin extends Plugin
if (counter == null)
{
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()), this, config,
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()[0]), this, config,
hit, specialWeapon);
infoBoxManager.addInfoBox(counter);
specialCounter[specialWeapon.ordinal()] = counter;

View File

@@ -33,20 +33,16 @@ import net.runelite.api.ItemID;
@Getter
enum SpecialWeapon
{
DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false, SpecialCounterConfig::dragonWarhammerThreshold),
ARCLIGHT("Arclight", ItemID.ARCLIGHT, false, SpecialCounterConfig::arclightThreshold),
DARKLIGHT("Darklight", ItemID.DARKLIGHT, false, SpecialCounterConfig::darklightThreshold),
BANDOS_GODSWORD("Bandos Godsword", ItemID.BANDOS_GODSWORD, true, SpecialCounterConfig::bandosGodswordThreshold),
BANDOS_GODSWORD_OR("Bandos Godsword", ItemID.BANDOS_GODSWORD_OR, true, SpecialCounterConfig::bandosGodswordThreshold),
BARRELCHEST_ANCHOR("Barrelchest Anchor", ItemID.BARRELCHEST_ANCHOR, true, (c) -> 0),
BONE_DAGGER("Bone Dagger", ItemID.BONE_DAGGER, true, (c) -> 0),
BONE_DAGGER_P("Bone Dagger (p)", ItemID.BONE_DAGGER_P, true, (c) -> 0),
BONE_DAGGER_P8876("Bone Dagger (p+)", ItemID.BONE_DAGGER_P_8876, true, (c) -> 0),
BONE_DAGGER_P8878("Bone Dagger (p++)", ItemID.BONE_DAGGER_P_8878, true, (c) -> 0),
DORGESHUUN_CROSSBOW("Dorgeshuun Crossbow", ItemID.DORGESHUUN_CROSSBOW, true, (c) -> 0);
DRAGON_WARHAMMER("Dragon Warhammer", new int[]{ItemID.DRAGON_WARHAMMER}, false, SpecialCounterConfig::dragonWarhammerThreshold),
ARCLIGHT("Arclight", new int[]{ItemID.ARCLIGHT}, false, SpecialCounterConfig::arclightThreshold),
DARKLIGHT("Darklight", new int[]{ItemID.DARKLIGHT}, false, SpecialCounterConfig::darklightThreshold),
BANDOS_GODSWORD("Bandos Godsword", new int[]{ItemID.BANDOS_GODSWORD, ItemID.BANDOS_GODSWORD_OR}, true, SpecialCounterConfig::bandosGodswordThreshold),
BARRELCHEST_ANCHOR("Barrelchest Anchor", new int[]{ItemID.BARRELCHEST_ANCHOR}, true, (c) -> 0),
BONE_DAGGER("Bone Dagger", new int[]{ItemID.BONE_DAGGER, ItemID.BONE_DAGGER_P, ItemID.BONE_DAGGER_P_8876, ItemID.BONE_DAGGER_P_8878}, true, (c) -> 0),
DORGESHUUN_CROSSBOW("Dorgeshuun Crossbow", new int[]{ItemID.DORGESHUUN_CROSSBOW}, true, (c) -> 0);
private final String name;
private final int itemID;
private final int[] itemID;
private final boolean damage;
private final Function<SpecialCounterConfig, Integer> threshold;
}

View File

@@ -42,6 +42,7 @@ public interface TimeTrackingConfig extends Config
String STOPWATCHES = "stopwatches";
String PREFER_SOONEST = "preferSoonest";
String NOTIFY = "notify";
String BIRDHOUSE_NOTIFY = "birdHouseNotification";
@ConfigItem(
keyName = "timeFormatMode",
@@ -65,17 +66,6 @@ public interface TimeTrackingConfig extends Config
return false;
}
@ConfigItem(
keyName = "birdHouseNotification",
name = "Bird house notification",
description = "Notify you when all bird houses are full",
position = 3
)
default boolean birdHouseNotification()
{
return false;
}
@ConfigItem(
keyName = "farmingContractInfoBox",
name = "Show farming contract infobox",

View File

@@ -31,24 +31,29 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.ItemID;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.timetracking.TabContentPanel;
import net.runelite.client.plugins.timetracking.TimeTrackingConfig;
import net.runelite.client.plugins.timetracking.TimeablePanel;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.DynamicGridLayout;
import javax.swing.JToggleButton;
public class BirdHouseTabPanel extends TabContentPanel
{
private static final Color COMPLETED_COLOR = ColorScheme.PROGRESS_COMPLETE_COLOR.darker();
private final ConfigManager configManager;
private final ItemManager itemManager;
private final BirdHouseTracker birdHouseTracker;
private final TimeTrackingConfig config;
private final List<TimeablePanel<BirdHouseSpace>> spacePanels;
BirdHouseTabPanel(ItemManager itemManager, BirdHouseTracker birdHouseTracker, TimeTrackingConfig config)
BirdHouseTabPanel(ConfigManager configManager, ItemManager itemManager, BirdHouseTracker birdHouseTracker,
TimeTrackingConfig config)
{
this.configManager = configManager;
this.itemManager = itemManager;
this.birdHouseTracker = birdHouseTracker;
this.config = config;
@@ -71,6 +76,17 @@ public class BirdHouseTabPanel extends TabContentPanel
first = false;
panel.setBorder(null);
}
JToggleButton toggleNotify = panel.getNotifyButton();
toggleNotify.addActionListener(e ->
{
if (configManager.getRSProfileKey() != null)
{
configManager.setRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.BIRDHOUSE_NOTIFY, toggleNotify.isSelected());
}
spacePanels.forEach(p -> p.getNotifyButton().setSelected(toggleNotify.isSelected()));
});
}
}
@@ -85,6 +101,9 @@ public class BirdHouseTabPanel extends TabContentPanel
{
long unixNow = Instant.now().getEpochSecond();
boolean notifications = Boolean.TRUE
.equals(configManager.getRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.BIRDHOUSE_NOTIFY, boolean.class));
for (TimeablePanel<BirdHouseSpace> panel : spacePanels)
{
BirdHouseSpace space = panel.getTimeable();
@@ -113,6 +132,8 @@ public class BirdHouseTabPanel extends TabContentPanel
panel.getProgress().setVisible(true);
}
panel.getNotifyButton().setSelected(notifications);
panel.getProgress().setForeground(state.getColor().darker());
switch (state)

View File

@@ -84,7 +84,7 @@ public class BirdHouseTracker
public BirdHouseTabPanel createBirdHouseTabPanel()
{
return new BirdHouseTabPanel(itemManager, this, config);
return new BirdHouseTabPanel(configManager, itemManager, this, config);
}
public void loadFromConfig()
@@ -180,7 +180,7 @@ public class BirdHouseTracker
summary = SummaryState.COMPLETED;
completionTime = 0;
if (config.birdHouseNotification())
if (Boolean.TRUE.equals(configManager.getRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.BIRDHOUSE_NOTIFY, boolean.class)))
{
notifier.notify("Your bird houses are ready to be dismantled.");
}

View File

@@ -75,10 +75,22 @@ public class ContainableFrame extends JFrame
javaVersion = javaVersion.substring(0, idx);
}
String[] s = javaVersion.split("\\.");
int major = Integer.parseInt(s[0]), minor = Integer.parseInt(s[1]), patch = Integer.parseInt(s[2]);
int major, minor, patch;
if (s.length == 3)
{
major = Integer.parseInt(s[0]);
minor = Integer.parseInt(s[1]);
patch = Integer.parseInt(s[2]);
}
else
{
major = Integer.parseInt(s[0]);
minor = -1;
patch = -1;
}
if (major == 12 || major == 13 || major == 14)
{
// These versions are since EOL & do not include JDK-8231564
// These versions are since EOL & do not include JDK-8231564, except for 13.0.4+
return false;
}
return major > 11 || (major == 11 && minor > 0) || (major == 11 && minor == 0 && patch >= 8);
@@ -138,6 +150,7 @@ public class ContainableFrame extends JFrame
/**
* Expand frame by specified value. If the frame is going to be expanded outside of screen push the frame to
* the side.
*
* @param value size to expand frame by
*/
public void expandBy(final int value)
@@ -197,6 +210,7 @@ public class ContainableFrame extends JFrame
/**
* Contract frame by specified value. If new frame size is less than it's minimum size, force the minimum size.
* If the frame was pushed from side before, restore it's original position.
*
* @param value value to contract frame by
*/
public void contractBy(final int value)