Skip to content

Commit

Permalink
Update OfficialAPI.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Oct 28, 2023
1 parent 6ffe9cd commit 55c1c9a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/main/java/io/github/emcw/utils/http/OfficialAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.JsonObject;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.CompletableFuture;

Expand All @@ -24,17 +25,8 @@ public OfficialAPI() { }
});
}

public JsonObject townyData() {
return townyData("");
}

public JsonObject townyData(@NotNull String endpoint) {
if (endpoint.startsWith("/")) {
endpoint = endpoint.substring(1);
}

// Get as JSON
String fullUrl = OAPI_DOMAIN + endpoint;
private @Nullable JsonObject townyData(@NotNull String endpoint) {
String fullUrl = OAPI_DOMAIN + (endpoint.startsWith("/") ? endpoint.substring(1) : endpoint);
CompletableFuture<JsonObject> data = get(fullUrl);

try {
Expand All @@ -47,6 +39,17 @@ public JsonObject townyData(@NotNull String endpoint) {
);
}

return new JsonObject();
return null;
}

public JsonObject serverInfo() {
// TODO: Proper deserialization of API response. (Using records?)
//return GsonUtil.deserialize(townyData(""));

return null;
}

protected static class Towns {

}
}

0 comments on commit 55c1c9a

Please sign in to comment.