Bukkit Scheduler not working?

Discussion in 'Plugin Development' started by BetaNyan, Jul 15, 2014.

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

    BetaNyan

    Heres my code:

    Code:java
    1. @EventHandler(priority=EventPriority.HIGH)
    2. public void onBlockPlace(BlockPlaceEvent e) {
    3. final Player p = e.getPlayer();
    4. final Block b = (Block) e.getBlockPlaced();
    5. if (b.getType() == Material.REDSTONE_TORCH_ON) {
    6. p.sendMessage("§a§lSupply crate dropped!");
    7. FallingBlock block = e.getPlayer().getWorld().spawnFallingBlock(e.getBlockPlaced().getLocation().add(0, 20, 0), Material.PISTON_BASE, (byte)6);
    8. final Block crate = (Block) block;
    9. float x = 0.1F;
    10. float y = 1.0F;
    11. float z = 0.1F;
    12. block.setVelocity(new Vector(x, y, z));
    13. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    14.  
    15. @Override
    16. public void run() {
    17. p.sendMessage("Test!");
    18. }
    19. }, 100);
    20.  
    21. }
    22.  
    23. }
    24.  


    Everything works, except the Test message. Why isn't it working?
     
  2. Offline

    mythbusterma

    If you're sure that it didn't happen after 5 seconds, you should store their UUID and look the player up again after 5 seconds.
     
  3. Offline

    BetaNyan

    Its not that send message isn't working, it's the task. I tried using other things in it, but nothing works.
     
  4. Offline

    TheMcScavenger

    It can actually be stored just fine.

    BetaNyan Why are you using Bukkit.getServer().getScheduler()?
    Code:java
    1. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
    2. public void run(){
    3. // your code
    4. }
    5. }, delay);
     
  5. Offline

    aaomidi

    What I would do is just initiate a new BukkitRunnable
    'new BukkitRunnable' and then go on from there.
     
Thread Status:
Not open for further replies.

Share This Page