mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Allow new teleport requests from senders if the last one has expired
This commit is contained in:
1 parent
bc309be15a
commit
c13ff1dfee
2 files changed
+27
-24
No files matched your search
@@ -43,8 +43,8 @@ public class TeleportRequestHandler {
|
||||
if (!VanishChecker.isVanished(targetPlayer)) {
|
||||
MessageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
||||
if (!HuskHomes.isIgnoringTeleportRequests(targetPlayer.getUniqueId())) {
|
||||
if (teleportRequests.containsKey(targetPlayer)) {
|
||||
teleportRequests.put(targetPlayer, new HashMap<>());
|
||||
if (isDuplicateRequest(targetPlayerName, targetPlayer)) {
|
||||
return;
|
||||
}
|
||||
teleportRequests.get(targetPlayer).put(requester.getName(), new TeleportRequest(requester.getName(),
|
||||
TeleportRequest.RequestType.TPA));
|
||||
@@ -73,8 +73,8 @@ public class TeleportRequestHandler {
|
||||
if (targetPlayer.getUniqueId() != requester.getUniqueId()) {
|
||||
MessageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
||||
if (!HuskHomes.isIgnoringTeleportRequests(targetPlayer.getUniqueId())) {
|
||||
if (teleportRequests.containsKey(targetPlayer)) {
|
||||
teleportRequests.put(targetPlayer, new HashMap<>());
|
||||
if (isDuplicateRequest(targetPlayerName, targetPlayer)) {
|
||||
return;
|
||||
}
|
||||
teleportRequests.get(targetPlayer).put(requester.getName(), new TeleportRequest(requester.getName(),
|
||||
TeleportRequest.RequestType.TPA_HERE));
|
||||
@@ -203,4 +203,24 @@ public class TeleportRequestHandler {
|
||||
}
|
||||
handleRequestReply(p, targetRequest, accepted);
|
||||
}
|
||||
|
||||
// Handle an incoming request; if it's a duplicate, return true, otherwise allow the new request (return false)
|
||||
public static boolean isDuplicateRequest(String senderName, Player recipient) {
|
||||
if (teleportRequests.containsKey(recipient)) {
|
||||
if (teleportRequests.get(recipient).containsKey(senderName)) {
|
||||
TeleportRequest request = teleportRequests.get(recipient).get(senderName);
|
||||
if (!request.isExpired()) {
|
||||
return true;
|
||||
} else {
|
||||
teleportRequests.get(recipient).remove(senderName);
|
||||
if (teleportRequests.get(recipient).isEmpty()) {
|
||||
teleportRequests.remove(recipient);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
teleportRequests.put(recipient, new HashMap<>());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user