Prevent sending teleport requests to self, send message on /tpall

This commit is contained in:
William committed 2022-08-24 22:24:35 +01:00
1 parent 312bff2efc
commit 98931c1900
7 files changed
+41 -18

No files matched your search

@@ -22,10 +22,17 @@ public class TpaCommand extends CommandBase implements TabCompletable {
if (args.length == 1) {
plugin.getRequestManager().sendTeleportRequest(onlineUser, args[0], TeleportRequest.RequestType.TPA).thenAccept(sent -> {
if (!sent) {
plugin.getLocales().getLocale("error_player_not_found", args[0]).ifPresent(onlineUser::sendMessage);
if (plugin.findPlayer(args[0]).isPresent()) {
plugin.getLocales().getLocale("error_teleport_request_self")
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales().getLocale("error_player_not_found", args[0])
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales().getLocale("tpa_request_sent", args[0]).ifPresent(onlineUser::sendMessage);
plugin.getLocales().getLocale("tpa_request_sent", args[0])
.ifPresent(onlineUser::sendMessage);
});
} else {
plugin.getLocales().getLocale("error_invalid_syntax", "/tpa <player>")