blob: d07265eff79ab7c4a41378b2a1fe89b34c41a880 (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package org.bukkit.entity;
/**
* Represents a villager NPC
*/
public interface Villager extends NPC {
/**
* Gets the current profession of this villager.
*
* @return Current profession.
*/
public Profession getProfession();
/**
* Sets the new profession of this villager.
*
* @param profession New profession.
*/
public void setProfession(Profession profession);
/**
* Represents the various different Villager professions there may be.
*/
public enum Profession {
FARMER(0),
LIBRARIAN(1),
PRIEST(2),
BLACKSMITH(3),
BUTCHER(4);
private static final Profession[] professions = new Profession[Profession.values().length];
private final int id;
static {
for (Profession type : values()) {
professions[type.getId()] = type;
}
}
private Profession(int id) {
this.id = id;
}
/**
* Gets the ID of this profession.
*
* @return Profession ID.
*/
public int getId() {
return id;
}
/**
* Gets a profession by its ID.
*
* @param id ID of the profession to get.
* @return Resulting profession, or null if not found.
*/
public static Profession getProfession(int id) {
return (id >= professions.length) ? null : professions[id];
}
}
}
|