Package org.bukkit.entity

# Interface Villager

All Superinterfaces:
  `AbstractVillager`, `Ageable`, `Attributable`, `Audience`, `Breedable`, `CommandSender`, `Creature`, `Damageable`, `Entity`, `Frictional`, `HoverEventSource<HoverEvent.ShowEntity>`, `InventoryHolder`, `LivingEntity`, `Lootable`, `Merchant`, `Metadatable`, `Mob`, `Nameable`, `NPC`, `Permissible`, `PersistentDataHolder`, `Pointered`, `ProjectileSource`, `ServerOperator`, `Sound.Emitter`

public interface Villager extends AbstractVillager
Represents a villager NPC

## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static enum`
`Villager.Profession`
Represents the various different Villager professions there may be.
`static enum`
`Villager.Type`
Represents Villager type, usually corresponding to what biome they spawn in.

## Nested classes/interfaces inherited from interface org.bukkit.entity.Entity

`Entity.Spigot`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`addTrades(int amount)`
Gives to this villager some potential new trades based to its profession and level.
`void`
`clearReputations()`
Clear all reputations from this villager.
`@NotNull Villager.Profession`
`getProfession()`
Gets the current profession of this villager.
`Reputation`
`getReputation(@NotNull UUID uniqueId)`
Get the `reputation` for a specific player by `UUID`.
`@NotNull Map<UUID,Reputation>`
`getReputations()`
Get all `reputations` for all players mapped by their `unique IDs`.
`int`
`getRestocksToday()`
Gets the amount of times a villager has restocked their trades today
`int`
`getVillagerExperience()`
Gets the trading experience of this villager.
`int`
`getVillagerLevel()`
Gets the level of this villager.
`@NotNull Villager.Type`
`getVillagerType()`
Gets the current type of this villager.
`boolean`
`increaseLevel(int amount)`
Increases the level of this villager.
`void`
`setProfession(@NotNull Villager.Profession profession)`
Sets the new profession of this villager.
`void`
`setReputation(@NotNull UUID uniqueId, Reputation reputation)`
Set the `reputation` for a specific player by `UUID`.
`void`
`setReputations(@NotNull Map<UUID,Reputation> reputations)`
Set all `reputations` for all players mapped by their `unique IDs`.
`void`
`setRestocksToday(int restocksToday)`
Sets the amount of times a villager has restocked their trades today
`void`
`setVillagerExperience(int experience)`
Sets the trading experience of this villager.
`void`
`setVillagerLevel(int level)`
Sets the level of this villager.
`void`
`setVillagerType(@NotNull Villager.Type type)`
Sets the new type of this villager.
`void`
`shakeHead()`
Causes this villager to shake his head.
`boolean`
`sleep(@NotNull Location location)`
Attempts to make this villager sleep at the given location.
`void`
`wakeup()`
Causes this villager to wake up if he's currently sleeping.
`@Nullable ZombieVillager`
`zombify()`
Convert this Villager into a ZombieVillager as if it was killed by a Zombie.

### Methods inherited from interface org.bukkit.entity.AbstractVillager

`getInventory, resetOffers`

### Methods inherited from interface org.bukkit.entity.Ageable

`getAge, isAdult, setAdult, setAge, setBaby`

### Methods inherited from interface org.bukkit.attribute.Attributable

`getAttribute, registerAttribute`

### Methods inherited from interface net.kyori.adventure.audience.Audience

`clearTitle, deleteMessage, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, openBook, playSound, playSound, playSound, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, showTitle, stopSound, stopSound`

### Methods inherited from interface org.bukkit.entity.Breedable

`canBreed, getAgeLock, setAgeLock, setBreed`

### Methods inherited from interface org.bukkit.command.CommandSender

`getName, name, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlainMessage, sendRichMessage`

### Methods inherited from interface org.bukkit.entity.Damageable

`damage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealth`

### Methods inherited from interface org.bukkit.entity.Entity

`addPassenger, addScoreboardTag, asHoverEvent, collidesAt, eject, fromMobSpawner, getBoundingBox, getChunk, getEntityId, getEntitySpawnReason, getFacing, getFallDistance, getFireTicks, getFreezeTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getMaxFreezeTicks, getNearbyEntities, getOrigin, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getSpawnCategory, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTicksLived, getTrackedPlayers, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isFreezeTickingLocked, isFrozen, isGlowing, isInBubbleColumn, isInLava, isInPowderedSnow, isInRain, isInsideVehicle, isInvulnerable, isInWater, isInWaterOrBubbleColumn, isInWaterOrRain, isInWaterOrRainOrBubbleColumn, isOnGround, isPersistent, isSilent, isTicking, isUnderWater, isValid, isVisualFire, leaveVehicle, lockFreezeTicks, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setFreezeTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, setVisualFire, spawnAt, spawnAt, spigot, teamDisplayName, teleport, teleport, teleport, teleport, teleport, teleport, teleport, teleport, teleportAsync, teleportAsync, wouldCollideUsing`

