Fix request spam filter filtering against expired requests

This commit is contained in:
William committed 2022-08-31 12:25:26 +01:00
1 parent 74cb268426
commit 2e04b5328c
1 file changed
+5 -5
@@ -92,8 +92,6 @@ public class RequestManager {
// If the player couldn't be found locally, send the request cross-server // If the player couldn't be found locally, send the request cross-server
if (plugin.getSettings().crossServer) { if (plugin.getSettings().crossServer) {
// Find the matching networked target // Find the matching networked target
return plugin.getNetworkMessenger().findPlayer(requester, targetUser).thenApply(networkedTarget -> { return plugin.getNetworkMessenger().findPlayer(requester, targetUser).thenApply(networkedTarget -> {
if (networkedTarget.isEmpty()) { if (networkedTarget.isEmpty()) {
@@ -141,11 +139,13 @@ public class RequestManager {
return Optional.empty(); return Optional.empty();
} }
// If the person already has a request of the same type by this player, don't bother sending another one // If the person already has an unexpired request of the same type by this player, don't bother sending another
if (getTeleportRequest(request.requesterName, recipient).map(existingRequest -> existingRequest.type) final Optional<TeleportRequest> existingRequest = getTeleportRequest(request.requesterName, recipient);
.orElse(null) == request.type) { if (existingRequest.isPresent()) {
if (existingRequest.get().type == request.type && !existingRequest.get().hasExpired()) {
return Optional.of(request); return Optional.of(request);
} }
}
// Add the request and display a message to the recipient // Add the request and display a message to the recipient
addTeleportRequest(request, recipient); addTeleportRequest(request, recipient);