Check Config

Discussion in 'Plugin Development' started by KoolzSkillz, Jul 30, 2014.

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

    KoolzSkillz

    Ok so I want to know if it is possible to make it so, we'll here is an example

    [
    #My plugins config

    # Answer true or false
    NewsCommand: true
    ]

    If it's true it sends em a msg if it is false it doesn't.

    Please can someone explain it to me, not just supply the code
     
  2. Offline

    user_90854156

    Check if getConfig().getBoolean("NewsCommand") is true whenever you are trying to send them a message.
     
  3. Offline

    KoolzSkillz

    I'm a bit confused can you show an example
     
  4. Offline

    stonar96

    Code:java
    1. public void onEnable() {
    2. getConfig().options().copyDefaults(true);
    3. getConfig().addDefault("NewsCommand", true); //or add a default config.yml to your plugin and do saveDefaultConfig();
    4. saveConfig();
    5. }

    Default values are values in the config, which always exists. If you delete them in the config, they will be created again. Advantage: You dont need a != null check, before you use values from the config.

    Code:java
    1. if (getConfig().getBoolean("NewsCommand")) {
    2. //code
    3. }
     
  5. Offline

    KoolzSkillz

    Thank you
     
Thread Status:
Not open for further replies.

Share This Page