forked from koxx12-dev/Skyclient-Cosmetics
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around JsDelivr caching
- Loading branch information
Showing
6 changed files
with
48 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package co.skyclient.scc.utils; | ||
|
||
import cc.polyfrost.oneconfig.utils.Multithreading; | ||
import cc.polyfrost.oneconfig.utils.NetworkUtils; | ||
import com.google.gson.JsonArray; | ||
|
||
public class JsDelivrUtils { | ||
private static String dataCommitId = "main"; | ||
private static String websiteCommitId = "main"; | ||
|
||
public static String getWebsiteUrl(String path) { | ||
return "https://cdn.jsdelivr.net/gh/SkyblockClient/Website@" + websiteCommitId + path; | ||
} | ||
|
||
public static String getDataUrl(String path) { | ||
return "https://cdn.jsdelivr.net/gh/SkyblockClient/SkyblockClient-REPO@" + dataCommitId + path; | ||
} | ||
|
||
public static void initialize() { | ||
Multithreading.runAsync(() -> { | ||
try { | ||
JsonArray websiteApi = NetworkUtils.getJsonElement("https://api.github.com/repos/SkyblockClient/Website/commits").getAsJsonArray(); | ||
websiteCommitId = websiteApi.get(0).getAsJsonObject().get("sha").getAsString(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
try { | ||
JsonArray dataApi = NetworkUtils.getJsonElement("https://api.github.com/repos/SkyblockClient/SkyblockClient-REPO/commits").getAsJsonArray(); | ||
dataCommitId = dataApi.get(0).getAsJsonObject().get("sha").getAsString(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
}); | ||
} | ||
} |
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