Checking if something in the config exists.

Discussion in 'Plugin Development' started by SleepyDog, Nov 4, 2014.

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

    SleepyDog

    Hey, i am making a plugin so people can do /checkapp, the problem is when they do /checkapp when i have not accepted it there is an error. On a playerjoinevent(I have already made this) i want it to set PLAYERNAME.isAccepted to 'notChecked'. BUT! i do not want it to set anything is the path to the config already exists.

    I was thinking something like


    if (config.whatever("path to config").exists) {
    //set that path to 'notChecked'
    }

    else {
    //do nothing.

    }




    Thankyou for the help!
     
  2. Offline

    Gamecube762

    if ( config.contains("Some.Path.to.Foo.Bar") ) then do nothing(it exists!)
    else config.set("Some.Path.to.Foo.Bar", someValue)
     
    Hawktasard likes this.
  3. Offline

    bennie3211

    This is what I'm using in my plugin to check if something is set in the config.yml
    Code:java
    1. if (config.isSet(iPath + "Lore")) {
    2. ArrayList<String> lores = new ArrayList<String>();
    3.  
    4. for (String lore : config.getStringList(iPath + "Lore")) {
    5. lores.add(ChatColor.translateAlternateColorCodes('&', lore));
    6. }
    7.  
    8. im.setLore(lores);
    9. }
     
  4. Offline

    SleepyDog




    I cant get this to work, is there a firstJoinEvent i can use?
     
  5. Offline

    Hawktasard

    Not exactly sure what you mean by FirstJoinEvent, but you can use player.hasPlayedBefore()
     
  6. Offline

    SleepyDog

    @Hawktasard
    so
    if(!event.getPlayer().hasJoinedBefore){
    //set config
    }



    I will try it, thanks!
     
Thread Status:
Not open for further replies.

Share This Page