I'm currenty trying to add a timer that runs a function x seconds after a player joins. Here's some of my Playelistener: Code: if(Config.debug_enable) Utils.Debug("Idle time is: "+seconds); IdleTimer = new Timer(player.getName()); IdleTimer.schedule(CheckIdle(player), seconds); And the function: Code: public TimerTask CheckIdle(Player player) { if (AuthDB.isAuthorized(player.getEntityId()) == false) { Messages.SendMessage("AuthDB_message_idle_kick", player, null); IdleTimer.cancel(); } else { IdleTimer.cancel(); } return null; } What am I doing wrong
You can simplify everything just by using the bukkit schedule Code: int Schedule = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new CheckIdle(player) , (x* 20L)); The int Schedule is only used if you want to track your schedule
Also be aware that since the bukkit api itself isn't thread safe, using any of the bukkit api within one of the Async scheduler methods may not be safe, and certainly isn't safe in your own custom threads.