Timer help?

Discussion in 'Plugin Development' started by redside100, Apr 6, 2014.

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

    redside100

    Hey there! I'm currently learning the Bukkit API, and I was wondering, how do you make it so a timer works ONLY for a specific player? For example, if I was making a plugin where if you right click with an iron axe, and you teleport to your eye destination, and a 5 second cooldown kicks in, wouldn't it kick in for ALL the players on the server? Or would it only take affect for the player that used the teleport?
     
  2. Offline

    Barnyard_Owl

    Code:java
    1. // ... event code + iron axe checking, etc ...
    2. final Player player = e.getPlayer( ); // get the player
    3. final Location toBlock = player.getTargetBlock( null, 50 ).getLocation( ); // get the block they're looking at
    4. new BukkitRunnable( ) { // create a new runnable
    5.  
    6. @Override
    7. public void run( ) {
    8. p.teleport( toBlock ); // teleport the player
    9. }
    10.  
    11. }.runTaskLater( myPluginInstance, 100 ); // run after 5 seconds (100 ticks)
    12.  

    It's quite simple to only teleport one player.
     
    redside100 likes this.
  3. Offline

    redside100

    Thanks! :3
     
Thread Status:
Not open for further replies.

Share This Page