feat: code

This commit is contained in:
2026-03-28 22:45:55 -07:00
parent bade441923
commit 808323f098
5 changed files with 93 additions and 22 deletions

View File

@@ -1,8 +1,10 @@
package online.mineroo.common.request;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import online.mineroo.common.NetworkServiceInterface;
@@ -168,6 +170,27 @@ public class ManagementRequest {
});
}
public CompletableFuture<Boolean> reportPlayers(List<Map<String, String>> players) {
String path = "/server/management/report-online-players";
JsonObject json = new JsonObject();
JsonArray array = new JsonArray();
for (Map<String, String> player : players) {
JsonObject obj = new JsonObject();
obj.addProperty("name", player.get("name"));
obj.addProperty("uuid", player.get("uuid"));
array.add(obj);
}
json.add("players", array);
return networkService.postData(path, json)
.thenApply(response -> { return true; })
.exceptionally(e -> {
logger.warn("Mineroo Report: Failed to report player list", e);
return false;
});
}
/**
* Gets the MOTD token received from the API.
*