我需要这个将播放器传送到另一台服务器,所以我该怎么做?我可以通过两种方式实现蹦极,但我宁愿不这样做,我的另一个选择就是对玩家进行sudo,这样我该怎么做?
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Multiplayer")) {
e.setCancelled(true);
e.getWhoClicked().closeInventory();
//Here I need it to make the player run the command /server multiplayer
答案 0 :(得分:1)
您可以使用player.performCommand(String command);
示例:
Player player;
player.performCommand("server multiplayer"); //No slash
答案 1 :(得分:0)
您可以使用player.chat()
:
Player player = Bukkit.getPlayer("username");
//Or player = bukkit.getServer().getPlayer("username");
//Or player = (Player) sender;
player.chat("/server multiplayer"); //With slash
答案 2 :(得分:0)
使用时解决:
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Multiplayer")) {
e.setCancelled(true);
e.getWhoClicked().closeInventory();
Player targetPlayer = Bukkit.getPlayer(e.getWhoClicked().getName());
targetPlayer.performCommand("server multiplayer");