Skip to content

Add methods for accessing skyblock/profiles endpoint #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,28 @@ public CompletableFuture<SkyBlockProfileReply> getSkyBlockProfile(String profile
);
}

/**
* @param player uuid of a player.
* @return the future
*/
public CompletableFuture<SkyBlockProfilesReply> getSkyBlockProfiles(UUID player) {
return get(SkyBlockProfilesReply.class, "skyblock/profiles",
HTTPQueryParams.create()
.add("uuid", player)
);
}

/**
* @param player uuid of a player in string format, can be both dashed or undashed.
* @return the future
*/
public CompletableFuture<SkyBlockProfilesReply> getSkyBlockProfiles(String player) {
return get(SkyBlockProfilesReply.class, "skyblock/profiles",
HTTPQueryParams.create()
.add("uuid", player)
);
}

public CompletableFuture<SkyBlockNewsReply> getSkyBlockNews() {
return get(SkyBlockNewsReply.class, "skyblock/news");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.hypixel.api.reply.skyblock;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import net.hypixel.api.reply.AbstractReply;

public class SkyBlockProfilesReply extends AbstractReply {
private JsonElement profiles;

public JsonArray getProfiles() {
if (profiles == null || profiles.isJsonNull()) {
return null;
} else {
return profiles.getAsJsonArray();
}
}

@Override
public String toString() {
return "SkyBlockProfilesReply{" +
"profiles=" + profiles +
"} " + super.toString();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}