EntitySkeleton: add item in hand, set max health

Discussion in 'Spigot Plugin Development' started by Sensonic, Apr 29, 2017.

  1. Hello, I want to create a custom Skeleton that has a name, more health and holds other custom items.
    I can add a name and setHealth, but i can't setMaxHealth and also setting items and armor just won't work.

    Thanks for helping, here is my code:
    Code (Text):
    Player p = (Player) sender;
                WorldServer world = ((CraftWorld)p.getWorld()).getHandle();
                Location loc = p.getLocation();

                if (args.length > 0) {
                    if (args[0].equalsIgnoreCase("define")) {
                        //get worldedit selection
                        if (getWorldEdit().getSelection(p) == null) {
                            p.sendMessage(title + "Please select a region with WorldEdit");
                            return false;
                        s = getWorldEdit().getSelection(p);
                        Location min = s.getMinimumPoint();
                        Location max = s.getMaximumPoint();

                        //boss mob creation
                        EntitySkeleton boss = new EntitySkeleton(world);
                        boss.setCustomName("§4§lDAFT BOSS");

                        ItemStack weapon = new ItemStack(Material.DIAMOND_SWORD);
                        weapon.setDurability((short) 0);
                        weapon.addEnchantment(Enchantment.DAMAGE_ALL, 5);
                        weapon.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);


  2. Hou aren't setting the weapon anywhere. I am not on my computer buit tray something like boss.setWeapon(weapon) or something likely about the maxHealth, I think setHealth is already setting the Max health to 400...
  3. No there's no such thing as boss.setWeapon(weapon). And setHealth does not.. it's still on 20hp when i setHealth to 400...
  4. Try .getEquipment that should do it.
  5. I can do that, but i can't do anything with it. It needs something like (Damageable)boss i think but I have no clue how to implement this.
  6. Use EntitySkeleton#setEquipment for the held item