Package org.bukkit.entity
Interface Villager
- All Superinterfaces:
AbstractVillager
,Ageable
,Attributable
,Audience
,Breedable
,CommandSender
,Creature
,Damageable
,Entity
,HoverEventSource<HoverEvent.ShowEntity>
,InventoryHolder
,LivingEntity
,Lootable
,Merchant
,Metadatable
,Mob
,Nameable
,NPC
,Permissible
,PersistentDataHolder
,ProjectileSource
,ServerOperator
Represents a villager NPC
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Represents the various different Villager professions there may be.static class
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 TypeMethodDescriptionvoid
Clear all reputations from this villager.Gets the current profession of this villager.getReputation(@NotNull UUID uniqueId)
Get thereputation
for a specific player byUUID
.Get allreputations
for all players mapped by theirunique IDs
.int
Gets the amount of times a villager has restocked their trades todayint
Gets the trading experience of this villager.int
Gets the level of this villager.Gets the current type of this villager.void
setProfession(@NotNull Villager.Profession profession)
Sets the new profession of this villager.void
setReputation(@NotNull UUID uniqueId, Reputation reputation)
Set thereputation
for a specific player byUUID
.void
setReputations(@NotNull Map<UUID,Reputation> reputations)
Set allreputations
for all players mapped by theirunique IDs
.void
setRestocksToday(int restocksToday)
Sets the amount of times a villager has restocked their trades todayvoid
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.boolean
Attempts to make this villager sleep at the given location.void
wakeup()
Causes this villager to wake up if he's currently sleeping.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, hideBossBar, openBook, openBook, playSound, playSound, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, showBossBar, showTitle, stopSound
Methods inherited from interface org.bukkit.entity.Breedable
canBreed, getAgeLock, setAgeLock, setBreed
Methods inherited from interface org.bukkit.command.CommandSender
getName, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage
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, eject, fromMobSpawner, getBoundingBox, getChunk, getEntityId, getEntitySpawnReason, getFacing, getFallDistance, getFireTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getNearbyEntities, getOrigin, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isGlowing, isInBubbleColumn, isInLava, isInRain, isInsideVehicle, isInvulnerable, isInWater, isInWaterOrBubbleColumn, isInWaterOrRain, isInWaterOrRainOrBubbleColumn, isOnGround, isPersistent, isSilent, isTicking, isValid, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, spigot, teleport, teleport, teleport, teleport, teleportAsync, teleportAsync
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
Methods inherited from interface org.bukkit.entity.LivingEntity
addPotionEffect, addPotionEffect, addPotionEffects, attack, clearActiveItem, getActiveItem, getActivePotionEffects, getArrowCooldown, getArrowsInBody, getArrowsStuck, getCanPickupItems, getCategory, getCollidableExemptions, getEquipment, getEyeHeight, getEyeHeight, getEyeLocation, getHandRaised, getHandRaisedTime, getHurtDirection, 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, isCollidable, isGliding, isHandRaised, isInvisible, isJumping, isLeashed, isRiptiding, isSleeping, isSwimming, playPickupItemAnimation, playPickupItemAnimation, rayTraceBlocks, rayTraceBlocks, removePotionEffect, setAI, setArrowCooldown, setArrowsInBody, setArrowsStuck, setCanPickupItems, setCollidable, setGliding, setHurtDirection, setInvisible, setJumping, setKiller, setLastDamage, setLeashHolder, setMaximumAir, setMaximumNoDamageTicks, setMemory, setNoDamageTicks, setRemainingAir, setRemoveWhenFarAway, setShieldBlockingDelay, setSwimming, 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
getHeadRotationSpeed, getMaxHeadPitch, getPathfinder, getTarget, isAware, isInDaylight, lookAt, lookAt, lookAt, lookAt, lookAt, lookAt, setAware, 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, recalculatePermissions, removeAttachment
Methods inherited from interface org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainer
Methods inherited from interface org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectile
Methods inherited from interface org.bukkit.permissions.ServerOperator
isOp, setOp
-
Method Details
-
getProfession
Gets the current profession of this villager.- Returns:
- Current profession.
-
setProfession
Sets the new profession of this villager.- Parameters:
profession
- New profession.
-
getVillagerType
Gets the current type of this villager.- Returns:
- Current type.
-
setVillagerType
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.- Parameters:
level
- the new level- Throws:
IllegalArgumentException
- if level not between [1, 5]
-
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
-
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
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
-
getReputation
Get thereputation
for a specific player byUUID
.- Parameters:
uniqueId
- TheUUID
of the player to get the reputation of.- Returns:
- The player's copied reputation with this villager.
-
getReputations
Get allreputations
for all players mapped by theirunique IDs
.- Returns:
- All
reputations
for all players in a copied map.
-
setReputation
Set thereputation
for a specific player byUUID
.- Parameters:
uniqueId
- TheUUID
of the player to set the reputation of.reputation
- Thereputation
to set.
-
setReputations
Set allreputations
for all players mapped by theirunique IDs
.- Parameters:
reputations
- Allreputations
for all players mapped by theirunique IDs
.
-
clearReputations
void clearReputations()Clear all reputations from this villager. This removes every single reputation regardless of its impact and the player associated.
-