config.getString Is Behaving Strangely

Discussion in 'Plugin Development' started by Junrall, May 28, 2012.

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

    Junrall

    When I run the following line, I'm able to see that NewPlayerGroup in my config contains the word "New"
    Code:
    player.sendMessage(config.getString("NewPlayerControl.Passcode.NewPlayerGroup"));
    But when I use an IF statement to check for "New", it does not work:
    Code:
    if (config.getString("NewPlayerControl.Passcode.NewPlayerGroup") == "New"){
                    player.sendMessage("Booooo!");
    }
    Actualy, now that I think about it... I'm having a similar problem with checking for a players group with Vault:
    When I run the following line it shows that I'm in the New group:
    Code:
    player.sendMessage(SafeWorld.perms.getPrimaryGroup(player));
    But when I check for the New group in an IF statement, it does not work:
    Code:
    if (SafeWorld.perms.getPrimaryGroup(player) == "New"){
                    player.sendMessage("Booooo!");
    }
    Any ideas on what I'm doing wrong?
     
  2. Offline

    I_am_not_funny

    To compare strings you must do
    Code:
    config.getString("Your config path here").equals("New")
     
    ferrybig likes this.
  3. Offline

    Junrall

    Thank you... that did the trick. :)
     
Thread Status:
Not open for further replies.

Share This Page