Help With Schedulers

Discussion in 'Plugin Development' started by XvBaseballkidvX, Jul 20, 2013.

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

    XvBaseballkidvX

    Hello everyone!

    I am currently working on an RPG plugin and I am having some trouble with the schedulers.

    Here is the problem:

    Code:java
    1. Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(this, new BukkitRunnable(){ ^^^ I get an error here!
    2. public void run(){
    3. Player p = e.getPlayer();
    4. miner.remove(p.getName());
    5. }
    6. }, 12000/*20 = 1 second*/);
    7.  
    8. }
    9. }


    I have this Scheduler in an EventHandler on a PlayerInteractEvent.

    This is in a separate class than the Main Class (The separate class does not extend JavaPlugin).

    Does anyone have an answer?

    All help is much appreciated, thank you for reading!
     
  2. Offline

    chasechocolate

    The first parameter should be the instance to the main class. Either make a static instance-getter or a constructor.
     
  3. Offline

    kamcio96

    Use:
    Code:java
    1. new BukkitRunnable(){
    2. @Override
    3. public void run() {
    4. Player p = e.getPlayer();
    5. miner.remove(p.getName());
    6. }
    7. }.runTaskLater(this, 12000L);
     
  4. Offline

    XvBaseballkidvX

    @ChaseChococlate kamcio96 Thank you both :D Let me test it out!
     
Thread Status:
Not open for further replies.

Share This Page