Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2021-12-15 05:49:19 +01:00
28 changed files with 382 additions and 141 deletions

View File

@@ -29,7 +29,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.runelite.api.Player;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.client.hiscore.HiscoreResult;
@Getter
@Setter

View File

@@ -33,9 +33,9 @@ import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemMapping;
import net.runelite.client.hiscore.HiscoreClient;
import net.runelite.client.hiscore.HiscoreResult;
import net.runelite.client.util.PvPUtil;
import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.http.api.item.ItemEquipmentStats;
import net.runelite.http.api.item.ItemStats;
import okhttp3.OkHttpClient;

View File

@@ -0,0 +1,165 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.hiscore;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
@Slf4j
@RequiredArgsConstructor
public class HiscoreClient
{
private final OkHttpClient client;
public HiscoreResult lookup(String username, HiscoreEndpoint endpoint) throws IOException
{
return lookup(username, endpoint.getHiscoreURL());
}
public CompletableFuture<HiscoreResult> lookupAsync(String username, HiscoreEndpoint endpoint)
{
return lookupAsync(username, endpoint.getHiscoreURL());
}
public HiscoreResult lookup(String username, HttpUrl endpoint) throws IOException
{
return lookupSync(username, endpoint);
}
public HiscoreResult lookup(String username) throws IOException
{
return lookup(username, HiscoreEndpoint.NORMAL);
}
private HiscoreResult lookupSync(String username, HttpUrl hiscoreUrl) throws IOException
{
try (Response response = client.newCall(buildRequest(username, hiscoreUrl)).execute())
{
return processResponse(username, response);
}
}
private CompletableFuture<HiscoreResult> lookupAsync(String username, HttpUrl hiscoreUrl)
{
CompletableFuture<HiscoreResult> future = new CompletableFuture<>();
client.newCall(buildRequest(username, hiscoreUrl)).enqueue(new Callback()
{
@Override
public void onFailure(Call call, IOException e)
{
future.completeExceptionally(e);
}
@Override
public void onResponse(Call call, Response response) throws IOException
{
try // NOPMD: UseTryWithResources
{
future.complete(processResponse(username, response));
}
finally
{
response.close();
}
}
});
return future;
}
private static Request buildRequest(String username, HttpUrl hiscoreUrl)
{
HttpUrl url = hiscoreUrl.newBuilder()
.addQueryParameter("player", username)
.build();
log.debug("Built URL {}", url);
return new Request.Builder()
.url(url)
.build();
}
private static HiscoreResult processResponse(String username, Response response) throws IOException
{
if (!response.isSuccessful())
{
if (response.code() == 404)
{
return null;
}
throw new IOException("Error retrieving data from Jagex Hiscores: " + response);
}
String responseStr = response.body().string();
return parseResponse(username, responseStr);
}
private static HiscoreResult parseResponse(String username, String responseStr) throws IOException
{
CSVParser parser = CSVParser.parse(responseStr, CSVFormat.DEFAULT);
HiscoreResultBuilder hiscoreBuilder = new HiscoreResultBuilder(username);
int count = 0;
for (CSVRecord record : parser.getRecords())
{
if (count++ >= HiscoreSkill.values().length)
{
log.warn("Jagex Hiscore API returned unexpected data");
break; // rest is other things?
}
// rank, level, experience
int rank = Integer.parseInt(record.get(0));
int level = Integer.parseInt(record.get(1));
// items that are not skills do not have an experience parameter
long experience = -1;
if (record.size() == 3)
{
experience = Long.parseLong(record.get(2));
}
Skill skill = new Skill(rank, level, experience);
hiscoreBuilder.setNextSkill(skill);
}
return hiscoreBuilder.build();
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 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 HOLDER 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.hiscore;
import lombok.Getter;
import okhttp3.HttpUrl;
@Getter
public enum HiscoreEndpoint
{
NORMAL("Normal", "https://services.runescape.com/m=hiscore_oldschool/index_lite.ws"),
IRONMAN("Ironman", "https://services.runescape.com/m=hiscore_oldschool_ironman/index_lite.ws"),
HARDCORE_IRONMAN("Hardcore Ironman", "https://services.runescape.com/m=hiscore_oldschool_hardcore_ironman/index_lite.ws"),
ULTIMATE_IRONMAN("Ultimate Ironman", "https://services.runescape.com/m=hiscore_oldschool_ultimate/index_lite.ws"),
DEADMAN("Deadman", "https://services.runescape.com/m=hiscore_oldschool_deadman/index_lite.ws"),
LEAGUE("Leagues", "https://services.runescape.com/m=hiscore_oldschool_seasonal/index_lite.ws"),
TOURNAMENT("Tournament", "https://services.runescape.com/m=hiscore_oldschool_tournament/index_lite.ws");
private final String name;
private final HttpUrl hiscoreURL;
HiscoreEndpoint(String name, String hiscoreURL)
{
this.name = name;
this.hiscoreURL = HttpUrl.get(hiscoreURL);
}
}

View File

@@ -22,7 +22,7 @@
* (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.game;
package net.runelite.client.hiscore;
import com.google.common.cache.CacheLoader;
import com.google.common.util.concurrent.ListenableFuture;
@@ -31,11 +31,8 @@ import com.google.common.util.concurrent.MoreExecutors;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService;
import lombok.extern.slf4j.Slf4j;
import static net.runelite.client.game.HiscoreManager.EMPTY;
import static net.runelite.client.game.HiscoreManager.NONE;
import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
import static net.runelite.client.hiscore.HiscoreManager.EMPTY;
import static net.runelite.client.hiscore.HiscoreManager.NONE;
@Slf4j
class HiscoreLoader extends CacheLoader<HiscoreManager.HiscoreKey, HiscoreResult>

View File

@@ -22,7 +22,7 @@
* (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.game;
package net.runelite.client.hiscore;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.LoadingCache;
@@ -33,9 +33,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AllArgsConstructor;
import lombok.Data;
import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
import okhttp3.OkHttpClient;
@Singleton
@@ -56,7 +53,7 @@ public class HiscoreManager
private final HiscoreClient hiscoreClient;
@Inject
public HiscoreManager(ScheduledExecutorService executor, OkHttpClient okHttpClient)
private HiscoreManager(ScheduledExecutorService executor, OkHttpClient okHttpClient)
{
hiscoreClient = new HiscoreClient(okHttpClient);
hiscoreCache = CacheBuilder.newBuilder()

View File

@@ -0,0 +1,294 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.hiscore;
import lombok.Data;
@Data
public class HiscoreResult
{
private String player;
private Skill overall;
private Skill attack;
private Skill defence;
private Skill strength;
private Skill hitpoints;
private Skill ranged;
private Skill prayer;
private Skill magic;
private Skill cooking;
private Skill woodcutting;
private Skill fletching;
private Skill fishing;
private Skill firemaking;
private Skill crafting;
private Skill smithing;
private Skill mining;
private Skill herblore;
private Skill agility;
private Skill thieving;
private Skill slayer;
private Skill farming;
private Skill runecraft;
private Skill hunter;
private Skill construction;
private Skill leaguePoints;
private Skill bountyHunterHunter;
private Skill bountyHunterRogue;
private Skill clueScrollAll;
private Skill clueScrollBeginner;
private Skill clueScrollEasy;
private Skill clueScrollMedium;
private Skill clueScrollHard;
private Skill clueScrollElite;
private Skill clueScrollMaster;
private Skill lastManStanding;
private Skill soulWarsZeal;
private Skill abyssalSire;
private Skill alchemicalHydra;
private Skill barrowsChests;
private Skill bryophyta;
private Skill callisto;
private Skill cerberus;
private Skill chambersOfXeric;
private Skill chambersOfXericChallengeMode;
private Skill chaosElemental;
private Skill chaosFanatic;
private Skill commanderZilyana;
private Skill corporealBeast;
private Skill crazyArchaeologist;
private Skill dagannothPrime;
private Skill dagannothRex;
private Skill dagannothSupreme;
private Skill derangedArchaeologist;
private Skill generalGraardor;
private Skill giantMole;
private Skill grotesqueGuardians;
private Skill hespori;
private Skill kalphiteQueen;
private Skill kingBlackDragon;
private Skill kraken;
private Skill kreearra;
private Skill krilTsutsaroth;
private Skill mimic;
private Skill nex;
private Skill nightmare;
private Skill phosanisNightmare;
private Skill obor;
private Skill sarachnis;
private Skill scorpia;
private Skill skotizo;
private Skill tempoross;
private Skill gauntlet;
private Skill corruptedGauntlet;
private Skill theatreOfBlood;
private Skill theatreOfBloodHardMode;
private Skill thermonuclearSmokeDevil;
private Skill tzKalZuk;
private Skill tzTokJad;
private Skill venenatis;
private Skill vetion;
private Skill vorkath;
private Skill wintertodt;
private Skill zalcano;
private Skill zulrah;
public Skill getSkill(HiscoreSkill skill)
{
switch (skill)
{
case ATTACK:
return attack;
case DEFENCE:
return defence;
case STRENGTH:
return strength;
case HITPOINTS:
return hitpoints;
case RANGED:
return ranged;
case PRAYER:
return prayer;
case MAGIC:
return magic;
case COOKING:
return cooking;
case WOODCUTTING:
return woodcutting;
case FLETCHING:
return fletching;
case FISHING:
return fishing;
case FIREMAKING:
return firemaking;
case CRAFTING:
return crafting;
case SMITHING:
return smithing;
case MINING:
return mining;
case HERBLORE:
return herblore;
case AGILITY:
return agility;
case THIEVING:
return thieving;
case SLAYER:
return slayer;
case FARMING:
return farming;
case RUNECRAFT:
return runecraft;
case HUNTER:
return hunter;
case CONSTRUCTION:
return construction;
case LEAGUE_POINTS:
return leaguePoints;
case OVERALL:
return overall;
case BOUNTY_HUNTER_HUNTER:
return bountyHunterHunter;
case BOUNTY_HUNTER_ROGUE:
return bountyHunterRogue;
case CLUE_SCROLL_ALL:
return clueScrollAll;
case CLUE_SCROLL_BEGINNER:
return clueScrollBeginner;
case CLUE_SCROLL_EASY:
return clueScrollEasy;
case CLUE_SCROLL_MEDIUM:
return clueScrollMedium;
case CLUE_SCROLL_HARD:
return clueScrollHard;
case CLUE_SCROLL_ELITE:
return clueScrollElite;
case CLUE_SCROLL_MASTER:
return clueScrollMaster;
case LAST_MAN_STANDING:
return lastManStanding;
case SOUL_WARS_ZEAL:
return soulWarsZeal;
case ABYSSAL_SIRE:
return abyssalSire;
case ALCHEMICAL_HYDRA:
return alchemicalHydra;
case BARROWS_CHESTS:
return barrowsChests;
case BRYOPHYTA:
return bryophyta;
case CALLISTO:
return callisto;
case CERBERUS:
return cerberus;
case CHAMBERS_OF_XERIC:
return chambersOfXeric;
case CHAMBERS_OF_XERIC_CHALLENGE_MODE:
return chambersOfXericChallengeMode;
case CHAOS_ELEMENTAL:
return chaosElemental;
case CHAOS_FANATIC:
return chaosFanatic;
case COMMANDER_ZILYANA:
return commanderZilyana;
case CORPOREAL_BEAST:
return corporealBeast;
case CRAZY_ARCHAEOLOGIST:
return crazyArchaeologist;
case DAGANNOTH_PRIME:
return dagannothPrime;
case DAGANNOTH_REX:
return dagannothRex;
case DAGANNOTH_SUPREME:
return dagannothSupreme;
case DERANGED_ARCHAEOLOGIST:
return derangedArchaeologist;
case GENERAL_GRAARDOR:
return generalGraardor;
case GIANT_MOLE:
return giantMole;
case GROTESQUE_GUARDIANS:
return grotesqueGuardians;
case HESPORI:
return hespori;
case KALPHITE_QUEEN:
return kalphiteQueen;
case KING_BLACK_DRAGON:
return kingBlackDragon;
case KRAKEN:
return kraken;
case KREEARRA:
return kreearra;
case KRIL_TSUTSAROTH:
return krilTsutsaroth;
case MIMIC:
return mimic;
case NEX:
return nex;
case NIGHTMARE:
return nightmare;
case PHOSANIS_NIGHTMARE:
return phosanisNightmare;
case OBOR:
return obor;
case SARACHNIS:
return sarachnis;
case SCORPIA:
return scorpia;
case SKOTIZO:
return skotizo;
case TEMPOROSS:
return tempoross;
case THE_GAUNTLET:
return gauntlet;
case THE_CORRUPTED_GAUNTLET:
return corruptedGauntlet;
case THEATRE_OF_BLOOD:
return theatreOfBlood;
case THEATRE_OF_BLOOD_HARD_MODE:
return theatreOfBloodHardMode;
case THERMONUCLEAR_SMOKE_DEVIL:
return thermonuclearSmokeDevil;
case TZKAL_ZUK:
return tzKalZuk;
case TZTOK_JAD:
return tzTokJad;
case VENENATIS:
return venenatis;
case VETION:
return vetion;
case VORKATH:
return vorkath;
case WINTERTODT:
return wintertodt;
case ZALCANO:
return zalcano;
case ZULRAH:
return zulrah;
default:
throw new IllegalArgumentException("Invalid hiscore skill");
}
}
}

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.hiscore;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
class HiscoreResultBuilder
{
private final String player;
private final List<Skill> skills = new ArrayList<>();
void setNextSkill(Skill skill)
{
skills.add(skill);
}
public Skill getSkill(int index)
{
return skills.get(index);
}
public HiscoreResult build()
{
HiscoreResult hiscoreResult = new HiscoreResult();
hiscoreResult.setPlayer(player);
int index = 0;
hiscoreResult.setOverall(skills.get(index++));
hiscoreResult.setAttack(skills.get(index++));
hiscoreResult.setDefence(skills.get(index++));
hiscoreResult.setStrength(skills.get(index++));
hiscoreResult.setHitpoints(skills.get(index++));
hiscoreResult.setRanged(skills.get(index++));
hiscoreResult.setPrayer(skills.get(index++));
hiscoreResult.setMagic(skills.get(index++));
hiscoreResult.setCooking(skills.get(index++));
hiscoreResult.setWoodcutting(skills.get(index++));
hiscoreResult.setFletching(skills.get(index++));
hiscoreResult.setFishing(skills.get(index++));
hiscoreResult.setFiremaking(skills.get(index++));
hiscoreResult.setCrafting(skills.get(index++));
hiscoreResult.setSmithing(skills.get(index++));
hiscoreResult.setMining(skills.get(index++));
hiscoreResult.setHerblore(skills.get(index++));
hiscoreResult.setAgility(skills.get(index++));
hiscoreResult.setThieving(skills.get(index++));
hiscoreResult.setSlayer(skills.get(index++));
hiscoreResult.setFarming(skills.get(index++));
hiscoreResult.setRunecraft(skills.get(index++));
hiscoreResult.setHunter(skills.get(index++));
hiscoreResult.setConstruction(skills.get(index++));
hiscoreResult.setLeaguePoints(skills.get(index++));
hiscoreResult.setBountyHunterHunter(skills.get(index++));
hiscoreResult.setBountyHunterRogue(skills.get(index++));
hiscoreResult.setClueScrollAll(skills.get(index++));
hiscoreResult.setClueScrollBeginner(skills.get(index++));
hiscoreResult.setClueScrollEasy(skills.get(index++));
hiscoreResult.setClueScrollMedium(skills.get(index++));
hiscoreResult.setClueScrollHard(skills.get(index++));
hiscoreResult.setClueScrollElite(skills.get(index++));
hiscoreResult.setClueScrollMaster(skills.get(index++));
hiscoreResult.setLastManStanding(skills.get(index++));
hiscoreResult.setSoulWarsZeal(skills.get(index++));
// seasonal doesn't have boss hiscores
if (index < skills.size())
{
hiscoreResult.setAbyssalSire(skills.get(index++));
hiscoreResult.setAlchemicalHydra(skills.get(index++));
hiscoreResult.setBarrowsChests(skills.get(index++));
hiscoreResult.setBryophyta(skills.get(index++));
hiscoreResult.setCallisto(skills.get(index++));
hiscoreResult.setCerberus(skills.get(index++));
hiscoreResult.setChambersOfXeric(skills.get(index++));
hiscoreResult.setChambersOfXericChallengeMode(skills.get(index++));
hiscoreResult.setChaosElemental(skills.get(index++));
hiscoreResult.setChaosFanatic(skills.get(index++));
hiscoreResult.setCommanderZilyana(skills.get(index++));
hiscoreResult.setCorporealBeast(skills.get(index++));
hiscoreResult.setCrazyArchaeologist(skills.get(index++));
hiscoreResult.setDagannothPrime(skills.get(index++));
hiscoreResult.setDagannothRex(skills.get(index++));
hiscoreResult.setDagannothSupreme(skills.get(index++));
hiscoreResult.setDerangedArchaeologist(skills.get(index++));
hiscoreResult.setGeneralGraardor(skills.get(index++));
hiscoreResult.setGiantMole(skills.get(index++));
hiscoreResult.setGrotesqueGuardians(skills.get(index++));
hiscoreResult.setHespori(skills.get(index++));
hiscoreResult.setKalphiteQueen(skills.get(index++));
hiscoreResult.setKingBlackDragon(skills.get(index++));
hiscoreResult.setKraken(skills.get(index++));
hiscoreResult.setKreearra(skills.get(index++));
hiscoreResult.setKrilTsutsaroth(skills.get(index++));
hiscoreResult.setMimic(skills.get(index++));
if (skills.size() > 83)
{
hiscoreResult.setNex(skills.get(index++));
}
hiscoreResult.setNightmare(skills.get(index++));
hiscoreResult.setPhosanisNightmare(skills.get(index++));
hiscoreResult.setObor(skills.get(index++));
hiscoreResult.setSarachnis(skills.get(index++));
hiscoreResult.setScorpia(skills.get(index++));
hiscoreResult.setSkotizo(skills.get(index++));
hiscoreResult.setTempoross(skills.get(index++));
hiscoreResult.setGauntlet(skills.get(index++));
hiscoreResult.setCorruptedGauntlet(skills.get(index++));
hiscoreResult.setTheatreOfBlood(skills.get(index++));
hiscoreResult.setTheatreOfBloodHardMode(skills.get(index++));
hiscoreResult.setThermonuclearSmokeDevil(skills.get(index++));
hiscoreResult.setTzKalZuk(skills.get(index++));
hiscoreResult.setTzTokJad(skills.get(index++));
hiscoreResult.setVenenatis(skills.get(index++));
hiscoreResult.setVetion(skills.get(index++));
hiscoreResult.setVorkath(skills.get(index++));
hiscoreResult.setWintertodt(skills.get(index++));
hiscoreResult.setZalcano(skills.get(index++));
hiscoreResult.setZulrah(skills.get(index++));
}
return hiscoreResult;
}
}

View File

@@ -0,0 +1,124 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.hiscore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import static net.runelite.client.hiscore.HiscoreSkillType.SKILL;
import static net.runelite.client.hiscore.HiscoreSkillType.ACTIVITY;
import static net.runelite.client.hiscore.HiscoreSkillType.BOSS;
@AllArgsConstructor
@Getter
public enum HiscoreSkill
{
OVERALL("Overall", HiscoreSkillType.OVERALL),
ATTACK("Attack", SKILL),
DEFENCE("Defence", SKILL),
STRENGTH("Strength", SKILL),
HITPOINTS("Hitpoints", SKILL),
RANGED("Ranged", SKILL),
PRAYER("Prayer", SKILL),
MAGIC("Magic", SKILL),
COOKING("Cooking", SKILL),
WOODCUTTING("Woodcutting", SKILL),
FLETCHING("Fletching", SKILL),
FISHING("Fishing", SKILL),
FIREMAKING("Firemaking", SKILL),
CRAFTING("Crafting", SKILL),
SMITHING("Smithing", SKILL),
MINING("Mining", SKILL),
HERBLORE("Herblore", SKILL),
AGILITY("Agility", SKILL),
THIEVING("Thieving", SKILL),
SLAYER("Slayer", SKILL),
FARMING("Farming", SKILL),
RUNECRAFT("Runecraft", SKILL),
HUNTER("Hunter", SKILL),
CONSTRUCTION("Construction", SKILL),
LEAGUE_POINTS("League Points", ACTIVITY),
BOUNTY_HUNTER_HUNTER("Bounty Hunter - Hunter", ACTIVITY),
BOUNTY_HUNTER_ROGUE("Bounty Hunter - Rogue", ACTIVITY),
CLUE_SCROLL_ALL("Clue Scrolls (all)", ACTIVITY),
CLUE_SCROLL_BEGINNER("Clue Scrolls (beginner)", ACTIVITY),
CLUE_SCROLL_EASY("Clue Scrolls (easy)", ACTIVITY),
CLUE_SCROLL_MEDIUM("Clue Scrolls (medium)", ACTIVITY),
CLUE_SCROLL_HARD("Clue Scrolls (hard)", ACTIVITY),
CLUE_SCROLL_ELITE("Clue Scrolls (elite)", ACTIVITY),
CLUE_SCROLL_MASTER("Clue Scrolls (master)", ACTIVITY),
LAST_MAN_STANDING("Last Man Standing", ACTIVITY),
SOUL_WARS_ZEAL("Soul Wars Zeal", ACTIVITY),
ABYSSAL_SIRE("Abyssal Sire", BOSS),
ALCHEMICAL_HYDRA("Alchemical Hydra", BOSS),
BARROWS_CHESTS("Barrows Chests", BOSS),
BRYOPHYTA("Bryophyta", BOSS),
CALLISTO("Callisto", BOSS),
CERBERUS("Cerberus", BOSS),
CHAMBERS_OF_XERIC("Chambers of Xeric", BOSS),
CHAMBERS_OF_XERIC_CHALLENGE_MODE("Chambers of Xeric: Challenge Mode", BOSS),
CHAOS_ELEMENTAL("Chaos Elemental", BOSS),
CHAOS_FANATIC("Chaos Fanatic", BOSS),
COMMANDER_ZILYANA("Commander Zilyana", BOSS),
CORPOREAL_BEAST("Corporeal Beast", BOSS),
CRAZY_ARCHAEOLOGIST("Crazy Archaeologist", BOSS),
DAGANNOTH_PRIME("Dagannoth Prime", BOSS),
DAGANNOTH_REX("Dagannoth Rex", BOSS),
DAGANNOTH_SUPREME("Dagannoth Supreme", BOSS),
DERANGED_ARCHAEOLOGIST("Deranged Archaeologist", BOSS),
GENERAL_GRAARDOR("General Graardor", BOSS),
GIANT_MOLE("Giant Mole", BOSS),
GROTESQUE_GUARDIANS("Grotesque Guardians", BOSS),
HESPORI("Hespori", BOSS),
KALPHITE_QUEEN("Kalphite Queen", BOSS),
KING_BLACK_DRAGON("King Black Dragon", BOSS),
KRAKEN("Kraken", BOSS),
KREEARRA("Kree'Arra", BOSS),
KRIL_TSUTSAROTH("K'ril Tsutsaroth", BOSS),
MIMIC("Mimic", BOSS),
NEX("Nex", BOSS),
NIGHTMARE("Nightmare", BOSS),
PHOSANIS_NIGHTMARE("Phosani's Nightmare", BOSS),
OBOR("Obor", BOSS),
SARACHNIS("Sarachnis", BOSS),
SCORPIA("Scorpia", BOSS),
SKOTIZO("Skotizo", BOSS),
TEMPOROSS("Tempoross", BOSS),
THE_GAUNTLET("The Gauntlet", BOSS),
THE_CORRUPTED_GAUNTLET("The Corrupted Gauntlet", BOSS),
THEATRE_OF_BLOOD("Theatre of Blood", BOSS),
THEATRE_OF_BLOOD_HARD_MODE("Theatre of Blood: Hard Mode", BOSS),
THERMONUCLEAR_SMOKE_DEVIL("Thermonuclear Smoke Devil", BOSS),
TZKAL_ZUK("TzKal-Zuk", BOSS),
TZTOK_JAD("TzTok-Jad", BOSS),
VENENATIS("Venenatis", BOSS),
VETION("Vet'ion", BOSS),
VORKATH("Vorkath", BOSS),
WINTERTODT("Wintertodt", BOSS),
ZALCANO("Zalcano", BOSS),
ZULRAH("Zulrah", BOSS);
private final String name;
private final HiscoreSkillType type;
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2019, Bram91 <https://github.com/bram91>
* 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.hiscore;
public enum HiscoreSkillType
{
OVERALL,
SKILL,
ACTIVITY,
BOSS
}

View File

@@ -0,0 +1,35 @@
/*
* 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.hiscore;
import lombok.Value;
@Value
public class Skill
{
int rank;
int level;
long experience;
}

View File

@@ -82,6 +82,11 @@ import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ChatInput;
import net.runelite.client.game.ItemManager;
import net.runelite.client.hiscore.HiscoreClient;
import net.runelite.client.hiscore.HiscoreEndpoint;
import net.runelite.client.hiscore.HiscoreResult;
import net.runelite.client.hiscore.HiscoreSkill;
import net.runelite.client.hiscore.Skill;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@@ -90,12 +95,6 @@ import net.runelite.client.util.QuantityFormatter;
import net.runelite.client.util.Text;
import net.runelite.http.api.chat.ChatClient;
import net.runelite.http.api.chat.Duels;
import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.http.api.hiscore.HiscoreSkill;
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
import net.runelite.http.api.hiscore.Skill;
import net.runelite.http.api.item.ItemPrice;
import okhttp3.OkHttpClient;
import org.apache.commons.text.WordUtils;
@@ -1372,16 +1371,14 @@ public class ChatCommandsPlugin extends Plugin
try
{
final SingleHiscoreSkillResult result = hiscoreClient.lookup(lookup.getName(), skill, lookup.getEndpoint());
final HiscoreResult result = hiscoreClient.lookup(lookup.getName(), lookup.getEndpoint());
if (result == null)
{
log.warn("unable to look up skill {} for {}: not found", skill, search);
return;
}
final Skill hiscoreSkill = result.getSkill();
final Skill hiscoreSkill = result.getSkill(skill);
ChatMessageBuilder chatMessageBuilder = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Level ")

View File

@@ -103,7 +103,6 @@ import net.runelite.client.util.Text;
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.worlds.WorldType;
import okhttp3.OkHttpClient;
import org.apache.commons.lang3.time.DurationFormatUtils;
@@ -260,12 +259,6 @@ public class GrandExchangePlugin extends Plugin
return configManager.getConfig(GrandExchangeConfig.class);
}
@Provides
OSBGrandExchangeClient provideOsbGrandExchangeClient(OkHttpClient okHttpClient)
{
return new OSBGrandExchangeClient(okHttpClient);
}
@Provides
GrandExchangeClient provideGrandExchangeClient(OkHttpClient okHttpClient)
{

View File

@@ -61,13 +61,13 @@ import net.runelite.client.ui.components.materialtabs.MaterialTab;
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.http.api.hiscore.HiscoreSkill;
import static net.runelite.http.api.hiscore.HiscoreSkill.*;
import net.runelite.http.api.hiscore.HiscoreSkillType;
import net.runelite.http.api.hiscore.Skill;
import net.runelite.client.hiscore.HiscoreClient;
import net.runelite.client.hiscore.HiscoreEndpoint;
import net.runelite.client.hiscore.HiscoreResult;
import net.runelite.client.hiscore.HiscoreSkill;
import static net.runelite.client.hiscore.HiscoreSkill.*;
import net.runelite.client.hiscore.HiscoreSkillType;
import net.runelite.client.hiscore.Skill;
import okhttp3.OkHttpClient;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

View File

@@ -56,7 +56,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 net.runelite.client.hiscore.HiscoreEndpoint;
@PluginDescriptor(
name = "HiScore",

View File

@@ -42,7 +42,7 @@ import net.runelite.api.ParamID;
import net.runelite.api.Player;
import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits;
import net.runelite.client.game.HiscoreManager;
import net.runelite.client.hiscore.HiscoreManager;
import net.runelite.client.game.NPCManager;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
@@ -53,7 +53,7 @@ import net.runelite.client.ui.overlay.components.ComponentConstants;
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
import net.runelite.client.util.Text;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.client.hiscore.HiscoreResult;
class OpponentInfoOverlay extends OverlayPanel
{

View File

@@ -49,7 +49,7 @@ import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.client.hiscore.HiscoreEndpoint;
@PluginDescriptor(
name = "Opponent Information",

View File

@@ -34,7 +34,7 @@ import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Player;
import net.runelite.api.Skill;
import net.runelite.client.game.HiscoreManager;
import net.runelite.client.hiscore.HiscoreManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
@@ -44,8 +44,8 @@ import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
import net.runelite.client.util.Text;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.http.api.hiscore.HiscoreSkill;
import net.runelite.client.hiscore.HiscoreResult;
import net.runelite.client.hiscore.HiscoreSkill;
class PlayerComparisonOverlay extends Overlay
{
@@ -153,7 +153,7 @@ class PlayerComparisonOverlay extends Overlay
final HiscoreSkill hiscoreSkill = HISCORE_COMBAT_SKILLS[i];
final Skill skill = COMBAT_SKILLS[i];
final net.runelite.http.api.hiscore.Skill opponentSkill = opponentSkills.getSkill(hiscoreSkill);
final net.runelite.client.hiscore.Skill opponentSkill = opponentSkills.getSkill(hiscoreSkill);
if (opponentSkill == null || opponentSkill.getLevel() == -1)
{

View File

@@ -58,13 +58,13 @@ import net.runelite.api.events.GameStateChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.HiscoreManager;
import net.runelite.client.hiscore.HiscoreManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.http.api.hiscore.Skill;
import net.runelite.client.hiscore.HiscoreEndpoint;
import net.runelite.client.hiscore.HiscoreResult;
import net.runelite.client.hiscore.Skill;
@PluginDescriptor(
name = "Player-owned House",

View File

@@ -135,6 +135,7 @@ public abstract class WidgetItemOverlay extends Overlay
protected void showOnBank()
{
drawAfterLayer(WidgetInfo.BANK_ITEM_CONTAINER);
drawAfterLayer(WidgetInfo.GROUP_STORAGE_ITEM_CONTAINER);
}
protected void showOnEquipment()