getConfig().getString(player.getDisplayName()) isn't returning the value

Discussion in 'Plugin Development' started by n31ln3t, May 26, 2013.

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

    n31ln3t

    Hello,

    I post this thread for an issue that has been going on for a while now, I am trying to get
    players value from the config.

    I mean, for e.g. pretend this is in the config:

    player: value

    I am trying to get the value of player.

    Thanks,
    Neil.
     
  2. Offline

    CubieX

    Do you really have the players "DisplayName" saved in your config? Or the normal "Name"?
    If the latter, use ".getName()".
     
  3. Offline

    n31ln3t

    I'm trying to compare two results.

    The argument from the command /login
    And the value of something in the config.

    I'm using: if(getConfig().getString(player.getName()+".password")==args[0])

    No work :(

    EDIT:
    My config is:
    cazagar:
    password: bluetas
     
  4. Offline

    mike0631

    You mean that your config is

    cazagar:
    *SPACE*password: bluetas

    Right?

    If so try to use:
    Code:java
    1.  
    2. if(getConfig().getString(player.getName()+".password").equals(args[0]))
    3.  
     
  5. Offline

    n31ln3t

    Thank you so much! You truly are a genius, 1 more question :D why do i have to have it say .equals? Doesn't getConfig().getString(player.getName()+".password") return the value in which I can just use == args[0]?

    Thanks :)

    Also, how do I check if a specific index exists, for example:
    if(blah.blah.exists)

    Don't worry guys, this is all fixed, no more answers needed!

    Thanks to everyone who helped! :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  6. Offline

    mike0631

    It returns a value but somehow with strings "==" wont really work.
     
  7. Offline

    Jogy34

    If I'm remembering this correctly the '==' operator compares all of the bytes in an object whereas the .equals() operator for Strings, I believe it compares each index of the String. I'm not quite sure why Strings that are the same have different bytes though but I think it might be because you are creating different objects, as String isn't a primitive type such as int or boolean. Don't hold me to that as it is just how I currently understand it. A quick google search would probably give a much better answer than that though.
     
  8. Offline

    gomeow

Thread Status:
Not open for further replies.

Share This Page