Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private HashMap<BukkitTask, Player> map = new HashMap<BukkitTask, Player>();
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onJoin(PlayerJoinEvent e){//L'event que tu veux
- //Lance la tâche avec délai
- BukkitTask id = Bukkit.getScheduler().runTaskLater(this, new BukkitRunnable() {
- @Override
- public void run() {
- /*On récupère notre BukkitTask*/
- BukkitTask t = null;
- for(BukkitTask task : Bukkit.getScheduler().getPendingTasks()){
- if(task.getTaskId() == this.getTaskId()){
- t = task;
- break;
- }
- }
- /*On récupère notre joueur associé à cette tâche*/
- Player player = map.get(t);
- player.performCommand("say Coucou");//On lui fait executer une commande
- map.remove(t);//On le supprime à la fin
- }
- }, 20*60*15);//Delai (ici 15 min)
- map.put(id, e.getPlayer());//On ajoute notre task à l'HashMap
- }
Advertisement
Add Comment
Please, Sign In to add comment