Solved MOTD help!

Discussion in 'Plugin Development' started by zakkinu2, Sep 22, 2013.

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

    zakkinu2

    Ok So i have this code:
    Code:
            if (command.equalsIgnoreCase("setmotd")){
                if (sender instanceof Player|| sender instanceof ConsoleCommandSender){
                    if (args.length == 0){
                        sender.sendMessage(ChatColor.RED+"/setmotd [motd]");
                    }else{
                        String cast = "";
                        for (String s : args){
                            cast = cast+s;
                        }
                        FileConfiguration con = this.getConfig();
                        con.set("motd", cast);
                        con.getString("motd").replaceAll("#", "\u00A7");
                        this.saveConfig();
                        sender.sendMessage(ChatColor.DARK_GREEN+"Motd: "+ChatColor.WHITE+cast.replaceAll("#", "ยง"));
                    }
                }
            }
    and i have this one to:
    Code:
        @EventHandler
        public void onMotd(ServerListPingEvent e){
            e.setMotd(this.getConfig().getString("motd").replaceAll("#", "\u00A7"));
        }
    Everything works great but the only problem i have is whenever i do "/setmotd Hello world" or something with a space the space wont show they will become 1 word! How do i fix it?
     
  2. Offline

    chasechocolate

    Change it to: cast += (s + " ").
     
  3. Offline

    zakkinu2

Thread Status:
Not open for further replies.

Share This Page