getCustomConfig() when not saved?

Discussion in 'Plugin Development' started by Dreeass, Jun 4, 2012.

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

    Dreeass

    I don't know if I'm doing something wrong, but I'm adding a translations to a plugin I'm making. So I add the following code for the custom config for the translation:
    (this gets executed after the config has saved)
    Code:java
    1. public FileConfiguration MsgConfig = null;
    2. public File MsgConfigFile = null;
    3.  
    4. public FileConfiguration getMsgConfig() {
    5. if(MsgConfig == null) {
    6. reloadMsgConfig();
    7. }
    8. return MsgConfig;
    9. }
    10. public void reloadMsgConfig() {
    11. InputStream defConfigStream = Main.class.getResourceAsStream("/me/Dreeass/Play/Messages/" + getConfig().getString("Language") + "_messages.yml");
    12.  
    13. if(defConfigStream != null) {
    14. YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
    15. MsgConfig.setDefaults(defConfig);
    16. }
    17. }

    Well it's not working and I'd also like to get my translations in the package me.Dreeass.Play.Messages, I tried some stuff but same result. How can I do this?
     
  2. Offline

    Dreeass

    I edited the code a little bit, just can't get it to work.
     
  3. Offline

    wouthacks

    I'm also trying to add translations and I was using some of the same code as you and I can't get it to work either. It would be helpful if someone could guide us through.
     
  4. Are you by any chance extending that class to JavaPlugin ? If you are, that's your problem... use a plugin pointer or static pointer.
     
    Dreeass likes this.
  5. Offline

    Dreeass

    Thanks, got it!
     
  6. Offline

    wouthacks

    thx Digi!
     
Thread Status:
Not open for further replies.

Share This Page