Plugin Not Working?

Discussion in 'Plugin Development' started by scarabcoder, Jan 30, 2014.

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

    scarabcoder

    Okay, I'm trying to make a minigame where water rises from the ground, and you have dodge the water. It's not working, because final variables can't be changed. But it has to be final because the scheduler that makes it rise says it has to be a final. Here is the code for the part that doesn't work:
    Code:java
    1. public void startFlood() {
    2. final int start = 0;
    3. final World world = Bukkit.getPlayer("scarabcoder").getWorld();
    4. this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    5.  
    6.  
    7. @Override
    8. public void run() {
    9. if(game = true){
    10. setBlocks(world, new Location(world, locat1.getX(), start, locat1.getZ()), new Location(world, locat2.getX(), start, locat2.getZ()), Material.WATER);
    11. start++;
    12. Bukkit.broadcastMessage("HIGHER");
    13. }
    14.  
    15. }
    16.  
    17. }, 40, 40);
    18.  
    19. }
     
  2. Offline

    Gater12

  3. Offline

    scarabcoder

    Gater12 I'll try that, thanks.
     
  4. Offline

    bfgbfggf

    you want repeat this task x times?
    int task = 0;
    Code:
    task = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
     
                private int start = 0;
                @Override
                public void run() {
                    if(game = true){
                        setBlocks(world, new Location(world, locat1.getX(), start, locat1.getZ()), new Location(world, locat2.getX(), start, locat2.getZ()), Material.WATER);
                        start++;
                        Bukkit.broadcastMessage("HIGHER");
                        if (start > X)
                              Bukkit.cancelTask(task);
                    }
     
                }
     
            }, 40, 40).getTaskID();
     
  5. Offline

    scarabcoder

    Gater12 It doesn't work....
    bfgbfggf Thanks, I'll try that.

    bfgbfggf It's not working, it's giving me the error: Cannot invoke getTaskID() on the primitive type int.
    And the 'task =' part is giving me the error: task cannot be resolved to a variable

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  6. Offline

    bfgbfggf

    so... just add it.
    int task = ....
    (one line is before [code ])
     
  7. Offline

    scarabcoder

    I tried that, same error :(
     
Thread Status:
Not open for further replies.

Share This Page