Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.wwsean08.RespawnHealth;
- import org.bukkit.event.player.PlayerListener;
- import org.bukkit.event.player.PlayerRespawnEvent;
- public class RespawnHealthPlayerListener extends PlayerListener{
- RespawnHealth plugin; //allows us to hook into the class that called us
- /*
- * the constructor of this class which saves the plugin that called us, which allows us to get information from it.
- * I could have just as easily passed the values, but I needed it anyways for scheduling, so did it this way.
- */
- public RespawnHealthPlayerListener(RespawnHealth instance){
- plugin = instance;
- }
- @Override
- public void onPlayerRespawn(PlayerRespawnEvent event){
- RespawnHealthRunnable respawnWait = new RespawnHealthRunnable(event.getPlayer(), plugin.respawnHealth, this); //instantiate the class that will remove the health
- plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, respawnWait, 40); //tell the server that in 40 server ticks run our respawnWait runnable
- //I don't know much about threads, and that 40 ticks was based off another plugin I know
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement