plugin command /<command> <player> <message>

Discussion in 'Plugin Development' started by TizFaver, Aug 3, 2021.

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

    TizFaver

    I just finished making a very simple plugin (just to start studying Java) with the command / ereport [player] [message], only the problem is that I can't make sure that in the third space (message) where the player should enter a message, instead of suggesting a player in the game, suggest . Explain better ... you know the command /tell? it's kind of the same thing. I would like it to come out like /tell and not /tell ...

    Here is what i have done:
    Code:
    package mc.trnetwork.cf.easyreport.commandsER;
    
    import mc.trnetwork.cf.easyreport.Main;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class ReportCmd implements CommandExecutor {
        private final Main main;
    
        public ReportCmd(Main main){
            this.main = main;
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (args.length == 0){
            if (sender instanceof Player){
            Player player = (Player) sender; //take the name of the player that call command
            }else{
                main.getLogger().info("You cannot report players from console!");
                return true;
            }
            } else{
                if (Bukkit.getPlayerExact(args[0]) != null){
                    Player MessToPlayerReported = (Player) Bukkit.getPlayerExact(args[0]);
                    MessToPlayerReported.sendMessage(ChatColor.RED + "HEY! you got reported, please stop or...");
                    if (sender instanceof Player){
                        Player PlayerWhoReported = (Player) sender;
                        PlayerWhoReported.sendMessage(ChatColor.GREEN + "You have reported \"" + args[0] + "\"!");
                    } else {
                        Bukkit.getLogger().info(ChatColor.RED + "Player \"" + args[0] + "\" was reported!");
                    }
                } else {
                    if (sender instanceof Player){
                        Player PlayerWhoReported2 = (Player) sender;
                        PlayerWhoReported2.sendMessage(ChatColor.RED + "Player \"" + args[0] + "\" was not found!");
                    } else {
                        Bukkit.getLogger().info("Player \"" + args[0] + "\" was not found!");
                    }
                }
            }
            return true;
        }
    }
    Honestly, I don't even know where I should change to do this
     
  2. Offline

    Kars

  3. Offline

    TizFaver

    mmm i checked some tutorials about tab completer, but is not i want, i like the tab completer for the player, but after have writed the player, i want that the user writes the message without the player's completer, using comand /tell, after writing the player, the bar pop up "<message>", and i want to do the same. but still interesting what you send to me about tab completer.
     
  4. Offline

    Kars

    @TizFaver you can use tabcompleter and set completions to null to stop completions from showing up.
     
Thread Status:
Not open for further replies.

Share This Page