Solved Message in config not working!

Discussion in 'Plugin Development' started by jusjus112, Nov 15, 2014.

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

    jusjus112

    Hey,
    i have a null pointer in my config with this line in my code:
    Code:java
    1. Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("enableMessage")
    2. .replace("{player}", sender.getName())));

    But i dont now how you add color codes and a playername together.
    I hope you guys can help me
    This is my config line:
    Code:
    enableMessage: '&8[&1!&8] &6Chat enabled by {player}! You can talk now' 
     
  2. Offline

    mrCookieSlime

    jusjus112
    The NPE might be refering to getConfig(). Did you setup your Config properly in the onEnable() method?
    Also, are you using this in your main class?
    If not, then you cannot just call getConfig() without an instanceof of your main class.
     
  3. jusjus112 Is this in your main class? Does it extend JavaPlugin?
     
  4. Offline

    JordyPwner

    Bukkit.getServer().broadcastMessage(getConfig().getString("enableMessage").replaceAll("&", "§").replace("{player}", sender.getName());
     
  5. Offline

    jusjus112

    bwfcwalshy JordyPwner mrCookieSlime
    I know that, and yes it is in my main class!
    But EVERYTHING i tried its not working!
    The console only says its null, null and null
    on this line:
    Code:
     Bukkit.getServer().broadcastMessage(config.getString("disableMessage").replaceAll("&", "§"));
    I'ts so annoying, and i dont no what to do.
    I think its that the server dont see whats the config!
    Im getting the config with this:
    Code:
    FileConfiguration config = null;
     
    public void onEnable() {
                config =  getConfig();
                getConfig().options().copyDefaults(true);
                saveDefaultConfig();
                        }
    EDIT: I'ts solved
     
  6. Offline

    leon3001

    Please tell us how you solved it so others with the same problem can find help here! :)
     
  7. Offline

    jusjus112

    I have solved this, with checking my config! I have a error on a line with 3 chars on the string!
    The code was correct, but my message was not correct!
     
Thread Status:
Not open for further replies.

Share This Page