Are there bounds on delay time?

Discussion in 'Plugin Development' started by TheSporech, Apr 16, 2016.

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

    TheSporech

    Hi!
    When you schedule a repeating task, are there any requirements for the how long you delay by? When i use values such as decimals, it doesn't delay at all.

    For a bit of context;
    In my plugin, i'm using the scheduler to create a particle projectile effect, for example:
    Code:
    List<Location> path = player.getLineOfSight(arguments)
    for (final Location loc : path) {
                MainClass.that.getServer().getScheduler().scheduleSyncDelayedTask(MainClass.that, new Runnable() {
                    @Override
                    public void run() {
                        loc.getWorld().spawnParticle(p,loc,3);
                        for (Entity e : loc.getWorld().getNearbyEntities(loc, 1, 1, 1)) {
                            if (e instanceof LivingEntity) {
                                ((Damageable) e).damage(damage,player);
                            }
                        }
                    }
                }, delay);
                delay += speed;
            }
        }
    It works, but when the value of speed is less than 1, the projectile will just travel instantly, and won't take its time to travel. So I concluded that there are boundaries on the delay time, is this true and if so, can i get around them?
     
  2. Offline

    Assist

    @TheSporech
    The delay is in ticks, 20 ticks is 1 second. So if the delay is 1, the task will run every 1/20th of a second.
     
  3. Offline

    TheSporech

    I get that, but can you delay by half a tick?
     
  4. Offline

    Assist

    @TheSporech
    I don't think so, the delay parameter is a long so it doesn't accept decimal values.
     
    Last edited: Apr 16, 2016
  5. Offline

    MisterErwin

    @TheSporech You can't do that.
    The reason is: The minecraft server ticks 20 times a second.
    And you would not able to do much between these ticks.
     
Thread Status:
Not open for further replies.

Share This Page