Some small changes to make IntelliJ's code analysis happy
This commit is contained in:
parent
cec5031aea
commit
a1e70b47f7
@ -56,7 +56,7 @@ public final class V2Importer {
|
||||
|
||||
private final Future<T> future;
|
||||
|
||||
public FutureCompatibilityCallback(Future<T> future) {
|
||||
private FutureCompatibilityCallback(Future<T> future) {
|
||||
this.future = future;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ public final class GrantConverter implements Block<Document> {
|
||||
this.oidToUniqueId = oidToUniqueId;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void apply(Document grant) {
|
||||
UUID target = oidToUniqueId.get(((Map<String, Object>) grant.get("target")).get("$id"));
|
||||
|
@ -20,6 +20,7 @@ public final class IpLogConverter implements Block<Document> {
|
||||
this.oidToUniqueId = oidToUniqueId;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void apply(Document ipLogEntry) {
|
||||
UUID user = oidToUniqueId.get(((Map<String, Object>) ipLogEntry.get("user")).get("$id"));
|
||||
|
@ -21,6 +21,7 @@ public final class PunishmentConverter implements Block<Document> {
|
||||
this.oidToUniqueId = oidToUniqueId;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void apply(Document punishment) {
|
||||
UUID target = oidToUniqueId.get(((Map<String, Object>) punishment.get("user")).get("$id"));
|
||||
|
@ -119,7 +119,7 @@ public final class ActorAttributeHandler implements Handler<RoutingContext> {
|
||||
}
|
||||
}
|
||||
|
||||
public void processNoAuthorization(RoutingContext ctx) {
|
||||
private void processNoAuthorization(RoutingContext ctx) {
|
||||
ctx.put("actor", new UnknownActor());
|
||||
ctx.next();
|
||||
}
|
||||
|
@ -34,47 +34,19 @@ public final class AuditLogEntry {
|
||||
@Getter private AuditLogActionType type;
|
||||
@Getter private Map<String, Object> metadata;
|
||||
|
||||
public static List<AuditLogEntry> findAllSync() {
|
||||
return SyncUtils.blockMulti(auditLogCollection.find().sort(new Document("performedAt", -1)));
|
||||
}
|
||||
|
||||
public static List<AuditLogEntry> findAllPaginatedSync(int skip, int pageSize) {
|
||||
return SyncUtils.blockMulti(auditLogCollection.find().sort(new Document("performedAt", -1)).skip(skip).limit(pageSize));
|
||||
}
|
||||
|
||||
public static AuditLogEntry findByIdSync(String id) {
|
||||
return SyncUtils.blockOne(auditLogCollection.find(new Document("_id", id)));
|
||||
}
|
||||
|
||||
public static List<AuditLogEntry> findByUserSync(User user) {
|
||||
return findByUserSync(user.getId());
|
||||
}
|
||||
|
||||
public static List<AuditLogEntry> findByUserSync(UUID user) {
|
||||
return SyncUtils.blockMulti(auditLogCollection.find(new Document("user", user)));
|
||||
}
|
||||
|
||||
public static void findAll(SingleResultCallback<List<AuditLogEntry>> callback) {
|
||||
auditLogCollection.find().sort(new Document("performedAt", -1)).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findAllPaginated(int skip, int pageSize, SingleResultCallback<List<AuditLogEntry>> callback) {
|
||||
auditLogCollection.find().sort(new Document("performedAt", -1)).skip(skip).limit(pageSize).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findById(String id, SingleResultCallback<AuditLogEntry> callback) {
|
||||
auditLogCollection.find(new Document("_id", id)).first(callback);
|
||||
}
|
||||
|
||||
public static void findByUser(User user, SingleResultCallback<List<AuditLogEntry>> callback) {
|
||||
findByUser(user.getId(), callback);
|
||||
}
|
||||
|
||||
public static void findByUser(UUID user, SingleResultCallback<List<AuditLogEntry>> callback) {
|
||||
auditLogCollection.find(new Document("user", user)).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public AuditLogEntry() {} // For Morphia
|
||||
public AuditLogEntry() {} // For Jackson
|
||||
|
||||
public AuditLogEntry(User user, String userIp, Actor actor, AuditLogActionType type, Map<String, Object> metadata) {
|
||||
this.id = new ObjectId().toString();
|
||||
|
@ -27,7 +27,7 @@ public final class Grant {
|
||||
@Getter @Id private String id;
|
||||
@Getter private UUID user;
|
||||
@Getter private String reason;
|
||||
@Getter private Set<String> scopes = new HashSet<>(); // So on things w/o scopes we still load properly (Morphia drops empty sets)
|
||||
@Getter private Set<String> scopes;
|
||||
@Getter private String rank;
|
||||
@Getter private Instant expiresAt;
|
||||
|
||||
@ -42,10 +42,6 @@ public final class Grant {
|
||||
return SyncUtils.blockMulti(grantsCollection.find().sort(new Document("addedAt", -1)));
|
||||
}
|
||||
|
||||
public static List<Grant> findAllPaginatedSync(int skip, int pageSize) {
|
||||
return SyncUtils.blockMulti(grantsCollection.find().sort(new Document("addedAt", -1)).skip(skip).limit(pageSize));
|
||||
}
|
||||
|
||||
public static List<Grant> findByRankSync(Collection<Rank> ranks) {
|
||||
Collection<String> convertedRanks = ranks.stream().map(Rank::getId).collect(Collectors.toList());
|
||||
return SyncUtils.blockMulti(grantsCollection.find(new Document("rank", new Document("$in", convertedRanks))));
|
||||
@ -63,19 +59,10 @@ public final class Grant {
|
||||
return SyncUtils.blockMulti(grantsCollection.find(new Document("user", user)));
|
||||
}
|
||||
|
||||
public static void findAll(SingleResultCallback<List<Grant>> callback) {
|
||||
grantsCollection.find().sort(new Document("addedAt", -1)).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findAllPaginated(int skip, int pageSize, SingleResultCallback<List<Grant>> callback) {
|
||||
grantsCollection.find().sort(new Document("addedAt", -1)).skip(skip).limit(pageSize).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findByRank(Collection<Rank> ranks, SingleResultCallback<List<Grant>> callback) {
|
||||
Collection<String> convertedRanks = ranks.stream().map(Rank::getId).collect(Collectors.toList());
|
||||
grantsCollection.find(new Document("rank", new Document("$in", convertedRanks))).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findById(String id, SingleResultCallback<Grant> callback) {
|
||||
grantsCollection.find(new Document("_id", id)).first(callback);
|
||||
}
|
||||
@ -108,7 +95,7 @@ public final class Grant {
|
||||
});
|
||||
}
|
||||
|
||||
public Grant() {} // For Morphia
|
||||
public Grant() {} // For Jackson
|
||||
|
||||
public Grant(User user, String reason, Set<ServerGroup> scopes, Rank rank, Instant expiresAt, User addedBy) {
|
||||
this.id = new ObjectId().toString();
|
||||
@ -126,11 +113,7 @@ public final class Grant {
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
if (expiresAt == null) {
|
||||
return false; // Never expires
|
||||
} else {
|
||||
return expiresAt.isBefore(Instant.now());
|
||||
}
|
||||
return expiresAt != null && expiresAt.isBefore(Instant.now());
|
||||
}
|
||||
|
||||
public boolean isRemoved() {
|
||||
|
@ -39,26 +39,10 @@ public final class IpBan {
|
||||
@Getter private Instant removedAt;
|
||||
@Getter private String removalReason;
|
||||
|
||||
public static List<IpBan> findAllSync() {
|
||||
return SyncUtils.blockMulti(ipBansCollection.find().sort(new Document("addedAt", -1)));
|
||||
}
|
||||
|
||||
public static List<IpBan> findAllPaginatedSync(int skip, int pageSize) {
|
||||
return SyncUtils.blockMulti(ipBansCollection.find().sort(new Document("addedAt", -1)).skip(skip).limit(pageSize));
|
||||
}
|
||||
|
||||
public static IpBan findByIdSync(String id) {
|
||||
return SyncUtils.blockOne(ipBansCollection.find(new Document("_id", id)));
|
||||
}
|
||||
|
||||
public static List<IpBan> findByIpSync(String userIp) {
|
||||
return SyncUtils.blockMulti(ipBansCollection.find(new Document("userIp", userIp)));
|
||||
}
|
||||
|
||||
public static void findAll(SingleResultCallback<List<IpBan>> callback) {
|
||||
ipBansCollection.find().sort(new Document("addedAt", -1)).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findAllPaginated(int skip, int pageSize, SingleResultCallback<List<IpBan>> callback) {
|
||||
ipBansCollection.find().sort(new Document("addedAt", -1)).skip(skip).limit(pageSize).into(new ArrayList<>(), callback);
|
||||
}
|
||||
@ -91,7 +75,7 @@ public final class IpBan {
|
||||
});
|
||||
}
|
||||
|
||||
public IpBan() {} // For Morphia
|
||||
public IpBan() {} // For Jackson
|
||||
|
||||
public IpBan(String userIp, Punishment linked) {
|
||||
this.id = new ObjectId().toString();
|
||||
@ -120,11 +104,7 @@ public final class IpBan {
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
if (expiresAt == null) {
|
||||
return false; // Never expires
|
||||
} else {
|
||||
return expiresAt.isBefore(Instant.now());
|
||||
}
|
||||
return expiresAt != null && expiresAt.isBefore(Instant.now());
|
||||
}
|
||||
|
||||
public boolean isRemoved() {
|
||||
@ -137,7 +117,7 @@ public final class IpBan {
|
||||
if (error != null) {
|
||||
callback.onResult(null, error);
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
if (punishment != null) {
|
||||
User.findById(punishment.getUser(), (user, error2) -> {
|
||||
|
@ -79,7 +79,7 @@ public final class IpLogEntry {
|
||||
ipLogCollection.find(new Document("user", user).append("userIp", userIp)).first(callback);
|
||||
}
|
||||
|
||||
public IpLogEntry() {} // For Morphia
|
||||
public IpLogEntry() {} // For Jackson
|
||||
|
||||
public IpLogEntry(User user, String userIp) {
|
||||
this.id = new ObjectId().toString();
|
||||
|
@ -26,10 +26,6 @@ public final class NotificationTemplate {
|
||||
@Getter @Setter private String subject;
|
||||
@Getter @Setter private String body;
|
||||
|
||||
public static List<NotificationTemplate> findAllSync() {
|
||||
return SyncUtils.blockMulti(notificationTemplatesCollection.find());
|
||||
}
|
||||
|
||||
public static NotificationTemplate findByIdSync(String id) {
|
||||
return SyncUtils.blockOne(notificationTemplatesCollection.find(new Document("_id", id)));
|
||||
}
|
||||
@ -42,7 +38,7 @@ public final class NotificationTemplate {
|
||||
notificationTemplatesCollection.find(new Document("_id", id)).first(callback);
|
||||
}
|
||||
|
||||
public NotificationTemplate() {} // For Morphia
|
||||
public NotificationTemplate() {} // For Jackson
|
||||
|
||||
public NotificationTemplate(String id, String subject, String body) {
|
||||
this.id = id;
|
||||
@ -75,12 +71,6 @@ public final class NotificationTemplate {
|
||||
callback.get();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
BlockingCallback<UpdateResult> callback = new BlockingCallback<>();
|
||||
notificationTemplatesCollection.replaceOne(new Document("_id", id), this, callback);
|
||||
callback.get();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
BlockingCallback<DeleteResult> callback = new BlockingCallback<>();
|
||||
notificationTemplatesCollection.deleteOne(new Document("_id", id), callback);
|
||||
|
@ -43,14 +43,6 @@ public final class Punishment {
|
||||
@Getter private Instant removedAt;
|
||||
@Getter private String removalReason;
|
||||
|
||||
public static List<Punishment> findAllSync() {
|
||||
return SyncUtils.blockMulti(punishmentsCollection.find().sort(new Document("addedAt", -1)));
|
||||
}
|
||||
|
||||
public static List<Punishment> findAllPaginatedSync(int skip, int pageSize) {
|
||||
return SyncUtils.blockMulti(punishmentsCollection.find().sort(new Document("addedAt", -1)).skip(skip).limit(pageSize));
|
||||
}
|
||||
|
||||
public static List<Punishment> findByTypeSync(Collection<PunishmentType> types) {
|
||||
Collection<String> convertedTypes = types.stream().map(PunishmentType::name).collect(Collectors.toList());
|
||||
return SyncUtils.blockMulti(punishmentsCollection.find(new Document("type", new Document("$in", convertedTypes))));
|
||||
@ -60,10 +52,6 @@ public final class Punishment {
|
||||
return SyncUtils.blockOne(punishmentsCollection.find(new Document("_id", id)));
|
||||
}
|
||||
|
||||
public static Punishment findByLinkedIpBanIdSync(String id) {
|
||||
return SyncUtils.blockOne(punishmentsCollection.find(new Document("linkedIpBanId", id)));
|
||||
}
|
||||
|
||||
public static List<Punishment> findByUserSync(User user) {
|
||||
return findByUserSync(user.getId());
|
||||
}
|
||||
@ -81,19 +69,10 @@ public final class Punishment {
|
||||
return SyncUtils.blockMulti(punishmentsCollection.find(new Document("user", user).append("type", new Document("$in", convertedTypes))));
|
||||
}
|
||||
|
||||
public static void findAll(SingleResultCallback<List<Punishment>> callback) {
|
||||
punishmentsCollection.find().sort(new Document("addedAt", -1)).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findAllPaginated(int skip, int pageSize, SingleResultCallback<List<Punishment>> callback) {
|
||||
punishmentsCollection.find().sort(new Document("addedAt", -1)).skip(skip).limit(pageSize).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findByType(Collection<PunishmentType> types, SingleResultCallback<List<Punishment>> callback) {
|
||||
Collection<String> convertedTypes = types.stream().map(PunishmentType::name).collect(Collectors.toList());
|
||||
punishmentsCollection.find(new Document("type", new Document("$in", convertedTypes))).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findById(String id, SingleResultCallback<Punishment> callback) {
|
||||
punishmentsCollection.find(new Document("_id", id)).first(callback);
|
||||
}
|
||||
@ -139,7 +118,7 @@ public final class Punishment {
|
||||
punishmentsCollection.find(new Document("user", user).append("type", new Document("$in", convertedTypes))).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public Punishment() {} // For Morphia
|
||||
public Punishment() {} // For Jackson
|
||||
|
||||
public Punishment(User user, String reason, PunishmentType type, Instant expiresAt, User addedBy, Actor actor, Map<String, Object> metadata) {
|
||||
this.id = new ObjectId().toString();
|
||||
@ -159,11 +138,7 @@ public final class Punishment {
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
if (expiresAt == null) {
|
||||
return false; // Never expires
|
||||
} else {
|
||||
return expiresAt.isBefore(Instant.now());
|
||||
}
|
||||
return expiresAt != null && expiresAt.isBefore(Instant.now());
|
||||
}
|
||||
|
||||
public boolean isRemoved() {
|
||||
|
@ -45,7 +45,7 @@ public final class Rank {
|
||||
return rankCache.get(id);
|
||||
}
|
||||
|
||||
public Rank() {} // For Morphia
|
||||
public Rank() {} // For Jackson
|
||||
|
||||
public Rank(String id, int weight, String displayName, String gameColor, String websiteColor, boolean staffRank) {
|
||||
this.id = id;
|
||||
@ -80,12 +80,6 @@ public final class Rank {
|
||||
callback.get();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
BlockingCallback<UpdateResult> callback = new BlockingCallback<>();
|
||||
ranksCollection.replaceOne(new Document("_id", id), this, callback);
|
||||
callback.get();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
BlockingCallback<DeleteResult> callback = new BlockingCallback<>();
|
||||
ranksCollection.deleteOne(new Document("_id", id), callback);
|
||||
|
@ -32,9 +32,9 @@ public final class Server {
|
||||
@Getter @ExcludeFromReplies String apiKey;
|
||||
@Getter private String serverGroup;
|
||||
@Getter private String serverIp;
|
||||
@Getter @Setter private Instant lastUpdatedAt;
|
||||
@Getter @Setter private double lastTps;
|
||||
@Getter @Setter @ExcludeFromReplies private Set<UUID> players;
|
||||
@Getter private Instant lastUpdatedAt;
|
||||
@Getter private double lastTps;
|
||||
@Getter @ExcludeFromReplies private Set<UUID> players;
|
||||
|
||||
public static List<Server> findAll() {
|
||||
updateCacheIfNeeded();
|
||||
@ -46,7 +46,7 @@ public final class Server {
|
||||
return serverCache.get(id);
|
||||
}
|
||||
|
||||
public Server() {} // For Morphia
|
||||
public Server() {} // For Jackson
|
||||
|
||||
public Server(String id, String displayName, String apiKey, ServerGroup serverGroup, String serverIp) {
|
||||
this.id = id;
|
||||
|
@ -29,10 +29,8 @@ public final class ServerGroup {
|
||||
|
||||
@Getter @Id private String id;
|
||||
@Getter private String image;
|
||||
// We define these HashSets up here because, in the event they're
|
||||
// empty, Morphia will load them as null, not empty sets.
|
||||
@Getter @Setter @ExcludeFromReplies private Set<String> announcements = new HashSet<>();
|
||||
@Getter @Setter @ExcludeFromReplies private Map<String, List<String>> permissions = new HashMap<>();
|
||||
@Getter @Setter @ExcludeFromReplies private Set<String> announcements;
|
||||
@Getter @Setter @ExcludeFromReplies private Map<String, List<String>> permissions;
|
||||
|
||||
// make this and other stuff async
|
||||
public static List<ServerGroup> findAll() {
|
||||
@ -45,7 +43,7 @@ public final class ServerGroup {
|
||||
return serverGroupCache.get(id);
|
||||
}
|
||||
|
||||
public ServerGroup() {} // For Morphia
|
||||
public ServerGroup() {} // For Jackson
|
||||
|
||||
public ServerGroup(String id, String image) {
|
||||
this.id = id;
|
||||
|
@ -50,10 +50,6 @@ public final class User {
|
||||
@Getter private Instant firstSeenAt;
|
||||
@Getter private boolean online;
|
||||
|
||||
public static List<User> findAllSync() {
|
||||
return SyncUtils.blockMulti(usersCollection.find().sort(new Document("lastSeenAt", -1)));
|
||||
}
|
||||
|
||||
public static User findByIdSync(String id) {
|
||||
UUID uuid;
|
||||
|
||||
@ -82,10 +78,6 @@ public final class User {
|
||||
return SyncUtils.blockOne(usersCollection.find(new Document("lastUsername", lastUsername)));
|
||||
}
|
||||
|
||||
public static void findAll(SingleResultCallback<List<User>> callback) {
|
||||
usersCollection.find().sort(new Document("lastSeenAt", -1)).into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findById(String id, SingleResultCallback<User> callback) {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(id);
|
||||
@ -123,15 +115,11 @@ public final class User {
|
||||
});
|
||||
}
|
||||
|
||||
public static void findByEmailToken(String emailToken, SingleResultCallback<User> callback) {
|
||||
usersCollection.find(new Document("emailToken", emailToken)).first(callback);
|
||||
}
|
||||
|
||||
public static void findByLastUsername(String lastUsername, SingleResultCallback<User> callback) {
|
||||
usersCollection.find(new Document("lastUsername", lastUsername)).first(callback);
|
||||
}
|
||||
|
||||
public User() {} // For Morphia
|
||||
public User() {} // For Jackson
|
||||
|
||||
// TODO: THIS IS CURRENTLY BLOCKING. MAYBE FOR THE HEARTBEAT WE CAN DO SOMETHING
|
||||
// TO MAKE IT NOT SO BLOCKING
|
||||
@ -139,11 +127,6 @@ public final class User {
|
||||
this.id = id;
|
||||
this.lastUsername = ""; // Intentional, so updateUsername actually does something.
|
||||
this.aliases = new HashMap<>();
|
||||
this.totpSecret = null;
|
||||
this.password = null;
|
||||
this.email = null;
|
||||
this.phoneNumber = null;
|
||||
this.lastSeenOn = null;
|
||||
this.lastSeenAt = Instant.now();
|
||||
this.firstSeenAt = Instant.now();
|
||||
|
||||
@ -226,11 +209,7 @@ public final class User {
|
||||
}
|
||||
|
||||
public Rank getHighestRankAnywhere() {
|
||||
return getHighestRankScoped(null);
|
||||
}
|
||||
|
||||
public Rank getHighestRankScoped(ServerGroup serverGroup) {
|
||||
return getHighestRankScoped(serverGroup, Grant.findByUserSync(this));
|
||||
return getHighestRankScoped(null, Grant.findByUserSync(this));
|
||||
}
|
||||
|
||||
// TODO: Clean
|
||||
|
@ -30,14 +30,6 @@ public final class UserMetaEntry {
|
||||
@Getter private String serverGroup;
|
||||
@Getter @Setter private Map<String, Object> data;
|
||||
|
||||
public static List<UserMetaEntry> findAllSync() {
|
||||
return SyncUtils.blockMulti(userMetaCollection.find());
|
||||
}
|
||||
|
||||
public static UserMetaEntry findByIdSync(String id) {
|
||||
return SyncUtils.blockOne(userMetaCollection.find(new Document("_id", id)));
|
||||
}
|
||||
|
||||
public static UserMetaEntry findByUserAndGroupSync(User user, ServerGroup serverGroup) {
|
||||
return findByUserAndGroupSync(user.getId(), serverGroup);
|
||||
}
|
||||
@ -46,23 +38,7 @@ public final class UserMetaEntry {
|
||||
return SyncUtils.blockOne(userMetaCollection.find(new Document("user", user).append("serverGroup", serverGroup.getId())));
|
||||
}
|
||||
|
||||
public static void findAll(SingleResultCallback<List<UserMetaEntry>> callback) {
|
||||
userMetaCollection.find().into(new ArrayList<>(), callback);
|
||||
}
|
||||
|
||||
public static void findById(String id, SingleResultCallback<UserMetaEntry> callback) {
|
||||
userMetaCollection.find(new Document("_id", id)).first(callback);
|
||||
}
|
||||
|
||||
public static void findByUserAndGroup(User user, ServerGroup serverGroup, SingleResultCallback<UserMetaEntry> callback) {
|
||||
findByUserAndGroup(user.getId(), serverGroup, callback);
|
||||
}
|
||||
|
||||
public static void findByUserAndGroup(UUID user, ServerGroup serverGroup, SingleResultCallback<UserMetaEntry> callback) {
|
||||
userMetaCollection.find(new Document("user", user).append("serverGroup", serverGroup.getId())).first(callback);
|
||||
}
|
||||
|
||||
public UserMetaEntry() {} // For Morphia
|
||||
public UserMetaEntry() {} // For Jackson
|
||||
|
||||
public UserMetaEntry(User user, ServerGroup serverGroup, Map<String, Object> data) {
|
||||
this.id = new ObjectId().toString();
|
||||
|
@ -108,7 +108,6 @@ public final class GETDump implements Handler<RoutingContext> {
|
||||
return;
|
||||
default:
|
||||
ErrorUtils.respondInvalidInput(ctx, type + " is not a valid type. Not in [ban, blacklist, accessDeniable, grant]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,12 +53,12 @@ public final class POSTUserGrant implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
Instant expiresAt;
|
||||
Instant expiresAt = null;
|
||||
|
||||
try {
|
||||
expiresAt = Instant.ofEpochMilli(Long.parseLong(ctx.request().getParam("expiresAt")));
|
||||
} catch (NumberFormatException ex) {
|
||||
expiresAt = null;
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Just leave it null, we don't need an expiration date.
|
||||
}
|
||||
|
||||
if (expiresAt != null && expiresAt.isBefore(Instant.now())) {
|
||||
|
@ -27,12 +27,12 @@ public final class POSTIpIpBan implements Handler<RoutingContext> {
|
||||
return;
|
||||
}
|
||||
|
||||
Instant expiresAt;
|
||||
Instant expiresAt = null;
|
||||
|
||||
try {
|
||||
expiresAt = Instant.ofEpochMilli(Long.parseLong(ctx.request().getParam("expiresAt")));
|
||||
} catch (NumberFormatException ex) {
|
||||
expiresAt = null;
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Just leave it null, we don't need an expiration date.
|
||||
}
|
||||
|
||||
if (expiresAt != null && expiresAt.isBefore(Instant.now())) {
|
||||
|
@ -43,12 +43,12 @@ public final class POSTUserPunish implements Handler<RoutingContext> {
|
||||
}
|
||||
}
|
||||
|
||||
Instant expiresAt;
|
||||
Instant expiresAt = null;
|
||||
|
||||
try {
|
||||
expiresAt = Instant.ofEpochMilli(Long.parseLong(ctx.request().getParam("expiresAt")));
|
||||
} catch (NumberFormatException ex) {
|
||||
expiresAt = null;
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Just leave it null, we don't need an expiration date.
|
||||
}
|
||||
|
||||
if (expiresAt != null && expiresAt.isBefore(Instant.now())) {
|
||||
|
@ -59,19 +59,17 @@ public final class POSTServerHeartbeat implements Handler<RoutingContext> {
|
||||
}
|
||||
|
||||
// TODO: ASYNC (MAKE ALL SAVES/INSERTS/ETC USED HERE ASYNC
|
||||
public Future<Void> createInfoResponse(Server server, double tps, Map<UUID, String> playerNames) {
|
||||
private Future<Void> createInfoResponse(Server server, double tps, Map<UUID, String> playerNames) {
|
||||
Future<Void> callback = Future.future();
|
||||
|
||||
server.setPlayers(playerNames.keySet());
|
||||
server.setLastTps(tps);
|
||||
server.setLastUpdatedAt(Instant.now());
|
||||
server.receivedHeartbeat(tps, playerNames.keySet());
|
||||
server.save();
|
||||
|
||||
callback.complete();
|
||||
return callback;
|
||||
}
|
||||
|
||||
public Future<Map<String, Object>> createPlayerResponse(Server server, Map<UUID, String> playerNames) {
|
||||
private Future<Map<String, Object>> createPlayerResponse(Server server, Map<UUID, String> playerNames) {
|
||||
Future<Map<String, Object>> callback = Future.future();
|
||||
|
||||
Future<Map<UUID, User>> userLookupCallback = Future.future();
|
||||
@ -142,7 +140,7 @@ public final class POSTServerHeartbeat implements Handler<RoutingContext> {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public Future<Map<String, Object>> createPermissionsResponse(ServerGroup serverGroup) {
|
||||
private Future<Map<String, Object>> createPermissionsResponse(ServerGroup serverGroup) {
|
||||
Future<Map<String, Object>> callback = Future.future();
|
||||
Map<String, Object> permissionsResponse = new HashMap<>();
|
||||
|
||||
@ -159,7 +157,7 @@ public final class POSTServerHeartbeat implements Handler<RoutingContext> {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public Future<Map<String, Object>> createEventsResponse(List<Object> eventsData) {
|
||||
private Future<Map<String, Object>> createEventsResponse(List<Object> eventsData) {
|
||||
Future<Map<String, Object>> callback = Future.future();
|
||||
|
||||
for (Object event : eventsData) {
|
||||
@ -182,7 +180,7 @@ public final class POSTServerHeartbeat implements Handler<RoutingContext> {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public Map<UUID, String> extractPlayerNames(Document reqJson) {
|
||||
private Map<UUID, String> extractPlayerNames(Document reqJson) {
|
||||
Map<UUID, String> result = new HashMap<>();
|
||||
|
||||
for (Object player : (List<Object>) reqJson.get("players")) {
|
||||
|
@ -52,8 +52,6 @@ public final class POSTUserLogin implements Handler<RoutingContext> {
|
||||
user = new User(uuid, username);
|
||||
}
|
||||
|
||||
Server actorServer = Server.findById(actor.getName());
|
||||
|
||||
IpLogEntry ipLogEntry = IpLogEntry.findByUserAndIpSync(user, userIp);
|
||||
|
||||
// We use a little bit more verbose code here to save on the
|
||||
@ -68,7 +66,7 @@ public final class POSTUserLogin implements Handler<RoutingContext> {
|
||||
}
|
||||
|
||||
user.updateUsername(username);
|
||||
user.getLoginInfo(actorServer, userIp, (loginInfo, error) -> {
|
||||
user.getLoginInfo(server, userIp, (loginInfo, error) -> {
|
||||
if (error != null) {
|
||||
ErrorUtils.respondInternalError(ctx, error);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user