Skip to content

Instantly share code, notes, and snippets.

@Paxination
Created April 10, 2015 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paxination/f4d354e524f0e96fede6 to your computer and use it in GitHub Desktop.
Save Paxination/f4d354e524f0e96fede6 to your computer and use it in GitHub Desktop.
suggested implementation for hospital beds for Disease bukkit plugin
import java.util.UUID;
import org.bukkit.plugin.Plugin;
public class HospitalBed implements Runnable{
private Plugin plugin;
UUID uuid;
int count = 6000;
//Default value for count;
public HospitalBed(Plugin plugin, UUID uuid){
this.plugin = plugin;
this.uuid = uuid;
count=plugin.getConfig().getInt("PATH.TO.INTEGER.IN.MINS")*1200;
//there is 1200 ticks in each minute. So we have to multiply by this.
}
@Override
public void run() {
if(plugin.getServer().getPlayer(uuid).isSleeping()){
count++;
//if they are sleeping, increase our counter.
//we count to make sure they are sleeping every tick of the time.
} else {
cancel();
//if they are not sleeping any more, we cancel this runnable
}
if(count==6000){
//clear their disease
}
}
public void cancel(){
this.cancel();
//cancels this runnable
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment