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

@@ -186,7 +186,8 @@ public class TeleportManager {
public CompletableFuture<Optional<TeleportResult>> teleportPlayerToPlayerByName(@NotNull String playerName,
@NotNull String targetPlayer,
@NotNull OnlineUser requester) {
final Optional<Position> localPositionTarget = plugin.findPlayer(targetPlayer).map(OnlineUser::getPosition);
final Optional<OnlineUser> localPlayer = plugin.findPlayer(playerName);
final Optional<Position> localPositionTarget = localPlayer.map(OnlineUser::getPosition);
if (localPositionTarget.isPresent()) {
return teleportPlayerByName(playerName, localPositionTarget.get(), requester);
}