diff --git a/common/src/main/java/net/william278/huskhomes/command/TpCommand.java b/common/src/main/java/net/william278/huskhomes/command/TpCommand.java index a14336b5..aa618a81 100644 --- a/common/src/main/java/net/william278/huskhomes/command/TpCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/TpCommand.java @@ -72,7 +72,15 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe plugin.getTeleportManager() .teleportPlayerToPlayerByName(playerToTeleportName, targetPosition.targetPlayer, onlineUser) .thenAccept(resultIfPlayerExists -> resultIfPlayerExists.ifPresentOrElse( - result -> plugin.getTeleportManager().finishTeleport(onlineUser, result), + result -> { + if (result.successful) { + plugin.getLocales().getLocale("teleporting_other_complete", + playerToTeleportName, targetPosition.targetPlayer) + .ifPresent(onlineUser::sendMessage); + return; + } + plugin.getTeleportManager().finishTeleport(onlineUser, result); + }, () -> plugin.getLocales().getLocale("error_player_not_found", playerToTeleportName) .ifPresent(onlineUser::sendMessage))); return; @@ -81,7 +89,18 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe assert targetPosition.targetPosition != null; plugin.getTeleportManager().teleportPlayerByName(playerToTeleportName, targetPosition.targetPosition, onlineUser) .thenAccept(resultIfPlayerExists -> resultIfPlayerExists.ifPresentOrElse( - result -> plugin.getTeleportManager().finishTeleport(onlineUser, result), + result -> { + if (result.successful && !playerToTeleportName.equalsIgnoreCase(onlineUser.username)) { + plugin.getLocales().getLocale("teleporting_other_complete_position", + playerToTeleportName, + Integer.toString((int) targetPosition.targetPosition.x), + Integer.toString((int) targetPosition.targetPosition.y), + Integer.toString((int) targetPosition.targetPosition.z)) + .ifPresent(onlineUser::sendMessage); + return; + } + plugin.getTeleportManager().finishTeleport(onlineUser, result); + }, () -> plugin.getLocales().getLocale("error_player_not_found", playerToTeleportName) .ifPresent(onlineUser::sendMessage))); return; @@ -153,7 +172,7 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe return completions; } completions.addAll(List.of("~", Integer.toString((int) user.getPosition().z))); - } else if (isCoordinate(args[1])){ + } else if (isCoordinate(args[1])) { if (user == null) { return completions; } 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 245d3ba8..f2314e6a 100644 --- a/common/src/main/java/net/william278/huskhomes/command/TpHereCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/TpHereCommand.java @@ -23,7 +23,20 @@ public class TpHereCommand extends CommandBase implements TabCompletable { .ifPresent(onlineUser::sendMessage); return; } - plugin.getTeleportManager().teleportPlayerByName(args[0], onlineUser.getPosition(), onlineUser); + final String targetPlayerName = args[0]; + plugin.getTeleportManager().teleportPlayerByName(targetPlayerName, onlineUser.getPosition(), onlineUser) + .thenAccept(resultIfPlayerExists -> resultIfPlayerExists.ifPresentOrElse( + result -> { + if (result.successful) { + plugin.getLocales().getLocale("teleporting_other_complete", + targetPlayerName, onlineUser.username) + .ifPresent(onlineUser::sendMessage); + return; + } + plugin.getTeleportManager().finishTeleport(onlineUser, result); + }, + () -> plugin.getLocales().getLocale("error_player_not_found", targetPlayerName) + .ifPresent(onlineUser::sendMessage))); } @Override diff --git a/common/src/main/resources/locales/en-gb.yml b/common/src/main/resources/locales/en-gb.yml index 6773040a..018015e6 100644 --- a/common/src/main/resources/locales/en-gb.yml +++ b/common/src/main/resources/locales/en-gb.yml @@ -1,4 +1,3 @@ -teleporting_last_position: '[Returning to your last position in](#00fb9a) [%1%](#00fb9a bold) [seconds](#00fb9a)' teleporting_offline_player: '[Teleporting you to where %1% last logged out…](#00fb9a)' teleporting_warmup_start: '[You will be teleported in](#00fb9a) [%1%](#00fb9a bold) [seconds, please stand still…](#00fb9a)' teleporting_cancelled_movement: '[Teleportation cancelled; you moved!](#ff7e5e)' @@ -7,6 +6,8 @@ teleporting_complete: '[Teleportation complete!](#00fb9a)' teleporting_action_bar_warmup: '[Teleporting in](#00fb9a) [%1%](#00fb9a bold)[…](#00fb9a)' teleporting_action_bar_processing: '[Teleporting…](#00fb9a)' teleporting_action_bar_cancelled: '[Teleportation cancelled!](#ff7e5e)' +teleporting_other_complete: '[Teleported %1% to %2%.](#00fb9a)' +teleporting_other_complete_position: '[Teleported %1% to ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)' edit_home_menu_title: '[Viewing details for your home,](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' edit_home_menu_title_other: '[Viewing details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)'