How to add Player names to the Config file

Discussion in 'Plugin Development' started by finalblade1234, Jan 20, 2013.

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

    finalblade1234

    how do i add player names to a config file/or does a
    ArrayList<String> last through the disable?
     
  2. Offline

    gomeow

    Using a normal config set method
     
  3. Offline

    TopGear93

    it completly depends on what config system you will be using. If your going to use the built in config then ill help you with the whole system. If you are using something else then I wont be able to help.
    Code:
    public List<String> playername = new Arraylist<String>();
    
     
  4. Offline

    gomeow

    What else would they use?
     
  5. Offline

    TopGear93

    Code:
    public void onEnable(){
    playername = plugin.getConfig().getStringList("playername");
    }
    public void onDisable(){
        getConfig().set("playername", playername);
      saveConfig();
    
    Code:
    public class config
    {
      public pname plugin;
     
      public config(pname plugin)
      {
        this.plugin = plugin;
      }
      public void setupConfig() {
        File config = new File(this.plugin.getDataFolder(), "config.yml");
        if (!config.exists()) {
          plugin.getConfig().options().header("pname");
          plugin.getConfig().addDefault("playername", pname.playername);
    plugin.getConfig().options().copyDefaults(true);
          plugin.saveConfig();
        }
      }
    }
    
     
  6. Offline

    gomeow

    That is basically the same way, just in a different class
     
    TopGear93 likes this.
  7. Offline

    TopGear93

    ah ok. not sure what you meant by "normal config set method". With the amount of time ive been on bukkit ive seen quite a few different config setups.
     
  8. Offline

    gomeow

    The easiest way of course is to just put saveDefaultConfig() in your onEnable and put a default one in your jar
     
Thread Status:
Not open for further replies.

Share This Page