From 5433cbad7453360370bb6466b0b9b5b2771b56aa Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 14:11:25 +0000 Subject: [PATCH 01/35] Just a start/idea of what we have in mind for 4.0. All subject to change. --- Example/pom.xml | 11 +- .../net/hypixel/example/CountsExample.java | 8 + .../java/net/hypixel/example/ExampleUtil.java | 8 +- .../hypixel/example/GameCountsExample.java | 8 - .../example/PunishmentStatsExample.java | 8 + .../hypixel/example/WatchdogStatsExample.java | 8 - .../example/http/UnirestHTTPClient.java | 27 ++++ Java/pom.xml | 9 +- .../main/java/net/hypixel/api/HypixelAPI.java | 151 +++++------------- .../hypixel/api/http/HypixelHTTPClient.java | 14 ++ ...{GameCountsReply.java => CountsReply.java} | 2 +- .../hypixel/api/reply/PlayerCountReply.java | 2 +- ...tsReply.java => PunishmentStatsReply.java} | 2 +- README.md | 3 +- pom.xml | 2 +- 15 files changed, 122 insertions(+), 141 deletions(-) create mode 100644 Example/src/main/java/net/hypixel/example/CountsExample.java delete mode 100644 Example/src/main/java/net/hypixel/example/GameCountsExample.java create mode 100644 Example/src/main/java/net/hypixel/example/PunishmentStatsExample.java delete mode 100644 Example/src/main/java/net/hypixel/example/WatchdogStatsExample.java create mode 100644 Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java create mode 100644 Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java rename Java/src/main/java/net/hypixel/api/reply/{GameCountsReply.java => CountsReply.java} (94%) rename Java/src/main/java/net/hypixel/api/reply/{WatchdogStatsReply.java => PunishmentStatsReply.java} (95%) diff --git a/Example/pom.xml b/Example/pom.xml index 5ce7a492..0ecafafa 100644 --- a/Example/pom.xml +++ b/Example/pom.xml @@ -6,7 +6,7 @@ Example net.hypixel - 2.0.0 + 4.0.0-SNAPSHOT true @@ -28,8 +28,13 @@ net.hypixel - Java - 2.0.0 + HypixelAPI + 4.0.0-SNAPSHOT + + + com.konghq + unirest-java + 3.11.09 diff --git a/Example/src/main/java/net/hypixel/example/CountsExample.java b/Example/src/main/java/net/hypixel/example/CountsExample.java new file mode 100644 index 00000000..1557ca37 --- /dev/null +++ b/Example/src/main/java/net/hypixel/example/CountsExample.java @@ -0,0 +1,8 @@ +package net.hypixel.example; + +public class CountsExample { + public static void main(String[] args) { + ExampleUtil.API.getCounts().whenComplete(ExampleUtil.getTestConsumer()); + ExampleUtil.await(); + } +} diff --git a/Example/src/main/java/net/hypixel/example/ExampleUtil.java b/Example/src/main/java/net/hypixel/example/ExampleUtil.java index cd7f810d..1b457c25 100644 --- a/Example/src/main/java/net/hypixel/example/ExampleUtil.java +++ b/Example/src/main/java/net/hypixel/example/ExampleUtil.java @@ -2,13 +2,19 @@ import net.hypixel.api.HypixelAPI; import net.hypixel.api.reply.AbstractReply; +import net.hypixel.example.http.UnirestHTTPClient; import java.util.UUID; import java.util.function.BiConsumer; public class ExampleUtil { - public static final HypixelAPI API = new HypixelAPI(UUID.fromString("64bd424e-ccb0-42ed-8b66-6e42a135afb4")); // arbitrary key, replace with your own to test + public static final HypixelAPI API; + + static { + String key = System.getProperty("apiKey", "64bd424e-ccb0-42ed-8b66-6e42a135afb4"); // arbitrary key, replace with your own to test or use the property + API = new HypixelAPI(UUID.fromString(key), new UnirestHTTPClient()); // arbitrary key, replace with your own to test + } public static final UUID HYPIXEL = UUID.fromString("f7c77d99-9f15-4a66-a87d-c4a51ef30d19"); diff --git a/Example/src/main/java/net/hypixel/example/GameCountsExample.java b/Example/src/main/java/net/hypixel/example/GameCountsExample.java deleted file mode 100644 index b588dfa3..00000000 --- a/Example/src/main/java/net/hypixel/example/GameCountsExample.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.hypixel.example; - -public class GameCountsExample { - public static void main(String[] args) { - ExampleUtil.API.getGameCounts().whenComplete(ExampleUtil.getTestConsumer()); - ExampleUtil.await(); - } -} diff --git a/Example/src/main/java/net/hypixel/example/PunishmentStatsExample.java b/Example/src/main/java/net/hypixel/example/PunishmentStatsExample.java new file mode 100644 index 00000000..c9d8d1c8 --- /dev/null +++ b/Example/src/main/java/net/hypixel/example/PunishmentStatsExample.java @@ -0,0 +1,8 @@ +package net.hypixel.example; + +public class PunishmentStatsExample { + public static void main(String[] args) { + ExampleUtil.API.getPunishmentStats().whenComplete(ExampleUtil.getTestConsumer()); + ExampleUtil.await(); + } +} diff --git a/Example/src/main/java/net/hypixel/example/WatchdogStatsExample.java b/Example/src/main/java/net/hypixel/example/WatchdogStatsExample.java deleted file mode 100644 index 00814e0f..00000000 --- a/Example/src/main/java/net/hypixel/example/WatchdogStatsExample.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.hypixel.example; - -public class WatchdogStatsExample { - public static void main(String[] args) { - ExampleUtil.API.getWatchdogStats().whenComplete(ExampleUtil.getTestConsumer()); - ExampleUtil.await(); - } -} diff --git a/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java b/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java new file mode 100644 index 00000000..9349fdd5 --- /dev/null +++ b/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java @@ -0,0 +1,27 @@ +package net.hypixel.example.http; + +import kong.unirest.HttpResponse; +import kong.unirest.Unirest; +import net.hypixel.api.http.HypixelHTTPClient; + +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public class UnirestHTTPClient implements HypixelHTTPClient { + + @Override + public CompletableFuture makeRequest(String url) { + return Unirest.get(url).asStringAsync().thenApply(HttpResponse::getBody); + } + + @Override + public CompletableFuture makeAuthenticatedRequest(String url, UUID apiKey) { + return Unirest.get(url).header("API-Key", apiKey.toString()).asStringAsync().thenApply(HttpResponse::getBody); + } + + @Override + public void shutdown() { + Unirest.shutDown(); + } + +} diff --git a/Java/pom.xml b/Java/pom.xml index 241c1991..9c574967 100644 --- a/Java/pom.xml +++ b/Java/pom.xml @@ -6,18 +6,13 @@ net.hypixel HypixelAPI - 3.0.0 + 4.0.0-SNAPSHOT com.google.code.gson gson - 2.3 - - - org.apache.httpcomponents - httpclient - 4.4 + 2.8.6 diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index bb5835a9..0beb083b 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -9,20 +9,15 @@ import net.hypixel.api.adapters.UUIDTypeAdapter; import net.hypixel.api.exceptions.APIThrottleException; import net.hypixel.api.exceptions.HypixelAPIException; +import net.hypixel.api.http.HypixelHTTPClient; import net.hypixel.api.reply.*; import net.hypixel.api.reply.skyblock.*; import net.hypixel.api.util.GameType; import net.hypixel.api.util.ResourceType; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; import java.time.ZonedDateTime; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; public class HypixelAPI { @@ -30,29 +25,23 @@ public class HypixelAPI { .registerTypeAdapter(UUID.class, new UUIDTypeAdapter()) .registerTypeAdapter(GameType.class, new GameTypeTypeAdapter()) .registerTypeAdapter(ZonedDateTime.class, new DateTimeTypeAdapter()) - .registerTypeAdapterFactory(new BoostersTypeAdapterFactory<>(BoostersReply.Booster.class)) - .create(); private static final String BASE_URL = "https://api.hypixel.net/"; private final UUID apiKey; + private final HypixelHTTPClient httpClient; - private final ExecutorService executorService; - private final HttpClient httpClient; - - public HypixelAPI(UUID apiKey) { + public HypixelAPI(UUID apiKey, HypixelHTTPClient httpClient) { this.apiKey = apiKey; - - this.executorService = Executors.newCachedThreadPool(); - this.httpClient = HttpClientBuilder.create().build(); + this.httpClient = httpClient; } /** - * Shuts down the internal executor service + * Shuts down the {@link HypixelHTTPClient} */ public void shutdown() { - executorService.shutdown(); + httpClient.shutdown(); } /** @@ -70,16 +59,8 @@ public CompletableFuture getLeaderboards() { return get(LeaderboardsReply.class, "leaderboards"); } - public CompletableFuture getWatchdogStats() { - return get(WatchdogStatsReply.class, "watchdogStats"); - } - - /** - * This is now included inside {@link HypixelAPI#getGameCounts()} - */ - @Deprecated - public CompletableFuture getPlayerCount() { - return get(PlayerCountReply.class, "playerCount"); + public CompletableFuture getPunishmentStats() { + return get(PunishmentStatsReply.class, "punishmentstats"); } public CompletableFuture getPlayerByUuid(UUID player) { @@ -94,7 +75,7 @@ public CompletableFuture getPlayerByUuid(String player) { return get(PlayerReply.class, "player", "uuid", player); } - @Deprecated + @Deprecated // TODO want this still? public CompletableFuture getPlayerByName(String player) { return get(PlayerReply.class, "player", "name", player); } @@ -135,36 +116,12 @@ public CompletableFuture getGuildById(String id) { return get(GuildReply.class, "guild", "id", id); } - /** - * You can directly get the guild using {@link HypixelAPI#getGuildByPlayer(UUID)} - */ - @Deprecated - public CompletableFuture findGuildByPlayer(UUID player) { - return get(FindGuildReply.class, "findGuild", "byUuid", player); - } - - /** - * You can directly get the guild using {@link HypixelAPI#getGuildByPlayer(String)} - */ - @Deprecated - public CompletableFuture findGuildByPlayer(String player) { - return get(FindGuildReply.class, "findGuild", "byUuid", player); - } - - /** - * You can directly get the guild using {@link HypixelAPI#getGuildByName(String)})} - */ - @Deprecated - public CompletableFuture findGuildByName(String name) { - return get(GuildReply.class, "findGuild", "byName", name); - } - public CompletableFuture getKey() { return get(KeyReply.class, "key"); } - public CompletableFuture getGameCounts() { - return get(GameCountsReply.class, "gameCounts"); + public CompletableFuture getCounts() { + return get(CountsReply.class, "counts"); } public CompletableFuture getSkyBlockProfile(String profile) { @@ -193,6 +150,7 @@ public CompletableFuture getStatus(UUID uuid) { /** * Gets up to 100 of the player's most recently played games. Games are removed from this list after 3 days. + * * @param uuid of player * @return CompletableFuture with recentGames reply */ @@ -230,68 +188,45 @@ public CompletableFuture getResource(String resource) { */ // TODO use a map of string to object? private CompletableFuture get(Class clazz, String request, Object... params) { - CompletableFuture future = new CompletableFuture<>(); - try { - if (params.length % 2 != 0) - throw new IllegalArgumentException("Need both key and value for parameters"); - - StringBuilder url = new StringBuilder(BASE_URL); + if (params.length % 2 != 0) { + throw new IllegalArgumentException("Need both key and value for parameters"); + } - url.append(request); - url.append("?key=").append(apiKey); + StringBuilder url = new StringBuilder(BASE_URL); + url.append(request); + boolean startedQuery = false; - for (int i = 0; i < params.length - 1; i += 2) { - url.append("&").append(params[i]).append("=").append(params[i + 1]); + for (int i = 0; i < params.length - 1; i += 2) { + if (!startedQuery) { + startedQuery = true; + url.append("?"); + } else { + url.append("&"); } - executorService.submit(() -> { - try { - R response = httpClient.execute(new HttpGet(url.toString()), obj -> { - String content = EntityUtils.toString(obj.getEntity(), "UTF-8"); - if (clazz == ResourceReply.class) { - return (R) new ResourceReply(GSON.fromJson(content, JsonObject.class)); - } else { - return GSON.fromJson(content, clazz); - } - }); - - checkReply(response); - - future.complete(response); - } catch (Throwable t) { - future.completeExceptionally(t); - } - }); - } catch (Throwable throwable) { - future.completeExceptionally(throwable); + url.append(params[i]).append("=").append(params[i + 1]); } - return future; + + return httpClient.makeAuthenticatedRequest(url.toString(), apiKey).thenApply(content -> { + R response; + if (clazz == ResourceReply.class) { + response = (R) new ResourceReply(GSON.fromJson(content, JsonObject.class)); + } else { + response = GSON.fromJson(content, clazz); + } + + checkReply(response); + + return response; + }); } private CompletableFuture requestResource(String resource) { - CompletableFuture future = new CompletableFuture<>(); - try { - StringBuilder url = new StringBuilder(BASE_URL); - url.append("resources/").append(resource); - - executorService.submit(() -> { - try { - ResourceReply response = httpClient.execute(new HttpGet(url.toString()), obj -> { - String content = EntityUtils.toString(obj.getEntity(), "UTF-8"); - return new ResourceReply(GSON.fromJson(content, JsonObject.class)); - }); - - checkReply(response); - - future.complete(response); - } catch (Throwable t) { - future.completeExceptionally(t); - } - }); - } catch (Throwable throwable) { - future.completeExceptionally(throwable); - } - return future; + return httpClient.makeRequest(BASE_URL + "resources/" + resource).thenApply(content -> { + ResourceReply reply = new ResourceReply(GSON.fromJson(content, JsonObject.class)); + checkReply(reply); + return reply; + }); } /** diff --git a/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java b/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java new file mode 100644 index 00000000..37c25bb1 --- /dev/null +++ b/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java @@ -0,0 +1,14 @@ +package net.hypixel.api.http; + +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public interface HypixelHTTPClient { + + CompletableFuture makeRequest(String url); + + CompletableFuture makeAuthenticatedRequest(String url, UUID apiKey); + + void shutdown(); + +} diff --git a/Java/src/main/java/net/hypixel/api/reply/GameCountsReply.java b/Java/src/main/java/net/hypixel/api/reply/CountsReply.java similarity index 94% rename from Java/src/main/java/net/hypixel/api/reply/GameCountsReply.java rename to Java/src/main/java/net/hypixel/api/reply/CountsReply.java index b5da6d05..31c7a7cd 100644 --- a/Java/src/main/java/net/hypixel/api/reply/GameCountsReply.java +++ b/Java/src/main/java/net/hypixel/api/reply/CountsReply.java @@ -2,7 +2,7 @@ import java.util.Map; -public class GameCountsReply extends AbstractReply { +public class CountsReply extends AbstractReply { private Map games; private int playerCount; diff --git a/Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java b/Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java index fa086db2..d88bdbe5 100644 --- a/Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java +++ b/Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java @@ -1,7 +1,7 @@ package net.hypixel.api.reply; /** - * This is now included inside {@link GameCountsReply} + * This is now included inside {@link CountsReply} */ @Deprecated public class PlayerCountReply extends AbstractReply { diff --git a/Java/src/main/java/net/hypixel/api/reply/WatchdogStatsReply.java b/Java/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java similarity index 95% rename from Java/src/main/java/net/hypixel/api/reply/WatchdogStatsReply.java rename to Java/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java index 5b0bc5bd..cbe7567e 100644 --- a/Java/src/main/java/net/hypixel/api/reply/WatchdogStatsReply.java +++ b/Java/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java @@ -2,7 +2,7 @@ import com.google.gson.annotations.SerializedName; -public class WatchdogStatsReply extends AbstractReply { +public class PunishmentStatsReply extends AbstractReply { @SerializedName("staff_rollingDaily") private int staffRollingDaily; @SerializedName("staff_total") diff --git a/README.md b/README.md index d4614f23..c2c9acb0 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,8 @@ If you require a higher limit than the above you can open a support ticket at ht You can obtain an API key by joining ```mc.hypixel.net``` with a valid Minecraft account and running the /api command. You will then be assigned a unique key that is to remain **private**. ### Dependencies -The Hypixel PublicAPI has the following dependencies: +The Hypixel Public API Java implementation has the following dependencies: * Google Gson library -* Apache HttpClient ### Bug Reporting You can create an issue here on GitHub to report a bug with the API or to suggest enhancements. diff --git a/pom.xml b/pom.xml index 0df9c032..39048159 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ net.hypixel PublicAPI pom - 2.0-SNAPSHOT + 4.0.0-SNAPSHOT Example From 75e7b01ea1c3d9c80229bfa7e35b7663db39424b Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 14:19:29 +0000 Subject: [PATCH 02/35] Add HTTPQueryParams for some cleaner handling over an array --- .../main/java/net/hypixel/api/HypixelAPI.java | 99 ++++++++++++------- .../net/hypixel/api/http/HTTPQueryParams.java | 40 ++++++++ 2 files changed, 101 insertions(+), 38 deletions(-) create mode 100644 Java/src/main/java/net/hypixel/api/http/HTTPQueryParams.java diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index 0beb083b..22802b02 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -9,6 +9,7 @@ import net.hypixel.api.adapters.UUIDTypeAdapter; import net.hypixel.api.exceptions.APIThrottleException; import net.hypixel.api.exceptions.HypixelAPIException; +import net.hypixel.api.http.HTTPQueryParams; import net.hypixel.api.http.HypixelHTTPClient; import net.hypixel.api.reply.*; import net.hypixel.api.reply.skyblock.*; @@ -64,7 +65,10 @@ public CompletableFuture getPunishmentStats() { } public CompletableFuture getPlayerByUuid(UUID player) { - return get(PlayerReply.class, "player", "uuid", player); + return get(PlayerReply.class, "player", + HTTPQueryParams.create() + .add("uuid", player) + ); } /** @@ -72,16 +76,25 @@ public CompletableFuture getPlayerByUuid(UUID player) { * @return the future */ public CompletableFuture getPlayerByUuid(String player) { - return get(PlayerReply.class, "player", "uuid", player); + return get(PlayerReply.class, "player", + HTTPQueryParams.create() + .add("uuid", player) + ); } @Deprecated // TODO want this still? public CompletableFuture getPlayerByName(String player) { - return get(PlayerReply.class, "player", "name", player); + return get(PlayerReply.class, "player", + HTTPQueryParams.create() + .add("name", player) + ); } public CompletableFuture getFriends(UUID player) { - return get(FriendsReply.class, "friends", "uuid", player); + return get(FriendsReply.class, "friends", + HTTPQueryParams.create() + .add("uuid", player) + ); } /** @@ -89,11 +102,17 @@ public CompletableFuture getFriends(UUID player) { * @return the future */ public CompletableFuture getFriends(String player) { - return get(FriendsReply.class, "friends", "uuid", player); + return get(FriendsReply.class, "friends", + HTTPQueryParams.create() + .add("uuid", player) + ); } public CompletableFuture getGuildByPlayer(UUID player) { - return get(GuildReply.class, "guild", "player", player); + return get(GuildReply.class, "guild", + HTTPQueryParams.create() + .add("player", player) + ); } /** @@ -101,11 +120,17 @@ public CompletableFuture getGuildByPlayer(UUID player) { * @return the future */ public CompletableFuture getGuildByPlayer(String player) { - return get(GuildReply.class, "guild", "player", player); + return get(GuildReply.class, "guild", + HTTPQueryParams.create() + .add("player", player) + ); } public CompletableFuture getGuildByName(String name) { - return get(GuildReply.class, "guild", "name", name); + return get(GuildReply.class, "guild", + HTTPQueryParams.create() + .add("name", name) + ); } /** @@ -113,7 +138,10 @@ public CompletableFuture getGuildByName(String name) { * @return the future */ public CompletableFuture getGuildById(String id) { - return get(GuildReply.class, "guild", "id", id); + return get(GuildReply.class, "guild", + HTTPQueryParams.create() + .add("id", id) + ); } public CompletableFuture getKey() { @@ -125,7 +153,10 @@ public CompletableFuture getCounts() { } public CompletableFuture getSkyBlockProfile(String profile) { - return get(SkyBlockProfileReply.class, "skyblock/profile", "profile", profile); + return get(SkyBlockProfileReply.class, "skyblock/profile", + HTTPQueryParams.create() + .add("profile", profile) + ); } public CompletableFuture getSkyBlockNews() { @@ -133,7 +164,10 @@ public CompletableFuture getSkyBlockNews() { } public CompletableFuture getSkyBlockAuctions(int page) { - return get(SkyBlockAuctionsReply.class, "skyblock/auctions", "page", page); + return get(SkyBlockAuctionsReply.class, "skyblock/auctions", + HTTPQueryParams.create() + .add("page", page) + ); } /** @@ -145,7 +179,10 @@ public CompletableFuture getSkyBlockAuctions(int page) { * @return CompletableFuture with status reply */ public CompletableFuture getStatus(UUID uuid) { - return get(StatusReply.class, "status", "uuid", uuid); + return get(StatusReply.class, "status", + HTTPQueryParams.create() + .add("uuid", uuid) + ); } /** @@ -155,7 +192,10 @@ public CompletableFuture getStatus(UUID uuid) { * @return CompletableFuture with recentGames reply */ public CompletableFuture getRecentGames(UUID uuid) { - return get(RecentGamesReply.class, "recentGames", "uuid", uuid); + return get(RecentGamesReply.class, "recentGames", + HTTPQueryParams.create() + .add("uuid", uuid) + ); } /** @@ -181,33 +221,16 @@ public CompletableFuture getResource(String resource) { return requestResource(resource); } - /** - * Execute Request asynchronously, executes Callback when finished - * - * @param request Request to get - */ - // TODO use a map of string to object? - private CompletableFuture get(Class clazz, String request, Object... params) { - if (params.length % 2 != 0) { - throw new IllegalArgumentException("Need both key and value for parameters"); - } - - StringBuilder url = new StringBuilder(BASE_URL); - url.append(request); - boolean startedQuery = false; - - for (int i = 0; i < params.length - 1; i += 2) { - if (!startedQuery) { - startedQuery = true; - url.append("?"); - } else { - url.append("&"); - } + private CompletableFuture get(Class clazz, String request) { + return get(clazz, request, null); + } - url.append(params[i]).append("=").append(params[i + 1]); + private CompletableFuture get(Class clazz, String request, HTTPQueryParams params) { + String url = BASE_URL + request; + if (params != null) { + url = params.getAsQueryString(url); } - - return httpClient.makeAuthenticatedRequest(url.toString(), apiKey).thenApply(content -> { + return httpClient.makeAuthenticatedRequest(url, apiKey).thenApply(content -> { R response; if (clazz == ResourceReply.class) { response = (R) new ResourceReply(GSON.fromJson(content, JsonObject.class)); diff --git a/Java/src/main/java/net/hypixel/api/http/HTTPQueryParams.java b/Java/src/main/java/net/hypixel/api/http/HTTPQueryParams.java new file mode 100644 index 00000000..3f64ad2e --- /dev/null +++ b/Java/src/main/java/net/hypixel/api/http/HTTPQueryParams.java @@ -0,0 +1,40 @@ +package net.hypixel.api.http; + +import java.util.HashMap; +import java.util.Map; + +public class HTTPQueryParams { + + public static HTTPQueryParams create() { + return new HTTPQueryParams(); + } + + private final Map params = new HashMap<>(); + + private HTTPQueryParams() { + + } + + public HTTPQueryParams add(String key, Object value) { + this.params.put(key, value); + return this; + } + + public String getAsQueryString(String base) { + StringBuilder url = new StringBuilder(base); + boolean startedQuery = false; + + for (Map.Entry entry : params.entrySet()) { + if (!startedQuery) { + startedQuery = true; + url.append("?"); + } else { + url.append("&"); + } + + url.append(entry.getKey()).append("=").append(entry.getValue()); + } + + return url.toString(); + } +} From db810c91406cb62efa1c82aa5600b7f142bf8706 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 14:22:06 +0000 Subject: [PATCH 03/35] Add a README.md here and remove PlayerCountReply.java --- Example/README.md | 3 +++ .../hypixel/api/reply/PlayerCountReply.java | 20 ------------------- 2 files changed, 3 insertions(+), 20 deletions(-) create mode 100644 Example/README.md delete mode 100644 Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java diff --git a/Example/README.md b/Example/README.md new file mode 100644 index 00000000..417f1b68 --- /dev/null +++ b/Example/README.md @@ -0,0 +1,3 @@ +# HypixelAPI Java Examples + +This codebase serves as examples for how to integrate the HypixelAPI into your project. \ No newline at end of file diff --git a/Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java b/Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java deleted file mode 100644 index d88bdbe5..00000000 --- a/Java/src/main/java/net/hypixel/api/reply/PlayerCountReply.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.hypixel.api.reply; - -/** - * This is now included inside {@link CountsReply} - */ -@Deprecated -public class PlayerCountReply extends AbstractReply { - private int playerCount; - - public int getPlayerCount() { - return playerCount; - } - - @Override - public String toString() { - return "PlayerCountReply{" + - "playerCount=" + playerCount + - "} " + super.toString(); - } -} From 24754359c124f02356d12654cbcadd4d2e385b63 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 14:27:57 +0000 Subject: [PATCH 04/35] Add ApacheHTTPClient to Example --- Example/pom.xml | 5 ++ .../java/net/hypixel/example/ExampleUtil.java | 4 +- .../example/http/ApacheHTTPClient.java | 56 +++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java diff --git a/Example/pom.xml b/Example/pom.xml index 0ecafafa..d39286b5 100644 --- a/Example/pom.xml +++ b/Example/pom.xml @@ -36,6 +36,11 @@ unirest-java 3.11.09 + + org.apache.httpcomponents + httpclient + 4.5.13 + \ No newline at end of file diff --git a/Example/src/main/java/net/hypixel/example/ExampleUtil.java b/Example/src/main/java/net/hypixel/example/ExampleUtil.java index 1b457c25..e2553e90 100644 --- a/Example/src/main/java/net/hypixel/example/ExampleUtil.java +++ b/Example/src/main/java/net/hypixel/example/ExampleUtil.java @@ -2,7 +2,7 @@ import net.hypixel.api.HypixelAPI; import net.hypixel.api.reply.AbstractReply; -import net.hypixel.example.http.UnirestHTTPClient; +import net.hypixel.example.http.ApacheHTTPClient; import java.util.UUID; import java.util.function.BiConsumer; @@ -13,7 +13,7 @@ public class ExampleUtil { static { String key = System.getProperty("apiKey", "64bd424e-ccb0-42ed-8b66-6e42a135afb4"); // arbitrary key, replace with your own to test or use the property - API = new HypixelAPI(UUID.fromString(key), new UnirestHTTPClient()); // arbitrary key, replace with your own to test + API = new HypixelAPI(UUID.fromString(key), new ApacheHTTPClient()); } public static final UUID HYPIXEL = UUID.fromString("f7c77d99-9f15-4a66-a87d-c4a51ef30d19"); diff --git a/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java b/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java new file mode 100644 index 00000000..d3400d22 --- /dev/null +++ b/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java @@ -0,0 +1,56 @@ +package net.hypixel.example.http; + +import net.hypixel.api.http.HypixelHTTPClient; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; + +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ApacheHTTPClient implements HypixelHTTPClient { + private final ExecutorService executorService; + private final HttpClient httpClient; + + public ApacheHTTPClient() { + this.executorService = Executors.newCachedThreadPool(); + this.httpClient = HttpClientBuilder.create().build(); + } + + @Override + public CompletableFuture makeRequest(String url) { + CompletableFuture future = new CompletableFuture<>(); + this.executorService.submit(() -> { + try { + future.complete(this.httpClient.execute(new HttpGet(url), obj -> EntityUtils.toString(obj.getEntity(), "UTF-8"))); + } catch (Throwable t) { + future.completeExceptionally(t); + } + }); + return future; + } + + @Override + public CompletableFuture makeAuthenticatedRequest(String url, UUID apiKey) { + CompletableFuture future = new CompletableFuture<>(); + this.executorService.submit(() -> { + try { + HttpGet request = new HttpGet(url); + request.addHeader("API-Key", apiKey.toString()); + future.complete(this.httpClient.execute(request, obj -> EntityUtils.toString(obj.getEntity(), "UTF-8"))); + } catch (Throwable t) { + future.completeExceptionally(t); + } + }); + return future; + } + + @Override + public void shutdown() { + this.executorService.shutdown(); + } + +} From ffefdf6f27902800f7ce5726a519a3291a03b084 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 17:22:46 +0000 Subject: [PATCH 05/35] checkReply return the same type --- .../main/java/net/hypixel/api/HypixelAPI.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index 22802b02..07e57a2d 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -231,25 +231,17 @@ private CompletableFuture get(Class clazz, Strin url = params.getAsQueryString(url); } return httpClient.makeAuthenticatedRequest(url, apiKey).thenApply(content -> { - R response; if (clazz == ResourceReply.class) { - response = (R) new ResourceReply(GSON.fromJson(content, JsonObject.class)); + return checkReply((R) new ResourceReply(GSON.fromJson(content, JsonObject.class))); } else { - response = GSON.fromJson(content, clazz); + return checkReply(GSON.fromJson(content, clazz)); } - - checkReply(response); - - return response; }); } private CompletableFuture requestResource(String resource) { - return httpClient.makeRequest(BASE_URL + "resources/" + resource).thenApply(content -> { - ResourceReply reply = new ResourceReply(GSON.fromJson(content, JsonObject.class)); - checkReply(reply); - return reply; - }); + return httpClient.makeRequest(BASE_URL + "resources/" + resource) + .thenApply(content -> checkReply(new ResourceReply(GSON.fromJson(content, JsonObject.class)))); } /** @@ -258,7 +250,7 @@ private CompletableFuture requestResource(String resource) { * @param reply The reply to check * @param The class of the reply */ - private void checkReply(T reply) { + private T checkReply(T reply) { if (reply != null) { if (reply.isThrottle()) { throw new APIThrottleException(); @@ -266,5 +258,6 @@ private void checkReply(T reply) { throw new HypixelAPIException(reply.getCause()); } } + return reply; } } From a9baafa36dd83cfca4050b4a61980d9e4ea005c2 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 17:53:52 +0000 Subject: [PATCH 06/35] Add comment for issue 249 --- Java/src/main/java/net/hypixel/api/HypixelAPI.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index 07e57a2d..cab4394b 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -82,7 +82,13 @@ public CompletableFuture getPlayerByUuid(String player) { ); } - @Deprecated // TODO want this still? + /** + * Get a player by their name. + * + * @deprecated While this method should continue functioning we recommend using the Mojang API for requesting UUID's by username. + * See issue #249 + */ + @Deprecated public CompletableFuture getPlayerByName(String player) { return get(PlayerReply.class, "player", HTTPQueryParams.create() From 4665b53e8d5203ee21bdaf2231bb70a48d227a10 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 17:54:42 +0000 Subject: [PATCH 07/35] Tweak doc --- Java/src/main/java/net/hypixel/api/HypixelAPI.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index cab4394b..5cb65a66 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -83,8 +83,7 @@ public CompletableFuture getPlayerByUuid(String player) { } /** - * Get a player by their name. - * + * @param player the minecraft username of the player. * @deprecated While this method should continue functioning we recommend using the Mojang API for requesting UUID's by username. * See issue #249 */ From 643ae52618633d4371182212c25f3836b0f59c5f Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 18:03:41 +0000 Subject: [PATCH 08/35] Some more tweaks towards javadocs etc --- .../main/java/net/hypixel/api/HypixelAPI.java | 88 +++++++++++-------- ...aarReply.java => SkyBlockBazaarReply.java} | 2 +- 2 files changed, 54 insertions(+), 36 deletions(-) rename Java/src/main/java/net/hypixel/api/reply/skyblock/{BazaarReply.java => SkyBlockBazaarReply.java} (98%) diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index 5cb65a66..c29508f7 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -33,6 +33,10 @@ public class HypixelAPI { private final UUID apiKey; private final HypixelHTTPClient httpClient; + /** + * @param apiKey the Hypixel API key to be used for the HTTP requests + * @param httpClient a {@link HypixelHTTPClient} that implements the HTTP behaviour for communicating with the API + */ public HypixelAPI(UUID apiKey, HypixelHTTPClient httpClient) { this.apiKey = apiKey; this.httpClient = httpClient; @@ -46,7 +50,7 @@ public void shutdown() { } /** - * @return currently set API key + * @return the currently set API key */ public UUID getApiKey() { return apiKey; @@ -64,6 +68,10 @@ public CompletableFuture getPunishmentStats() { return get(PunishmentStatsReply.class, "punishmentstats"); } + /** + * @param player uuid of a player + * @return {@link CompletableFuture} containing {@link PlayerReply} + */ public CompletableFuture getPlayerByUuid(UUID player) { return get(PlayerReply.class, "player", HTTPQueryParams.create() @@ -73,7 +81,7 @@ public CompletableFuture getPlayerByUuid(UUID player) { /** * @param player uuid of a player in string format, can be both dashed or undashed. - * @return the future + * @return {@link CompletableFuture} containing {@link PlayerReply} */ public CompletableFuture getPlayerByUuid(String player) { return get(PlayerReply.class, "player", @@ -84,6 +92,7 @@ public CompletableFuture getPlayerByUuid(String player) { /** * @param player the minecraft username of the player. + * @return {@link CompletableFuture} containing {@link PlayerReply} * @deprecated While this method should continue functioning we recommend using the Mojang API for requesting UUID's by username. * See issue #249 */ @@ -103,8 +112,8 @@ public CompletableFuture getFriends(UUID player) { } /** - * @param player uuid of a player in string format, can be both dashed or undashed. - * @return the future + * @param player uuid of a player in string format, can be both dashed or undashed + * @return {@link CompletableFuture} containing {@link FriendsReply} */ public CompletableFuture getFriends(String player) { return get(FriendsReply.class, "friends", @@ -113,6 +122,10 @@ public CompletableFuture getFriends(String player) { ); } + /** + * @param player uuid of a player + * @return {@link CompletableFuture} containing {@link GuildReply} + */ public CompletableFuture getGuildByPlayer(UUID player) { return get(GuildReply.class, "guild", HTTPQueryParams.create() @@ -121,8 +134,8 @@ public CompletableFuture getGuildByPlayer(UUID player) { } /** - * @param player uuid of a player in string format, can be both dashed or undashed. - * @return the future + * @param player uuid of a player in string format, can be both dashed or undashed + * @return {@link CompletableFuture} containing {@link GuildReply} */ public CompletableFuture getGuildByPlayer(String player) { return get(GuildReply.class, "guild", @@ -131,6 +144,10 @@ public CompletableFuture getGuildByPlayer(String player) { ); } + /** + * @param name the name of the guild + * @return {@link CompletableFuture} containing {@link GuildReply} + */ public CompletableFuture getGuildByName(String name) { return get(GuildReply.class, "guild", HTTPQueryParams.create() @@ -140,7 +157,7 @@ public CompletableFuture getGuildByName(String name) { /** * @param id mongo id hex string - * @return the future + * @return {@link CompletableFuture} containing {@link GuildReply} */ public CompletableFuture getGuildById(String id) { return get(GuildReply.class, "guild", @@ -157,31 +174,13 @@ public CompletableFuture getCounts() { return get(CountsReply.class, "counts"); } - public CompletableFuture getSkyBlockProfile(String profile) { - return get(SkyBlockProfileReply.class, "skyblock/profile", - HTTPQueryParams.create() - .add("profile", profile) - ); - } - - public CompletableFuture getSkyBlockNews() { - return get(SkyBlockNewsReply.class, "skyblock/news"); - } - - public CompletableFuture getSkyBlockAuctions(int page) { - return get(SkyBlockAuctionsReply.class, "skyblock/auctions", - HTTPQueryParams.create() - .add("page", page) - ); - } - /** * Gets the current status of the player with information about the server they are in * at that moment. * In case the person is in limbo, result will be the last known server * * @param uuid of player - * @return CompletableFuture with status reply + * @return {@link CompletableFuture} containing {@link StatusReply} */ public CompletableFuture getStatus(UUID uuid) { return get(StatusReply.class, "status", @@ -194,7 +193,7 @@ public CompletableFuture getStatus(UUID uuid) { * Gets up to 100 of the player's most recently played games. Games are removed from this list after 3 days. * * @param uuid of player - * @return CompletableFuture with recentGames reply + * @return {@link CompletableFuture} containing {@link RecentGamesReply} */ public CompletableFuture getRecentGames(UUID uuid) { return get(RecentGamesReply.class, "recentGames", @@ -207,23 +206,41 @@ public CompletableFuture getRecentGames(UUID uuid) { * Retrieve resources which don't change often. * * @param resource to be requested - * @return CompletableFuture with resource reply + * @return {@link CompletableFuture} containing {@link ResourceReply} */ public CompletableFuture getResource(ResourceType resource) { return getResource(resource.getPath()); } + public CompletableFuture getResource(String resource) { + return requestResource(resource); + } + + public CompletableFuture getSkyBlockProfile(String profile) { + return get(SkyBlockProfileReply.class, "skyblock/profile", + HTTPQueryParams.create() + .add("profile", profile) + ); + } + + public CompletableFuture getSkyBlockNews() { + return get(SkyBlockNewsReply.class, "skyblock/news"); + } + + public CompletableFuture getSkyBlockAuctions(int page) { + return get(SkyBlockAuctionsReply.class, "skyblock/auctions", + HTTPQueryParams.create() + .add("page", page) + ); + } + /** * Requests information about products in bazaar. * - * @return CompletableFuture with BazaarReply + * @return {@link CompletableFuture} containing {@link SkyBlockBazaarReply} */ - public CompletableFuture getBazaar() { - return get(BazaarReply.class, "skyblock/bazaar"); - } - - public CompletableFuture getResource(String resource) { - return requestResource(resource); + public CompletableFuture getSkyBlockBazaar() { + return get(SkyBlockBazaarReply.class, "skyblock/bazaar"); } private CompletableFuture get(Class clazz, String request) { @@ -254,6 +271,7 @@ private CompletableFuture requestResource(String resource) { * * @param reply The reply to check * @param The class of the reply + * @return the same object that was provided for cleaner usage */ private T checkReply(T reply) { if (reply != null) { diff --git a/Java/src/main/java/net/hypixel/api/reply/skyblock/BazaarReply.java b/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java similarity index 98% rename from Java/src/main/java/net/hypixel/api/reply/skyblock/BazaarReply.java rename to Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java index ae9e2f36..5fc403ef 100644 --- a/Java/src/main/java/net/hypixel/api/reply/skyblock/BazaarReply.java +++ b/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; -public class BazaarReply extends AbstractReply { +public class SkyBlockBazaarReply extends AbstractReply { private long lastUpdated; private Map products; From cda8ec71c8a6703a503121df8a802c56e7f30870 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 28 Feb 2021 20:32:10 +0000 Subject: [PATCH 09/35] Move SkyBlockBazaarReply to use longs instead of ints Fixes #274 --- .../reply/skyblock/SkyBlockBazaarReply.java | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java b/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java index 5fc403ef..6e18d051 100644 --- a/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java +++ b/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java @@ -76,11 +76,11 @@ public String toString() { public class Summary { - private int amount; + private long amount; private double pricePerUnit; - private int orders; + private long orders; - public int getAmount() { + public long getAmount() { return amount; } @@ -88,7 +88,7 @@ public double getPricePerUnit() { return pricePerUnit; } - public int getOrders() { + public long getOrders() { return orders; } @@ -105,22 +105,14 @@ public String toString() { public class Status { private String productId; - private double sellPrice; - - private int sellVolume; - - private int sellMovingWeek; - - private int sellOrders; - + private long sellVolume; + private long sellMovingWeek; + private long sellOrders; private double buyPrice; - - private int buyVolume; - - private int buyMovingWeek; - - private int buyOrders; + private long buyVolume; + private long buyMovingWeek; + private long buyOrders; public String getProductId() { return productId; @@ -130,15 +122,15 @@ public double getSellPrice() { return sellPrice; } - public int getSellVolume() { + public long getSellVolume() { return sellVolume; } - public int getSellMovingWeek() { + public long getSellMovingWeek() { return sellMovingWeek; } - public int getSellOrders() { + public long getSellOrders() { return sellOrders; } @@ -146,15 +138,15 @@ public double getBuyPrice() { return buyPrice; } - public int getBuyVolume() { + public long getBuyVolume() { return buyVolume; } - public int getBuyMovingWeek() { + public long getBuyMovingWeek() { return buyMovingWeek; } - public int getBuyOrders() { + public long getBuyOrders() { return buyOrders; } From f3c8a6d4d118582755af01705b285661b87b86fa Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 14 Mar 2021 15:56:01 +0000 Subject: [PATCH 10/35] Fix Bazaar Example --- .../java/net/hypixel/example/skyblock/GetBazaarExample.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/src/main/java/net/hypixel/example/skyblock/GetBazaarExample.java b/Example/src/main/java/net/hypixel/example/skyblock/GetBazaarExample.java index 37b7b70b..5acc4101 100644 --- a/Example/src/main/java/net/hypixel/example/skyblock/GetBazaarExample.java +++ b/Example/src/main/java/net/hypixel/example/skyblock/GetBazaarExample.java @@ -4,7 +4,7 @@ public class GetBazaarExample { public static void main(String[] args) { - ExampleUtil.API.getBazaar().whenComplete(ExampleUtil.getTestConsumer()); + ExampleUtil.API.getSkyBlockBazaar().whenComplete(ExampleUtil.getTestConsumer()); ExampleUtil.await(); } } From 9e6dfd33063ba9d0124cc73b16d55d2e14c0b3ba Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 14 Mar 2021 15:56:49 +0000 Subject: [PATCH 11/35] Add a comment about the recent change to the name endpoint --- Java/src/main/java/net/hypixel/api/HypixelAPI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index c29508f7..f34c1221 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -95,6 +95,7 @@ public CompletableFuture getPlayerByUuid(String player) { * @return {@link CompletableFuture} containing {@link PlayerReply} * @deprecated While this method should continue functioning we recommend using the Mojang API for requesting UUID's by username. * See issue #249 + * This endpoint is also subject to limiting requests of the same username in a short period of time. */ @Deprecated public CompletableFuture getPlayerByName(String player) { From 98d3f1576473ebd88767cefb40b4266def4e4078 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 19:23:14 +0100 Subject: [PATCH 12/35] Make member static --- Java/src/main/java/net/hypixel/api/reply/GuildReply.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Java/src/main/java/net/hypixel/api/reply/GuildReply.java b/Java/src/main/java/net/hypixel/api/reply/GuildReply.java index 3eef7a21..862079f4 100644 --- a/Java/src/main/java/net/hypixel/api/reply/GuildReply.java +++ b/Java/src/main/java/net/hypixel/api/reply/GuildReply.java @@ -113,7 +113,7 @@ public String toString() { '}'; } - public class Member { + public static class Member { private UUID uuid; private String rank; private ZonedDateTime joined; From edc181ba98166862e733757d7aa3593a1f311943 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 19:24:34 +0100 Subject: [PATCH 13/35] Add REPLAY and SMP GameType --- Java/src/main/java/net/hypixel/api/util/GameType.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Java/src/main/java/net/hypixel/api/util/GameType.java b/Java/src/main/java/net/hypixel/api/util/GameType.java index 51e37bd9..b319a9f4 100644 --- a/Java/src/main/java/net/hypixel/api/util/GameType.java +++ b/Java/src/main/java/net/hypixel/api/util/GameType.java @@ -27,7 +27,10 @@ public enum GameType { BUILD_BATTLE("Build Battle", "BuildBattle", 60), DUELS("Duels", "Duels", 61), SKYBLOCK("SkyBlock", "SkyBlock", 63), - PIT("Pit", "Pit", 64); + PIT("Pit", "Pit", 64), + REPLAY("Replay", "Replay", 65), + SMP("SMP", "SMP", 67), + ; private static final GameType[] VALUES = values(); From 25eed71a1e75cad1b4e360c6d02a30448469efc6 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 19:37:36 +0100 Subject: [PATCH 14/35] Readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 00843067..f8d7fd33 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,13 @@ documentation can be found in the code. ### GitHub Issues -Github issues should only be used to report bugs. Everything else should either be in Github discussions or use the +GitHub issues should only be used to report bugs. Everything else should either be in GitHub discussions or use the Hypixel [Code Creations](https://hypixel.net/forums/code-creations.65/) forum. ### Usage -You can use this API as a dependency via the public Hypixel maven repo. +You can use this API as a dependency via the public Hypixel maven repo. You can use +the [Example Code](https://github.com/HypixelDev/PublicAPI/tree/master/Example) as a good starting point. ```xml @@ -28,7 +29,7 @@ You can use this API as a dependency via the public Hypixel maven repo. net.hypixel HypixelAPI - 3.0.0 + 4.0.0 ``` From ab0534497d6a4e9037d398e41549532f5cb012e0 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 19:37:44 +0100 Subject: [PATCH 15/35] Some tweaks, API Key is now passed and only handdled by the HTTP Client --- .../java/net/hypixel/example/ExampleUtil.java | 2 +- .../example/http/ApacheHTTPClient.java | 35 +++++++++---------- .../example/http/UnirestHTTPClient.java | 9 +++-- .../main/java/net/hypixel/api/HypixelAPI.java | 13 ++----- .../hypixel/api/http/HypixelHTTPClient.java | 3 +- 5 files changed, 28 insertions(+), 34 deletions(-) diff --git a/Example/src/main/java/net/hypixel/example/ExampleUtil.java b/Example/src/main/java/net/hypixel/example/ExampleUtil.java index e2553e90..f7252319 100644 --- a/Example/src/main/java/net/hypixel/example/ExampleUtil.java +++ b/Example/src/main/java/net/hypixel/example/ExampleUtil.java @@ -13,7 +13,7 @@ public class ExampleUtil { static { String key = System.getProperty("apiKey", "64bd424e-ccb0-42ed-8b66-6e42a135afb4"); // arbitrary key, replace with your own to test or use the property - API = new HypixelAPI(UUID.fromString(key), new ApacheHTTPClient()); + API = new HypixelAPI(new ApacheHTTPClient(UUID.fromString(key))); } public static final UUID HYPIXEL = UUID.fromString("f7c77d99-9f15-4a66-a87d-c4a51ef30d19"); diff --git a/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java b/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java index d3400d22..6c79460d 100644 --- a/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java +++ b/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java @@ -6,46 +6,45 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; +import java.io.IOException; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ApacheHTTPClient implements HypixelHTTPClient { + private final UUID apiKey; private final ExecutorService executorService; private final HttpClient httpClient; - public ApacheHTTPClient() { + public ApacheHTTPClient(UUID apiKey) { + this.apiKey = apiKey; this.executorService = Executors.newCachedThreadPool(); this.httpClient = HttpClientBuilder.create().build(); } @Override public CompletableFuture makeRequest(String url) { - CompletableFuture future = new CompletableFuture<>(); - this.executorService.submit(() -> { + return CompletableFuture.supplyAsync(() -> { try { - future.complete(this.httpClient.execute(new HttpGet(url), obj -> EntityUtils.toString(obj.getEntity(), "UTF-8"))); - } catch (Throwable t) { - future.completeExceptionally(t); + return this.httpClient.execute(new HttpGet(url), obj -> EntityUtils.toString(obj.getEntity(), "UTF-8")); + } catch (IOException e) { + throw new RuntimeException(e); } - }); - return future; + }, this.executorService); } @Override - public CompletableFuture makeAuthenticatedRequest(String url, UUID apiKey) { - CompletableFuture future = new CompletableFuture<>(); - this.executorService.submit(() -> { + public CompletableFuture makeAuthenticatedRequest(String url) { + return CompletableFuture.supplyAsync(() -> { + HttpGet request = new HttpGet(url); + request.addHeader("API-Key", this.apiKey.toString()); try { - HttpGet request = new HttpGet(url); - request.addHeader("API-Key", apiKey.toString()); - future.complete(this.httpClient.execute(request, obj -> EntityUtils.toString(obj.getEntity(), "UTF-8"))); - } catch (Throwable t) { - future.completeExceptionally(t); + return this.httpClient.execute(request, obj -> EntityUtils.toString(obj.getEntity(), "UTF-8")); + } catch (IOException e) { + throw new RuntimeException(e); } - }); - return future; + }, this.executorService); } @Override diff --git a/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java b/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java index 9349fdd5..ec1cc8d0 100644 --- a/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java +++ b/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java @@ -8,6 +8,11 @@ import java.util.concurrent.CompletableFuture; public class UnirestHTTPClient implements HypixelHTTPClient { + private final UUID apiKey; + + public UnirestHTTPClient(UUID apiKey) { + this.apiKey = apiKey; + } @Override public CompletableFuture makeRequest(String url) { @@ -15,8 +20,8 @@ public CompletableFuture makeRequest(String url) { } @Override - public CompletableFuture makeAuthenticatedRequest(String url, UUID apiKey) { - return Unirest.get(url).header("API-Key", apiKey.toString()).asStringAsync().thenApply(HttpResponse::getBody); + public CompletableFuture makeAuthenticatedRequest(String url) { + return Unirest.get(url).header("API-Key", this.apiKey.toString()).asStringAsync().thenApply(HttpResponse::getBody); } @Override diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/Java/src/main/java/net/hypixel/api/HypixelAPI.java index f34c1221..c54df9a0 100644 --- a/Java/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/Java/src/main/java/net/hypixel/api/HypixelAPI.java @@ -30,15 +30,13 @@ public class HypixelAPI { .create(); private static final String BASE_URL = "https://api.hypixel.net/"; - private final UUID apiKey; private final HypixelHTTPClient httpClient; /** * @param apiKey the Hypixel API key to be used for the HTTP requests * @param httpClient a {@link HypixelHTTPClient} that implements the HTTP behaviour for communicating with the API */ - public HypixelAPI(UUID apiKey, HypixelHTTPClient httpClient) { - this.apiKey = apiKey; + public HypixelAPI(HypixelHTTPClient httpClient) { this.httpClient = httpClient; } @@ -49,13 +47,6 @@ public void shutdown() { httpClient.shutdown(); } - /** - * @return the currently set API key - */ - public UUID getApiKey() { - return apiKey; - } - public CompletableFuture getBoosters() { return get(BoostersReply.class, "boosters"); } @@ -253,7 +244,7 @@ private CompletableFuture get(Class clazz, Strin if (params != null) { url = params.getAsQueryString(url); } - return httpClient.makeAuthenticatedRequest(url, apiKey).thenApply(content -> { + return httpClient.makeAuthenticatedRequest(url).thenApply(content -> { if (clazz == ResourceReply.class) { return checkReply((R) new ResourceReply(GSON.fromJson(content, JsonObject.class))); } else { diff --git a/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java b/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java index 37c25bb1..4d2375b4 100644 --- a/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java +++ b/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java @@ -1,13 +1,12 @@ package net.hypixel.api.http; -import java.util.UUID; import java.util.concurrent.CompletableFuture; public interface HypixelHTTPClient { CompletableFuture makeRequest(String url); - CompletableFuture makeAuthenticatedRequest(String url, UUID apiKey); + CompletableFuture makeAuthenticatedRequest(String url); void shutdown(); From 71d8bf106289f0a4a00b7c440ee74db93b86d1b9 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:02:52 +0100 Subject: [PATCH 16/35] Move a lot of things --- {Java => hypixel-api-core}/pom.xml | 2 +- .../main/java/net/hypixel/api/HypixelAPI.java | 0 .../adapters/BoostersTypeAdapterFactory.java | 0 .../CustomizedTypeAdapterFactory.java | 0 .../api/adapters/DateTimeTypeAdapter.java | 0 .../api/adapters/GameTypeTypeAdapter.java | 0 .../hypixel/api/adapters/UUIDTypeAdapter.java | 0 .../api/exceptions/APIThrottleException.java | 0 .../api/exceptions/HypixelAPIException.java | 0 .../net/hypixel/api/http/HTTPQueryParams.java | 0 .../hypixel/api/http/HypixelHTTPClient.java | 0 .../main/java/net/hypixel/api/pets/Pet.java | 0 .../net/hypixel/api/pets/PetAttribute.java | 0 .../java/net/hypixel/api/pets/PetStats.java | 0 .../java/net/hypixel/api/pets/PetType.java | 0 .../net/hypixel/api/reply/AbstractReply.java | 0 .../net/hypixel/api/reply/BoostersReply.java | 0 .../net/hypixel/api/reply/CountsReply.java | 0 .../net/hypixel/api/reply/FindGuildReply.java | 0 .../net/hypixel/api/reply/FriendsReply.java | 0 .../net/hypixel/api/reply/GuildReply.java | 0 .../java/net/hypixel/api/reply/KeyReply.java | 1 + .../hypixel/api/reply/LeaderboardsReply.java | 0 .../net/hypixel/api/reply/PlayerReply.java | 0 .../api/reply/PunishmentStatsReply.java | 0 .../hypixel/api/reply/RecentGamesReply.java | 3 +- .../net/hypixel/api/reply/StatusReply.java | 2 - .../api/reply/skyblock/ResourceReply.java | 0 .../reply/skyblock/SkyBlockAuctionsReply.java | 0 .../reply/skyblock/SkyBlockBazaarReply.java | 0 .../api/reply/skyblock/SkyBlockNewsReply.java | 2 +- .../reply/skyblock/SkyBlockProfileReply.java | 0 .../java/net/hypixel/api/util/Banner.java | 0 .../java/net/hypixel/api/util/GameType.java | 0 .../java/net/hypixel/api/util/ILeveling.java | 0 .../java/net/hypixel/api/util/Rarity.java | 0 .../net/hypixel/api/util/ResourceType.java | 0 .../java/net/hypixel/api/util/Utilities.java | 0 {Example => hypixel-api-example}/README.md | 0 {Example => hypixel-api-example}/pom.xml | 11 +++-- .../hypixel/api}/example/CountsExample.java | 2 +- .../net/hypixel/api}/example/ExampleUtil.java | 4 +- .../api}/example/GetBoostersExample.java | 2 +- .../api}/example/GetFriendsExample.java | 2 +- .../hypixel/api}/example/GetGuildExample.java | 2 +- .../api}/example/GetLeaderboardsExample.java | 2 +- .../api}/example/GetPlayerExample.java | 2 +- .../api}/example/GetRecentGamesExample.java | 2 +- .../api}/example/GetResourceExample.java | 2 +- .../api}/example/GetStatusExample.java | 2 +- .../hypixel/api}/example/KeyInfoExample.java | 2 +- .../api}/example/PunishmentStatsExample.java | 2 +- .../example/skyblock/GetBazaarExample.java | 4 +- .../skyblock/GetSkyBlockAuctionsExample.java | 4 +- .../skyblock/GetSkyBlockNewsExample.java | 4 +- .../skyblock/GetSkyBlockProfileExample.java | 4 +- hypixel-api-transport-apache/pom.xml | 40 +++++++++++++++++++ .../hypixel/api/apache}/ApacheHTTPClient.java | 2 +- hypixel-api-transport-unirest/pom.xml | 40 +++++++++++++++++++ .../api/unirest}/UnirestHTTPClient.java | 2 +- pom.xml | 8 ++-- 61 files changed, 120 insertions(+), 35 deletions(-) rename {Java => hypixel-api-core}/pom.xml (97%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/HypixelAPI.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/adapters/BoostersTypeAdapterFactory.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/adapters/CustomizedTypeAdapterFactory.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/adapters/DateTimeTypeAdapter.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/adapters/UUIDTypeAdapter.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/http/HTTPQueryParams.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/pets/Pet.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/pets/PetAttribute.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/pets/PetStats.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/pets/PetType.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/AbstractReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/BoostersReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/CountsReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/FindGuildReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/FriendsReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/GuildReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/KeyReply.java (99%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/PlayerReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/RecentGamesReply.java (99%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/StatusReply.java (98%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockAuctionsReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockNewsReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfileReply.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/util/Banner.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/util/GameType.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/util/ILeveling.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/util/Rarity.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/util/ResourceType.java (100%) rename {Java => hypixel-api-core}/src/main/java/net/hypixel/api/util/Utilities.java (100%) rename {Example => hypixel-api-example}/README.md (100%) rename {Example => hypixel-api-example}/pom.xml (83%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/CountsExample.java (85%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/ExampleUtil.java (93%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetBoostersExample.java (85%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetFriendsExample.java (86%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetGuildExample.java (87%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetLeaderboardsExample.java (86%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetPlayerExample.java (87%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetRecentGamesExample.java (87%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetResourceExample.java (88%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/GetStatusExample.java (91%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/KeyInfoExample.java (85%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/PunishmentStatsExample.java (86%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/skyblock/GetBazaarExample.java (70%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/skyblock/GetSkyBlockAuctionsExample.java (88%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/skyblock/GetSkyBlockNewsExample.java (70%) rename {Example/src/main/java/net/hypixel => hypixel-api-example/src/main/java/net/hypixel/api}/example/skyblock/GetSkyBlockProfileExample.java (90%) create mode 100644 hypixel-api-transport-apache/pom.xml rename {Example/src/main/java/net/hypixel/example/http => hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache}/ApacheHTTPClient.java (98%) create mode 100644 hypixel-api-transport-unirest/pom.xml rename {Example/src/main/java/net/hypixel/example/http => hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest}/UnirestHTTPClient.java (96%) diff --git a/Java/pom.xml b/hypixel-api-core/pom.xml similarity index 97% rename from Java/pom.xml rename to hypixel-api-core/pom.xml index 9c574967..5c58f9b3 100644 --- a/Java/pom.xml +++ b/hypixel-api-core/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.hypixel - HypixelAPI + hypixel-api-core 4.0.0-SNAPSHOT diff --git a/Java/src/main/java/net/hypixel/api/HypixelAPI.java b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/HypixelAPI.java rename to hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java diff --git a/Java/src/main/java/net/hypixel/api/adapters/BoostersTypeAdapterFactory.java b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/BoostersTypeAdapterFactory.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/adapters/BoostersTypeAdapterFactory.java rename to hypixel-api-core/src/main/java/net/hypixel/api/adapters/BoostersTypeAdapterFactory.java diff --git a/Java/src/main/java/net/hypixel/api/adapters/CustomizedTypeAdapterFactory.java b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/CustomizedTypeAdapterFactory.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/adapters/CustomizedTypeAdapterFactory.java rename to hypixel-api-core/src/main/java/net/hypixel/api/adapters/CustomizedTypeAdapterFactory.java diff --git a/Java/src/main/java/net/hypixel/api/adapters/DateTimeTypeAdapter.java b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/DateTimeTypeAdapter.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/adapters/DateTimeTypeAdapter.java rename to hypixel-api-core/src/main/java/net/hypixel/api/adapters/DateTimeTypeAdapter.java diff --git a/Java/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java rename to hypixel-api-core/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java diff --git a/Java/src/main/java/net/hypixel/api/adapters/UUIDTypeAdapter.java b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/UUIDTypeAdapter.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/adapters/UUIDTypeAdapter.java rename to hypixel-api-core/src/main/java/net/hypixel/api/adapters/UUIDTypeAdapter.java diff --git a/Java/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java rename to hypixel-api-core/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java diff --git a/Java/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java rename to hypixel-api-core/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java diff --git a/Java/src/main/java/net/hypixel/api/http/HTTPQueryParams.java b/hypixel-api-core/src/main/java/net/hypixel/api/http/HTTPQueryParams.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/http/HTTPQueryParams.java rename to hypixel-api-core/src/main/java/net/hypixel/api/http/HTTPQueryParams.java diff --git a/Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java rename to hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java diff --git a/Java/src/main/java/net/hypixel/api/pets/Pet.java b/hypixel-api-core/src/main/java/net/hypixel/api/pets/Pet.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/pets/Pet.java rename to hypixel-api-core/src/main/java/net/hypixel/api/pets/Pet.java diff --git a/Java/src/main/java/net/hypixel/api/pets/PetAttribute.java b/hypixel-api-core/src/main/java/net/hypixel/api/pets/PetAttribute.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/pets/PetAttribute.java rename to hypixel-api-core/src/main/java/net/hypixel/api/pets/PetAttribute.java diff --git a/Java/src/main/java/net/hypixel/api/pets/PetStats.java b/hypixel-api-core/src/main/java/net/hypixel/api/pets/PetStats.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/pets/PetStats.java rename to hypixel-api-core/src/main/java/net/hypixel/api/pets/PetStats.java diff --git a/Java/src/main/java/net/hypixel/api/pets/PetType.java b/hypixel-api-core/src/main/java/net/hypixel/api/pets/PetType.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/pets/PetType.java rename to hypixel-api-core/src/main/java/net/hypixel/api/pets/PetType.java diff --git a/Java/src/main/java/net/hypixel/api/reply/AbstractReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/AbstractReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/AbstractReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/AbstractReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/BoostersReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/BoostersReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/BoostersReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/BoostersReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/CountsReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/CountsReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/CountsReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/CountsReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/FindGuildReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/FindGuildReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/FindGuildReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/FindGuildReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/FriendsReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/FriendsReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/FriendsReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/FriendsReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/GuildReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/GuildReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/GuildReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/GuildReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/KeyReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/KeyReply.java similarity index 99% rename from Java/src/main/java/net/hypixel/api/reply/KeyReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/KeyReply.java index be90dea2..26654ab8 100644 --- a/Java/src/main/java/net/hypixel/api/reply/KeyReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/KeyReply.java @@ -1,6 +1,7 @@ package net.hypixel.api.reply; import com.google.gson.annotations.SerializedName; + import java.util.UUID; public class KeyReply extends AbstractReply { diff --git a/Java/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/PlayerReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/PlayerReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/PlayerReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/PlayerReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/PunishmentStatsReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/RecentGamesReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/RecentGamesReply.java similarity index 99% rename from Java/src/main/java/net/hypixel/api/reply/RecentGamesReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/RecentGamesReply.java index 5c4a82ee..8257887f 100644 --- a/Java/src/main/java/net/hypixel/api/reply/RecentGamesReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/RecentGamesReply.java @@ -1,8 +1,9 @@ package net.hypixel.api.reply; +import net.hypixel.api.util.GameType; + import java.time.ZonedDateTime; import java.util.List; -import net.hypixel.api.util.GameType; public class RecentGamesReply extends AbstractReply { diff --git a/Java/src/main/java/net/hypixel/api/reply/StatusReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/StatusReply.java similarity index 98% rename from Java/src/main/java/net/hypixel/api/reply/StatusReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/StatusReply.java index e8f48245..9e5c51b9 100644 --- a/Java/src/main/java/net/hypixel/api/reply/StatusReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/StatusReply.java @@ -2,8 +2,6 @@ import net.hypixel.api.util.GameType; -import java.util.Optional; - public class StatusReply extends AbstractReply { /** diff --git a/Java/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockAuctionsReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockAuctionsReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockAuctionsReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockAuctionsReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockBazaarReply.java diff --git a/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockNewsReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockNewsReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockNewsReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockNewsReply.java index 6bfd7bad..d1942496 100644 --- a/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockNewsReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockNewsReply.java @@ -1,7 +1,7 @@ package net.hypixel.api.reply.skyblock; -import com.google.gson.JsonElement; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import net.hypixel.api.reply.AbstractReply; public class SkyBlockNewsReply extends AbstractReply { diff --git a/Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfileReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfileReply.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfileReply.java rename to hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfileReply.java diff --git a/Java/src/main/java/net/hypixel/api/util/Banner.java b/hypixel-api-core/src/main/java/net/hypixel/api/util/Banner.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/util/Banner.java rename to hypixel-api-core/src/main/java/net/hypixel/api/util/Banner.java diff --git a/Java/src/main/java/net/hypixel/api/util/GameType.java b/hypixel-api-core/src/main/java/net/hypixel/api/util/GameType.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/util/GameType.java rename to hypixel-api-core/src/main/java/net/hypixel/api/util/GameType.java diff --git a/Java/src/main/java/net/hypixel/api/util/ILeveling.java b/hypixel-api-core/src/main/java/net/hypixel/api/util/ILeveling.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/util/ILeveling.java rename to hypixel-api-core/src/main/java/net/hypixel/api/util/ILeveling.java diff --git a/Java/src/main/java/net/hypixel/api/util/Rarity.java b/hypixel-api-core/src/main/java/net/hypixel/api/util/Rarity.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/util/Rarity.java rename to hypixel-api-core/src/main/java/net/hypixel/api/util/Rarity.java diff --git a/Java/src/main/java/net/hypixel/api/util/ResourceType.java b/hypixel-api-core/src/main/java/net/hypixel/api/util/ResourceType.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/util/ResourceType.java rename to hypixel-api-core/src/main/java/net/hypixel/api/util/ResourceType.java diff --git a/Java/src/main/java/net/hypixel/api/util/Utilities.java b/hypixel-api-core/src/main/java/net/hypixel/api/util/Utilities.java similarity index 100% rename from Java/src/main/java/net/hypixel/api/util/Utilities.java rename to hypixel-api-core/src/main/java/net/hypixel/api/util/Utilities.java diff --git a/Example/README.md b/hypixel-api-example/README.md similarity index 100% rename from Example/README.md rename to hypixel-api-example/README.md diff --git a/Example/pom.xml b/hypixel-api-example/pom.xml similarity index 83% rename from Example/pom.xml rename to hypixel-api-example/pom.xml index d39286b5..8de6e66f 100644 --- a/Example/pom.xml +++ b/hypixel-api-example/pom.xml @@ -2,11 +2,14 @@ + + hypixel-api + net.hypixel + 4.0.0-SNAPSHOT + 4.0.0 - Example - net.hypixel - 4.0.0-SNAPSHOT + hypixel-api-example true @@ -28,7 +31,7 @@ net.hypixel - HypixelAPI + hypixel-api-transport-apache 4.0.0-SNAPSHOT diff --git a/Example/src/main/java/net/hypixel/example/CountsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/CountsExample.java similarity index 85% rename from Example/src/main/java/net/hypixel/example/CountsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/CountsExample.java index 1557ca37..9079f2b9 100644 --- a/Example/src/main/java/net/hypixel/example/CountsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/CountsExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class CountsExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/ExampleUtil.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/ExampleUtil.java similarity index 93% rename from Example/src/main/java/net/hypixel/example/ExampleUtil.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/ExampleUtil.java index f7252319..9fb2b1e9 100644 --- a/Example/src/main/java/net/hypixel/example/ExampleUtil.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/ExampleUtil.java @@ -1,8 +1,8 @@ -package net.hypixel.example; +package net.hypixel.api.example; import net.hypixel.api.HypixelAPI; +import net.hypixel.api.apache.ApacheHTTPClient; import net.hypixel.api.reply.AbstractReply; -import net.hypixel.example.http.ApacheHTTPClient; import java.util.UUID; import java.util.function.BiConsumer; diff --git a/Example/src/main/java/net/hypixel/example/GetBoostersExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetBoostersExample.java similarity index 85% rename from Example/src/main/java/net/hypixel/example/GetBoostersExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetBoostersExample.java index 46b59b8a..190ccd78 100644 --- a/Example/src/main/java/net/hypixel/example/GetBoostersExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetBoostersExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class GetBoostersExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/GetFriendsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetFriendsExample.java similarity index 86% rename from Example/src/main/java/net/hypixel/example/GetFriendsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetFriendsExample.java index 5d6c3375..470ffac0 100644 --- a/Example/src/main/java/net/hypixel/example/GetFriendsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetFriendsExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class GetFriendsExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/GetGuildExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetGuildExample.java similarity index 87% rename from Example/src/main/java/net/hypixel/example/GetGuildExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetGuildExample.java index 394e1ebd..91997b7c 100644 --- a/Example/src/main/java/net/hypixel/example/GetGuildExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetGuildExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class GetGuildExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/GetLeaderboardsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetLeaderboardsExample.java similarity index 86% rename from Example/src/main/java/net/hypixel/example/GetLeaderboardsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetLeaderboardsExample.java index 5ee203e6..cd7e5096 100644 --- a/Example/src/main/java/net/hypixel/example/GetLeaderboardsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetLeaderboardsExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class GetLeaderboardsExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/GetPlayerExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetPlayerExample.java similarity index 87% rename from Example/src/main/java/net/hypixel/example/GetPlayerExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetPlayerExample.java index bb45390e..22ba58af 100644 --- a/Example/src/main/java/net/hypixel/example/GetPlayerExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetPlayerExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class GetPlayerExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/GetRecentGamesExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetRecentGamesExample.java similarity index 87% rename from Example/src/main/java/net/hypixel/example/GetRecentGamesExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetRecentGamesExample.java index 62fbcc07..9dd5ed75 100644 --- a/Example/src/main/java/net/hypixel/example/GetRecentGamesExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetRecentGamesExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class GetRecentGamesExample { diff --git a/Example/src/main/java/net/hypixel/example/GetResourceExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetResourceExample.java similarity index 88% rename from Example/src/main/java/net/hypixel/example/GetResourceExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetResourceExample.java index a6108ed7..a5c58f43 100644 --- a/Example/src/main/java/net/hypixel/example/GetResourceExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetResourceExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; import net.hypixel.api.util.ResourceType; diff --git a/Example/src/main/java/net/hypixel/example/GetStatusExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java similarity index 91% rename from Example/src/main/java/net/hypixel/example/GetStatusExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java index 96ab615d..39f98226 100644 --- a/Example/src/main/java/net/hypixel/example/GetStatusExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class GetStatusExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/KeyInfoExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/KeyInfoExample.java similarity index 85% rename from Example/src/main/java/net/hypixel/example/KeyInfoExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/KeyInfoExample.java index 5e9014f8..79b9951b 100644 --- a/Example/src/main/java/net/hypixel/example/KeyInfoExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/KeyInfoExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class KeyInfoExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/PunishmentStatsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/PunishmentStatsExample.java similarity index 86% rename from Example/src/main/java/net/hypixel/example/PunishmentStatsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/PunishmentStatsExample.java index c9d8d1c8..ed6e6b30 100644 --- a/Example/src/main/java/net/hypixel/example/PunishmentStatsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/PunishmentStatsExample.java @@ -1,4 +1,4 @@ -package net.hypixel.example; +package net.hypixel.api.example; public class PunishmentStatsExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/skyblock/GetBazaarExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetBazaarExample.java similarity index 70% rename from Example/src/main/java/net/hypixel/example/skyblock/GetBazaarExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetBazaarExample.java index 5acc4101..2424ba7a 100644 --- a/Example/src/main/java/net/hypixel/example/skyblock/GetBazaarExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetBazaarExample.java @@ -1,6 +1,6 @@ -package net.hypixel.example.skyblock; +package net.hypixel.api.example.skyblock; -import net.hypixel.example.ExampleUtil; +import net.hypixel.api.example.ExampleUtil; public class GetBazaarExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockAuctionsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockAuctionsExample.java similarity index 88% rename from Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockAuctionsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockAuctionsExample.java index 9881958a..789af16c 100644 --- a/Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockAuctionsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockAuctionsExample.java @@ -1,6 +1,6 @@ -package net.hypixel.example.skyblock; +package net.hypixel.api.example.skyblock; -import net.hypixel.example.ExampleUtil; +import net.hypixel.api.example.ExampleUtil; public class GetSkyBlockAuctionsExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockNewsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockNewsExample.java similarity index 70% rename from Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockNewsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockNewsExample.java index 5a80d321..11c77b99 100644 --- a/Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockNewsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockNewsExample.java @@ -1,6 +1,6 @@ -package net.hypixel.example.skyblock; +package net.hypixel.api.example.skyblock; -import net.hypixel.example.ExampleUtil; +import net.hypixel.api.example.ExampleUtil; public class GetSkyBlockNewsExample { public static void main(String[] args) { diff --git a/Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockProfileExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfileExample.java similarity index 90% rename from Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockProfileExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfileExample.java index 977e4ffd..d96b0eb7 100644 --- a/Example/src/main/java/net/hypixel/example/skyblock/GetSkyBlockProfileExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfileExample.java @@ -1,7 +1,7 @@ -package net.hypixel.example.skyblock; +package net.hypixel.api.example.skyblock; import com.google.gson.JsonElement; -import net.hypixel.example.ExampleUtil; +import net.hypixel.api.example.ExampleUtil; import java.util.Map; diff --git a/hypixel-api-transport-apache/pom.xml b/hypixel-api-transport-apache/pom.xml new file mode 100644 index 00000000..5262d978 --- /dev/null +++ b/hypixel-api-transport-apache/pom.xml @@ -0,0 +1,40 @@ + + + + hypixel-api + net.hypixel + 4.0.0-SNAPSHOT + + 4.0.0 + + hypixel-api-transport-apache + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + net.hypixel + hypixel-api-core + 4.0.0-SNAPSHOT + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + + \ No newline at end of file diff --git a/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java b/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHTTPClient.java similarity index 98% rename from Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java rename to hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHTTPClient.java index 6c79460d..ff4b22e4 100644 --- a/Example/src/main/java/net/hypixel/example/http/ApacheHTTPClient.java +++ b/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHTTPClient.java @@ -1,4 +1,4 @@ -package net.hypixel.example.http; +package net.hypixel.api.apache; import net.hypixel.api.http.HypixelHTTPClient; import org.apache.http.client.HttpClient; diff --git a/hypixel-api-transport-unirest/pom.xml b/hypixel-api-transport-unirest/pom.xml new file mode 100644 index 00000000..8f0368a7 --- /dev/null +++ b/hypixel-api-transport-unirest/pom.xml @@ -0,0 +1,40 @@ + + + + hypixel-api + net.hypixel + 4.0.0-SNAPSHOT + + 4.0.0 + + hypixel-api-transport-unirest + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + net.hypixel + hypixel-api-core + 4.0.0-SNAPSHOT + + + com.konghq + unirest-java + 3.11.09 + + + + \ No newline at end of file diff --git a/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java b/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHTTPClient.java similarity index 96% rename from Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java rename to hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHTTPClient.java index ec1cc8d0..6d95a035 100644 --- a/Example/src/main/java/net/hypixel/example/http/UnirestHTTPClient.java +++ b/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHTTPClient.java @@ -1,4 +1,4 @@ -package net.hypixel.example.http; +package net.hypixel.api.unirest; import kong.unirest.HttpResponse; import kong.unirest.Unirest; diff --git a/pom.xml b/pom.xml index 39048159..8e64740b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,15 @@ 4.0.0 net.hypixel - PublicAPI + hypixel-api pom 4.0.0-SNAPSHOT - Example - Java + hypixel-api-core + hypixel-api-example + hypixel-api-transport-apache + hypixel-api-transport-unirest \ No newline at end of file From d79e4c237b6ea0754740922ba194675e2a719d41 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:15:42 +0100 Subject: [PATCH 17/35] Readme changes --- README.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f8d7fd33..7c15c181 100644 --- a/README.md +++ b/README.md @@ -15,24 +15,47 @@ Hypixel [Code Creations](https://hypixel.net/forums/code-creations.65/) forum. ### Usage -You can use this API as a dependency via the public Hypixel maven repo. You can use +You can use this API as a dependency via the public Hypixel maven repo. You can also use the [Example Code](https://github.com/HypixelDev/PublicAPI/tree/master/Example) as a good starting point. +#### Hypixel Maven Repo + ```xml + Hypixel https://repo.hypixel.net/repository/Hypixel/ ``` +#### Transports + +We include two built in options communicating with the Hypixel API, you can include either of these or even include the +core API directly and create your own instance of HypixelHTTPClient. + +Below is an example of using the Apache HttpClient based transport dependency via Maven. + ```xml + net.hypixel - HypixelAPI + hypixel-api-transport-apache 4.0.0 ``` +```java +public class Main { + public static void main(String[] args) { + HypixelHTTPClient client = new ApacheHTTPClient(UUID.fromString("your-api-key-here")); + HypixelAPI hypixelAPI = new HypixelAPI(client); + hypixelAPI.getPlayerByName("Hypixel").thenAccept(System.out::println); + } +} +``` + +#### Gradle + This repo can also be used with Gradle in the following form. ```gradle @@ -43,12 +66,14 @@ repositories { ```gradle dependencies { - implementation 'net.hypixel:HypixelAPI:3.0.0' + implementation 'net.hypixel:hypixel-api-transport-apache:4.0.0' } ``` ### Dependencies + The Hypixel Public API Java implementation has the following dependencies: + * Google Gson library ### Query Limitations From 1439a17d4f5c2865deaf02abd7c32c6c6ab68957 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:15:49 +0100 Subject: [PATCH 18/35] Readme changes --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 7c15c181..0e3ebed2 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,9 @@ Hypixel [Code Creations](https://hypixel.net/forums/code-creations.65/) forum. You can use this API as a dependency via the public Hypixel maven repo. You can also use the [Example Code](https://github.com/HypixelDev/PublicAPI/tree/master/Example) as a good starting point. -#### Hypixel Maven Repo +#### Hypixel Maven Repo ```xml - Hypixel https://repo.hypixel.net/repository/Hypixel/ @@ -34,9 +33,7 @@ We include two built in options communicating with the Hypixel API, you can incl core API directly and create your own instance of HypixelHTTPClient. Below is an example of using the Apache HttpClient based transport dependency via Maven. - ```xml - net.hypixel hypixel-api-transport-apache @@ -63,7 +60,6 @@ repositories { maven { url 'https://repo.hypixel.net/repository/Hypixel/' } } ``` - ```gradle dependencies { implementation 'net.hypixel:hypixel-api-transport-apache:4.0.0' From 8eef69df366d256cded85919cdad98145253f223 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:17:00 +0100 Subject: [PATCH 19/35] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e3ebed2..a609222d 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,12 @@ dependencies { ### Dependencies -The Hypixel Public API Java implementation has the following dependencies: +The Hypixel API Core implementation has the following dependencies: * Google Gson library +Transports will also have dependencies where required. + ### Query Limitations The API server has a request limit of 120 queries per minute. Any abuse of the API or intentions to bypass this limit ( From e4534c0ae2cee6d11036604e8ce494c41d524180 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:19:28 +0100 Subject: [PATCH 20/35] update license time --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index cc788c28..84355340 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Hypixel Inc. +Copyright (c) 2021 Hypixel Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 7f1fea804fce4893291241558bed96dacbe91098 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:22:01 +0100 Subject: [PATCH 21/35] Remove these, will make sure its all on the main docs --- README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/README.md b/README.md index a609222d..153d8501 100644 --- a/README.md +++ b/README.md @@ -74,18 +74,6 @@ The Hypixel API Core implementation has the following dependencies: Transports will also have dependencies where required. -### Query Limitations - -The API server has a request limit of 120 queries per minute. Any abuse of the API or intentions to bypass this limit ( -such as with multiple API keys) will lead to your API key being reset or banned. - -If you require a higher limit than the above you can open a support ticket at https://support.hypixel.net and provide -your use case and why you require a higher limit. - -### Obtaining an API Key - -You can obtain an API key by joining ```mc.hypixel.net``` with a valid Minecraft account and running the /api command. -You will then be assigned a unique key that is to remain **private**. ### Contributing From 4cecf98c2821f1834d74d3ec68d66104d049a7b6 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:22:34 +0100 Subject: [PATCH 22/35] Example link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 153d8501..2c22cc85 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Hypixel [Code Creations](https://hypixel.net/forums/code-creations.65/) forum. ### Usage You can use this API as a dependency via the public Hypixel maven repo. You can also use -the [Example Code](https://github.com/HypixelDev/PublicAPI/tree/master/Example) as a good starting point. +the [Example Code](https://github.com/HypixelDev/PublicAPI/tree/master/hypixel-api-example) as a good starting point. #### Hypixel Maven Repo From 44dac462a874789ad3d61803cb68c62f70d4c094 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:30:34 +0100 Subject: [PATCH 23/35] tweaks --- README.md | 2 +- hypixel-api-core/pom.xml | 49 +++---------------------- hypixel-api-transport-apache/README.md | 27 ++++++++++++++ hypixel-api-transport-unirest/README.md | 27 ++++++++++++++ hypixel-api-transport-unirest/pom.xml | 2 +- pom.xml | 44 ++++++++++++++++++++++ 6 files changed, 105 insertions(+), 46 deletions(-) create mode 100644 hypixel-api-transport-apache/README.md create mode 100644 hypixel-api-transport-unirest/README.md diff --git a/README.md b/README.md index 2c22cc85..ac1c68c3 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ dependencies { The Hypixel API Core implementation has the following dependencies: -* Google Gson library +* [Google Gson library](https://mvnrepository.com/artifact/com.google.code.gson/gson) Transports will also have dependencies where required. diff --git a/hypixel-api-core/pom.xml b/hypixel-api-core/pom.xml index 5c58f9b3..300cd7d6 100644 --- a/hypixel-api-core/pom.xml +++ b/hypixel-api-core/pom.xml @@ -8,6 +8,11 @@ hypixel-api-core 4.0.0-SNAPSHOT + + 1.8 + 1.8 + + com.google.code.gson @@ -16,48 +21,4 @@ - - - Hypixel - https://repo.hypixel.net/repository/Hypixel/ - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - UTF-8 - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - none - true - - - - - diff --git a/hypixel-api-transport-apache/README.md b/hypixel-api-transport-apache/README.md new file mode 100644 index 00000000..1366f541 --- /dev/null +++ b/hypixel-api-transport-apache/README.md @@ -0,0 +1,27 @@ +Hypixel Public API - Apache Transport +====== + +```xml + + net.hypixel + hypixel-api-transport-apache + 4.0.0 + +``` + +```java +public class Main { + public static void main(String[] args) { + HypixelHTTPClient client = new ApacheHTTPClient(UUID.fromString("your-api-key-here")); + HypixelAPI hypixelAPI = new HypixelAPI(client); + hypixelAPI.getPlayerByName("Hypixel").thenAccept(System.out::println); + } +} +``` + +### Dependencies + +This transport depends on the following: + +* [Google Gson library](https://mvnrepository.com/artifact/com.google.code.gson/gson) (for hypixel-api-core) +* [Apache HttpClient](https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient) \ No newline at end of file diff --git a/hypixel-api-transport-unirest/README.md b/hypixel-api-transport-unirest/README.md new file mode 100644 index 00000000..9e551750 --- /dev/null +++ b/hypixel-api-transport-unirest/README.md @@ -0,0 +1,27 @@ +Hypixel Public API - Unirest Transport +====== + +```xml + + net.hypixel + hypixel-api-transport-unirest + 4.0.0 + +``` + +```java +public class Main { + public static void main(String[] args) { + HypixelHTTPClient client = new UnirestHTTPClient(UUID.fromString("your-api-key-here")); + HypixelAPI hypixelAPI = new HypixelAPI(client); + hypixelAPI.getPlayerByName("Hypixel").thenAccept(System.out::println); + } +} +``` + +### Dependencies + +This transport depends on the following: + +* [Google Gson library](https://mvnrepository.com/artifact/com.google.code.gson/gson) (for hypixel-api-core) +* [Unirest Java](https://mvnrepository.com/artifact/com.konghq/unirest-java) \ No newline at end of file diff --git a/hypixel-api-transport-unirest/pom.xml b/hypixel-api-transport-unirest/pom.xml index 8f0368a7..a9c8dcee 100644 --- a/hypixel-api-transport-unirest/pom.xml +++ b/hypixel-api-transport-unirest/pom.xml @@ -33,7 +33,7 @@ com.konghq unirest-java - 3.11.09 + 3.11.11 diff --git a/pom.xml b/pom.xml index 8e64740b..facb75d4 100644 --- a/pom.xml +++ b/pom.xml @@ -16,4 +16,48 @@ hypixel-api-transport-unirest + + + Hypixel + https://repo.hypixel.net/repository/Hypixel/ + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + UTF-8 + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.1 + + none + true + + + + + \ No newline at end of file From b153827a5e056b102dceef2ec420ae7c36aa3fca Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:33:49 +0100 Subject: [PATCH 24/35] Tweak --- README.md | 42 ++++++------------------- hypixel-api-transport-apache/README.md | 12 +++++++ hypixel-api-transport-unirest/README.md | 12 +++++++ 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index ac1c68c3..98d1abec 100644 --- a/README.md +++ b/README.md @@ -27,44 +27,20 @@ the [Example Code](https://github.com/HypixelDev/PublicAPI/tree/master/hypixel-a ``` -#### Transports - -We include two built in options communicating with the Hypixel API, you can include either of these or even include the -core API directly and create your own instance of HypixelHTTPClient. - -Below is an example of using the Apache HttpClient based transport dependency via Maven. -```xml - - net.hypixel - hypixel-api-transport-apache - 4.0.0 - -``` - -```java -public class Main { - public static void main(String[] args) { - HypixelHTTPClient client = new ApacheHTTPClient(UUID.fromString("your-api-key-here")); - HypixelAPI hypixelAPI = new HypixelAPI(client); - hypixelAPI.getPlayerByName("Hypixel").thenAccept(System.out::println); - } -} -``` - -#### Gradle - -This repo can also be used with Gradle in the following form. - +This repo can also be used with Gradle. ```gradle repositories { maven { url 'https://repo.hypixel.net/repository/Hypixel/' } } ``` -```gradle -dependencies { - implementation 'net.hypixel:hypixel-api-transport-apache:4.0.0' -} -``` + +#### Transports + +We include two built in options communicating with the Hypixel API, you can include either of these or even include the +core API directly and create your own instance of HypixelHTTPClient. + +* [Apache HttpClient Transport](hypixel-api-transport-apache) +* [Unirest Java Transport](hypixel-api-transport-unirest) ### Dependencies diff --git a/hypixel-api-transport-apache/README.md b/hypixel-api-transport-apache/README.md index 1366f541..d8bbb236 100644 --- a/hypixel-api-transport-apache/README.md +++ b/hypixel-api-transport-apache/README.md @@ -1,6 +1,8 @@ Hypixel Public API - Apache Transport ====== +### Usage + ```xml net.hypixel @@ -9,6 +11,16 @@ Hypixel Public API - Apache Transport ``` +Can also be included with Gradle. + +```gradle +dependencies { + implementation 'net.hypixel:hypixel-api-transport-apache:4.0.0' +} +``` + +### Example code + ```java public class Main { public static void main(String[] args) { diff --git a/hypixel-api-transport-unirest/README.md b/hypixel-api-transport-unirest/README.md index 9e551750..fa26ac68 100644 --- a/hypixel-api-transport-unirest/README.md +++ b/hypixel-api-transport-unirest/README.md @@ -1,6 +1,8 @@ Hypixel Public API - Unirest Transport ====== +### Usage + ```xml net.hypixel @@ -9,6 +11,16 @@ Hypixel Public API - Unirest Transport ``` +Can also be included with Gradle. + +```gradle +dependencies { + implementation 'net.hypixel:hypixel-api-transport-unirest:4.0.0' +} +``` + +### Example code + ```java public class Main { public static void main(String[] args) { From 687a737b9f51bfe2041127745d9ae59b9b630b5a Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:34:27 +0100 Subject: [PATCH 25/35] Link direct to README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 98d1abec..3fa5f061 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ repositories { We include two built in options communicating with the Hypixel API, you can include either of these or even include the core API directly and create your own instance of HypixelHTTPClient. -* [Apache HttpClient Transport](hypixel-api-transport-apache) -* [Unirest Java Transport](hypixel-api-transport-unirest) +* [Apache HttpClient Transport](hypixel-api-transport-apache/README.md) +* [Unirest Java Transport](hypixel-api-transport-unirest/README.md) ### Dependencies From 16d3069696b3e0365630f7e0e21fa4d6461037fc Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 20:45:27 +0100 Subject: [PATCH 26/35] Tweak examples --- hypixel-api-transport-apache/README.md | 8 +++++++- hypixel-api-transport-unirest/README.md | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hypixel-api-transport-apache/README.md b/hypixel-api-transport-apache/README.md index d8bbb236..09852b2f 100644 --- a/hypixel-api-transport-apache/README.md +++ b/hypixel-api-transport-apache/README.md @@ -26,7 +26,13 @@ public class Main { public static void main(String[] args) { HypixelHTTPClient client = new ApacheHTTPClient(UUID.fromString("your-api-key-here")); HypixelAPI hypixelAPI = new HypixelAPI(client); - hypixelAPI.getPlayerByName("Hypixel").thenAccept(System.out::println); + hypixelAPI.getPlayerByName("Hypixel") + .exceptionally(throwable -> { + // Handle exceptions here + throwable.printStackTrace(); + return null; + }) + .thenAccept(System.out::println); } } ``` diff --git a/hypixel-api-transport-unirest/README.md b/hypixel-api-transport-unirest/README.md index fa26ac68..b8311094 100644 --- a/hypixel-api-transport-unirest/README.md +++ b/hypixel-api-transport-unirest/README.md @@ -26,7 +26,13 @@ public class Main { public static void main(String[] args) { HypixelHTTPClient client = new UnirestHTTPClient(UUID.fromString("your-api-key-here")); HypixelAPI hypixelAPI = new HypixelAPI(client); - hypixelAPI.getPlayerByName("Hypixel").thenAccept(System.out::println); + hypixelAPI.getPlayerByName("Hypixel") + .exceptionally(throwable -> { + // Handle exceptions here + throwable.printStackTrace(); + return null; + }) + .thenAccept(System.out::println); } } ``` From 3b602718980e9b588c4346a0e7aa7cb4cd98e641 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 21:13:47 +0100 Subject: [PATCH 27/35] New exceptions and rename some stuff --- .../main/java/net/hypixel/api/HypixelAPI.java | 59 ++++++++++++------- .../api/exceptions/APIThrottleException.java | 7 --- .../api/exceptions/BadResponseException.java | 9 +++ .../exceptions/BadStatusCodeException.java | 20 +++++++ .../api/exceptions/HypixelAPIException.java | 19 +----- .../hypixel/api/http/HypixelHTTPClient.java | 13 ---- .../hypixel/api/http/HypixelHttpClient.java | 13 ++++ .../hypixel/api/http/HypixelHttpResponse.java | 20 +++++++ .../net/hypixel/api/reply/AbstractReply.java | 8 +-- .../api/reply/skyblock/ResourceReply.java | 5 +- .../net/hypixel/api/example/ExampleUtil.java | 4 +- hypixel-api-transport-apache/README.md | 2 +- ...eHTTPClient.java => ApacheHttpClient.java} | 19 +++--- hypixel-api-transport-unirest/README.md | 2 +- .../api/unirest/UnirestHTTPClient.java | 32 ---------- .../api/unirest/UnirestHttpClient.java | 33 +++++++++++ 16 files changed, 156 insertions(+), 109 deletions(-) delete mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadResponseException.java create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadStatusCodeException.java delete mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpResponse.java rename hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/{ApacheHTTPClient.java => ApacheHttpClient.java} (61%) delete mode 100644 hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHTTPClient.java create mode 100644 hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java index c54df9a0..44eb69cb 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java @@ -3,14 +3,16 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; import net.hypixel.api.adapters.BoostersTypeAdapterFactory; import net.hypixel.api.adapters.DateTimeTypeAdapter; import net.hypixel.api.adapters.GameTypeTypeAdapter; import net.hypixel.api.adapters.UUIDTypeAdapter; -import net.hypixel.api.exceptions.APIThrottleException; -import net.hypixel.api.exceptions.HypixelAPIException; +import net.hypixel.api.exceptions.BadResponseException; +import net.hypixel.api.exceptions.BadStatusCodeException; import net.hypixel.api.http.HTTPQueryParams; -import net.hypixel.api.http.HypixelHTTPClient; +import net.hypixel.api.http.HypixelHttpClient; +import net.hypixel.api.http.HypixelHttpResponse; import net.hypixel.api.reply.*; import net.hypixel.api.reply.skyblock.*; import net.hypixel.api.util.GameType; @@ -30,18 +32,17 @@ public class HypixelAPI { .create(); private static final String BASE_URL = "https://api.hypixel.net/"; - private final HypixelHTTPClient httpClient; + private final HypixelHttpClient httpClient; /** - * @param apiKey the Hypixel API key to be used for the HTTP requests - * @param httpClient a {@link HypixelHTTPClient} that implements the HTTP behaviour for communicating with the API + * @param httpClient a {@link HypixelHttpClient} that implements the HTTP behaviour for communicating with the API */ - public HypixelAPI(HypixelHTTPClient httpClient) { + public HypixelAPI(HypixelHttpClient httpClient) { this.httpClient = httpClient; } /** - * Shuts down the {@link HypixelHTTPClient} + * Shuts down the {@link HypixelHttpClient} */ public void shutdown() { httpClient.shutdown(); @@ -244,18 +245,38 @@ private CompletableFuture get(Class clazz, Strin if (params != null) { url = params.getAsQueryString(url); } - return httpClient.makeAuthenticatedRequest(url).thenApply(content -> { - if (clazz == ResourceReply.class) { - return checkReply((R) new ResourceReply(GSON.fromJson(content, JsonObject.class))); - } else { - return checkReply(GSON.fromJson(content, clazz)); - } - }); + return httpClient.makeAuthenticatedRequest(url) + .thenApply(this::checkResponse) + .thenApply(response -> { + if (clazz == ResourceReply.class) { + return checkReply((R) new ResourceReply(GSON.fromJson(response.getBody(), JsonObject.class))); + } + return checkReply(GSON.fromJson(response.getBody(), clazz)); + }); } private CompletableFuture requestResource(String resource) { return httpClient.makeRequest(BASE_URL + "resources/" + resource) - .thenApply(content -> checkReply(new ResourceReply(GSON.fromJson(content, JsonObject.class)))); + .thenApply(this::checkResponse) + .thenApply(response -> checkReply(new ResourceReply(GSON.fromJson(response.getBody(), JsonObject.class)))); + } + + /** + * Checks the status of the response and throws an exception if needed + */ + private HypixelHttpResponse checkResponse(HypixelHttpResponse response) { + if (response.getStatusCode() == 200) { + return response; + } + + String cause; + try { + cause = GSON.fromJson(response.getBody(), JsonObject.class).get("cause").getAsString(); + } catch (JsonSyntaxException ignored) { + cause = "Unknown (body is not json)"; + } + + throw new BadStatusCodeException(response.getStatusCode(), cause); } /** @@ -267,10 +288,8 @@ private CompletableFuture requestResource(String resource) { */ private T checkReply(T reply) { if (reply != null) { - if (reply.isThrottle()) { - throw new APIThrottleException(); - } else if (!reply.isSuccess()) { - throw new HypixelAPIException(reply.getCause()); + if (!reply.isSuccess()) { + throw new BadResponseException(reply.getCause()); } } return reply; diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java deleted file mode 100644 index d07c3828..00000000 --- a/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/APIThrottleException.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.hypixel.api.exceptions; - -public class APIThrottleException extends HypixelAPIException { - public APIThrottleException() { - super("You have passed the API throttle limit!"); - } -} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadResponseException.java b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadResponseException.java new file mode 100644 index 00000000..064f1cc0 --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadResponseException.java @@ -0,0 +1,9 @@ +package net.hypixel.api.exceptions; + +public class BadResponseException extends HypixelAPIException { + + public BadResponseException(String responseCause) { + super(responseCause); + } + +} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadStatusCodeException.java b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadStatusCodeException.java new file mode 100644 index 00000000..2435b67a --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadStatusCodeException.java @@ -0,0 +1,20 @@ +package net.hypixel.api.exceptions; + +public class BadStatusCodeException extends HypixelAPIException { + private final int statusCode; + private final String responseCause; + + public BadStatusCodeException(int statusCode, String responseCause) { + super("Got a bad status code " + statusCode + ", cause \"" + responseCause + "\""); + this.statusCode = statusCode; + this.responseCause = responseCause; + } + + public int getStatusCode() { + return statusCode; + } + + public String getResponseCause() { + return responseCause; + } +} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java index 7507fb02..ee65f999 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java @@ -1,24 +1,9 @@ package net.hypixel.api.exceptions; -@SuppressWarnings("unused") -public class HypixelAPIException extends RuntimeException { +public abstract class HypixelAPIException extends RuntimeException { - public HypixelAPIException() { - } - - public HypixelAPIException(String message) { + protected HypixelAPIException(String message) { super(message); } - public HypixelAPIException(String message, Throwable cause) { - super(message, cause); - } - - public HypixelAPIException(Throwable cause) { - super(cause); - } - - public HypixelAPIException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } } diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java deleted file mode 100644 index 4d2375b4..00000000 --- a/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHTTPClient.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.hypixel.api.http; - -import java.util.concurrent.CompletableFuture; - -public interface HypixelHTTPClient { - - CompletableFuture makeRequest(String url); - - CompletableFuture makeAuthenticatedRequest(String url); - - void shutdown(); - -} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java new file mode 100644 index 00000000..21eab8c1 --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java @@ -0,0 +1,13 @@ +package net.hypixel.api.http; + +import java.util.concurrent.CompletableFuture; + +public interface HypixelHttpClient { + + CompletableFuture makeRequest(String url); + + CompletableFuture makeAuthenticatedRequest(String url); + + void shutdown(); + +} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpResponse.java b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpResponse.java new file mode 100644 index 00000000..dc198540 --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpResponse.java @@ -0,0 +1,20 @@ +package net.hypixel.api.http; + +public class HypixelHttpResponse { + + private final int statusCode; + private final String body; + + public HypixelHttpResponse(int statusCode, String body) { + this.statusCode = statusCode; + this.body = body; + } + + public int getStatusCode() { + return statusCode; + } + + public String getBody() { + return body; + } +} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/AbstractReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/AbstractReply.java index d0bd15ff..f366112a 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/reply/AbstractReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/AbstractReply.java @@ -2,14 +2,9 @@ public abstract class AbstractReply { - protected boolean throttle; protected boolean success; protected String cause; - public boolean isThrottle() { - return throttle; - } - public boolean isSuccess() { return success; } @@ -21,8 +16,7 @@ public String getCause() { @Override public String toString() { return "AbstractReply{" + - "throttle=" + throttle + - ", success=" + success + + "success=" + success + ", cause='" + cause + '\'' + '}'; } diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java index 438c7265..ff2f0b29 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/ResourceReply.java @@ -5,8 +5,8 @@ public class ResourceReply extends AbstractReply { - private long lastUpdated; - private JsonObject response; + private final long lastUpdated; + private final JsonObject response; public ResourceReply(JsonObject response) { this.response = response; @@ -26,6 +26,7 @@ public JsonObject getResponse() { /** * Gets unix time when the resource was updated. * Will return -1 if last updated was not included in response + * * @return long unix time */ public long getLastUpdated() { diff --git a/hypixel-api-example/src/main/java/net/hypixel/api/example/ExampleUtil.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/ExampleUtil.java index 9fb2b1e9..94190af6 100644 --- a/hypixel-api-example/src/main/java/net/hypixel/api/example/ExampleUtil.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/ExampleUtil.java @@ -1,7 +1,7 @@ package net.hypixel.api.example; import net.hypixel.api.HypixelAPI; -import net.hypixel.api.apache.ApacheHTTPClient; +import net.hypixel.api.apache.ApacheHttpClient; import net.hypixel.api.reply.AbstractReply; import java.util.UUID; @@ -13,7 +13,7 @@ public class ExampleUtil { static { String key = System.getProperty("apiKey", "64bd424e-ccb0-42ed-8b66-6e42a135afb4"); // arbitrary key, replace with your own to test or use the property - API = new HypixelAPI(new ApacheHTTPClient(UUID.fromString(key))); + API = new HypixelAPI(new ApacheHttpClient(UUID.fromString(key))); } public static final UUID HYPIXEL = UUID.fromString("f7c77d99-9f15-4a66-a87d-c4a51ef30d19"); diff --git a/hypixel-api-transport-apache/README.md b/hypixel-api-transport-apache/README.md index 09852b2f..336f1c42 100644 --- a/hypixel-api-transport-apache/README.md +++ b/hypixel-api-transport-apache/README.md @@ -24,7 +24,7 @@ dependencies { ```java public class Main { public static void main(String[] args) { - HypixelHTTPClient client = new ApacheHTTPClient(UUID.fromString("your-api-key-here")); + HypixelHttpClient client = new ApacheHttpClient(UUID.fromString("your-api-key-here")); HypixelAPI hypixelAPI = new HypixelAPI(client); hypixelAPI.getPlayerByName("Hypixel") .exceptionally(throwable -> { diff --git a/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHTTPClient.java b/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHttpClient.java similarity index 61% rename from hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHTTPClient.java rename to hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHttpClient.java index ff4b22e4..5a43d09a 100644 --- a/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHTTPClient.java +++ b/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHttpClient.java @@ -1,6 +1,8 @@ package net.hypixel.api.apache; -import net.hypixel.api.http.HypixelHTTPClient; +import net.hypixel.api.http.HypixelHttpClient; +import net.hypixel.api.http.HypixelHttpResponse; +import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; @@ -12,22 +14,24 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -public class ApacheHTTPClient implements HypixelHTTPClient { +public class ApacheHttpClient implements HypixelHttpClient { + private final UUID apiKey; private final ExecutorService executorService; private final HttpClient httpClient; - public ApacheHTTPClient(UUID apiKey) { + public ApacheHttpClient(UUID apiKey) { this.apiKey = apiKey; this.executorService = Executors.newCachedThreadPool(); this.httpClient = HttpClientBuilder.create().build(); } @Override - public CompletableFuture makeRequest(String url) { + public CompletableFuture makeRequest(String url) { return CompletableFuture.supplyAsync(() -> { try { - return this.httpClient.execute(new HttpGet(url), obj -> EntityUtils.toString(obj.getEntity(), "UTF-8")); + HttpResponse response = this.httpClient.execute(new HttpGet(url)); + return new HypixelHttpResponse(response.getStatusLine().getStatusCode(), EntityUtils.toString(response.getEntity(), "UTF-8")); } catch (IOException e) { throw new RuntimeException(e); } @@ -35,12 +39,13 @@ public CompletableFuture makeRequest(String url) { } @Override - public CompletableFuture makeAuthenticatedRequest(String url) { + public CompletableFuture makeAuthenticatedRequest(String url) { return CompletableFuture.supplyAsync(() -> { HttpGet request = new HttpGet(url); request.addHeader("API-Key", this.apiKey.toString()); try { - return this.httpClient.execute(request, obj -> EntityUtils.toString(obj.getEntity(), "UTF-8")); + HttpResponse response = this.httpClient.execute(request); + return new HypixelHttpResponse(response.getStatusLine().getStatusCode(), EntityUtils.toString(response.getEntity(), "UTF-8")); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/hypixel-api-transport-unirest/README.md b/hypixel-api-transport-unirest/README.md index b8311094..f97cfb1a 100644 --- a/hypixel-api-transport-unirest/README.md +++ b/hypixel-api-transport-unirest/README.md @@ -24,7 +24,7 @@ dependencies { ```java public class Main { public static void main(String[] args) { - HypixelHTTPClient client = new UnirestHTTPClient(UUID.fromString("your-api-key-here")); + HypixelHttpClient client = new UnirestHttpClient(UUID.fromString("your-api-key-here")); HypixelAPI hypixelAPI = new HypixelAPI(client); hypixelAPI.getPlayerByName("Hypixel") .exceptionally(throwable -> { diff --git a/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHTTPClient.java b/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHTTPClient.java deleted file mode 100644 index 6d95a035..00000000 --- a/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHTTPClient.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.hypixel.api.unirest; - -import kong.unirest.HttpResponse; -import kong.unirest.Unirest; -import net.hypixel.api.http.HypixelHTTPClient; - -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -public class UnirestHTTPClient implements HypixelHTTPClient { - private final UUID apiKey; - - public UnirestHTTPClient(UUID apiKey) { - this.apiKey = apiKey; - } - - @Override - public CompletableFuture makeRequest(String url) { - return Unirest.get(url).asStringAsync().thenApply(HttpResponse::getBody); - } - - @Override - public CompletableFuture makeAuthenticatedRequest(String url) { - return Unirest.get(url).header("API-Key", this.apiKey.toString()).asStringAsync().thenApply(HttpResponse::getBody); - } - - @Override - public void shutdown() { - Unirest.shutDown(); - } - -} diff --git a/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java b/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java new file mode 100644 index 00000000..d12da93e --- /dev/null +++ b/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java @@ -0,0 +1,33 @@ +package net.hypixel.api.unirest; + +import kong.unirest.Unirest; +import net.hypixel.api.http.HypixelHttpClient; +import net.hypixel.api.http.HypixelHttpResponse; + +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public class UnirestHttpClient implements HypixelHttpClient { + + private final UUID apiKey; + + public UnirestHttpClient(UUID apiKey) { + this.apiKey = apiKey; + } + + @Override + public CompletableFuture makeRequest(String url) { + return Unirest.get(url).asStringAsync().thenApply(res -> new HypixelHttpResponse(res.getStatus(), res.getBody())); + } + + @Override + public CompletableFuture makeAuthenticatedRequest(String url) { + return Unirest.get(url).header("API-Key", this.apiKey.toString()).asStringAsync().thenApply(res -> new HypixelHttpResponse(res.getStatus(), res.getBody())); + } + + @Override + public void shutdown() { + Unirest.shutDown(); + } + +} From 8b03f3f04c415a7eb6b278b5b351843f84b19b2a Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 21:27:09 +0100 Subject: [PATCH 28/35] Add getSkyBlockProfiles method --- .../main/java/net/hypixel/api/HypixelAPI.java | 7 +++++++ .../reply/skyblock/SkyBlockProfilesReply.java | 21 +++++++++++++++++++ .../skyblock/GetSkyBlockProfilesExample.java | 10 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java create mode 100644 hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java index 44eb69cb..0e5312f9 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java @@ -216,6 +216,13 @@ public CompletableFuture getSkyBlockProfile(String profile ); } + public CompletableFuture getSkyBlockProfiles(UUID player) { + return get(SkyBlockProfilesReply.class, "skyblock/profiles", + HTTPQueryParams.create() + .add("uuid", player) + ); + } + public CompletableFuture getSkyBlockNews() { return get(SkyBlockNewsReply.class, "skyblock/news"); } diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java new file mode 100644 index 00000000..cf00f955 --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java @@ -0,0 +1,21 @@ +package net.hypixel.api.reply.skyblock; + +import com.google.gson.JsonObject; +import net.hypixel.api.reply.AbstractReply; + +import java.util.List; + +public class SkyBlockProfilesReply extends AbstractReply { + private List profiles; + + public List getProfiles() { + return profiles; + } + + @Override + public String toString() { + return "SkyBlockProfilesReply{" + + "profiles=" + profiles + + "} " + super.toString(); + } +} diff --git a/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java new file mode 100644 index 00000000..feecad85 --- /dev/null +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java @@ -0,0 +1,10 @@ +package net.hypixel.api.example.skyblock; + +import net.hypixel.api.example.ExampleUtil; + +public class GetSkyBlockProfilesExample { + public static void main(String[] args) { + ExampleUtil.API.getSkyBlockProfiles(ExampleUtil.HYPIXEL).whenComplete(ExampleUtil.getTestConsumer()); + ExampleUtil.await(); + } +} From 903841b83e5f99a7aa46ba0643c63c5464990212 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 22:15:23 +0100 Subject: [PATCH 29/35] Add ServerType along with LobbyType --- .../main/java/net/hypixel/api/HypixelAPI.java | 9 +++--- .../api/adapters/GameTypeTypeAdapter.java | 2 +- .../api/adapters/ServerTypeTypeAdapter.java | 26 +++++++++++++++++ .../api/{util => data/type}/GameType.java | 5 ++-- .../net/hypixel/api/data/type/LobbyType.java | 28 +++++++++++++++++++ .../net/hypixel/api/data/type/ServerType.java | 25 +++++++++++++++++ .../net/hypixel/api/reply/BoostersReply.java | 2 +- .../hypixel/api/reply/LeaderboardsReply.java | 2 +- .../hypixel/api/reply/RecentGamesReply.java | 4 +-- .../net/hypixel/api/reply/StatusReply.java | 17 +++++------ .../hypixel/api/example/GetStatusExample.java | 4 ++- 11 files changed, 103 insertions(+), 21 deletions(-) create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/adapters/ServerTypeTypeAdapter.java rename hypixel-api-core/src/main/java/net/hypixel/api/{util => data/type}/GameType.java (96%) create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java create mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/data/type/ServerType.java diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java index 0e5312f9..d55b325a 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java @@ -4,10 +4,9 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; -import net.hypixel.api.adapters.BoostersTypeAdapterFactory; -import net.hypixel.api.adapters.DateTimeTypeAdapter; -import net.hypixel.api.adapters.GameTypeTypeAdapter; -import net.hypixel.api.adapters.UUIDTypeAdapter; +import net.hypixel.api.adapters.*; +import net.hypixel.api.data.type.GameType; +import net.hypixel.api.data.type.ServerType; import net.hypixel.api.exceptions.BadResponseException; import net.hypixel.api.exceptions.BadStatusCodeException; import net.hypixel.api.http.HTTPQueryParams; @@ -15,7 +14,6 @@ import net.hypixel.api.http.HypixelHttpResponse; import net.hypixel.api.reply.*; import net.hypixel.api.reply.skyblock.*; -import net.hypixel.api.util.GameType; import net.hypixel.api.util.ResourceType; import java.time.ZonedDateTime; @@ -27,6 +25,7 @@ public class HypixelAPI { private static final Gson GSON = new GsonBuilder() .registerTypeAdapter(UUID.class, new UUIDTypeAdapter()) .registerTypeAdapter(GameType.class, new GameTypeTypeAdapter()) + .registerTypeAdapter(ServerType.class, new ServerTypeTypeAdapter()) .registerTypeAdapter(ZonedDateTime.class, new DateTimeTypeAdapter()) .registerTypeAdapterFactory(new BoostersTypeAdapterFactory<>(BoostersReply.Booster.class)) .create(); diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java index 4a12ef04..bcd36941 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/GameTypeTypeAdapter.java @@ -1,7 +1,7 @@ package net.hypixel.api.adapters; import com.google.gson.*; -import net.hypixel.api.util.GameType; +import net.hypixel.api.data.type.GameType; import java.lang.reflect.Type; diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/adapters/ServerTypeTypeAdapter.java b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/ServerTypeTypeAdapter.java new file mode 100644 index 00000000..ea89251e --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/adapters/ServerTypeTypeAdapter.java @@ -0,0 +1,26 @@ +package net.hypixel.api.adapters; + +import com.google.gson.*; +import net.hypixel.api.data.type.GameType; +import net.hypixel.api.data.type.ServerType; + +import java.lang.reflect.Type; + +public class ServerTypeTypeAdapter implements JsonDeserializer, JsonSerializer { + + @Override + public JsonElement serialize(ServerType src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src.name()); + } + + @Override + public ServerType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + String raw = json.getAsString(); + try { + return GameType.fromId(Integer.parseInt(raw)); + } catch (NumberFormatException ignored) { + } + return ServerType.valueOf(raw); + } + +} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/util/GameType.java b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/GameType.java similarity index 96% rename from hypixel-api-core/src/main/java/net/hypixel/api/util/GameType.java rename to hypixel-api-core/src/main/java/net/hypixel/api/data/type/GameType.java index b319a9f4..c76ecceb 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/util/GameType.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/GameType.java @@ -1,6 +1,6 @@ -package net.hypixel.api.util; +package net.hypixel.api.data.type; -public enum GameType { +public enum GameType implements ServerType { QUAKECRAFT("Quakecraft", "Quake", 2), WALLS("Walls", "Walls", 3), PAINTBALL("Paintball", "Paintball", 4), @@ -80,6 +80,7 @@ public static GameType[] getValues() { /** * @return The official name of the GameType */ + @Override public String getName() { return name; } diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java new file mode 100644 index 00000000..2c42fd6e --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java @@ -0,0 +1,28 @@ +package net.hypixel.api.data.type; + +public enum LobbyType implements ServerType { + MAIN("Main Lobby"), + TOURNAMENT("Tournament Hall"), + ; + + private static final LobbyType[] VALUES = values(); + + private final String name; + + LobbyType(String name) { + this.name = name; + } + + /** + * Exposing this method allows people to use the array without cloning. + * Slightly faster but not as safe since the array could be modified. + */ + public static LobbyType[] getValues() { + return VALUES; + } + + @Override + public String getName() { + return name; + } +} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/data/type/ServerType.java b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/ServerType.java new file mode 100644 index 00000000..aa73aa21 --- /dev/null +++ b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/ServerType.java @@ -0,0 +1,25 @@ +package net.hypixel.api.data.type; + +public interface ServerType { + + String name(); + + String getName(); + + static ServerType valueOf(String value) { + try { + return GameType.valueOf(value); + } catch (IllegalArgumentException e) { + // ignored + } + + try { + return LobbyType.valueOf(value); + } catch (IllegalArgumentException e) { + // ignored + } + + return null; + } + +} diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/BoostersReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/BoostersReply.java index a45145f6..e9c24c14 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/reply/BoostersReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/BoostersReply.java @@ -1,6 +1,6 @@ package net.hypixel.api.reply; -import net.hypixel.api.util.GameType; +import net.hypixel.api.data.type.GameType; import java.time.ZonedDateTime; import java.util.List; diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java index fe2e6b8b..74e7d45e 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/LeaderboardsReply.java @@ -1,6 +1,6 @@ package net.hypixel.api.reply; -import net.hypixel.api.util.GameType; +import net.hypixel.api.data.type.GameType; import java.util.List; import java.util.Map; diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/RecentGamesReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/RecentGamesReply.java index 8257887f..ecac2e54 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/reply/RecentGamesReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/RecentGamesReply.java @@ -1,6 +1,6 @@ package net.hypixel.api.reply; -import net.hypixel.api.util.GameType; +import net.hypixel.api.data.type.GameType; import java.time.ZonedDateTime; import java.util.List; @@ -41,7 +41,7 @@ public ZonedDateTime getStartDate() { /** * @return Game played during this session - * @see net.hypixel.api.util.GameType + * @see GameType */ public GameType getGameType() { return gameType; diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/StatusReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/StatusReply.java index 9e5c51b9..5aaee3f7 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/reply/StatusReply.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/reply/StatusReply.java @@ -1,6 +1,7 @@ package net.hypixel.api.reply; -import net.hypixel.api.util.GameType; +import com.google.gson.annotations.SerializedName; +import net.hypixel.api.data.type.ServerType; public class StatusReply extends AbstractReply { @@ -21,7 +22,7 @@ public String toString() { "} " + super.toString(); } - public class Session { + public static class Session { /** * Boolean if player is online. @@ -30,12 +31,12 @@ public class Session { private boolean online; /** - * GameType could be null if a new game has been released - * and GameType is not yet added to {@link GameType}. + * ServerType could be null if a new game/lobby has been released and type is not yet added. *

* This will NOT throw an exception. */ - private GameType gameType; + @SerializedName("gameType") + private ServerType serverType; /** * Mode of game being played @@ -53,8 +54,8 @@ public boolean isOnline() { return online; } - public GameType getGameType() { - return gameType; + public ServerType getServerType() { + return serverType; } public String getMode() { @@ -69,7 +70,7 @@ public String getMap() { public String toString() { return "Session{" + "online=" + online + - ", gameType=" + gameType + + ", serverType=" + serverType + ", mode=" + mode + ", map=" + map + "}"; diff --git a/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java index 39f98226..f487452a 100644 --- a/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java @@ -1,10 +1,12 @@ package net.hypixel.api.example; +import java.util.UUID; + public class GetStatusExample { public static void main(String[] args) { // online may vary from player to player, this is a setting that can be disabled by the player // see comment in StatusReply - ExampleUtil.API.getStatus(ExampleUtil.HYPIXEL).whenComplete(ExampleUtil.getTestConsumer()); + ExampleUtil.API.getStatus(UUID.fromString("ad8fefaa-8351-454b-b739-a4eaa872173f")).whenComplete(ExampleUtil.getTestConsumer()); ExampleUtil.await(); } } From 816379cb79956b514e92c9d47d8c565a16191973 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 22:15:41 +0100 Subject: [PATCH 30/35] Add a comment --- .../src/main/java/net/hypixel/api/data/type/LobbyType.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java index 2c42fd6e..1e69336d 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java @@ -1,5 +1,8 @@ package net.hypixel.api.data.type; +/** + * A LobbyType is used for lobbies which do not have a gametype linked. + */ public enum LobbyType implements ServerType { MAIN("Main Lobby"), TOURNAMENT("Tournament Hall"), From d04052835550d6fc23419d0eca22ef17a32c8fdd Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 22:16:03 +0100 Subject: [PATCH 31/35] Back to Hypixel example --- .../main/java/net/hypixel/api/example/GetStatusExample.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java index f487452a..39f98226 100644 --- a/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetStatusExample.java @@ -1,12 +1,10 @@ package net.hypixel.api.example; -import java.util.UUID; - public class GetStatusExample { public static void main(String[] args) { // online may vary from player to player, this is a setting that can be disabled by the player // see comment in StatusReply - ExampleUtil.API.getStatus(UUID.fromString("ad8fefaa-8351-454b-b739-a4eaa872173f")).whenComplete(ExampleUtil.getTestConsumer()); + ExampleUtil.API.getStatus(ExampleUtil.HYPIXEL).whenComplete(ExampleUtil.getTestConsumer()); ExampleUtil.await(); } } From 7f101c4d6cacddb77935fa5cc0c84a03b5d3fb55 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 9 May 2021 22:26:49 +0100 Subject: [PATCH 32/35] Add User Agent --- .../src/main/java/net/hypixel/api/http/HypixelHttpClient.java | 2 ++ .../main/java/net/hypixel/api/apache/ApacheHttpClient.java | 2 +- .../main/java/net/hypixel/api/unirest/UnirestHttpClient.java | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java index 21eab8c1..0ae4995e 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/http/HypixelHttpClient.java @@ -4,6 +4,8 @@ public interface HypixelHttpClient { + String DEFAULT_USER_AGENT = "Hypixel PublicAPI/4.0.0"; + CompletableFuture makeRequest(String url); CompletableFuture makeAuthenticatedRequest(String url); diff --git a/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHttpClient.java b/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHttpClient.java index 5a43d09a..c4600bb8 100644 --- a/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHttpClient.java +++ b/hypixel-api-transport-apache/src/main/java/net/hypixel/api/apache/ApacheHttpClient.java @@ -23,7 +23,7 @@ public class ApacheHttpClient implements HypixelHttpClient { public ApacheHttpClient(UUID apiKey) { this.apiKey = apiKey; this.executorService = Executors.newCachedThreadPool(); - this.httpClient = HttpClientBuilder.create().build(); + this.httpClient = HttpClientBuilder.create().setUserAgent(DEFAULT_USER_AGENT).build(); } @Override diff --git a/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java b/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java index d12da93e..48690211 100644 --- a/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java +++ b/hypixel-api-transport-unirest/src/main/java/net/hypixel/api/unirest/UnirestHttpClient.java @@ -17,12 +17,12 @@ public UnirestHttpClient(UUID apiKey) { @Override public CompletableFuture makeRequest(String url) { - return Unirest.get(url).asStringAsync().thenApply(res -> new HypixelHttpResponse(res.getStatus(), res.getBody())); + return Unirest.get(url).header("User-Agent", DEFAULT_USER_AGENT).asStringAsync().thenApply(res -> new HypixelHttpResponse(res.getStatus(), res.getBody())); } @Override public CompletableFuture makeAuthenticatedRequest(String url) { - return Unirest.get(url).header("API-Key", this.apiKey.toString()).asStringAsync().thenApply(res -> new HypixelHttpResponse(res.getStatus(), res.getBody())); + return Unirest.get(url).header("User-Agent", DEFAULT_USER_AGENT).header("API-Key", this.apiKey.toString()).asStringAsync().thenApply(res -> new HypixelHttpResponse(res.getStatus(), res.getBody())); } @Override From 3c1ef7a089dd378282b87b17b8309c0f125f0008 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Mon, 10 May 2021 12:48:36 +0100 Subject: [PATCH 33/35] Be consistent --- .../api/example/{CountsExample.java => GetCountsExample.java} | 2 +- ...nishmentStatsExample.java => GetPunishmentStatsExample.java} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename hypixel-api-example/src/main/java/net/hypixel/api/example/{CountsExample.java => GetCountsExample.java} (86%) rename hypixel-api-example/src/main/java/net/hypixel/api/example/{PunishmentStatsExample.java => GetPunishmentStatsExample.java} (83%) diff --git a/hypixel-api-example/src/main/java/net/hypixel/api/example/CountsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetCountsExample.java similarity index 86% rename from hypixel-api-example/src/main/java/net/hypixel/api/example/CountsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetCountsExample.java index 9079f2b9..9f7f32c3 100644 --- a/hypixel-api-example/src/main/java/net/hypixel/api/example/CountsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetCountsExample.java @@ -1,6 +1,6 @@ package net.hypixel.api.example; -public class CountsExample { +public class GetCountsExample { public static void main(String[] args) { ExampleUtil.API.getCounts().whenComplete(ExampleUtil.getTestConsumer()); ExampleUtil.await(); diff --git a/hypixel-api-example/src/main/java/net/hypixel/api/example/PunishmentStatsExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetPunishmentStatsExample.java similarity index 83% rename from hypixel-api-example/src/main/java/net/hypixel/api/example/PunishmentStatsExample.java rename to hypixel-api-example/src/main/java/net/hypixel/api/example/GetPunishmentStatsExample.java index ed6e6b30..34574991 100644 --- a/hypixel-api-example/src/main/java/net/hypixel/api/example/PunishmentStatsExample.java +++ b/hypixel-api-example/src/main/java/net/hypixel/api/example/GetPunishmentStatsExample.java @@ -1,6 +1,6 @@ package net.hypixel.api.example; -public class PunishmentStatsExample { +public class GetPunishmentStatsExample { public static void main(String[] args) { ExampleUtil.API.getPunishmentStats().whenComplete(ExampleUtil.getTestConsumer()); ExampleUtil.await(); From db0624884ac5f8130625d0dc45fd9d6b902f3a3b Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Mon, 10 May 2021 12:50:00 +0100 Subject: [PATCH 34/35] Include versions in Readme --- README.md | 2 +- hypixel-api-transport-apache/README.md | 4 ++-- hypixel-api-transport-unirest/README.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3fa5f061..c5b4486e 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ core API directly and create your own instance of HypixelHTTPClient. The Hypixel API Core implementation has the following dependencies: -* [Google Gson library](https://mvnrepository.com/artifact/com.google.code.gson/gson) +* [Google Gson library - 2.8.6](https://mvnrepository.com/artifact/com.google.code.gson/gson) Transports will also have dependencies where required. diff --git a/hypixel-api-transport-apache/README.md b/hypixel-api-transport-apache/README.md index 336f1c42..1061a8fb 100644 --- a/hypixel-api-transport-apache/README.md +++ b/hypixel-api-transport-apache/README.md @@ -41,5 +41,5 @@ public class Main { This transport depends on the following: -* [Google Gson library](https://mvnrepository.com/artifact/com.google.code.gson/gson) (for hypixel-api-core) -* [Apache HttpClient](https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient) \ No newline at end of file +* [Google Gson library - 2.8.6](https://mvnrepository.com/artifact/com.google.code.gson/gson) (for hypixel-api-core) +* [Apache HttpClient - 4.5.13](https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient) \ No newline at end of file diff --git a/hypixel-api-transport-unirest/README.md b/hypixel-api-transport-unirest/README.md index f97cfb1a..7f7f8598 100644 --- a/hypixel-api-transport-unirest/README.md +++ b/hypixel-api-transport-unirest/README.md @@ -41,5 +41,5 @@ public class Main { This transport depends on the following: -* [Google Gson library](https://mvnrepository.com/artifact/com.google.code.gson/gson) (for hypixel-api-core) -* [Unirest Java](https://mvnrepository.com/artifact/com.konghq/unirest-java) \ No newline at end of file +* [Google Gson library - 2.8.6](https://mvnrepository.com/artifact/com.google.code.gson/gson) (for hypixel-api-core) +* [Unirest Java - 3.11.11](https://mvnrepository.com/artifact/com.konghq/unirest-java) \ No newline at end of file From 64ac624378f8b6e1aa2726dc97d32d0c4428585c Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Mon, 10 May 2021 13:50:31 +0100 Subject: [PATCH 35/35] Remove skyblock profiles cause another PR has it --- .../main/java/net/hypixel/api/HypixelAPI.java | 7 ------- .../reply/skyblock/SkyBlockProfilesReply.java | 21 ------------------- .../skyblock/GetSkyBlockProfilesExample.java | 10 --------- 3 files changed, 38 deletions(-) delete mode 100644 hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java delete mode 100644 hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java index d55b325a..8483187a 100644 --- a/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java +++ b/hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java @@ -215,13 +215,6 @@ public CompletableFuture getSkyBlockProfile(String profile ); } - public CompletableFuture getSkyBlockProfiles(UUID player) { - return get(SkyBlockProfilesReply.class, "skyblock/profiles", - HTTPQueryParams.create() - .add("uuid", player) - ); - } - public CompletableFuture getSkyBlockNews() { return get(SkyBlockNewsReply.class, "skyblock/news"); } diff --git a/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java b/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java deleted file mode 100644 index cf00f955..00000000 --- a/hypixel-api-core/src/main/java/net/hypixel/api/reply/skyblock/SkyBlockProfilesReply.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.hypixel.api.reply.skyblock; - -import com.google.gson.JsonObject; -import net.hypixel.api.reply.AbstractReply; - -import java.util.List; - -public class SkyBlockProfilesReply extends AbstractReply { - private List profiles; - - public List getProfiles() { - return profiles; - } - - @Override - public String toString() { - return "SkyBlockProfilesReply{" + - "profiles=" + profiles + - "} " + super.toString(); - } -} diff --git a/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java b/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java deleted file mode 100644 index feecad85..00000000 --- a/hypixel-api-example/src/main/java/net/hypixel/api/example/skyblock/GetSkyBlockProfilesExample.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.hypixel.api.example.skyblock; - -import net.hypixel.api.example.ExampleUtil; - -public class GetSkyBlockProfilesExample { - public static void main(String[] args) { - ExampleUtil.API.getSkyBlockProfiles(ExampleUtil.HYPIXEL).whenComplete(ExampleUtil.getTestConsumer()); - ExampleUtil.await(); - } -}