Evil Bracket of Doom

Discussion in 'Plugin Development' started by MegaNarwhal, Sep 2, 2012.

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

    MegaNarwhal

    I'm trying to write a plugin for my server to allow the donator rank to set the time to day. Here's my code (without the imports and stuff):

    PHP:
    public boolean onCommand(CommandSender playerCommand cmdString labelString[] args){
            
    String bcprefix = (ChatColor.AQUA "[DB]");
            if(
    cmd.getName().equalsIgnoreCase("daytime")){
                if (
    player.hasPermission("db.daytime")){
                    (
    World w:Bukkit.getWorlds()) w.setTime(12000);
                
    getServer().broadcastMessage(bcprefix player.getName() + ChatColor.AQUA " has set the time to day!");
                return 
    true;
                }
            }
            return 
    false;
        }
    }
    The only error I'm getting in Eclipse is the bracket right after ("db.daytime"))... What am I doing wrong? Help is appreciated :)
     
  2. Offline

    Firefly

    Code:
    (World w:Bukkit.getWorlds()) w.setTime(12000);
    What are you trying to do here? Is that supposed to be a for-loop? If so, you forgot the for.
     
  3. Offline

    Acrobot

    You forgot your "for" loop?

    Code:
    if (player.hasPermission("db.daytime")){
      (World w:Bukkit.getWorlds()) w.setTime(12000);
    
    You probably want "for (World w : Bukkit.getWorlds()) { w.setTime(12000); }

    EDIT: Ninja'd by Firefly
     
  4. Offline

    MegaNarwhal

    I'm trying to set the time to day in all worlds. Keep in mind this is my first plugin so I'm not sure what everything does.

    EDIT: Acrobot: I did what you said to do and the bracket is no longer underlined, but it still tells me "Syntax error on token "{", for expected after this token".

    EDIT: Sorry! After I saved it, it no longer says that :p Thanks for the help!
     
  5. Offline

    Acrobot

    Could you post your code again? And tell us where the error is happening?
     
Thread Status:
Not open for further replies.

Share This Page