-
-
Notifications
You must be signed in to change notification settings - Fork 295
/
RabbitType.java
45 lines (37 loc) · 1.03 KB
/
RabbitType.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package net.citizensnpcs.trait;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftRabbit;
import org.bukkit.entity.Rabbit;
public class RabbitType extends Trait {
private Rabbit rabbit;
@Persist
private RabbitTypes type = RabbitTypes.BROWN;
public RabbitType() {
super("rabbittype");
}
@Override
public void onSpawn() {
rabbit = npc.getEntity() instanceof Rabbit ? (Rabbit) npc.getEntity() : null;
setType(type);
}
public void setType(RabbitTypes type) {
this.type = type;
if (rabbit != null && rabbit.isValid()) {
((CraftRabbit) rabbit).getHandle().setRabbitType(type.type);
}
}
public enum RabbitTypes {
BLACK(2),
BLACKANDWHITE(3),
BROWN(0),
GOLD(4),
KILLER(99),
SALTANDPEPPER(5),
WHITE(1);
public int type;
RabbitTypes(int type) {
this.type = type;
}
}
}