Hello Everyone, Ive recently been working with Bukkit schedule. And was woundering how to implement a scheduled delay to an event? if i was to define player once more inside these bracekets it would not work: Code: public void run(){ } Also for my event it looks like this but does not work at all: Code: @EventHandler public void onInteract(PlayerInteractEvent event) { this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { Player player = event.getPlayer(); if (player.getItemInHand().getType() == Material.IRON_SWORD && (event.getAction() == Action.RIGHT_CLICK_BLOCK)) { player.setVelocity(player.getVelocity().add(new Vector(0, 1.0, 0))) } }, 60L); }
I'm not sure if this was just a typo, but you might want a semicolon after you set the player's velocity.
Lucky for you i'm a professional when it comes to schedulers: Code: private *main class name* plugin; private *class name*(*Main class name* plugin){ this.plugin = plugin; } @EventHandler public void onInteract(PlayerInteractEvent event) { final Player player = event.getPlayer(); if (player.getItemInHand().getType() == Material.IRON_SWORD && (event.getAction() == Action.RIGHT_CLICK_BLOCK)) { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { player.setVelocity(player.getVelocity().add(new Vector(0, 1.0, 0))); } }, -time in seconds-*20L); } } }