How to check if a string exists in a config?

Discussion in 'Plugin Development' started by 1Achmed1, Apr 6, 2014.

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

    1Achmed1

    How do I go about this...
    [​IMG]
     
  2. Offline

    Wizehh

    By any chance, are you watching a 'BCBroz' video?
    Anyway, you'd want to do something like this:
    PHP:
    if (getConfig().getString(player.getName()) != null) {
        
    //contains string
    }
    And you compare values with '=='. '=' is used to initalize (set the value).
     
  3. Offline

    1Achmed1

    I wasn't... it's code from an old project lol.
     
  4. Offline

    coasterman10

    The best way to do this is to use the method present in the API, the contains() method.
    Code:java
    1. if (getConfig().contains(player.getName())) {
    2. // The config contains a value under the player's name
    3. }
     
Thread Status:
Not open for further replies.

Share This Page