aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/profileviewer
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2023-07-21 09:28:48 +0200
committerGitHub <noreply@github.com>2023-07-21 09:28:48 +0200
commit34835697e889799e2b4e97c3bbf0ea73c04d5a64 (patch)
tree421de44a9dcff26b44bab18fcde9ed89ef066f28 /src/main/java/io/github/moulberry/notenoughupdates/profileviewer
parent3184880b31e9dc8d8985411468112c6b49e5b480 (diff)
downloadnotenoughupdates-34835697e889799e2b4e97c3bbf0ea73c04d5a64.tar.gz
notenoughupdates-34835697e889799e2b4e97c3bbf0ea73c04d5a64.tar.bz2
notenoughupdates-34835697e889799e2b4e97c3bbf0ea73c04d5a64.zip
Use ursa-minor as API proxy (#762)
* Use ursa-minor as API proxy * Allow setting a ursa server url * Make client aware of x-ursa-expires * Make profile data syncer work using legacy api * Add better header support * Add manual call functionality * Improve callUrsa to allow for raw strings * Save tokens better and add logs on http failure status codes * Remove API key requirement for PV * Make museum in pv also use ursa
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java30
2 files changed, 15 insertions, 25 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
index a81956f2..ed3cf8ef 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.profileviewer;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.UrsaClient;
import io.github.moulberry.notenoughupdates.util.Utils;
import lombok.Getter;
import net.minecraft.init.Blocks;
@@ -474,7 +475,7 @@ public class ProfileViewer {
updatingResourceCollection.set(true);
NotEnoughUpdates.INSTANCE.manager.apiUtils
- .newHypixelApiRequest("resources/skyblock/collections")
+ .newAnonymousHypixelApiRequest("resources/skyblock/collections")
.requestJson()
.thenAccept(jsonObject -> {
updatingResourceCollection.set(false);
@@ -528,11 +529,8 @@ public class ProfileViewer {
callback.accept(null);
} else {
if (!uuidToHypixelProfile.containsKey(uuid)) {
- manager.apiUtils
- .newHypixelApiRequest("player")
- .queryArgument("uuid", uuid)
- .maxCacheAge(Duration.ofSeconds(30))
- .requestJson()
+ manager.ursaClient
+ .get(UrsaClient.player(Utils.parseDashlessUUID(uuid)))
.thenAccept(playerJson -> {
if (
playerJson != null &&
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java
index 88251d32..61872980 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java
@@ -28,6 +28,7 @@ import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryData;
import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.UrsaClient;
import io.github.moulberry.notenoughupdates.util.Utils;
import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo;
import lombok.Getter;
@@ -84,6 +85,7 @@ public class SkyblockProfiles {
"social"
);
private final ProfileViewer profileViewer;
+ // TODO: replace with UUID type
private final String uuid;
private final AtomicBoolean updatingSkyblockProfilesState = new AtomicBoolean(false);
private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
@@ -119,10 +121,8 @@ public class SkyblockProfiles {
lastStatusInfoState = currentTime;
updatingPlayerStatusState.set(true);
- profileViewer.getManager().apiUtils
- .newHypixelApiRequest("status")
- .queryArgument("uuid", uuid)
- .requestJson()
+ profileViewer.getManager().ursaClient
+ .get(UrsaClient.status(Utils.parseDashlessUUID(uuid)))
.handle((jsonObject, ex) -> {
updatingPlayerStatusState.set(false);
@@ -143,10 +143,8 @@ public class SkyblockProfiles {
lastBingoInfoState = currentTime;
updatingBingoInfo.set(true);
- NotEnoughUpdates.INSTANCE.manager.apiUtils
- .newHypixelApiRequest("skyblock/bingo")
- .queryArgument("uuid", uuid)
- .requestJson()
+ NotEnoughUpdates.INSTANCE.manager.ursaClient
+ .get(UrsaClient.bingo(Utils.parseDashlessUUID(uuid)))
.handle(((jsonObject, throwable) -> {
updatingBingoInfo.set(false);
@@ -317,10 +315,8 @@ public class SkyblockProfiles {
lastPlayerInfoState = currentTime;
updatingSkyblockProfilesState.set(true);
- profileViewer.getManager().apiUtils
- .newHypixelApiRequest("skyblock/profiles")
- .queryArgument("uuid", uuid)
- .requestJson()
+ profileViewer.getManager().ursaClient
+ .get(UrsaClient.profiles(Utils.parseDashlessUUID(uuid)))
.handle((profilesJson, throwable) -> {
if (profilesJson != null && profilesJson.has("success")
&& profilesJson.get("success").getAsBoolean() && profilesJson.has("profiles")) {
@@ -388,10 +384,8 @@ public class SkyblockProfiles {
lastGuildInfoState = currentTime;
updatingGuildInfoState.set(true);
- profileViewer.getManager().apiUtils
- .newHypixelApiRequest("guild")
- .queryArgument("player", uuid)
- .requestJson()
+ profileViewer.getManager().ursaClient
+ .get(UrsaClient.guild(Utils.parseDashlessUUID(uuid)))
.handle((jsonObject, ex) -> {
updatingGuildInfoState.set(false);
@@ -649,9 +643,7 @@ public class SkyblockProfiles {
updatingMuseumData.set(true);
String profileId = getOuterProfileJson().get("profile_id").getAsString();
- profileViewer.getManager().apiUtils.newHypixelApiRequest("skyblock/museum")
- .queryArgument("profile", profileId)
- .requestJson()
+ profileViewer.getManager().ursaClient.get(UrsaClient.museumForProfile(profileId))
.handle((museumJson, throwable) -> {
if (museumJson != null && museumJson.has("success")
&& museumJson.get("success").getAsBoolean() && museumJson.has("members")) {