package net.wayward_realms.waywardunconsciousness;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class PlayerDeathListener implements Listener {

    private WaywardUnconsciousness plugin;

    public PlayerDeathListener(WaywardUnconsciousness plugin) {
        this.plugin = plugin;
    }

    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent event) {
        event.setDeathMessage("");
        plugin.setUnconscious(event.getEntity(), true);
        plugin.setDeathLocation(event.getEntity(), event.getEntity().getLocation());
        plugin.setDeathTime(event.getEntity());
        List<ItemStack> drops = new ArrayList<>(event.getDrops());
        plugin.setDeathInventory(event.getEntity(), drops);
        event.getDrops().clear();
    }

}

@@ -45,16 +45,135 @@
 sness;%0A%0A
+import net.wayward_realms.waywardlib.character.CharacterPlugin;%0Aimport org.bukkit.Bukkit;%0Aimport org.bukkit.ChatColor;%0A
 import o
@@ -198,24 +198,24 @@
 entHandler;%0A
-
 import org.b
@@ -323,16 +323,68 @@
 emStack;
+%0Aimport org.bukkit.plugin.RegisteredServiceProvider;
 %0A%0Aimport
@@ -739,16 +739,1910 @@
 ge(%22%22);%0A
+        switch (event.getEntity().getLastDamageCause().getCause()) %7B%0A            case FIRE:%0A            case FIRE_TICK:%0A            case LAVA:%0A            case DROWNING:%0A                RegisteredServiceProvider%3CCharacterPlugin%3E characterPluginProvider = plugin.getServer().getServicesManager().getRegistration(CharacterPlugin.class);%0A                if (characterPluginProvider != null) %7B%0A                    CharacterPlugin characterPlugin = characterPluginProvider.getProvider();%0A                    characterPlugin.getActiveCharacter(event.getEntity()).setDead(true);%0A                    characterPlugin.setActiveCharacter(event.getEntity(), characterPlugin.createNewCharacter(event.getEntity()));%0A                    event.getDrops().clear();%0A                    event.getEntity().sendMessage(plugin.getPrefix() + ChatColor.RED + %22Your death was determined to be a fatality, and a new character has been created for you.%22);%0A                %7D%0A                break;%0A            case FALL:%0A                if (event.getEntity().getFallDistance() %3E= 64) %7B%0A                    characterPluginProvider = plugin.getServer().getServicesManager().getRegistration(CharacterPlugin.class);%0A                    if (characterPluginProvider != null) %7B%0A                        CharacterPlugin characterPlugin = characterPluginProvider.getProvider();%0A                        characterPlugin.getActiveCharacter(event.getEntity()).setDead(true);%0A                        characterPlugin.setActiveCharacter(event.getEntity(), characterPlugin.createNewCharacter(event.getEntity()));%0A                        event.getDrops().clear();%0A                        event.getEntity().sendMessage(plugin.getPrefix() + ChatColor.RED + %22Your death was determined to be a fatality, and a new character has been created for you.%22);%0A                    %7D%0A                %7D%0A                break;%0A            default:%0A        
         
@@ -2685,24 +2685,32 @@
 y(), true);%0A
+        
         plug
@@ -2782,32 +2782,40 @@
 ion());%0A        
+     
+   
 plugin.setDeathT
@@ -2834,24 +2834,32 @@
 tEntity());%0A
+        
         List
@@ -2913,32 +2913,40 @@
 ops());%0A        
+     
+   
 plugin.setDeathI
@@ -2977,24 +2977,32 @@
 (), drops);%0A
+        
         even
@@ -3019,21 +3019,55 @@
 ().clear();%0A
+                break;%0A        %7D%0A%0A
     %7D%0A%0A%7D%0A

Make some player death causes kill the character, closes #20