Solved Change Display Name With /nick <name>

Discussion in 'Spigot Plugin Help' started by Icy_Code, May 29, 2017.

  1. Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if(cmd.getName().equalsIgnoreCase("nick") && sender instanceof Player) {
    if(args.length > 0) {
    String name = args.toString();
    Player player = (Player) sender;

    player.setDisplayName(name);
    return true;
    } else {
    sender.sendMessage(ChatColor.RED + "Invaild Args.");
    }
    }

    return false;
    }

    Returns (Changes Name To):
    [Ljava.lang.String:[email protected]

    How can I change the players name to the argument of /nick
     
  2. String name = args[0]

    ;)
     
    • Like Like x 2