[1.7] String not working / updating.

Discussion in 'Spigot Plugin Development' started by Renamed, Jun 1, 2018.

  1. My string gets a string from the config, then replaces any %setting% with the players setting
    however it does not update everytime the player does the command.. it will only update when the player does /reload
    code:
    Code (Java):
    if (plugin.getConfig().getBoolean("playerData." + p.getUniqueId() + ".enabled") == false) {
                                setting = setting.replaceAll("%setting%", "OFF");
                                p.sendMessage("off, true");
                            }
                            int settingLevel = plugin.getConfig().getInt("playerData." + p.getUniqueId() + ".setting");
                            if(settingLevel == 1) {
                                setting = setting.replaceAll("%setting%", "1");
                                p.sendMessage("1, true");
                            }
                            if(settingLevel == 2) {
                                setting = setting.replaceAll("%setting%", "2");
                                p.sendMessage("2, true");
                            }
                            if(settingLevel == 3) {
                                setting = setting.replaceAll("%setting%", "3");
                                p.sendMessage("3, true");
                            }
     
  2. I think you have to call the code whenever you need it and not only in onEnable method.
     
  3. Yeah, I would say so too
     
  4. never mind, i figured out what to do

    if anyone is reading this in the same situation as me,
    you have to:

    call from the config each time you want to replace it rather than only once in your onenable, otherwise it will be completely overwritten the first time