### Methods inherited from interface io.papermc.paper.entity.Frictional

`getFrictionState, setFrictionState`

### Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource

`asHoverEvent`

### Methods inherited from interface org.bukkit.entity.LivingEntity

`addPotionEffect, addPotionEffect, addPotionEffects, attack, broadcastSlotBreak, broadcastSlotBreak, canBreatheUnderwater, clearActiveItem, damageItemStack, damageItemStack, getActiveItem, getActivePotionEffects, getArrowCooldown, getArrowsInBody, getArrowsStuck, getBeeStingerCooldown, getBeeStingersInBody, getCanPickupItems, getCategory, getCollidableExemptions, getDeathSound, getDrinkingSound, getEatingSound, getEyeHeight, getEyeHeight, getEyeLocation, getFallDamageSound, getFallDamageSoundBig, getFallDamageSoundSmall, getHandRaised, getHandRaisedTime, getHurtDirection, getHurtSound, getItemUseRemainingTime, getKiller, getLastDamage, getLastTwoTargetBlocks, getLeashHolder, getLineOfSight, getMaximumAir, getMaximumNoDamageTicks, getMemory, getNoDamageTicks, getPotionEffect, getRemainingAir, getRemoveWhenFarAway, getShieldBlockingDelay, getTargetBlock, getTargetBlock, getTargetBlock, getTargetBlockExact, getTargetBlockExact, getTargetBlockFace, getTargetBlockFace, getTargetBlockInfo, getTargetBlockInfo, getTargetEntity, getTargetEntity, getTargetEntityInfo, getTargetEntityInfo, hasAI, hasLineOfSight, hasLineOfSight, hasPotionEffect, isClimbing, isCollidable, isGliding, isHandRaised, isInvisible, isJumping, isLeashed, isRiptiding, isSleeping, isSwimming, knockback, playPickupItemAnimation, playPickupItemAnimation, rayTraceBlocks, rayTraceBlocks, removePotionEffect, setAI, setArrowCooldown, setArrowsInBody, setArrowsStuck, setBeeStingerCooldown, setBeeStingersInBody, setCanPickupItems, setCollidable, setGliding, setHurtDirection, setInvisible, setJumping, setKiller, setLastDamage, setLeashHolder, setMaximumAir, setMaximumNoDamageTicks, setMemory, setNoDamageTicks, setRemainingAir, setRemoveWhenFarAway, setShieldBlockingDelay, setSwimming, swingHand, swingMainHand, swingOffHand`

### Methods inherited from interface org.bukkit.loot.Lootable

`clearLootTable, getLootTable, getSeed, hasLootTable, setLootTable, setLootTable, setSeed`

### Methods inherited from interface org.bukkit.inventory.Merchant

`getRecipe, getRecipeCount, getRecipes, getTrader, isTrading, setRecipe, setRecipes`

### Methods inherited from interface org.bukkit.metadata.Metadatable

`getMetadata, hasMetadata, removeMetadata, setMetadata`

### Methods inherited from interface org.bukkit.entity.Mob

`getAmbientSound, getEquipment, getHeadRotationSpeed, getMaxHeadPitch, getPathfinder, getTarget, isAware, isInDaylight, isLeftHanded, lookAt, lookAt, lookAt, lookAt, lookAt, lookAt, setAware, setLeftHanded, setTarget`

### Methods inherited from interface org.bukkit.Nameable

`customName, customName, getCustomName, setCustomName`

### Methods inherited from interface org.bukkit.permissions.Permissible

`addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, permissionValue, permissionValue, recalculatePermissions, removeAttachment`

### Methods inherited from interface org.bukkit.persistence.PersistentDataHolder

`getPersistentDataContainer`

### Methods inherited from interface net.kyori.adventure.pointer.Pointered

`get, getOrDefault, getOrDefaultFrom, pointers`

### Methods inherited from interface org.bukkit.projectiles.ProjectileSource

`launchProjectile, launchProjectile, launchProjectile`

### Methods inherited from interface org.bukkit.permissions.ServerOperator

`isOp, setOp`

