package net.simpvp.Events;

import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.scheduler.BukkitRunnable;

/** Class is responsible for listening to player deaths
 * and making sure no xp is dropped in the events
 * and that players don't keep any set gamemodes
 */
public class PlayerDeath implements Listener {

	@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled=true)
	public void onPlayerDeath(PlayerDeathEvent event) {
		Player player = event.getEntity();

		if (!player.isOp() && player.getGameMode() != GameMode.SURVIVAL) {
			player.setGameMode(GameMode.SURVIVAL);
		}

		if (!Event.isPlayerActive(player.getUniqueId())) {
			return;
		}

		event.setDroppedExp(0);

		// It doesn't seem to like it if we just call respawn before this
		// event has finished processing, so schedule it to run as a task ASAP.
		new BukkitRunnable() {
			@Override
			public void run() {
				player.spigot().respawn();
			}
		}.runTaskLater(Events.instance, 0);
	}
}

@@ -769,16 +769,18 @@
 L);%0A%09%09%7D%0A
+%09%09
 %0A%09%09if (!
@@ -866,16 +866,130 @@
 dExp(0);
+%0A%09%09%0A%09%09if (Event.getKeepMyInventory() == true) %7B%0A%09%09%09event.setKeepInventory(true);%0A%09%09%09event.getDrops().clear();%0A%0A%09%09%7D
 %0A%0A%09%09// I

Update PlayerDeath.java