package net.glowstone.entity.passive;

import java.util.concurrent.ThreadLocalRandom;
import net.glowstone.entity.meta.MetadataIndex;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Wolf;

//import net.glowstone.entity.meta.MetadataIndex.TameableFlags;

public class GlowWolf extends GlowTameable implements Wolf {

    private DyeColor collarColor;

    public GlowWolf(Location location) {
        super(location, EntityType.WOLF, 8);
        collarColor = DyeColor
            .getByDyeData((byte) ThreadLocalRandom.current().nextInt(DyeColor.values().length));
        setBoundingBox(0.6, 0.85);
    }

    @Override
    public boolean isAngry() {
        return false;
        //metadata.getBit(MetadataIndex.WOLF_FLAGS, TameableFlags.WOLF_IS_ANGRY); TODO 1.9 - Angry seems missing from the metadata according to wiki.vg
    }

    @Override
    public void setAngry(boolean angry) {
        //metadata.setBit(MetadataIndex.WOLF_FLAGS, TameableFlags.WOLF_IS_ANGRY, angry); TODO 1.9 - Angry seems missing from the metadata according to wiki.vg
    }

    @Override
    public DyeColor getCollarColor() {
        return collarColor;
    }

    @Override
    public void setCollarColor(DyeColor color) {
        metadata.set(MetadataIndex.WOLF_COLOR, color.getDyeData());
        collarColor = color;
    }

    public boolean isBegging() {
        return metadata.getBoolean(MetadataIndex.WOLF_BEGGING);
    }

    public void setBegging(boolean begging) {
        metadata.set(MetadataIndex.WOLF_BEGGING, begging);
    }

    @Override
    public void setTamed(boolean isTamed) {
        if (tamed != isTamed) {
            // Change max health of wolf when he's got tamed. See MinecraftWiki for more information!
            if (isTamed && getMaxHealth() == 8) {
                setMaxHealth(20);
                setHealth(20);
            }
        }
        super.setTamed(isTamed);
    }

    @Override
    public void setOwner(AnimalTamer animalTamer) {
        // TODO
        super.setOwner(animalTamer);
    }

    @Override
    public void setHealth(double health) {
        metadata.set(MetadataIndex.WOLF_HEALTH, (float) health);
        super.setHealth(health);
    }

    @Override
    protected Sound getHurtSound() {
        return Sound.ENTITY_WOLF_HURT;
    }

    @Override
    protected Sound getDeathSound() {
        return Sound.ENTITY_WOLF_DEATH;
    }

    @Override
    protected Sound getAmbientSound() {
        return Sound.ENTITY_WOLF_AMBIENT;
    }
}

@@ -79,16 +79,38 @@
 Random;%0A
+import lombok.Getter;%0A
 import n
@@ -464,16 +464,28 @@
 Wolf %7B%0A%0A
+    @Getter%0A
     priv
@@ -511,16 +511,125 @@
 Color;%0A%0A
+    /**%0A     * Creates a wolf with a random collar color.%0A     *%0A     * @param location the location%0A     */%0A
     publ
@@ -1024,16 +1024,27 @@
 _ANGRY);
+%0A        //
  TODO 1.
@@ -1257,16 +1257,27 @@
  angry);
+%0A        //
  TODO 1.
@@ -1350,96 +1350,8 @@
  %7D%0A%0A
-    @Override%0A    public DyeColor getCollarColor() %7B%0A        return collarColor;%0A    %7D%0A%0A
     
@@ -1919,17 +1919,16 @@
 ormation
-!
 %0A       

Fix CheckStyle issues in entity/passive/GlowWolf.java (#783)