Skip to content
Open
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
27 changes: 27 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 @@ -161,6 +161,11 @@ public CompletableFuture<CountsReply> getCounts() {
return get(true, CountsReply.class, "counts");
}

public CompletableFuture<ResourcePackReply> getResourcePacks() {
return get(false, ResourcePackReply.class, "resources/packs",null, 5L);
}


/**
* Gets the current status of the player with information about the server they are in
* at that moment.
Expand Down Expand Up @@ -208,6 +213,28 @@ public CompletableFuture<IPetRepository> getPetRepository() {
.thenApply(PetRepositoryImpl::new);
}

/**
* @param profile Profile ID of which you are requesting the Garden for.
* @return the future
*/
public CompletableFuture<SkyBlockGardenReply> getSkyBlockGarden(String profile) {
return get(true, SkyBlockGardenReply.class, "skyblock/garden",
HTTPQueryParams.create()
.add("profile", profile)
);
}

/**
* @param profile Profile ID of which you are requesting the Museum for.
* @return the future
*/
public CompletableFuture<SkyBlockMuseumReply> getSkyblockMuseum(String profile) {
return get(true, SkyBlockMuseumReply.class, "skyblock/museum",
HTTPQueryParams.create()
.add("profile", profile)
);
}

public CompletableFuture<SkyBlockProfileReply> getSkyBlockProfile(String profile) {
return get(true, SkyBlockProfileReply.class, "skyblock/profile",
HTTPQueryParams.create()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package net.hypixel.api.reply;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;

public class ResourcePackReply extends AbstractReply {
public List<ResourcePack> packs;

/**
* Convenience function.
* @return Skyblock Resource Pack.
* @throws IllegalAccessException if no resourcepack with the configured id is found.
*/
public ResourcePack getSkyblockPack() throws IllegalAccessException {
return packs.stream().filter(a -> a.gameId.equals("SkyBlock")).findFirst().orElseThrow(()->new IllegalAccessException("SkyBlock pack not found"));
}


public static class ResourcePack {
/**
* For example "SkyBlock"
*/
public String gameId;
public Long lastUpdated;
public UUID deployUUID;
public List<VersionResourcePack> versions;
public VersionResourcePack latest(){
return versions.stream().max(Comparator.comparingInt(a -> a.packFormat)).orElse(null);
}
}

public static class VersionResourcePack {
/**
* These are the mc packformats used.
*/
public int packFormat;
public String url;
public String hash;

/**
* Downloads the file from the download url to the specified file. Note that this is a Zip Archive!
*/
public void downloadToFile(File file) throws IOException {
URL url = new URL(this.url);
try (InputStream in = url.openStream()) {
Files.copy(in, Paths.get(file.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.hypixel.api.reply.skyblock;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.hypixel.api.reply.RateLimitedReply;

public class SkyBlockGardenReply extends RateLimitedReply {
private JsonElement garden;

public JsonObject getGarden() {
if (garden == null || garden.isJsonNull()) {
return null;
} else {
return garden.getAsJsonObject();
}
}

@Override
public String toString() {
return "SkyBlockGardenReply{" +
"profile=" + garden +
"} " + super.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.hypixel.api.reply.skyblock;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.hypixel.api.reply.RateLimitedReply;

public class SkyBlockMuseumReply extends RateLimitedReply {
private JsonElement members;

public JsonObject getMuseum() {
if (members == null || members.isJsonNull()) {
return null;
} else {
return members.getAsJsonObject();
}
}

@Override
public String toString() {
return "SkyBlockMuseumReply{" +
"profile=" + members +
"} " + super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum ResourceType {
SKYBLOCK_ITEMS("skyblock/items"),
SKYBLOCK_ELECTION("skyblock/election"),
SKYBLOCK_BINGO("skyblock/bingo"),
;
RESOURCE_PACKS("resourcepacks"),;

/**
* Path to resource
Expand Down