mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
Added Villager API for getting/setting Profession. This adds BUKKIT-887
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
577152ebd1
commit
0e0427ebeb
2 changed files with 57 additions and 1 deletions
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue