SPIGOT-4834: API for Villager levels and experience

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2019-05-05 12:03:15 +10:00
parent 692e60f3f0
commit 11c5260e6a

View File

@ -40,6 +40,42 @@ public interface Villager extends AbstractVillager {
*/ */
public void setVillagerType(@NotNull Type type); public void setVillagerType(@NotNull Type type);
/**
* Gets the level of this villager.
*
* A villager with a level <= 1 and no experience is liable to lose its
* profession.
*
* @return this villager's level
*/
public int getVillagerLevel();
/**
* Sets the level of this villager.
*
* A villager with a level <= 1 and no experience is liable to lose its
* profession.
*
* @param level the new level
* @throws IllegalArgumentException if level not between [0, 5]
*/
public void setVillagerLevel(int level);
/**
* Gets the trading experience of this villager.
*
* @return trading experience
*/
public int getVillagerExperience();
/**
* Sets the trading experience of this villager.
*
* @param experience new experience
* @throws IllegalArgumentException if experience < 0
*/
public void setVillagerExperience(int experience);
/** /**
* Represents Villager type, usually corresponding to what biome they spawn * Represents Villager type, usually corresponding to what biome they spawn
* in. * in.
@ -73,52 +109,49 @@ public interface Villager extends AbstractVillager {
public enum Profession implements Keyed { public enum Profession implements Keyed {
NONE, NONE,
/** /**
* Armorer profession. Wears a black apron. * Armorer profession. Wears a black apron. Armorers primarily trade for
* Armorers primarily trade for iron armor, chainmail armor, and * iron armor, chainmail armor, and sometimes diamond armor.
* sometimes diamond armor.
*/ */
ARMORER, ARMORER,
/** /**
* Butcher profession. Wears a white apron. * Butcher profession. Wears a white apron. Butchers primarily trade for
* Butchers primarily trade for raw and cooked food. * raw and cooked food.
*/ */
BUTCHER, BUTCHER,
/** /**
* Cartographer profession. Wears a white robe. * Cartographer profession. Wears a white robe. Cartographers primarily
* Cartographers primarily trade for explorer maps and some paper. * trade for explorer maps and some paper.
*/ */
CARTOGRAPHER, CARTOGRAPHER,
/** /**
* Cleric profession. Wears a purple robe. * Cleric profession. Wears a purple robe. Clerics primarily trade for
* Clerics primarily trade for rotten flesh, gold ingot, redstone, * rotten flesh, gold ingot, redstone, lapis, ender pearl, glowstone,
* lapis, ender pearl, glowstone, and bottle o' enchanting. * and bottle o' enchanting.
*/ */
CLERIC, CLERIC,
/** /**
* Farmer profession. Wears a brown robe. * Farmer profession. Wears a brown robe. Farmers primarily trade for
* Farmers primarily trade for food-related items. * food-related items.
*/ */
FARMER, FARMER,
/** /**
* Fisherman profession. Wears a brown robe. * Fisherman profession. Wears a brown robe. Fisherman primarily trade
* Fisherman primarily trade for fish, as well as possibly selling * for fish, as well as possibly selling string and/or coal.
* string and/or coal.
*/ */
FISHERMAN, FISHERMAN,
/** /**
* Fletcher profession. Wears a brown robe. * Fletcher profession. Wears a brown robe. Fletchers primarily trade
* Fletchers primarily trade for string, bows, and arrows. * for string, bows, and arrows.
*/ */
FLETCHER, FLETCHER,
/** /**
* Leatherworker profession. Wears a white apron. * Leatherworker profession. Wears a white apron. Leatherworkers
* Leatherworkers primarily trade for leather, and leather armor, as * primarily trade for leather, and leather armor, as well as saddles.
* well as saddles.
*/ */
LEATHERWORKER, LEATHERWORKER,
/** /**
* Librarian profession. Wears a white robe. * Librarian profession. Wears a white robe. Librarians primarily trade
* Librarians primarily trade for paper, books, and enchanted books. * for paper, books, and enchanted books.
*/ */
LIBRARIAN, LIBRARIAN,
/** /**
@ -126,25 +159,23 @@ public interface Villager extends AbstractVillager {
*/ */
MASON, MASON,
/** /**
* Nitwit profession. Wears a green apron, cannot trade. * Nitwit profession. Wears a green apron, cannot trade. Nitwit
* Nitwit villagers do not do anything. They do not have any trades by * villagers do not do anything. They do not have any trades by default.
* default.
*/ */
NITWIT, NITWIT,
/** /**
* Sheperd profession. Wears a brown robe. * Sheperd profession. Wears a brown robe. Shepherds primarily trade for
* Shepherds primarily trade for wool items, and shears. * wool items, and shears.
*/ */
SHEPHERD, SHEPHERD,
/** /**
* Toolsmith profession. Wears a black apron. * Toolsmith profession. Wears a black apron. Tool smiths primarily
* Tool smiths primarily trade for iron and diamond tools. * trade for iron and diamond tools.
*/ */
TOOLSMITH, TOOLSMITH,
/** /**
* Weaponsmith profession. Wears a black apron. * Weaponsmith profession. Wears a black apron. Weapon smiths primarily
* Weapon smiths primarily trade for iron and diamond weapons, sometimes * trade for iron and diamond weapons, sometimes enchanted.
* enchanted.
*/ */
WEAPONSMITH; WEAPONSMITH;
private final NamespacedKey key; private final NamespacedKey key;