Player player = Player.Find(name); if (player != null && player.IsOnline) { // Player is online, do something here }
Player player = Player.Find(name); if (player != null && player.IsOnline) { player.Teleport(x, y, z); }
Player player = Player.Find(name); if (player != null && player.IsOnline) { player.SendMessage("Hello, player!"); }This code sends a message to a player using the `SendMessage` method. In all three examples, the Player class is utilized from the MCForge package library.