Add special handling for @s operator to support vanilla suggestions

This commit is contained in:
William278 committed 2022-09-06 00:21:10 +03:00
1 parent 50289d9ca5
commit af91b224a0
1 file changed
+2 -2
@@ -41,8 +41,8 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe
plugin.getCache().updatePlayerListCache(plugin, onlineUser).join(); plugin.getCache().updatePlayerListCache(plugin, onlineUser).join();
final String playerToTeleport = plugin.getCache().players.stream() final String playerToTeleport = plugin.getCache().players.stream()
.filter(user -> user.equalsIgnoreCase(targetPlayerToTeleport)).findFirst() .filter(user -> user.equalsIgnoreCase(targetPlayerToTeleport)).findFirst()
.or(() -> plugin.getCache().players.stream() .or(() -> Optional.ofNullable(targetPlayerToTeleport.equals("@s") ? onlineUser.username : null))
.filter(user -> user.toLowerCase().startsWith(targetPlayerToTeleport)).findFirst()) .or(() -> plugin.getCache().players.stream().filter(user -> user.toLowerCase().startsWith(targetPlayerToTeleport)).findFirst())
.orElse(null); .orElse(null);
// Ensure the player to teleport exists // Ensure the player to teleport exists