}
public @Override void onPlayerRespawn(PlayerRespawnEvent event)
{
Player player = event.getPlayer();
GameState gs = Current.GameStates.get(player.getName());
if (gs != null)
{
if (gs.canRespawn())
{
String respawnWorld = event.getRespawnLocation().getWorld().getName();
if (!gs.getWorld().getName().equalsIgnoreCase(respawnWorld))
{
event.setRespawnLocation(gs.getWorld().getSpawnLocation());
}
if (gs.getMap().getNumberOfLives() >= 0)
{
int livesLeft = gs.getMap().getNumberOfLives() - gs.getDeathCount();
if (livesLeft > 0)
{
player.sendMessage("You Have " + livesLeft + " Lives Left.");
}
else
{
player.sendMessage(ChatColor.RED + "You Have No Lives Left.");
}
}
}
else
{
player.sendMessage("You have died too many times, sending you back home.");
String worldName = player.getWorld().getName();
event.setRespawnLocation(gs.getEntryPoint());
gs.setInChallenge(false);
if (gs.getMap().getResetInventory())
{
gs.toggleInventory();
}
Current.Plugin.getServer().unloadWorld(worldName, true);
Current.GameWorlds.remove(worldName);
gs.PendingRemoval = true;