Solved Combatlog

Discussion in 'Plugin Development' started by TheFl4me, May 16, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    TheFl4me

    Hey im trying to code a Combatlog plugin. When a player logs out (combatlogs) he is killed and drops all the items he had in his inventory(because he died). But the way it is atm the player dies yes, but he does not drop any items.

    Any help?

    Code:
    @EventHandler
        public void CombatLog(PlayerQuitEvent e) {
            Player p = e.getPlayer();
            String combatlog_msg = KitPvP.getPlugin().getLanguage().CombatLog_combatlogged.replaceAll("%p", p.getName());
            if(KitPvP.getPlugin().getCombatLog().combatlog.contains(p)) {
                KitPvP.getPlugin().getCombatLog().death.add(p);
                p.setHealth(0);
                KitPvP.getPlugin().getCombatLog().death.remove(p);
                for(Player all : Bukkit.getServer().getOnlinePlayers()) {
                    all.sendMessage(combatlog_msg);
                }
            }
        }
    P.S
    The death arraylist is for something else ignore it i need it like that.
     
    1. loop through the items in his inventory and drop them
    2. clear the players inventory
    3. kill him
     
  2. Offline

    TheFl4me

    Thank you this worked :) although now looking through my code again i noticed the main reason why it was not working was because i had another PlayerQuitEvent which cleared the inv of the player. I now fixed that and doing p.setHealth(0) is enough and works fine :p
    (srry for me being stupid(again))
     
Thread Status:
Not open for further replies.

Share This Page