About arguments in a command

Discussion in 'Plugin Development' started by Praxounet, Dec 30, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    Praxounet

    So basically I'm making a party plugin, and I have this issue in the chat when I invite somebody (I'm inviting myself because I'm testing it on local), like instead of just placing the name of the player it makes a "CraftPlayer{name=Praxounet}" :

    woow.PNG

    the command I run is : /party invite Praxounet
    (but it works with any player names)

    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] args) {
          
            Player player = (Player)sender;
          
            Player p = Bukkit.getPlayer(args[1]);
          
            if (cmd.getName().equalsIgnoreCase("party")) {
                if (args.length == 2) {
                    if (args[0].equalsIgnoreCase("invite")) {
                      
                        if (p != null) {
                         player.sendMessage(p.getPlayer() + "a bien été invité !");
                         p.sendMessage(player.getPlayer() + "vous a invité !");
                  
                          
                       
                            return true;
                        }
                    }
                }
            }

    Any ideas how to fix this problem ?
     

    Attached Files:

  2. Online

    timtower Administrator Administrator Moderator

    @Praxounet Player#getName, then you get a normal name.
     
  3. Offline

    Praxounet

    @timtower sorry for not understanding, but where exactly ?
     
  4. Online

    timtower Administrator Administrator Moderator

    On the place where you print the name.
     
  5. Offline

    Praxounet

    thank you so much !
     
Thread Status:
Not open for further replies.

Share This Page