mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Fix inconsistencies with /tpignore, close #238
This commit is contained in:
1 parent
ca70ed4ae9
commit
febb177f6c
4 files changed
+34
-9
No files matched your search
@@ -19,6 +19,12 @@ public class TpaAllCommand extends CommandBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||||
|
if (plugin.getRequestManager().isIgnoringRequests(onlineUser)) {
|
||||||
|
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
|
||||||
|
.ifPresent(onlineUser::sendMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
plugin.getLocales().getLocale("error_invalid_syntax", "/tpaall")
|
plugin.getLocales().getLocale("error_invalid_syntax", "/tpaall")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
|
|||||||
@@ -19,22 +19,30 @@ public class TpaCommand extends CommandBase implements TabCompletable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||||
|
if (plugin.getRequestManager().isIgnoringRequests(onlineUser)) {
|
||||||
|
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
|
||||||
|
.ifPresent(onlineUser::sendMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
plugin.getRequestManager()
|
plugin.getRequestManager()
|
||||||
.sendTeleportRequest(onlineUser, args[0], TeleportRequest.RequestType.TPA)
|
.sendTeleportRequest(onlineUser, args[0], TeleportRequest.RequestType.TPA)
|
||||||
.thenAccept(sent -> {
|
.thenAccept(sent -> {
|
||||||
if (sent.isPresent()) {
|
if (sent.isEmpty()) {
|
||||||
plugin.getLocales().getLocale("tpa_request_sent", sent.get().getRecipientName())
|
if (args[0].equalsIgnoreCase(onlineUser.username)) {
|
||||||
.ifPresent(onlineUser::sendMessage);
|
|
||||||
} else {
|
|
||||||
if (plugin.findPlayer(args[0]).isPresent()) {
|
|
||||||
plugin.getLocales().getLocale("error_teleport_request_self")
|
plugin.getLocales().getLocale("error_teleport_request_self")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLocales().getLocale("error_player_not_found", args[0])
|
plugin.getLocales().getLocale("error_player_not_found", args[0])
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.getLocales().getLocale("tpa_request_sent", sent.get().getRecipientName())
|
||||||
|
.ifPresent(onlineUser::sendMessage);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
plugin.getLocales().getLocale("error_invalid_syntax", "/tpa <player>")
|
plugin.getLocales().getLocale("error_invalid_syntax", "/tpa <player>")
|
||||||
|
|||||||
@@ -19,20 +19,28 @@ public class TpaHereCommand extends CommandBase implements TabCompletable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||||
|
if (plugin.getRequestManager().isIgnoringRequests(onlineUser)) {
|
||||||
|
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
|
||||||
|
.ifPresent(onlineUser::sendMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
plugin.getRequestManager()
|
plugin.getRequestManager()
|
||||||
.sendTeleportRequest(onlineUser, args[0], TeleportRequest.RequestType.TPA_HERE)
|
.sendTeleportRequest(onlineUser, args[0], TeleportRequest.RequestType.TPA_HERE)
|
||||||
.thenAccept(sent -> {
|
.thenAccept(sent -> {
|
||||||
if (sent.isEmpty()) {
|
if (sent.isEmpty()) {
|
||||||
if (plugin.findPlayer(args[0]).isPresent()) {
|
if (args[0].equalsIgnoreCase(onlineUser.username)) {
|
||||||
plugin.getLocales().getLocale("error_teleport_request_self")
|
plugin.getLocales().getLocale("error_teleport_request_self")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLocales().getLocale("error_player_not_found", args[0])
|
plugin.getLocales().getLocale("error_player_not_found", args[0])
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLocales().getLocale("tpahere_request_sent", sent.get().getRecipientName())
|
plugin.getLocales().getLocale("tpahere_request_sent", sent.get().getRecipientName())
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -216,7 +216,8 @@ public class RequestManager {
|
|||||||
boolean accepted) {
|
boolean accepted) {
|
||||||
// Check the recipient is not ignoring teleport requests
|
// Check the recipient is not ignoring teleport requests
|
||||||
if (isIgnoringRequests(recipient)) {
|
if (isIgnoringRequests(recipient)) {
|
||||||
plugin.getLocales().getLocale("error_ignoring_teleport_requests").ifPresent(recipient::sendMessage);
|
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
|
||||||
|
.ifPresent(recipient::sendMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,14 +240,16 @@ public class RequestManager {
|
|||||||
public void respondToTeleportRequest(@NotNull OnlineUser recipient, boolean accepted) {
|
public void respondToTeleportRequest(@NotNull OnlineUser recipient, boolean accepted) {
|
||||||
// Check the recipient is not ignoring teleport requests
|
// Check the recipient is not ignoring teleport requests
|
||||||
if (isIgnoringRequests(recipient)) {
|
if (isIgnoringRequests(recipient)) {
|
||||||
plugin.getLocales().getLocale("error_ignoring_teleport_requests").ifPresent(recipient::sendMessage);
|
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
|
||||||
|
.ifPresent(recipient::sendMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the latest request and handle the response
|
// Get the latest request and handle the response
|
||||||
final Optional<TeleportRequest> lastRequest = getLastTeleportRequest(recipient);
|
final Optional<TeleportRequest> lastRequest = getLastTeleportRequest(recipient);
|
||||||
if (lastRequest.isEmpty()) {
|
if (lastRequest.isEmpty()) {
|
||||||
plugin.getLocales().getLocale("error_no_teleport_requests").ifPresent(recipient::sendMessage);
|
plugin.getLocales().getLocale("error_no_teleport_requests")
|
||||||
|
.ifPresent(recipient::sendMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handleRequestResponse(lastRequest.get(), recipient, accepted);
|
handleRequestResponse(lastRequest.get(), recipient, accepted);
|
||||||
|
|||||||
Reference in new issue
Block a user