Solved BlockStatements error plz help!

Discussion in 'Plugin Development' started by krisvos130, Feb 24, 2014.

Thread Status:
Not open for further replies.
  1. I've had 1 error in my plugin and that is the only reason it hasn't been working. here is the code.
    Code:java
    1. package me.KrisVos130.Tutorial;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class Tutorial extends JavaPlugin {
    10. @Override
    11. public void onEnable() {
    12. getLogger().info("UHC Timer Enabled!");
    13. }
    14.  
    15. @Override
    16. public void onDisable() {
    17. getLogger().info("UHC Timer Disabled!");
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    21. if(cmd.getName().equalsIgnoreCase("Timer-Start")) {
    22. do Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    23.  
    24. public void run() {
    25. Bukkit.getServer().broadcastMessage(ChatColor.DARK_RED + "20 Minutes in!"); {
    26. }
    27. }
    28. } , 1200L, 0L);
    29. }
    30. return false;
    31. }
    32. }

    The problem is at line 29 where ; is underlined in red with this error: Syntax error, insert "while ( Expression ) ;" to complete BlockStatements
    I'm really bad with java so please help.
     
  2. Offline

    Dpasi314

    You have a random do statement in your code...
    The Syntax of a do statement is
    Code:java
    1.  
    2. do {
    3. // stuff
    4. }
    5.  
    6. while(condition);
    7.  

    You don't have the while statement to go along with the do, and that's why it's throwing an error. The easiest way to fix is to just remove the do in front of your
    Code:java
    1.  
    2. do Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    3.  


    That or add a while loop.
     
  3. Thanks alot! it works now and the timer works fully automatic now. I'm still learning java so sorry for the stupidity from me to ask this dumb question.
     
Thread Status:
Not open for further replies.

Share This Page