6 | * Created using slothpixel/hypixelconstants
7 | * as a reference.
8 | */
9 | public enum GuildAchievement {
10 | /**
11 | * A tiered achievement based on the highest amount of experience earned by a guild in a single
12 | * day.
13 | */
14 | EXPERIENCE_KINGS,
15 |
16 | /**
17 | * A tiered achievement based on the highest number of members a guild has had online at the
18 | * same time.
19 | */
20 | ONLINE_PLAYERS,
21 |
22 | /**
23 | * A tiered achievement based on a guild's highest level.
24 | */
25 | PRESTIGE,
26 |
27 | /**
28 | * A tiered achievement based on the highest number of combined wins (in mini-games) between
29 | * members of a guild on the same day.
30 | */
31 | WINNERS
32 | }
33 |
--------------------------------------------------------------------------------
/hypixel-api-core/src/main/java/net/hypixel/api/data/type/LobbyType.java:
--------------------------------------------------------------------------------
1 | package net.hypixel.api.data.type;
2 |
3 | /**
4 | * A LobbyType is used for lobbies which do not have a gametype linked.
5 | */
6 | public enum LobbyType implements ServerType {
7 | MAIN("Main Lobby"),
8 | TOURNAMENT("Tournament Hall"),
9 | ;
10 |
11 | private static final LobbyType[] VALUES = values();
12 |
13 | private final String name;
14 |
15 | LobbyType(String name) {
16 | this.name = name;
17 | }
18 |
19 | /**
20 | * Exposing this method allows people to use the array without cloning.
21 | * Slightly faster but not as safe since the array could be modified.
22 | */
23 | public static LobbyType[] getValues() {
24 | return VALUES;
25 | }
26 |
27 | @Override
28 | public String getName() {
29 | return name;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/hypixel-api-core/src/main/java/net/hypixel/api/data/type/ServerType.java:
--------------------------------------------------------------------------------
1 | package net.hypixel.api.data.type;
2 |
3 | public interface ServerType {
4 |
5 | String name();
6 |
7 | String getName();
8 |
9 | static ServerType valueOf(String value) {
10 | try {
11 | return GameType.valueOf(value);
12 | } catch (IllegalArgumentException e) {
13 | // ignored
14 | }
15 |
16 | try {
17 | return LobbyType.valueOf(value);
18 | } catch (IllegalArgumentException e) {
19 | // ignored
20 | }
21 |
22 | return null;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadResponseException.java:
--------------------------------------------------------------------------------
1 | package net.hypixel.api.exceptions;
2 |
3 | public class BadResponseException extends HypixelAPIException {
4 |
5 | public BadResponseException(String responseCause) {
6 | super(responseCause);
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/BadStatusCodeException.java:
--------------------------------------------------------------------------------
1 | package net.hypixel.api.exceptions;
2 |
3 | public class BadStatusCodeException extends HypixelAPIException {
4 | private final int statusCode;
5 | private final String responseCause;
6 |
7 | public BadStatusCodeException(int statusCode, String responseCause) {
8 | super("Got a bad status code " + statusCode + ", cause \"" + responseCause + "\"");
9 | this.statusCode = statusCode;
10 | this.responseCause = responseCause;
11 | }
12 |
13 | public int getStatusCode() {
14 | return statusCode;
15 | }
16 |
17 | public String getResponseCause() {
18 | return responseCause;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/hypixel-api-core/src/main/java/net/hypixel/api/exceptions/HypixelAPIException.java:
--------------------------------------------------------------------------------
1 | package net.hypixel.api.exceptions;
2 |
3 | public abstract class HypixelAPIException extends RuntimeException {
4 |
5 | protected HypixelAPIException(String message) {
6 | super(message);
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/hypixel-api-core/src/main/java/net/hypixel/api/http/HTTPQueryParams.java:
--------------------------------------------------------------------------------
1 | package net.hypixel.api.http;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class HTTPQueryParams {
7 |
8 | public static HTTPQueryParams create() {
9 | return new HTTPQueryParams();
10 | }
11 |
12 | private final Map
41 | * If the player does not {@link #exists() exist}, methods may return unexpected results.
42 | */
43 | public static class Player extends UnstableHypixelObject {
44 |
45 | private static final String DEFAULT_RANK = "NONE";
46 |
47 | /**
48 | * @param raw A JSON object representing a Hypixel player, as returned from the API. If this
49 | * object is valid, it can be retrieved later via {@link #getRaw()}.
50 | */
51 | public Player(JsonElement raw) {
52 | super(raw);
53 | }
54 |
55 | /**
56 | * @return The player's Minecraft UUID, or {@code null} if the player does not {@link
57 | * #exists() exist}.
58 | */
59 | public UUID getUuid() {
60 | String uuidStr = getStringProperty("uuid", null);
61 | return uuidStr != null ? Utilities.uuidFromString(uuidStr) : null;
62 | }
63 |
64 | /**
65 | * @return The Minecraft username that the player had when they last connected to Hypixel.
66 | * {@code null} if the player's name is unknown.
67 | */
68 | public String getName() {
69 | // Attempt to get their display name
70 | String displayName = getStringProperty("displayname", null);
71 | if (displayName != null) {
72 | return displayName;
73 | }
74 |
75 | // Fallback to their most recently-known alias
76 | JsonArray knownAliases = getArrayProperty("knownAliases");
77 | if (knownAliases != null && knownAliases.size() > 0) {
78 | return knownAliases.get(knownAliases.size() - 1).getAsString();
79 | }
80 |
81 | // Fallback to lowercase variants of their name
82 | return getStringProperty("playername", getStringProperty("username", null));
83 | }
84 |
85 | /**
86 | * @return The total amount of network experience earned by the player.
87 | */
88 | public long getNetworkExp() {
89 | long exp = getLongProperty("networkExp", 0);
90 | exp += ILeveling.getTotalExpToFullLevel(getLongProperty("networkLevel", 0) + 1);
91 | return exp;
92 | }
93 |
94 | /**
95 | * @return The player's precise network level, including their progress to the next level.
96 | */
97 | public double getNetworkLevel() {
98 | return ILeveling.getExactLevel(getNetworkExp());
99 | }
100 |
101 | /**
102 | * @return The total amount of karma points earned by the player.
103 | */
104 | public long getKarma() {
105 | return getLongProperty("karma", 0);
106 | }
107 |
108 | /**
109 | * @return The date when the player first connected to Hypixel. Defaults to the unix epoch
110 | * when unknown.
111 | */
112 | public ZonedDateTime getFirstLoginDate() {
113 | return getTimestamp("firstLogin");
114 | }
115 |
116 | /**
117 | * @return The last known time when the player connected to the main Hypixel network.
118 | * Defaults to the unix epoch when unknown.
119 | */
120 | public ZonedDateTime getLastLoginDate() {
121 | return getTimestamp("lastLogin");
122 | }
123 |
124 | /**
125 | * @return The last known time when the player disconnected from the main Hypixel network.
126 | * Defaults to the unix epoch when unknown.
127 | */
128 | public ZonedDateTime getLastLogoutDate() {
129 | return getTimestamp("lastLogout");
130 | }
131 |
132 | /**
133 | * @return {@code true} if the player is currently connected to the Hypixel network. {@code
134 | * false} otherwise, or if the player's online status is hidden in the API.
135 | * @see HypixelAPI#getStatus(UUID)
136 | * @deprecated The status
endpoint ({@link HypixelAPI#getStatus(UUID)}) is
137 | * recommended for checking a player's online status.
138 | */
139 | @Deprecated
140 | public boolean isOnline() {
141 | return getLongProperty("lastLogin", 0) > getLongProperty("lastLogout", 0);
142 | }
143 |
144 | /**
145 | * @return The color of the player's "+"s if they have MVP+ or MVP++. If they do not have
146 | * either rank, or if they have not selected a color, {@code RED} is returned as the
147 | * default.
148 | */
149 | public String getSelectedPlusColor() {
150 | return getStringProperty("rankPlusColor", "RED");
151 | }
152 |
153 | /**
154 | * Note, returned colors use the names seen in this
155 | * table, in all uppercase. For example, {@code DARK_BLUE} and {@code GRAY}.
156 | *
157 | * @return The color of the player's name tag if they have MVP++. Defaults to {@code GOLD}.
158 | */
159 | public String getSuperstarTagColor() {
160 | return getStringProperty("monthlyRankColor", "GOLD");
161 | }
162 |
163 | /**
164 | * Returns the most privileged network rank that the player has.
165 | *
166 | * Example: If...
167 | *
171 | * ...then this method will return {@code MODERATOR}, because it has the highest permission
172 | * level of the three ranks.
173 | *
174 | * @return The most privileged network rank that the player has, or {@code NONE} if they do
175 | * not have any.
176 | * @apiNote Display prefixes are not considered, as they have no effect on permissions.
177 | * Examples include "OWNER" and "MOJANG".
178 | * @see "How
179 | * do I get a player's rank prefix?"
180 | */
181 | public String getHighestRank() {
182 | if (hasRankInField("rank")) {
183 | return getStringProperty("rank", DEFAULT_RANK);
184 |
185 | } else if (hasRankInField("monthlyPackageRank")) {
186 | return getStringProperty("monthlyPackageRank", DEFAULT_RANK);
187 |
188 | } else if (hasRankInField("newPackageRank")) {
189 | return getStringProperty("newPackageRank", DEFAULT_RANK);
190 |
191 | } else if (hasRankInField("packageRank")) {
192 | return getStringProperty("packageRank", DEFAULT_RANK);
193 | }
194 |
195 | return DEFAULT_RANK;
196 | }
197 |
198 | /**
199 | * @return {@code true} if the player has a network rank (e.g. {@code VIP}, {@code MVP++},
200 | * {@code MODERATOR}, etc).
201 | * @apiNote Display prefixes are not considered, as they are technically not ranks. Examples
202 | * include "OWNER" and "MOJANG".
203 | */
204 | public boolean hasRank() {
205 | return !getHighestRank().equals(DEFAULT_RANK);
206 | }
207 |
208 | /**
209 | * @return {@code true} if the player is a member of the Hypixel
210 | * Build Team. Otherwise {@code false}.
211 | */
212 | public boolean isOnBuildTeam() {
213 | return getBooleanProperty("buildTeam", false)
214 | || getBooleanProperty("buildTeamAdmin", false);
215 | }
216 |
217 | /**
218 | * @return The player's most recently played {@link GameType}, or {@code null} if it is
219 | * unknown.
220 | */
221 | public GameType getMostRecentGameType() {
222 | try {
223 | return GameType.valueOf(getStringProperty("mostRecentGameType", ""));
224 | } catch (IllegalArgumentException ignored) {
225 | return null;
226 | }
227 | }
228 |
229 | /**
230 | * @return Information about the player's lobby pets, or {@code null} if they have none.
231 | * @deprecated Use {@link #getPetStats(IPetRepository)} instead
232 | */
233 | @Deprecated
234 | public PetStats getPetStats() {
235 | return getPetStats(BackwardsCompatibilityPetRepositoryImpl.INSTANCE);
236 | }
237 |
238 | /**
239 | * @return Information about the player's lobby pets, or {@code null} if they have none.
240 | */
241 | public PetStats getPetStats(IPetRepository petRepository) {
242 | JsonObject petStats = getObjectProperty("petStats");
243 | if (petStats == null) {
244 | return null;
245 | }
246 |
247 | Type statsObjectType = new TypeToken