How to create an event after ~ 30 seconds?

Discussion in 'Plugin Development' started by Gabriel333, Sep 24, 2011.

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

    Gabriel333

    I want to do some actions after some time (like 30 seconds) after I have opened a door with my plugin.

    I have wondered if Im going to use the metods Notify and wait? Can someone tell me the way to go?
     
  2. Offline

    Shamebot

    No.
    Use the BukkitScheduler, SyncDelayedTask.
     
  3. Offline

    Gabriel333

    Thanks!!! I think I got it now :)

    This is for anyone else who don't know who to do use scheduleSyncDelayedTask.... :) This piece of code worked in my plugin :)
    Code:
        public static int Schedule(final SpoutPlayer sPlayer,
                final SpoutBlock sBlock, int closetimer) {
            int fs = closetimer * 20;
            // 20 ticks ~ 1 second
            int taskID = BIT.plugin.getServer().getScheduler()
                    .scheduleSyncDelayedTask(BIT.plugin, new Runnable() {
                        public void run() {
                            SpoutBlock sb = sBlock;
                            SpoutPlayer sp = sPlayer;
                            if (G333Config.g333Config.DEBUG_DOOR)
                                sp.sendMessage("Autoclosing the door");
                            if (BITDigiLock.isDoor(sb)) {
                                if (BITDigiLock.isDoorOpen(sp, sb))
                                    BITDigiLock.closeDoor(sp, sb);
                            }
                        }
                    }, fs);
            return taskID;
        }
     
  4. Offline

    Orcem12

    @Gabriel333 How would this be done without Spout?
     
  5. Offline

    Gabriel333

    You dont need Spout to do this. "scheduleSyncDelayedTask" is a Bukkit method :)
     
  6. Offline

    Orcem12

    Ah, okay thanks ^^
     
Thread Status:
Not open for further replies.

Share This Page