Use Ageable instead of Animals

This commit is contained in:
aPunch 2012-03-22 00:19:54 -05:00
parent 7521e1765d
commit 98dbdfd784
3 changed files with 13 additions and 15 deletions

View File

@ -11,8 +11,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkit.version>1.2.3-R0.2-SNAPSHOT</bukkit.version>
<craftbukkit.version>1.2.3-R0.2-SNAPSHOT</craftbukkit.version>
<bukkit.version>1.2.3-R0.3-SNAPSHOT</bukkit.version>
<craftbukkit.version>1.2.3-R0.3-SNAPSHOT</craftbukkit.version>
<citizensapi.version>2.0-SNAPSHOT</citizensapi.version>
<build.number>Unknown</build.number>
</properties>

View File

@ -31,7 +31,7 @@ import net.citizensnpcs.util.Paginator;
import net.citizensnpcs.util.StringHelper;
import org.bukkit.ChatColor;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager.Profession;
@ -123,8 +123,7 @@ public class NPCCommands {
int age = 0;
if (args.hasFlag('b')) {
// TODO: Use Ageable when it is implemented
if (!Animals.class.isAssignableFrom(type.getEntityClass()))
if (!Ageable.class.isAssignableFrom(type.getEntityClass()))
Messaging.sendError(player, "The mob type '" + type.name().toLowerCase().replace("_", "-")
+ "' cannot be aged.");
else {

View File

@ -1,6 +1,6 @@
package net.citizensnpcs.trait;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Ageable;
import net.citizensnpcs.api.exception.NPCLoadException;
import net.citizensnpcs.api.npc.NPC;
@ -30,31 +30,30 @@ public class Age extends Trait implements Runnable, Toggleable {
@Override
public void onNPCSpawn() {
// TODO: Switch to use Ageable when that is implemented
if (npc.getBukkitEntity() instanceof Animals) {
Animals animal = (Animals) npc.getBukkitEntity();
animal.setAge(age);
animal.setAgeLock(locked);
if (npc.getBukkitEntity() instanceof Ageable) {
Ageable entity = (Ageable) npc.getBukkitEntity();
entity.setAge(age);
entity.setAgeLock(locked);
}
}
@Override
public void run() {
if (!locked)
age = ((Animals) npc.getBukkitEntity()).getAge();
age = ((Ageable) npc.getBukkitEntity()).getAge();
}
@Override
public boolean toggle() {
locked = !locked;
((Animals) npc.getBukkitEntity()).setAgeLock(locked);
((Ageable) npc.getBukkitEntity()).setAgeLock(locked);
return locked;
}
public void setAge(int age) {
this.age = age;
if (npc.getBukkitEntity() instanceof Animals)
((Animals) npc.getBukkitEntity()).setAge(age);
if (npc.getBukkitEntity() instanceof Ageable)
((Ageable) npc.getBukkitEntity()).setAge(age);
}
@Override