Death Message Help

Discussion in 'Spigot Help' started by LazerShadow, May 28, 2015.

  1. For some reason when it sends the player how much health they had it always says 20.0 no matter how much health they have. I have even caught the killer on fire right before the death.

    Code (Text):
            event.setDeathMessage(ChatColor.GOLD + "Death> " + ChatColor.RED + player.getName() + ChatColor.GRAY +  " was killed by " + ChatColor.RED + killer.getName() + ChatColor.GRAY + " with " + killer.getItemInHand().getType().name().replace("_", " ").toLowerCase() + ChatColor.GRAY + ".");
            player.sendMessage(ChatColor.GOLD + "Death> " + ChatColor.GRAY + "Your killer had " + ChatColor.RED + killer.getHealthScale() + ChatColor.GRAY + " hearts left. (Currently bugged)");
           
    All code:
    Code (Text):
        @EventHandler(priority=EventPriority.HIGHEST)
        public void onDeath(PlayerDeathEvent event) {
            final Player player = event.getEntity().getPlayer();
            Player killer = event.getEntity().getKiller();

            player.setHealth(20);
            player.setGameMode(GameMode.SPECTATOR);
           
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                @Override
                public void run() {
                   
                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:tp " + player.getName() + " 718.2053 206.0000 -693.0194");
                        player.setGameMode(GameMode.SURVIVAL);
                       
                        ItemStack item = new ItemStack(Material.NETHER_STAR, 1);
                        ItemMeta meta = item.getItemMeta();
                        meta.setDisplayName(ChatColor.GOLD + "Kit Selector §7(Right Click)");
                        List<String> lore = new ArrayList<String>();
                        lore.add("§7Right Click this item to select your kit!");
                        meta.setLore(lore);
                        item.setItemMeta(meta);
                        player.getInventory().addItem(item);
                }
        }, 100L);
           
            event.setDeathMessage(ChatColor.GOLD + "Death> " + ChatColor.RED + player.getName() + ChatColor.GRAY +  " was killed by " + ChatColor.RED + killer.getName() + ChatColor.GRAY + " with " + killer.getItemInHand().getType().name().replace("_", " ").toLowerCase() + ChatColor.GRAY + ".");
            player.sendMessage(ChatColor.GOLD + "Death> " + ChatColor.GRAY + "Your killer had " + ChatColor.RED + killer.getHealthScale() + ChatColor.GRAY + " hearts left. (Currently bugged)");
           
            event.getDrops().clear();
           
           
           
        }