Solved How to get arguments of command?

Discussion in 'Plugin Development' started by QuietW, Jun 12, 2019.

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


    Hello! (Perhaps in the text many mistakes, because I from Russia, sorry!)
    I wanna make broadcast-plugin, but I don`t know how to get arguments(text to broadcast).
    public boolean onCommand(CommandSender s, Command cmd, String label, String args[]) {
            if(cmd.getName().equalsIgnoreCase("qbcast")) {
                String ar = args.toString();
                Bukkit.broadcastMessage("§a(QuietPlay - Газета) §7" + ar + "§7§o(Пишет: §8§o" + s.getName() + ")");
                return true;
            return false;
    When i type /qbast in chat - the result does not please me upload_2019-6-12_15-48-29.png
    (sorry for russian text)
  2. Offline

    timtower Moderator Moderator

    @QuietW Make a loop, loop over the arguments and add them to the same string.
  3. Offline

    bwfcwalshy Retired Staff

    Or just Java 8 way: String.join(" ", args);
    user_91277742 and Kars like this.
  4. Offline


    Thank you!
Thread Status:
Not open for further replies.

Share This Page