How do I set up a config?

Discussion in 'Plugin Development' started by DragsZombies, Mar 30, 2013.

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

    DragsZombies

    I want to be able to change The amount of damage the player takes, and the time it takes for the player to take damage within the config.yml file.

    Code:
    public class ToxicityPlugin extends JavaPlugin implements Listener{
     
        Long tickdelay = (long) 5;
     
        public void onEnable(){
     
            this.getConfig();
     
            this.saveConfig();
     
            this.getConfig().set("delay-between-damage-in-seconds", 20);
     
            tickdelay = this.getConfig().getLong("delay-between-damage-in-seconds")*20;
     
            this.reloadConfig();
     
            this.saveDefaultConfig();
     
            this.getPluginLoader().createRegisteredListeners(this, this);
     
            getServer().getPluginManager().registerEvents(this, this);
        }
        public void onDisable(){
     
        }
    This is where it gets the config but there's nothing in the config, so it doesn't really do anything(from my understanding).
     
  2. Offline

    504Dug

    Firstly, read about plugin.yml creation.
    More importantly, you don't want to store information such as item damage in plugin.yml. Instead, create a second file from which you can read values (see a tutorial on reading .yml files).
     
  3. Offline

    DragsZombies

    Alright, Thanks for the help! :)
     
Thread Status:
Not open for further replies.

Share This Page