mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 22:16:34 +00:00
Make ignored/vanish teleport requests display like the user is offline
This commit is contained in:
2 files changed
+14
-3
No files matched your search
@@ -126,7 +126,7 @@ public class TpCommand extends Command implements TabProvider {
|
|||||||
((int) basePosition.getX() + " " + (int) basePosition.getY()),
|
((int) basePosition.getX() + " " + (int) basePosition.getY()),
|
||||||
((int) basePosition.getX() + " " + (int) basePosition.getY() + " " + (int) basePosition.getZ()))
|
((int) basePosition.getX() + " " + (int) basePosition.getY() + " " + (int) basePosition.getZ()))
|
||||||
: List.of());
|
: List.of());
|
||||||
completions.addAll(plugin.getPlayerList());
|
completions.addAll(plugin.getPlayerList(false));
|
||||||
return completions.stream()
|
return completions.stream()
|
||||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||||
.sorted().collect(Collectors.toList());
|
.sorted().collect(Collectors.toList());
|
||||||
@@ -143,7 +143,7 @@ public class TpCommand extends Command implements TabProvider {
|
|||||||
((int) basePosition.getX() + " " + (int) basePosition.getY()),
|
((int) basePosition.getX() + " " + (int) basePosition.getY()),
|
||||||
((int) basePosition.getX() + " " + (int) basePosition.getY() + " " + (int) basePosition.getZ()))
|
((int) basePosition.getX() + " " + (int) basePosition.getY() + " " + (int) basePosition.getZ()))
|
||||||
: List.of());
|
: List.of());
|
||||||
completions.addAll(plugin.getPlayerList());
|
completions.addAll(plugin.getPlayerList(false));
|
||||||
}
|
}
|
||||||
return completions.stream()
|
return completions.stream()
|
||||||
.filter(s -> s.toLowerCase().startsWith(args[1].toLowerCase()))
|
.filter(s -> s.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ public class RequestsManager {
|
|||||||
if (localTarget.get().equals(requester)) {
|
if (localTarget.get().equals(requester)) {
|
||||||
throw new IllegalArgumentException("Cannot send a teleport request to yourself");
|
throw new IllegalArgumentException("Cannot send a teleport request to yourself");
|
||||||
}
|
}
|
||||||
|
if (localTarget.get().isVanished()) {
|
||||||
|
throw new IllegalArgumentException("Cannot send a teleport request to a vanished player");
|
||||||
|
}
|
||||||
plugin.fireEvent(plugin.getSendTeleportRequestEvent(requester, request),
|
plugin.fireEvent(plugin.getSendTeleportRequestEvent(requester, request),
|
||||||
(event -> sendLocalTeleportRequest(request, localTarget.get())));
|
(event -> sendLocalTeleportRequest(request, localTarget.get())));
|
||||||
return;
|
return;
|
||||||
@@ -323,7 +326,15 @@ public class RequestsManager {
|
|||||||
* @param request The {@link TeleportRequest} to handle
|
* @param request The {@link TeleportRequest} to handle
|
||||||
*/
|
*/
|
||||||
public void handleLocalRequestResponse(@NotNull OnlineUser requester, @NotNull TeleportRequest request) {
|
public void handleLocalRequestResponse(@NotNull OnlineUser requester, @NotNull TeleportRequest request) {
|
||||||
boolean accepted = request.getStatus() == TeleportRequest.Status.ACCEPTED;
|
// If the request was ignored, act as if the player was not found
|
||||||
|
if (request.getStatus() == TeleportRequest.Status.IGNORED) {
|
||||||
|
plugin.getLocales().getLocale("error_player_not_found", request.getRecipientName())
|
||||||
|
.ifPresent(requester::sendMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the response confirmation to the requester
|
||||||
|
final boolean accepted = request.getStatus() == TeleportRequest.Status.ACCEPTED;
|
||||||
plugin.getLocales().getLocale("teleport_request_" + (accepted ? "accepted" : "declined"),
|
plugin.getLocales().getLocale("teleport_request_" + (accepted ? "accepted" : "declined"),
|
||||||
request.getRecipientName()).ifPresent(requester::sendMessage);
|
request.getRecipientName()).ifPresent(requester::sendMessage);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user