Minecraft_652
public class SimpleCommand implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender commandSender,@NotNull Command command,@NotNull String label, String[] args) {
}
怎么从这个commandSender里头拿到Player对象
具体想达到的效果为,拿到Player对象后,以获取的Player发送一条指定命令
换句话说,我是Player123,我现在使用了/simplecommand然后通过这个间接让我使用了/give Player123 diamond_sword
实际效果就是给了我一把钻石剑,可以不考虑权限问题


结冰的离季
if(commandSender instanceof Player){
Player player = (Player)ommandSender;
}

hd2098101
万分感谢万分感谢万分感谢

o2072108706
自己看api去,有 PlayerCommandSendEvent这个事件可以用

o2072108706
本帖最后由 o2072108706 于 2021-9-27 22:59 编辑
  1. @EventHandler
  2.     public void onCommandSend(PlayerCommandSendEvent event) {
  3.         String playerName = event.getPlayer().getName();
  4.         Bukkit.getServer().getLogger().info("/give" + playerName +"diamond_sword");
  5.     }
复制代码
或许可以说试试

第一页 上一页 下一页 最后一页