How to check a variable through config?

Discussion in 'Plugin Development' started by harrybridgen, Jun 2, 2014.

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

    harrybridgen

    Hey, I was trying to make it so it would check if a string off the config is true or false. How can I do this? I tried doing this:
    Code:java
    1. if (getConfig().getString("revolution") = true) {
    2. player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "REVOLUTION AGAINST " + getConfig().getString("revolutionagainst"));

    Config:
    Code:
    revolution: false
    revolutionagainst: Whiterun
    However, this doesn't work. Im still learning java. Help :)
     
  2. Offline

    MineCrashKoen

    Don't get the String, get a Boolean. Also, in an If statement, don't use = for comparison, use ==
     
  3. Offline

    Konkz

    PHP:
    if (getConfig().getBoolean("path.to.my.boolean")) { // If it's true
    // do this
    } else { // if it's not true
    // do this
    }
     
  4. Offline

    harrybridgen

  5. Offline

    Konkz

    No problem, I suggest learning Java first and coming back to Bukkit at a later date. harrybridgen
     
    AdamQpzm likes this.
Thread Status:
Not open for further replies.

Share This Page