Remove unused methods/fields

This commit is contained in:
Colin McDonald 2016-05-20 16:19:13 -04:00
parent 3bf8fde060
commit 2c3069de9a
5 changed files with 11 additions and 14 deletions

View File

@ -14,10 +14,7 @@ import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.frozenorb.apiv3.actors.ActorType;
import net.frozenorb.apiv3.filters.*;
import net.frozenorb.apiv3.models.Grant;
import net.frozenorb.apiv3.models.IPLogEntry;
import net.frozenorb.apiv3.models.Punishment;
import net.frozenorb.apiv3.models.User;
import net.frozenorb.apiv3.models.*;
import net.frozenorb.apiv3.routes.GETDump;
import net.frozenorb.apiv3.routes.GETWhoAmI;
import net.frozenorb.apiv3.routes.NotFound;
@ -48,6 +45,7 @@ import net.frozenorb.apiv3.serialization.ObjectIdTypeAdapter;
import net.frozenorb.apiv3.unsorted.BugsnagSLF4JLogger;
import net.frozenorb.apiv3.unsorted.LoggingExceptionHandler;
import net.frozenorb.apiv3.utils.IPUtils;
import net.frozenorb.apiv3.utils.PermissionUtils;
import net.frozenorb.apiv3.utils.UUIDUtils;
import org.bson.Document;
import org.bson.types.ObjectId;

View File

@ -7,15 +7,14 @@ import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Indexed;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Entity(value = "ranks", noClassnameStored = true)
public final class Rank {
private static Map<String, Rank> rankCache = null;
private static List<Rank> sortedRankCache = null;
private static long rankCacheUpdated = 0;
@Getter @Id private String id;
@ -32,7 +31,7 @@ public final class Rank {
public static List<Rank> values() {
updateCacheIfNeeded();
return ImmutableList.copyOf(rankCache.values());
return ImmutableList.copyOf(sortedRankCache);
}
public Rank() {} // For Morphia
@ -53,12 +52,15 @@ public final class Rank {
private static void updateCacheIfNeeded() {
if (rankCache == null || (System.currentTimeMillis() - rankCacheUpdated) > TimeUnit.MINUTES.toMillis(1)) {
Map<String, Rank> working = new HashMap<>();
List<Rank> workingSorted = new ArrayList<>();
for (Rank rank : APIv3.getDatastore().createQuery(Rank.class).order("weight").asList()) {
working.put(rank.getId(), rank);
workingSorted.add(rank);
}
rankCache = working;
sortedRankCache = workingSorted;
rankCacheUpdated = System.currentTimeMillis();
}
}

View File

@ -14,7 +14,6 @@ import java.util.*;
public final class Server {
@Getter @Id private String id;
@Getter private String bungeeId;
@Getter private String displayName;
@Getter @ExcludeFromReplies String apiKey;
@Getter @Indexed private String serverGroup;
@ -33,9 +32,8 @@ public final class Server {
public Server() {} // For Morphia
public Server(String id, String bungeeId, String displayName, String apiKey, ServerGroup serverGroup, String serverIp) {
public Server(String id, String displayName, String apiKey, ServerGroup serverGroup, String serverIp) {
this.id = id;
this.bungeeId = bungeeId;
this.displayName = displayName;
this.apiKey = apiKey;
this.serverGroup = serverGroup.getId();

View File

@ -13,7 +13,6 @@ public final class POSTServer implements Route {
public Object handle(Request req, Response res) {
String id = req.queryParams("id");
String bungeeId = req.queryParams("bungeeId");
String displayName = req.queryParams("displayName");
String apiKey = req.queryParams("apiKey");
ServerGroup group = ServerGroup.byId(req.queryParams("group"));
@ -27,7 +26,7 @@ public final class POSTServer implements Route {
return ErrorUtils.invalidInput("IP address \"" + ip + "\" is not valid.");
}
Server server = new Server(id, bungeeId, displayName, apiKey, group, ip);
Server server = new Server(id, displayName, apiKey, group, ip);
APIv3.getDatastore().save(server);
return server;
}