summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2012-03-03 01:58:30 +0000
committerNathan Adams <dinnerbone@dinnerbone.com>2012-03-03 01:58:30 +0000
commitbfe455e1b653b6258f827640c53a59c17ea6f0bf (patch)
treef6ff98e84004f084bd4aa485938a9b0786f6f29a /src/main/java/org
parent0a9cf32d3a4b6e45660fe1d88e777545070546ae (diff)
downloadbukkit-bfe455e1b653b6258f827640c53a59c17ea6f0bf.tar
bukkit-bfe455e1b653b6258f827640c53a59c17ea6f0bf.tar.gz
bukkit-bfe455e1b653b6258f827640c53a59c17ea6f0bf.tar.lz
bukkit-bfe455e1b653b6258f827640c53a59c17ea6f0bf.tar.xz
bukkit-bfe455e1b653b6258f827640c53a59c17ea6f0bf.zip
Added Villager API for getting/setting Profession. This adds BUKKIT-887
Diffstat (limited to 'src/main/java/org')
-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];
+ }
+ }
}