Solved Replace string in config isn't working?

Discussion in 'Spigot Plugin Development' started by iMedia, Feb 16, 2020.

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

    Supporter

    I don't know if I'm just making 1 stupid mistake but this should be working
    Code (Text):

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        Player p = (Player) sender;
        AccountHandler rank = new AccountHandler(p);
        if(rank.getRank().getRank(RankClass.MODERATOR)) {
            if(Main.plugin.getConfig().getString("silence").equals("false")) {
                Main.plugin.getConfig().getString("silence").replace("false","true");
                Main.plugin.saveConfig();
                Main.plugin.reloadConfig();
                p.sendMessage("Config false");
            }else {
                p.sendMessage("Config true");
            }
        }else {
            //NO PERMS MSG
        }
        return true;
    }
     
    I'm trying to replace the string in the config but it isn't changing the string. There aren't any errors in the console
     
    • Funny Funny x 2
  2. Use:
    Code (Text):
    Main.plugin.getConfig().set("silence","true")
    Not:
    Code (Text):
    Main.plugin.getConfig().getString("silence").replace("false","true");
     
  3. iMedia

    Supporter

    Yeah thanks, I just noticed actually looking back at some old code I've made before. I was having a stupid moment.
     
    • Funny Funny x 1
Thread Status:
Not open for further replies.