Advertisement
Guest User

RespawnHealthPlayerListener.java

a guest
Jul 31st, 2011
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. package com.wwsean08.RespawnHealth;
  2.  
  3. import org.bukkit.event.player.PlayerListener;
  4. import org.bukkit.event.player.PlayerRespawnEvent;
  5.  
  6. public class RespawnHealthPlayerListener extends PlayerListener{
  7.     RespawnHealth plugin;   //allows us to hook into the class that called us
  8.     /*
  9.      * the constructor of this class which saves the plugin that called us, which allows us to get information from it.
  10.      * I could have just as easily passed the values, but I needed it anyways for scheduling, so did it this way.
  11.      */
  12.     public RespawnHealthPlayerListener(RespawnHealth instance){
  13.         plugin = instance;
  14.     }
  15.    
  16.     @Override
  17.     public void onPlayerRespawn(PlayerRespawnEvent event){
  18.         RespawnHealthRunnable respawnWait = new RespawnHealthRunnable(event.getPlayer(), plugin.respawnHealth, this);   //instantiate the class that will remove the health
  19.         plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, respawnWait, 40);     //tell the server that in 40 server ticks run our respawnWait runnable  
  20.                                                                                                 //I don't know much about threads, and that 40 ticks was based off another plugin I know
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement