Kill player

Discussion in 'Plugin Development' started by thatdubstepgamer, Aug 16, 2013.

Thread Status:
Not open for further replies.
  1. How do you kill your self when you do /ninja? I dont know how with the new update.
     
  2. Offline

    Axe2760

    player.setHealth(0.0);
     
  3. Its not killing the player heres my code
    Code:
                if (commandLabel.equalsIgnoreCase("ninja")){
                    player.setHealth(0.0);
                    player.getInventory().clear();
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000, 2));
                    ItemStack goldsword = new ItemStack(Material.GOLD_SWORD, 1);
                    ItemStack steak = new ItemStack(Material.COOKED_BEEF, 4);
                    ItemStack compass = new ItemStack(Material.COMPASS, 1);
                    goldsword.addEnchantment(Enchantment.DURABILITY, 3);
                    goldsword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
                    PlayerInventory pi = player.getInventory();
                    pi.addItem(goldsword);
                    pi.addItem(steak);
                    pi.addItem(compass);
     
  4. Offline

    Axe2760

    How can you add items to the inventory of a dead player? Use PlayerRespawnEvent.

    As for the health not setting to 0, I'm afraid I can't help you further. Is the command registered in your plugin.yml?
     
Thread Status:
Not open for further replies.

Share This Page