diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-27 02:25:50 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-27 02:25:50 +0900 |
commit | bd6d9e260916648d28f21b034d910c81d2c226fa (patch) | |
tree | c662540085efacd2e77abaa80e484011cb825054 /mod/src/main/java/kr/syeyoung/dungeonsguide | |
parent | 85680da71fabcbd5179eab1b9e4698b3aa92722c (diff) | |
download | Skyblock-Dungeons-Guide-bd6d9e260916648d28f21b034d910c81d2c226fa.tar.gz Skyblock-Dungeons-Guide-bd6d9e260916648d28f21b034d910c81d2c226fa.tar.bz2 Skyblock-Dungeons-Guide-bd6d9e260916648d28f21b034d910c81d2c226fa.zip |
- Proper User Agent
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java/kr/syeyoung/dungeonsguide')
4 files changed, 9 insertions, 2 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java index cbc8be12..010530f6 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java @@ -25,6 +25,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfileParser; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; @@ -80,6 +81,7 @@ public class ApiFetcher { public static JsonObject getJson(String url) throws IOException { URLConnection connection = new URL(url).openConnection(); + connection.setRequestProperty("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); @@ -89,6 +91,7 @@ public class ApiFetcher { public static JsonArray getJsonArr(String url) throws IOException { URLConnection connection = new URL(url).openConnection(); + connection.setRequestProperty("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); return gson.fromJson(new InputStreamReader(connection.getInputStream()), JsonArray.class); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java index 4db364d0..d16a8ab5 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java @@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.mod.guiv2.elements.image; import com.google.common.util.concurrent.ThreadFactoryBuilder; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import lombok.Data; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -77,7 +78,7 @@ public class ImageTexture { URL urlObj = new URL(url); HttpURLConnection huc = (HttpURLConnection) urlObj.openConnection(); - huc.addRequestProperty("User-Agent", "DungeonsGuideMod (dungeons.guide, 1.0)"); + huc.addRequestProperty("User-Agent", "DungeonsGuide (dungeons.guide, "+ VersionInfo.VERSION +")"); ImageInputStream imageInputStream = ImageIO.createImageInputStream(huc.getInputStream()); Iterator<ImageReader> readers = ImageIO.getImageReaders(imageInputStream); if(!readers.hasNext()) throw new IOException("No image reader what" + url); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java index 4de6b258..02160bb1 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.mod.stomp; import com.google.common.util.concurrent.ThreadFactoryBuilder; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import lombok.Getter; import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; @@ -43,6 +44,7 @@ public class StompClient extends WebSocketClient { addHeader("Authorization", token); + addHeader("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); logger.info("connecting websocket"); if (!connectBlocking()) { diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java index 2a10ba7e..61151c33 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.mod.utils; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import java.io.IOException; import java.io.InputStreamReader; @@ -31,7 +32,7 @@ public class SkyblockUtils { URL url = new URL("https://hypixel-api.inventivetalent.org/api/skyblock/calendar"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); JsonObject object = (JsonObject) new JsonParser().parse(inputStreamReader); if (!object.get("success").getAsBoolean()) { |