package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityTameableAnimal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Creature; import org.bukkit.entity.Tameable; public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creature { public CraftTameableAnimal(CraftServer server, EntityTameableAnimal entity) { super(server, entity); } @Override public EntityTameableAnimal getHandle() { return (EntityTameableAnimal)super.getHandle(); } public AnimalTamer getOwner() { if (("").equals(getOwnerName())) return null; AnimalTamer owner = getServer().getPlayerExact(getOwnerName()); if (owner == null) { owner = getServer().getOfflinePlayer(getOwnerName()); } return owner; } public String getOwnerName() { return getHandle().getOwnerName(); } public boolean isTamed() { return getHandle().isTamed(); } public void setOwner(AnimalTamer tamer) { if (tamer != null) { setTamed(true); getHandle().setPathEntity(null); setOwnerName(tamer.getName()); } else { setTamed(false); setOwnerName(""); } } public void setOwnerName(String ownerName) { getHandle().setOwnerName(ownerName == null ? "" : ownerName); } public void setTamed(boolean tame) { getHandle().setTamed(tame); if (!tame) { setOwnerName(""); } } public boolean isSitting() { return getHandle().isSitting(); } public void setSitting(boolean sitting) { getHandle().setSitting(sitting); getHandle().setPathEntity(null); } @Override public String toString() { return getClass().getSimpleName() + "{owner=" + getOwner() + ",tamed=" + isTamed() + "}"; } }