From b850a822c1cd79cc5b8e9181b4b9e6b61977e0ec Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 13 Dec 2018 14:10:26 +1100 Subject: SPIGOT-4526: Add conversion time API for Zombie & subclasses --- src/main/java/org/bukkit/entity/Husk.java | 37 +++++++++++++++++++- src/main/java/org/bukkit/entity/PigZombie.java | 24 +++++++++++++ src/main/java/org/bukkit/entity/Zombie.java | 31 +++++++++++++++++ .../java/org/bukkit/entity/ZombieVillager.java | 40 ++++++++++++++++++++-- 4 files changed, 129 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bukkit/entity/Husk.java b/src/main/java/org/bukkit/entity/Husk.java index 17139a2e..85ada1c6 100644 --- a/src/main/java/org/bukkit/entity/Husk.java +++ b/src/main/java/org/bukkit/entity/Husk.java @@ -3,4 +3,39 @@ package org.bukkit.entity; /** * Represents a Husk - variant of {@link Zombie}. */ -public interface Husk extends Zombie { } +public interface Husk extends Zombie { + + /** + * Get if this entity is in the process of converting to a Zombie as a + * result of being underwater. + * + * @return conversion status + */ + @Override + boolean isConverting(); + + /** + * Gets the amount of ticks until this entity will be converted to a Zombie + * as a result of being underwater. + * + * When this reaches 0, the entity will be converted. + * + * @return conversion time + * @throws IllegalStateException if {@link #isConverting()} is false. + */ + @Override + int getConversionTime(); + + /** + * Sets the amount of ticks until this entity will be converted to a Zombie + * as a result of being underwater. + * + * When this reaches 0, the entity will be converted. A value of less than 0 + * will stop the current conversion process without converting the current + * entity. + * + * @param time new conversion time + */ + @Override + void setConversionTime(int time); +} diff --git a/src/main/java/org/bukkit/entity/PigZombie.java b/src/main/java/org/bukkit/entity/PigZombie.java index 2f086728..ae9eaaa8 100644 --- a/src/main/java/org/bukkit/entity/PigZombie.java +++ b/src/main/java/org/bukkit/entity/PigZombie.java @@ -33,4 +33,28 @@ public interface PigZombie extends Zombie { * @return True if the zombie is angry, otherwise false. */ boolean isAngry(); + + /** + * Not applicable to this entity + * + * @return false + */ + @Override + public boolean isConverting(); + + /** + * Not applicable to this entity + * + * @return UnsuppotedOperationException + */ + @Override + public int getConversionTime(); + + /** + * Not applicable to this entity + * + * @param time unused + */ + @Override + public void setConversionTime(int time); } diff --git a/src/main/java/org/bukkit/entity/Zombie.java b/src/main/java/org/bukkit/entity/Zombie.java index cf53ea22..bdc6206a 100644 --- a/src/main/java/org/bukkit/entity/Zombie.java +++ b/src/main/java/org/bukkit/entity/Zombie.java @@ -48,4 +48,35 @@ public interface Zombie extends Monster { */ @Deprecated public Villager.Profession getVillagerProfession(); + + /** + * Get if this entity is in the process of converting to a Drowned as a + * result of being underwater. + * + * @return conversion status + */ + boolean isConverting(); + + /** + * Gets the amount of ticks until this entity will be converted to a Drowned + * as a result of being underwater. + * + * When this reaches 0, the entity will be converted. + * + * @return conversion time + * @throws IllegalStateException if {@link #isConverting()} is false. + */ + int getConversionTime(); + + /** + * Sets the amount of ticks until this entity will be converted to a Drowned + * as a result of being underwater. + * + * When this reaches 0, the entity will be converted. A value of less than 0 + * will stop the current conversion process without converting the current + * entity. + * + * @param time new conversion time + */ + void setConversionTime(int time); } diff --git a/src/main/java/org/bukkit/entity/ZombieVillager.java b/src/main/java/org/bukkit/entity/ZombieVillager.java index f6ab96c8..256e7cc2 100644 --- a/src/main/java/org/bukkit/entity/ZombieVillager.java +++ b/src/main/java/org/bukkit/entity/ZombieVillager.java @@ -8,12 +8,48 @@ public interface ZombieVillager extends Zombie { /** * Sets the villager profession of this zombie. */ - public void setVillagerProfession(Villager.Profession profession); + @Override + void setVillagerProfession(Villager.Profession profession); /** * Returns the villager profession of this zombie. * * @return the profession or null */ - public Villager.Profession getVillagerProfession(); + @Override + Villager.Profession getVillagerProfession(); + + /** + * Get if this entity is in the process of converting to a Villager as a + * result of being cured. + * + * @return conversion status + */ + @Override + boolean isConverting(); + + /** + * Gets the amount of ticks until this entity will be converted to a + * Villager as a result of being cured. + * + * When this reaches 0, the entity will be converted. + * + * @return conversion time + * @throws IllegalStateException if {@link #isConverting()} is false. + */ + @Override + int getConversionTime(); + + /** + * Sets the amount of ticks until this entity will be converted to a + * Villager as a result of being cured. + * + * When this reaches 0, the entity will be converted. A value of less than 0 + * will stop the current conversion process without converting the current + * entity. + * + * @param time new conversion time + */ + @Override + void setConversionTime(int time); } -- cgit v1.2.3