From a049e5af9458f67647aad378f77013446ac50ead Mon Sep 17 00:00:00 2001 From: William278 Date: Fri, 14 Feb 2025 13:01:16 +0000 Subject: [PATCH] fix: return `Username`s as valid `Teleportable`s, close #773 also correctly handle `TELEPORTER_INVALID` TeleportationExceptions with an error message --- .../java/net/william278/huskhomes/command/TpHereCommand.java | 3 ++- .../william278/huskhomes/teleport/TeleportationException.java | 3 +++ .../main/java/net/william278/huskhomes/teleport/Username.java | 2 +- common/src/main/resources/locales/bg-bg.yml | 1 + common/src/main/resources/locales/de-de.yml | 1 + common/src/main/resources/locales/en-gb.yml | 1 + common/src/main/resources/locales/es-es.yml | 1 + common/src/main/resources/locales/fr-fr.yml | 1 + common/src/main/resources/locales/it-it.yml | 1 + common/src/main/resources/locales/ja-jp.yml | 1 + common/src/main/resources/locales/ko-kr.yml | 1 + common/src/main/resources/locales/pl-pl.yml | 1 + common/src/main/resources/locales/pt-br.yml | 1 + common/src/main/resources/locales/ru-ru.yml | 1 + common/src/main/resources/locales/tr-tr.yml | 1 + common/src/main/resources/locales/uk-ua.yml | 1 + common/src/main/resources/locales/vi-vn.yml | 1 + common/src/main/resources/locales/zh-cn.yml | 1 + common/src/main/resources/locales/zh-tw.yml | 1 + 19 files changed, 22 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/net/william278/huskhomes/command/TpHereCommand.java b/common/src/main/java/net/william278/huskhomes/command/TpHereCommand.java index 6e5bf331..d7886bd5 100644 --- a/common/src/main/java/net/william278/huskhomes/command/TpHereCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/TpHereCommand.java @@ -55,7 +55,8 @@ public void execute(@NotNull OnlineUser executor, @NotNull String[] args) { .target(executor.getPosition()) .buildAndComplete(false, target); - plugin.getLocales().getLocale("teleporting_other_complete", target, executor.getName()); + plugin.getLocales().getLocale("teleporting_other_complete", target, executor.getName()) + .ifPresent(executor::sendMessage); } } diff --git a/common/src/main/java/net/william278/huskhomes/teleport/TeleportationException.java b/common/src/main/java/net/william278/huskhomes/teleport/TeleportationException.java index 1ff5116d..a42e3480 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/TeleportationException.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/TeleportationException.java @@ -45,6 +45,9 @@ public void displayMessage(@Nullable CommandUser user, @NotNull String... args) case TELEPORTER_NOT_FOUND -> plugin.getLocales() .getLocale("error_player_not_found", args) .ifPresent(user::sendMessage); + case TELEPORTER_INVALID -> plugin.getLocales() + .getLocale("error_player_not_teleportable", args) + .ifPresent(user::sendMessage); case TARGET_NOT_FOUND -> plugin.getLocales() .getLocale("error_target_not_found") .ifPresent(user::sendMessage); diff --git a/common/src/main/java/net/william278/huskhomes/teleport/Username.java b/common/src/main/java/net/william278/huskhomes/teleport/Username.java index 7abfca25..68a8cefb 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/Username.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/Username.java @@ -72,6 +72,6 @@ public String getName() { */ @Override public boolean isValid() { - return false; + return true; } } diff --git a/common/src/main/resources/locales/bg-bg.yml b/common/src/main/resources/locales/bg-bg.yml index f103a3df..5fcb4ac1 100644 --- a/common/src/main/resources/locales/bg-bg.yml +++ b/common/src/main/resources/locales/bg-bg.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Error:](#ff3300) [You cannot send a teleport request to yourself.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Грешка:](#ff3300) [Не можахме да открием играча %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Error:](#ff3300) [You cannot randomly teleport in this world.](#ff7e5e)' error_on_cooldown: '[Error:](#ff3300) [You must wait %1% before doing that again.](#ff7e5e)' error_console_command_only: '[Error:](#ff3300) [That command can only be run from the server console.](#ff7e5e)' diff --git a/common/src/main/resources/locales/de-de.yml b/common/src/main/resources/locales/de-de.yml index 0d34126a..2baade86 100644 --- a/common/src/main/resources/locales/de-de.yml +++ b/common/src/main/resources/locales/de-de.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Fehler:](#ff3300) [Du kannst dir selbst keine Teleportanfrage stellen.](#ff7e5e)' error_target_not_found: '[Fehler:](#ff3300) [Der Zielspieler konnte nicht gefunden werden.](#ff7e5e)' error_player_not_found: '[Fehler:](#ff3300) [Der Spieler %1% konnte nicht gefunden werden.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Fehler:](#ff3300) [Du kannst dich in dieser Welt nicht zufällig teleportieren.](#ff7e5e)' error_on_cooldown: '[Fehler:](#ff3300) [Du musst %1% warten, bevor du dies wieder tun kannst.](#ff7e5e)' error_console_command_only: '[Fehler:](#ff3300) [Dieser Befehl kann nur von der Serverkonsole aus ausgeführt werden.](#ff7e5e)' diff --git a/common/src/main/resources/locales/en-gb.yml b/common/src/main/resources/locales/en-gb.yml index 264c1e70..1f47c8e3 100644 --- a/common/src/main/resources/locales/en-gb.yml +++ b/common/src/main/resources/locales/en-gb.yml @@ -157,6 +157,7 @@ locales: error_teleport_request_self: '[Error:](#ff3300) [You cannot send a teleport request to yourself.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Error:](#ff3300) [Could not find the player %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Error:](#ff3300) [You cannot randomly teleport in this world.](#ff7e5e)' error_on_cooldown: '[Error:](#ff3300) [You must wait %1% before doing that again.](#ff7e5e)' error_console_command_only: '[Error:](#ff3300) [That command can only be run from the server console.](#ff7e5e)' diff --git a/common/src/main/resources/locales/es-es.yml b/common/src/main/resources/locales/es-es.yml index dbdd8e85..587f9ea9 100644 --- a/common/src/main/resources/locales/es-es.yml +++ b/common/src/main/resources/locales/es-es.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Error:](#ff3300) [No puedes enviar una solicitud de teletransporte a ti mismo.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Error:](#ff3300) [No se ha podido encontrar el jugador %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Error:](#ff3300) [No puedes teletransportarte al azar en este mundo.](#ff7e5e)' error_on_cooldown: '[Error:](#ff3300) [You must wait %1% before doing that again.](#ff7e5e)' error_console_command_only: '[Error:](#ff3300) [Ese comando sólo se puede ejecutar desde la consola del servidor.](#ff7e5e)' diff --git a/common/src/main/resources/locales/fr-fr.yml b/common/src/main/resources/locales/fr-fr.yml index ad72588c..fd10df70 100644 --- a/common/src/main/resources/locales/fr-fr.yml +++ b/common/src/main/resources/locales/fr-fr.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Erreur :](#ff3300) [Vous ne pouvez pas vous téléporter sur vous-même.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Le joueur ciblé est introuvable.](#ff7e5e)' error_player_not_found: '[Erreur :](#ff3300) [Le joueur %1% est introuvable.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Erreur :](#ff3300) [Vous ne pouvez pas vous téléporter aléatoirement dans ce monde.](#ff7e5e)' error_on_cooldown: '[Erreur :](#ff3300) [Vous devez attendre %1% avant de refaire ça.](#ff7e5e)' error_console_command_only: '[Erreur :](#ff3300) [Cette commande ne peut être executée que depuis la console.](#ff7e5e)' diff --git a/common/src/main/resources/locales/it-it.yml b/common/src/main/resources/locales/it-it.yml index 0ef7de3c..3bd3b366 100644 --- a/common/src/main/resources/locales/it-it.yml +++ b/common/src/main/resources/locales/it-it.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Errore:](#ff3300) [Non puoi teletrasportarti da te stesso!](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Errore:](#ff3300) [Non trovo il giocatore: %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Errore:](#ff3300) [Non puoi teletrasportarti randomicamente in questo mondo.](#ff7e5e)' error_on_cooldown: '[Error:](#ff3300) [You must wait %1% before doing that again.](#ff7e5e)' error_console_command_only: '[Errore:](#ff3300) [Quel comando può essere eseguito solo da console.](#ff7e5e)' diff --git a/common/src/main/resources/locales/ja-jp.yml b/common/src/main/resources/locales/ja-jp.yml index 053165f6..dd56f3ad 100644 --- a/common/src/main/resources/locales/ja-jp.yml +++ b/common/src/main/resources/locales/ja-jp.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[エラー:](#ff3300) [自分自身にテレポートリクエストを送ることはできません。](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[エラー:](#ff3300) [プレイヤー %1% が見つかりませんでした。](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[エラー:](#ff3300) [このワールドでは、ランダムテレポートはできません。](#ff7e5e)' error_on_cooldown: '[Error:](#ff3300) [You must wait %1% before doing that again.](#ff7e5e)' error_console_command_only: '[エラー:](#ff3300) [そのコマンドはサーバーコンソールからしか実行できません。](#ff7e5e)' diff --git a/common/src/main/resources/locales/ko-kr.yml b/common/src/main/resources/locales/ko-kr.yml index e8141609..9ca2d348 100644 --- a/common/src/main/resources/locales/ko-kr.yml +++ b/common/src/main/resources/locales/ko-kr.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[오류:](#ff3300) [자신에게 이동 요청을 보낼 수 없습니다.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[오류:](#ff3300) [%1%님을 찾을 수 없습니다.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[오류:](#ff3300) [이 세계에서는 랜덤 이동할 수 없습니다.](#ff7e5e)' error_on_cooldown: '[오류:](#ff3300) [다시 하기 위해서는 %1%를 기다려야 합니다.](#ff7e5e)' error_console_command_only: '[오류:](#ff3300) [이 명령어는 콘솔에서만 실행할 수 있습니다.](#ff7e5e)' diff --git a/common/src/main/resources/locales/pl-pl.yml b/common/src/main/resources/locales/pl-pl.yml index 650f1297..fb417e67 100644 --- a/common/src/main/resources/locales/pl-pl.yml +++ b/common/src/main/resources/locales/pl-pl.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Błąd:](#ff3300) [Nie możesz wysłać prośby o teleportację do siebie.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Błąd:](#ff3300) [Nie można znaleźć gracza %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Błąd:](#ff3300) [Nie możesz losowo teleportować się w tej krainie.](#ff7e5e)' error_on_cooldown: '[Błąd:](#ff3300) [Musisz poczekać %1% przed kolejnym próbą.](#ff7e5e)' error_console_command_only: '[Błąd:](#ff3300) [Tą komendę można wykonać tylko z konsoli serwera.](#ff7e5e)' diff --git a/common/src/main/resources/locales/pt-br.yml b/common/src/main/resources/locales/pt-br.yml index 1fefde66..fec6ef4d 100644 --- a/common/src/main/resources/locales/pt-br.yml +++ b/common/src/main/resources/locales/pt-br.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Erro:](#ff3300) [Você não pode enviar um pedido de teleporte para si mesmo.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Erro:](#ff3300) [Não foi possível encontrar o jogador %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Erro:](#ff3300) [Você não pode se teleportar aleatoriamente neste mundo.](#ff7e5e)' error_on_cooldown: '[Erro:](#ff3300) [Você deve esperar %1% antes de fazer isso novamente.](#ff7e5e)' error_console_command_only: '[Erro:](#ff3300) [Esse comando só pode ser executado pelo console do servidor.](#ff7e5e)' diff --git a/common/src/main/resources/locales/ru-ru.yml b/common/src/main/resources/locales/ru-ru.yml index 9b5137b5..b4a0a598 100644 --- a/common/src/main/resources/locales/ru-ru.yml +++ b/common/src/main/resources/locales/ru-ru.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Ошибка:](#ff3300) [Вы не можете отправить запрос на телепортацию самому себе.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Ошибка:](#ff3300) [Не удалось найти игрока %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Ошибка:](#ff3300) [Вы не можете случайно телепортироваться в этот мир.](#ff7e5e)' error_on_cooldown: '[Ошибка:](#ff3300) [Подождите %1% перед повторным выполнением данного действия.](#ff7e5e)' error_console_command_only: '[Ошибка:](#ff3300) [Эту команду можно выполнить только из консоли сервера.](#ff7e5e)' diff --git a/common/src/main/resources/locales/tr-tr.yml b/common/src/main/resources/locales/tr-tr.yml index 0e0a028c..5528eeb9 100644 --- a/common/src/main/resources/locales/tr-tr.yml +++ b/common/src/main/resources/locales/tr-tr.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Hata:](#ff3300) [Kendinize ışınlanma isteği gönderemezsiniz.](#ff7e5e)' error_target_not_found: '[Hata:](#ff3300) [Hedef oyuncu bulunamadı.](#ff7e5e)' error_player_not_found: '[Hata:](#ff3300) [%1% adlı oyuncu bulunamadı.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Hata:](#ff3300) [Bu dünyada rastgele ışınlanamazsınız.](#ff7e5e)' error_on_cooldown: '[Hata:](#ff3300) [Tekrar yapmadan önce %1% beklemelisiniz.](#ff7e5e)' error_console_command_only: '[Hata:](#ff3300) [Bu komut yalnızca sunucu konsolundan çalıştırılabilir.](#ff7e5e)' diff --git a/common/src/main/resources/locales/uk-ua.yml b/common/src/main/resources/locales/uk-ua.yml index 0157b78d..4d8090ca 100644 --- a/common/src/main/resources/locales/uk-ua.yml +++ b/common/src/main/resources/locales/uk-ua.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Error:](#ff3300) [You cannot send a teleport request to yourself.](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [Could not find the target player.](#ff7e5e)' error_player_not_found: '[Помилка:](#ff3300) [Не вдалося знайти гравця %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Error:](#ff3300) [You cannot randomly teleport in this world.](#ff7e5e)' error_on_cooldown: '[Error:](#ff3300) [You must wait %1% before doing that again.](#ff7e5e)' error_console_command_only: '[Error:](#ff3300) [That command can only be run from the server console.](#ff7e5e)' diff --git a/common/src/main/resources/locales/vi-vn.yml b/common/src/main/resources/locales/vi-vn.yml index c0df5d74..e58a96dc 100644 --- a/common/src/main/resources/locales/vi-vn.yml +++ b/common/src/main/resources/locales/vi-vn.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[Lỗi:](#ff3300) [Bạn không thể gửi yêu cầu dịch chuyển cho bản thân, bạn có nhầm không?](#ff7e5e)' error_target_not_found: '[Lỗi:](#ff3300) [Không thể tìm thấy người chơi được chỉ định.](#ff7e5e)' error_player_not_found: '[Lỗi:](#ff3300) [Không thể tìm thấy người chơi %1%.](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[Lỗi:](#ff3300) [Bạn không thể dịch chuyển ngẫu nhiên trong thế giới này.](#ff7e5e)' error_on_cooldown: '[Lỗi:](#ff3300) [Bạn phải đợi %1% trước khi làm lại điều đó.](#ff7e5e)' error_console_command_only: '[Lỗi:](#ff3300) [Lệnh đó chỉ có thể được dùng từ bảng điều khiển máy chủ.](#ff7e5e)' diff --git a/common/src/main/resources/locales/zh-cn.yml b/common/src/main/resources/locales/zh-cn.yml index 2d496c03..d3ee7720 100644 --- a/common/src/main/resources/locales/zh-cn.yml +++ b/common/src/main/resources/locales/zh-cn.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[错误:](#ff3300) [不能向自己发送传送请求](#ff7e5e)' error_target_not_found: '[Error:](#ff3300) [没有找到目标玩家.](#ff7e5e)' error_player_not_found: '[错误:](#ff3300) [没有找到玩家 %1%](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[错误:](#ff3300) [你不能在这个世界随机传送](#ff7e5e)' error_on_cooldown: '[错误:](#ff3300) [你需要等待 %1% 才能再次进行此操作](#ff7e5e)' error_console_command_only: '[错误:](#ff3300) [该命令只能从服务器控制台运行](#ff7e5e)' diff --git a/common/src/main/resources/locales/zh-tw.yml b/common/src/main/resources/locales/zh-tw.yml index 1c60f1c8..f51cf85e 100644 --- a/common/src/main/resources/locales/zh-tw.yml +++ b/common/src/main/resources/locales/zh-tw.yml @@ -158,6 +158,7 @@ locales: error_teleport_request_self: '[錯誤:](#ff3300)[您不能向自己發送傳送請求。](#ff7e5e)' error_target_not_found: '[錯誤:](#ff3300)[找不到目標玩家!](#ff7e5e)' error_player_not_found: '[錯誤:](#ff3300)[沒有找到玩家 %1%。](#ff7e5e)' + error_player_not_teleportable: '[Error:](#ff3300) [The target player, %1%, cannot be teleported right now.](#ff7e5e)' error_rtp_restricted_world: '[錯誤:](#ff3300)[您不能在這個世界隨機傳送。](#ff7e5e)' error_on_cooldown: '[錯誤:](#ff3300)[您必須等待 %1% 後才能再次執行此操作。](#ff7e5e)' error_console_command_only: '[錯誤:](#ff3300)[該指令只能從伺服器控制台執行。](#ff7e5e)'