From ab9a606c395902e222365a8eaf84f674b523492f Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 10 Aug 2018 19:47:56 +1000 Subject: Improve entity hierarchy by adding Mob interface. --- src/main/java/org/bukkit/entity/Ambient.java | 2 +- src/main/java/org/bukkit/entity/Creature.java | 21 +-------------------- src/main/java/org/bukkit/entity/Flying.java | 2 +- src/main/java/org/bukkit/entity/Mob.java | 24 ++++++++++++++++++++++++ src/main/java/org/bukkit/entity/Slime.java | 17 +---------------- 5 files changed, 28 insertions(+), 38 deletions(-) create mode 100644 src/main/java/org/bukkit/entity/Mob.java (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/entity/Ambient.java b/src/main/java/org/bukkit/entity/Ambient.java index 779e3897..613830a7 100644 --- a/src/main/java/org/bukkit/entity/Ambient.java +++ b/src/main/java/org/bukkit/entity/Ambient.java @@ -3,4 +3,4 @@ package org.bukkit.entity; /** * Represents an ambient mob */ -public interface Ambient extends LivingEntity {} +public interface Ambient extends Mob {} diff --git a/src/main/java/org/bukkit/entity/Creature.java b/src/main/java/org/bukkit/entity/Creature.java index f223f55b..6c9c5e85 100644 --- a/src/main/java/org/bukkit/entity/Creature.java +++ b/src/main/java/org/bukkit/entity/Creature.java @@ -4,23 +4,4 @@ package org.bukkit.entity; * Represents a Creature. Creatures are non-intelligent monsters or animals * which have very simple abilities. */ -public interface Creature extends LivingEntity { - - /** - * Instructs this Creature to set the specified LivingEntity as its - * target. - *

- * Hostile creatures may attack their target, and friendly creatures may - * follow their target. - * - * @param target New LivingEntity to target, or null to clear the target - */ - public void setTarget(LivingEntity target); - - /** - * Gets the current target of this Creature - * - * @return Current target of this creature, or null if none exists - */ - public LivingEntity getTarget(); -} +public interface Creature extends Mob {} diff --git a/src/main/java/org/bukkit/entity/Flying.java b/src/main/java/org/bukkit/entity/Flying.java index 4f16a26c..580ce18b 100644 --- a/src/main/java/org/bukkit/entity/Flying.java +++ b/src/main/java/org/bukkit/entity/Flying.java @@ -3,4 +3,4 @@ package org.bukkit.entity; /** * Represents a Flying Entity. */ -public interface Flying extends LivingEntity {} +public interface Flying extends Mob {} diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java new file mode 100644 index 00000000..15dee0ee --- /dev/null +++ b/src/main/java/org/bukkit/entity/Mob.java @@ -0,0 +1,24 @@ +package org.bukkit.entity; + +/** + * Represents a Mob. Mobs are living entities with simple AI. + */ +public interface Mob extends LivingEntity { + + /** + * Instructs this Mob to set the specified LivingEntity as its target. + *

+ * Hostile creatures may attack their target, and friendly creatures may + * follow their target. + * + * @param target New LivingEntity to target, or null to clear the target + */ + public void setTarget(LivingEntity target); + + /** + * Gets the current target of this Mob + * + * @return Current target of this creature, or null if none exists + */ + public LivingEntity getTarget(); +} diff --git a/src/main/java/org/bukkit/entity/Slime.java b/src/main/java/org/bukkit/entity/Slime.java index 0d87d203..1119e26e 100644 --- a/src/main/java/org/bukkit/entity/Slime.java +++ b/src/main/java/org/bukkit/entity/Slime.java @@ -3,7 +3,7 @@ package org.bukkit.entity; /** * Represents a Slime. */ -public interface Slime extends LivingEntity { +public interface Slime extends Mob { /** * @return The size of the slime @@ -14,19 +14,4 @@ public interface Slime extends LivingEntity { * @param sz The new size of the slime. */ public void setSize(int sz); - - /** - * Set the {@link LivingEntity} target for this slime. Set to null to clear - * the target. - * - * @param target the entity to target - */ - public void setTarget(LivingEntity target); - - /** - * Get the {@link LivingEntity} this slime is currently targeting. - * - * @return the current target, or null if no target exists. - */ - public LivingEntity getTarget(); } -- cgit v1.2.3