Player player = Bukkit.getPlayer("Player1"); String command = "/give " + player.getName() + " diamond_pickaxe"; Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
Player player = Bukkit.getPlayer("Player1"); String command = "/tp " + player.getName() + " 100 64 100"; Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);In this code, we first get a reference to the player object with the username "Player1". We then create the command string to teleport the player to the specified coordinates. Finally, we use dispatchCommand to execute the command in the console. Both examples are using the java org.bukkit library.