2016-04-08 13:12:31 +02:00
|
|
|
package net.frozenorb.apiv3.models;
|
2016-02-06 02:58:49 +01:00
|
|
|
|
|
|
|
import lombok.Getter;
|
2016-03-21 23:28:17 +01:00
|
|
|
import net.frozenorb.apiv3.APIv3;
|
|
|
|
import org.mongodb.morphia.annotations.Entity;
|
|
|
|
import org.mongodb.morphia.annotations.Id;
|
2016-02-06 02:58:49 +01:00
|
|
|
|
2016-03-21 23:28:17 +01:00
|
|
|
import java.util.*;
|
2016-02-06 02:58:49 +01:00
|
|
|
|
2016-03-21 23:28:17 +01:00
|
|
|
@Entity(value = "servers", noClassnameStored = true)
|
|
|
|
public final class Server {
|
2016-02-08 00:03:42 +01:00
|
|
|
|
2016-04-08 13:12:31 +02:00
|
|
|
@Getter @Id private String id;
|
2016-02-08 00:03:42 +01:00
|
|
|
@Getter private String bungeeId;
|
|
|
|
@Getter private String displayName;
|
|
|
|
@Getter private String secret;
|
|
|
|
@Getter private String group;
|
2016-02-23 13:14:42 +01:00
|
|
|
@Getter private String ip;
|
2016-03-21 23:28:17 +01:00
|
|
|
@Getter private Date lastUpdate;
|
2016-02-08 00:03:42 +01:00
|
|
|
@Getter private double lastTps;
|
2016-03-21 23:28:17 +01:00
|
|
|
@Getter private Set<UUID> players;
|
2016-02-08 00:03:42 +01:00
|
|
|
|
2016-03-21 23:28:17 +01:00
|
|
|
public static Server byId(String id) {
|
|
|
|
return APIv3.getDatastore().createQuery(Server.class).field("id").equal(id).get();
|
2016-02-08 00:03:42 +01:00
|
|
|
}
|
|
|
|
|
2016-03-21 23:28:17 +01:00
|
|
|
public Server() {} // For Morphia
|
|
|
|
|
2016-04-08 13:12:31 +02:00
|
|
|
public Server(String id, String bungeeId, String displayName, String secret, ServerGroup group, String ip) {
|
2016-03-21 23:28:17 +01:00
|
|
|
this.id = id;
|
|
|
|
this.bungeeId = bungeeId;
|
|
|
|
this.displayName = displayName;
|
|
|
|
this.secret = secret;
|
2016-04-08 13:12:31 +02:00
|
|
|
this.group = group.getId();
|
2016-03-21 23:28:17 +01:00
|
|
|
this.ip = ip;
|
|
|
|
this.lastUpdate = new Date();
|
|
|
|
this.lastTps = 0;
|
|
|
|
this.players = new HashSet<>();
|
2016-02-08 00:03:42 +01:00
|
|
|
}
|
|
|
|
|
2016-03-21 23:28:17 +01:00
|
|
|
public ServerGroup resolveGroup() {
|
|
|
|
return ServerGroup.byId(group);
|
2016-02-06 02:58:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|