From daaf0aa6a949e5d701397c2ff7a95a4738408ebf Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 3 May 2011 00:36:02 +1000 Subject: [PATCH] AnimalTamer and Tameable interfaces, and corresponding features. Documentation improvements. --- .../java/org/bukkit/entity/AnimalTamer.java | 5 +++ .../java/org/bukkit/entity/HumanEntity.java | 2 +- src/main/java/org/bukkit/entity/Tameable.java | 39 +++++++++++++++++++ src/main/java/org/bukkit/entity/Wolf.java | 32 ++------------- 4 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 src/main/java/org/bukkit/entity/AnimalTamer.java create mode 100644 src/main/java/org/bukkit/entity/Tameable.java diff --git a/src/main/java/org/bukkit/entity/AnimalTamer.java b/src/main/java/org/bukkit/entity/AnimalTamer.java new file mode 100644 index 00000000..da958dad --- /dev/null +++ b/src/main/java/org/bukkit/entity/AnimalTamer.java @@ -0,0 +1,5 @@ +package org.bukkit.entity; + +public interface AnimalTamer { + +} diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java index 60f7b345..75d028a2 100644 --- a/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java @@ -7,7 +7,7 @@ import org.bukkit.inventory.PlayerInventory; /** * Represents a human entity, such as an NPC or a player */ -public interface HumanEntity extends LivingEntity { +public interface HumanEntity extends LivingEntity, AnimalTamer { /** * Returns the name of this player * diff --git a/src/main/java/org/bukkit/entity/Tameable.java b/src/main/java/org/bukkit/entity/Tameable.java new file mode 100644 index 00000000..a9dd8664 --- /dev/null +++ b/src/main/java/org/bukkit/entity/Tameable.java @@ -0,0 +1,39 @@ +package org.bukkit.entity; + +public interface Tameable { + + /** + * Check if this is tamed + * + * If something is tamed then a player can not tame it through normal methods, even if it does not belong to anyone in particular. + * + * @return true if this has been tamed + */ + public boolean isTamed(); + + /** + * Sets if this has been tamed. Not necessary if the method setOwner has been used, as it tames automatically. + * + * If something is tamed then a player can not tame it through normal methods, even if it does not belong to anyone in particular. + * + * @param tame true if tame + */ + public void setTamed(boolean tame); + + /** + * Gets the current owning AnimalTamer + * + * @return the owning AnimalTamer, or null if not owned + */ + public AnimalTamer getOwner(); + + /** + * Set this to be owned by given AnimalTamer. + * If the owner is not null, this will be tamed and will have any current path it is following removed. + * If the owner is set to null, this will be untamed, and the current owner removed. + * + * @param tamer the AnimalTamer who should own this + */ + public void setOwner(AnimalTamer tamer); + +} diff --git a/src/main/java/org/bukkit/entity/Wolf.java b/src/main/java/org/bukkit/entity/Wolf.java index e87a8d8a..eb9cf64a 100644 --- a/src/main/java/org/bukkit/entity/Wolf.java +++ b/src/main/java/org/bukkit/entity/Wolf.java @@ -4,7 +4,7 @@ package org.bukkit.entity; /** * Represents a Wolf */ -public interface Wolf extends Animals { +public interface Wolf extends Animals, Tameable { /** * Checks if this wolf is angry * @@ -14,6 +14,7 @@ public interface Wolf extends Animals { /** * Sets the anger of this wolf + * An angry wolf can not be fed or tamed, and will actively look for targets to attack. * * @param angry true if angry */ @@ -28,37 +29,10 @@ public interface Wolf extends Animals { /** * Sets if this wolf is sitting + * Will remove any path that the wolf was following beforehand. * * @param sitting true if sitting */ public void setSitting(boolean sitting); - /** - * Check if this wolf is tame - * - * @return true if tame - */ - public boolean isTame(); - - /** - * Sets if wolf is tame - * - * @param tame true if tame - */ - public void setTame(boolean tame); - - /** - * Gets the name of the current owning player - * - * @return owners name, "" or null if unowned - */ - public String getOwner(); - - /** - * Set the wolf to be owned by given player (also is tamed) - * - * @param player name of owner, or null/"" if setting to unowned - */ - public void setOwner(String player); - }