Config problems yet once more

Discussion in 'Plugin Development' started by Typhoon5, Dec 22, 2011.

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

    Typhoon5

    This was working fine for awhile, then after some changes it stopped working. After i undid the changes it still refuses to work. The problem is it's not properly making the config, it just makes a blank config file.

    If you need my listener please let me know.

    Any help would be greatly appreciated!

    Main:
    Code:
    package me.typhoon5.dailybonus;
    
    import org.bukkit.plugin.java.JavaPlugin;
    import java.util.logging.Logger;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.configuration.file.FileConfiguration;
    import me.typhoon5.dailybonus.commands.CommandExecutor_Bonus;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.Event.Type;
    import me.typhoon5.dailybonus.listeners.Listener_Player;
    
    public class DailyBonus extends JavaPlugin{
     private Logger log;
     private PluginDescriptionFile description;
    
     private String prefix;
     private boolean config_giveonjoin;
     private int config_bonusitemid;
     private int config_bonuscooldown;
     private Listener_Player listenerPlayer;
    
     @Override
     public void onEnable(){
      log = Logger.getLogger("Minecraft");
      description = getDescription();
      prefix = "["+description.getName()+"] ";
    
      log("loading "+description.getFullName());
    
      setupConfiguration();
      listenerPlayer = new Listener_Player(this);
    
      getServer().getPluginManager().registerEvent(Type.PLAYER_JOIN, listenerPlayer, Priority.Normal, this);
    
      getCommand("bonus").setExecutor(new CommandExecutor_Bonus(this));
    
     }
    
     @Override
     public void onDisable(){
      log("disabled "+description.getFullName());
    
     }
     public void log(String message){
      log.info(prefix+message);
     }
    
     private void setupConfiguration(){
      FileConfiguration cfg = getConfig();
    
      config_giveonjoin = cfg.getBoolean("GiveOnJoin", true);
      config_bonusitemid = cfg.getInt("BonusItemID", 1);
      config_bonuscooldown = cfg.getInt("BonusCooldown", 1440);
    
      saveConfig();
     }
    
     public boolean getConfig_giveonjoin(){
      return config_giveonjoin;
     }
    
     public int getConfig_bonusitemid(){
      return config_bonusitemid;
     }
    
     public int getConfig_bonuscooldown(){
      return config_bonuscooldown;
     }
    
    }
    
     
  2. Offline

    bergerkiller

    @Typhoon5 To create the configuration, you need to set it afterwards:
    Code:
      config_giveonjoin = cfg.getBoolean("GiveOnJoin", true);
      cfg.set("GiveOnJoin", config_giveonjoin);
    But if you have a lot of nodes, I recommend you make some sort of routine which does this automatically. (like config.parse, which gets the value and sets it in the configuration afterwards)
     
    Typhoon5 likes this.
  3. Offline

    Typhoon5

    Thanks let me try it out

    Thanks fixed

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
Thread Status:
Not open for further replies.

Share This Page