package net.frozenorb.apiv3.model; import lombok.Getter; import net.frozenorb.apiv3.APIv3; import org.bson.Document; import org.mongodb.morphia.annotations.Entity; import org.mongodb.morphia.annotations.Id; import java.lang.annotation.Documented; import java.time.Instant; import java.util.*; @Entity(value = "servers", noClassnameStored = true) public final class Server { @Id private String id; @Getter private String bungeeId; @Getter private String displayName; @Getter private String secret; @Getter private String group; @Getter private String ip; @Getter private Date lastUpdate; @Getter private double lastTps; @Getter private Set players; public static Server byId(String id) { return APIv3.getDatastore().createQuery(Server.class).field("id").equal(id).get(); } public Server() {} // For Morphia public Server(String id, String bungeeId, String displayName, String secret, String group, String ip) { this.id = id; this.bungeeId = bungeeId; this.displayName = displayName; this.secret = secret; this.group = group; this.ip = ip; this.lastUpdate = new Date(); this.lastTps = 0; this.players = new HashSet<>(); } public ServerGroup resolveGroup() { return ServerGroup.byId(group); } }