## Method Details

### getProfession

@NotNull @NotNull Villager.Profession getProfession()
Gets the current profession of this villager.

Returns:
  Current profession.

### setProfession

void setProfession(@NotNull @NotNull Villager.Profession profession)
Sets the new profession of this villager.

Parameters:
  `profession` - New profession.

### getVillagerType

@NotNull @NotNull Villager.Type getVillagerType()
Gets the current type of this villager.

Returns:
  Current type.

### setVillagerType

void setVillagerType(@NotNull @NotNull Villager.Type type)
Sets the new type of this villager.

Parameters:
  `type` - New type.

### getVillagerLevel

int getVillagerLevel()
Gets the level of this villager. A villager with a level of 1 and no experience is liable to lose its profession.

Returns:
  this villager's level

### setVillagerLevel

void setVillagerLevel(int level)
Sets the level of this villager. A villager with a level of 1 and no experience is liable to lose its profession. This doesn't update the trades of this villager.

Parameters:
  `level` - the new level
Throws:
  `IllegalArgumentException` - if level not between [1, 5]
See Also:
  - `increaseLevel(int)`

### getVillagerExperience

int getVillagerExperience()
Gets the trading experience of this villager.

Returns:
  trading experience

### setVillagerExperience

void setVillagerExperience(int experience)
Sets the trading experience of this villager.

Parameters:
  `experience` - new experience
Throws:
  `IllegalArgumentException` - if experience < 0

### increaseLevel

boolean increaseLevel(int amount)
Increases the level of this villager. The villager will also unlock new recipes unlike the raw method `setVillagerLevel(int)`.

A villager with a level of 1 and no experience is liable to lose its profession.

A master villager has a level of 5 in its profession and will unlock 10 trades (2 per level).

Parameters:
  `amount` - The amount of level
Returns:
  Whether trades are unlocked
Throws:
  `IllegalArgumentException` - if current level plus the amount isn't between [1, 5] or the amount isn't positive
See Also:
  - `setVillagerLevel(int)`

### addTrades

boolean addTrades(int amount)
Gives to this villager some potential new trades based to its profession and level.

Parameters:
  `amount` - The amount of trades to give
Returns:
  Whether trades are added
Throws:
  `IllegalArgumentException` - if the amount isn't positive

### getRestocksToday

int getRestocksToday()
Gets the amount of times a villager has restocked their trades today

Returns:
  The amount of trade restocks.

### setRestocksToday

void setRestocksToday(int restocksToday)
Sets the amount of times a villager has restocked their trades today

Parameters:
  `restocksToday` - new restock count

### sleep

boolean sleep(@NotNull @NotNull Location location)
Attempts to make this villager sleep at the given location.
The location must be in the current world and have a bed placed at the location. The villager will put its head on the specified block while sleeping.

Parameters:
  `location` - the location of the bed
Returns:
  whether the sleep was successful

### wakeup

void wakeup()
Causes this villager to wake up if he's currently sleeping.

Throws:
  `IllegalStateException` - if not sleeping

### shakeHead

void shakeHead()
Causes this villager to shake his head.

### zombify

@Nullable @Nullable ZombieVillager zombify()
Convert this Villager into a ZombieVillager as if it was killed by a Zombie. Note: this will fire a EntityTransformEvent

Returns:
  the converted entity `ZombieVillager` or null if the conversion its cancelled

### getReputation

@Nullable Reputation getReputation(@NotNull @NotNull UUID uniqueId)
Get the `reputation` for a specific player by `UUID`.

Parameters:
  `uniqueId` - The `UUID` of the player to get the reputation of.
Returns:
  The player's copied reputation with this villager.

### getReputations

@NotNull @NotNull Map<UUID,Reputation> getReputations()
Get all `reputations` for all players mapped by their `unique IDs`.

Returns:
  All `reputations` for all players in a copied map.

### setReputation

void setReputation(@NotNull @NotNull UUID uniqueId, @NotNull Reputation reputation)
Set the `reputation` for a specific player by `UUID`.

Parameters:
  `uniqueId` - The `UUID` of the player to set the reputation of.
  `reputation` - The `reputation` to set.

### setReputations

void setReputations(@NotNull @NotNull Map<UUID,Reputation> reputations)
Set all `reputations` for all players mapped by their `unique IDs`.

Parameters:
  `reputations` - All `reputations` for all players mapped by their `unique IDs`.

### clearReputations

void clearReputations()
Clear all reputations from this villager. This removes every single reputation regardless of its impact and the player associated.