mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 18:50:51 +01:00
SPIGOT-4820: Villager Type API
By: md_5 <git@md-5.net>
This commit is contained in:
parent
7bcfc2f673
commit
713ac360bf
2 changed files with 69 additions and 1 deletions
|
@ -9,6 +9,7 @@ import org.bukkit.block.Biome;
|
|||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.loot.LootTables;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -116,6 +117,18 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
* @see Statistic
|
||||
*/
|
||||
Registry<Statistic> STATISTIC = new SimpleRegistry<>(Statistic.class);
|
||||
/**
|
||||
* Villager profession.
|
||||
*
|
||||
* @see Villager.Profession
|
||||
*/
|
||||
Registry<Villager.Profession> VILLAGER_PROFESSION = new SimpleRegistry<>(Villager.Profession.class);
|
||||
/**
|
||||
* Villager type.
|
||||
*
|
||||
* @see Villager.Type
|
||||
*/
|
||||
Registry<Villager.Type> VILLAGER_TYPE = new SimpleRegistry<>(Villager.Type.class);
|
||||
|
||||
/**
|
||||
* Get the object by its key.
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.bukkit.entity;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -22,11 +25,52 @@ public interface Villager extends AbstractVillager {
|
|||
*/
|
||||
public void setProfession(@NotNull Profession profession);
|
||||
|
||||
/**
|
||||
* Gets the current type of this villager.
|
||||
*
|
||||
* @return Current type.
|
||||
*/
|
||||
@NotNull
|
||||
public Type getVillagerType();
|
||||
|
||||
/**
|
||||
* Sets the new type of this villager.
|
||||
*
|
||||
* @param type New type.
|
||||
*/
|
||||
public void setVillagerType(@NotNull Type type);
|
||||
|
||||
/**
|
||||
* Represents Villager type, usually corresponding to what biome they spawn
|
||||
* in.
|
||||
*/
|
||||
public enum Type implements Keyed {
|
||||
|
||||
DESERT,
|
||||
JUNGLE,
|
||||
PLAINS,
|
||||
SAVANNA,
|
||||
SNOWY,
|
||||
SWAMP,
|
||||
TAIGA;
|
||||
private final NamespacedKey key;
|
||||
|
||||
private Type() {
|
||||
this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the various different Villager professions there may be.
|
||||
* Villagers have different trading options depending on their profession,
|
||||
*/
|
||||
public enum Profession {
|
||||
public enum Profession implements Keyed {
|
||||
NONE,
|
||||
/**
|
||||
* Armorer profession. Wears a black apron.
|
||||
|
@ -103,5 +147,16 @@ public interface Villager extends AbstractVillager {
|
|||
* enchanted.
|
||||
*/
|
||||
WEAPONSMITH;
|
||||
private final NamespacedKey key;
|
||||
|
||||
private Profession() {
|
||||
this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue