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-04-30 20:03:34 +02:00
|
|
|
import lombok.Setter;
|
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-04-27 02:46:34 +02: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;
|
2016-05-01 02:08:58 +02:00
|
|
|
@Getter private String apiKey;
|
2016-02-08 00:03:42 +01:00
|
|
|
@Getter private String group;
|
2016-02-23 13:14:42 +01:00
|
|
|
@Getter private String ip;
|
2016-04-30 20:03:34 +02:00
|
|
|
@Getter @Setter private Date lastUpdate;
|
|
|
|
@Getter @Setter private double lastTps;
|
|
|
|
@Getter @Setter 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) {
|
2016-04-17 21:23:02 +02:00
|
|
|
return APIv3.getDatastore().createQuery(Server.class).field("id").equalIgnoreCase(id).get();
|
2016-02-08 00:03:42 +01:00
|
|
|
}
|
|
|
|
|
2016-04-27 02:46:34 +02:00
|
|
|
public static List<Server> values() {
|
|
|
|
return APIv3.getDatastore().createQuery(Server.class).asList();
|
|
|
|
}
|
|
|
|
|
2016-03-21 23:28:17 +01:00
|
|
|
public Server() {} // For Morphia
|
|
|
|
|
2016-05-01 02:08:58 +02:00
|
|
|
public Server(String id, String bungeeId, String displayName, String apiKey, ServerGroup group, String ip) {
|
2016-03-21 23:28:17 +01:00
|
|
|
this.id = id;
|
|
|
|
this.bungeeId = bungeeId;
|
|
|
|
this.displayName = displayName;
|
2016-05-01 02:08:58 +02:00
|
|
|
this.apiKey = apiKey;
|
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-05-01 02:20:12 +02:00
|
|
|
public void delete() {
|
|
|
|
APIv3.getDatastore().delete(this);
|
|
|
|
}
|
|
|
|
|
2016-02-06 02:58:49 +01:00
|
|
|
}
|