Player player = Bukkit.getPlayerExact("bob123"); if (player != null) { player.sendMessage("Hello, " + player.getName() + "!"); }
if (Bukkit.getPlayerExact("alice456") != null) { System.out.println("The player Alice is online!"); }In this example, the getPlayerExact method is used to check if the player with the exact username "alice456" is currently online by checking if the returned value is not null. If the player is found, a message is sent to the console using the println method.