Fix a few things

This commit is contained in:
Colin McDonald 2016-02-07 18:09:54 -05:00
parent 4b9b073e20
commit f94fd33f5d
2 changed files with 5 additions and 5 deletions

View File

@ -31,12 +31,8 @@ public class APIv3 extends AbstractVerticle {
ctx.next(); ctx.next();
}); });
Server.findServersByGroup("MineHG", res -> {
res.result().forEach(Server::update);
});
coreHttpRouter.get("/servers").handler(ctx -> { coreHttpRouter.get("/servers").handler(ctx -> {
Server.findServersByGroup("MineHG", res -> { Server.findAllServers(res -> {
if (res.succeeded()) { if (res.succeeded()) {
JsonArray response = new JsonArray(); JsonArray response = new JsonArray();

View File

@ -29,6 +29,10 @@ public final class Server {
@Getter private double lastTps; @Getter private double lastTps;
@Getter private List<UUID> players; @Getter private List<UUID> players;
public static void findAllServers(Handler<AsyncResult<List<Server>>> callback) {
MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), Server::new, callback);
}
public static void findServerById(String id, Handler<AsyncResult<Server>> callback) { public static void findServerById(String id, Handler<AsyncResult<Server>> callback) {
MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), Server::new, callback); MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), Server::new, callback);
} }