From 2e04b5328cc8dd3982cb224eb4461c98922ff09b Mon Sep 17 00:00:00 2001 From: William Date: Wed, 31 Aug 2022 12:25:26 +0100 Subject: [PATCH] Fix request spam filter filtering against expired requests --- .../william278/huskhomes/request/RequestManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/net/william278/huskhomes/request/RequestManager.java b/common/src/main/java/net/william278/huskhomes/request/RequestManager.java index 33eaba6e..e30ee805 100644 --- a/common/src/main/java/net/william278/huskhomes/request/RequestManager.java +++ b/common/src/main/java/net/william278/huskhomes/request/RequestManager.java @@ -92,8 +92,6 @@ public class RequestManager { // If the player couldn't be found locally, send the request cross-server if (plugin.getSettings().crossServer) { - - // Find the matching networked target return plugin.getNetworkMessenger().findPlayer(requester, targetUser).thenApply(networkedTarget -> { if (networkedTarget.isEmpty()) { @@ -141,10 +139,12 @@ public class RequestManager { return Optional.empty(); } - // If the person already has a request of the same type by this player, don't bother sending another one - if (getTeleportRequest(request.requesterName, recipient).map(existingRequest -> existingRequest.type) - .orElse(null) == request.type) { - return Optional.of(request); + // If the person already has an unexpired request of the same type by this player, don't bother sending another + final Optional existingRequest = getTeleportRequest(request.requesterName, recipient); + if (existingRequest.isPresent()) { + if (existingRequest.get().type == request.type && !existingRequest.get().hasExpired()) { + return Optional.of(request); + } } // Add the request and display a message to the recipient