Solved Command not working

Discussion in 'Plugin Development' started by Dablakbandit, Dec 7, 2013.

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

    Dablakbandit

    The code
    Code:java
    1. if((args.length == 2) && ((args[0].equalsIgnoreCase("toggle")))){
    2. for (final World world : Bukkit.getServer().getWorlds()) {
    3. String worldreal = world.getName();
    4. if(args[2].equalsIgnoreCase(worldreal)){
    5. worldEnabled = getConfig().getBoolean("Worlds." + worldreal + ".Enabled");
    6. if(worldEnabled = true){
    7. this.getConfig().set("Worlds." + worldreal + ".Enabled", "False");
    8. }
    9. else if(worldEnabled = false){
    10. this.getConfig().set("Worlds." + worldreal + ".Enabled", "True");
    11. }
    12. }
    13. }
    14. }
    15.  


    Doesn't work? Can someone help?

    Edit: I read the error and it seems to have a problem with the
    Code:java
    1. if(args[2].equalsIgnoreCase(worldreal)){

    it enabled/disbaled it, but there was no change in the config?

    Thanks in advanced!
    Dablakbandit
     
  2. Offline

    Developing

    Code:java
    1. if(worldEnabled = true){

    Should be
    Code:java
    1. if(worldEnabled == true){


    Code:java
    1. if(worldEnabled = false){

    Should be
    Code:java
    1. if(worldEnabled == false){
     
  3. Offline

    Dablakbandit

    Developing

    still getting an error on the
    Code:java
    1. if(args[2].equalsIgnoreCase(worldreal)){


    Thanks,
    Dablakbandit
     
  4. Offline

    Developing

  5. Offline

    Necrodoom

    Dablakbandit Its recommended that you read a bit more about how ifs and arrays work, you have checked for args.length == 2, which means only args[0] and args[1] exist. you need to check if length is 3.
     
    Dablakbandit and Rocoty like this.
  6. Offline

    Dablakbandit

    Necrodoom

    I'm so stupid, thanks!
    Dablakbandit

    And i have read, but i just forgot to put that as a 1 the one before it is a 0, :p so silly.
     
Thread Status:
Not open for further replies.

Share This Page