summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/bukkit/entity/Ocelot.java2
-rw-r--r--src/main/java/org/bukkit/entity/Villager.java56
2 files changed, 57 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/entity/Ocelot.java b/src/main/java/org/bukkit/entity/Ocelot.java
index a4df056b..90db8d61 100644
--- a/src/main/java/org/bukkit/entity/Ocelot.java
+++ b/src/main/java/org/bukkit/entity/Ocelot.java
@@ -56,7 +56,7 @@ public interface Ocelot extends Animals, Tameable {
* @param id ID of the cat type to get.
* @return Resulting type, or null if not found.
*/
- public static final Type getType(int id) {
+ public static Type getType(int id) {
return (id >= types.length) ? null : types[id];
}
}
diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java
index 1fa8392f..d07265ef 100644
--- a/src/main/java/org/bukkit/entity/Villager.java
+++ b/src/main/java/org/bukkit/entity/Villager.java
@@ -4,5 +4,61 @@ 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];
+ }
+ }
}