mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 04:35:50 +01:00
Use Ageable instead of Animals
This commit is contained in:
parent
8c8b3ac122
commit
a144f1cee4
4
pom.xml
4
pom.xml
@ -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>
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user