scheduleSyncDelayedTask Doesnt work!

Discussion in 'Plugin Development' started by _thecoffeefox_, Mar 25, 2024.

  1. Offline

    _thecoffeefox_

    Hello! I am making a plugin (as you understand). And i am using the scheduleSyncDelayedTask to give next effects after a while, but it doesnt work!
    scheduleSyncDelayedTask works only between 0 and 40L! i've tried so much, but that didn't help.

    player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60, 0, false, false));
    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 3, false, false));


    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    @Overridepublic void run() {
    player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 140, 0, false, false));
    player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 140, 3, false, false));
    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 140, 1, false, false));
    }
    },60L);
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    ChaceUnderwood

    The problem you're having with your plugin is that you're trying to set the delay to 60 ticks, which may be too short a time interval for some effects. Try increasing this value to 120 or even 140 ticks to ensure all effects are applied correctly. You will also need to make sure that your plugin is configured correctly and takes into account all aspects of asynchronous work in the Minecraft API.
     
  4. Offline

    timtower Administrator Administrator Moderator

    3 seconds works fine though.
    There is no asynchronous work being done here.
    What part of the plugin could be wrongly configured?
     

Share This Page