Solved Checking if a String at config equals something

Discussion in 'Plugin Development' started by ElCreeperHD, Feb 5, 2016.

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

    ElCreeperHD

    Hello, I am trying to implement config on my plugin. The value "language" is set to en, and the message into the if is not displaying...
    Code:
     if(plugin.getConfig().getString("language") == "en" || plugin.getConfig().getString("language") == "EN" || plugin.getConfig().getString("language") == null)    {
                    op.sendMessage(ChatColor.GREEN + "The player " + ChatColor.AQUA + ev.getPlayer().getName() + ChatColor.GREEN + " mentioned you!");   
                }
     
  2. Offline

    Javlin

    Compare strings with Object#equals, and instead of checking for different cases, use String#equalsIgnoreCase
     
  3. Offline

    mcdorli

    What is your config's name?
     
  4. Offline

    ElCreeperHD

    @mcdorli The config is config.yml?
    EDIT: @Javlin Thanks! Solved. I tried to use that method before but it was not working!
     
    Last edited: Feb 7, 2016
  5. Try using the "equalsIgnoreCase"
    Like this:

    if (getConfig().getString("LOL").equalsIgnoreCase("en") ) {
    //Do something
    }

    @ElCreeperHD
     
Thread Status:
Not open for further replies.

Share This Page