-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #806 from SkyblockerMod/networth
Networth
- Loading branch information
Showing
18 changed files
with
355 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockItemData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.hysky.skyblocker.skyblock.item; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.slf4j.Logger; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParser; | ||
import com.mojang.logging.LogUtils; | ||
|
||
import de.hysky.skyblocker.utils.Http; | ||
import de.hysky.skyblocker.utils.networth.NetworthDataSuppliers; | ||
|
||
public class SkyblockItemData { | ||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
|
||
public static void init() { | ||
updateItems().thenAcceptAsync(items -> { | ||
PlayerHeadHashCache.loadSkins(items); | ||
NetworthDataSuppliers.updateSkyblockItemData(items); | ||
}); | ||
} | ||
|
||
private static CompletableFuture<JsonArray> updateItems() { | ||
return CompletableFuture.supplyAsync(() -> { | ||
try { | ||
String response = Http.sendGetRequest("https://api.hypixel.net/v2/resources/skyblock/items"); | ||
JsonObject itemsData = JsonParser.parseString(response).getAsJsonObject(); | ||
|
||
return itemsData.getAsJsonArray("items"); | ||
} catch (Exception e) { | ||
LOGGER.error("[Skyblocker Item Data Loader] Failed to load items data from the Hypixel API!", e); | ||
} | ||
|
||
//Complete the future exceptionally so that the other things don't run | ||
throw new IllegalStateException(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.