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
Represents a villager NPC
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents the various different Villager professions there may be.static enumRepresents Villager type, usually corresponding to what biome they spawn in.Nested classes/interfaces inherited from interface org.bukkit.entity.EntityEntity.Spigot
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaddTrades(int amount) Gives to this villager some potential new trades based to its profession and level.voidClear all reputations from this villager.Gets the current profession of this villager.getReputation(@NotNull UUID uniqueId) Get thereputationfor a specific player byUUID.Get allreputationsfor all players mapped by theirunique IDs.intGets the amount of times a villager has restocked their trades todayintGets the trading experience of this villager.intGets the level of this villager.Gets the current type of this villager.booleanincreaseLevel(int amount) Increases the level of this villager.voidsetProfession(@NotNull Villager.Profession profession) Sets the new profession of this villager.voidsetReputation(@NotNull UUID uniqueId, Reputation reputation) Set thereputationfor a specific player byUUID.voidsetReputations(@NotNull Map<UUID, Reputation> reputations) Set allreputationsfor all players mapped by theirunique IDs.voidsetRestocksToday(int restocksToday) Sets the amount of times a villager has restocked their trades todayvoidsetVillagerExperience(int experience) Sets the trading experience of this villager.voidsetVillagerLevel(int level) Sets the level of this villager.voidSets the new type of this villager.voidCauses this villager to shake his head.booleanAttempts to make this villager sleep at the given location.voidwakeup()Causes this villager to wake up if he's currently sleeping.zombify()Convert this Villager into a ZombieVillager as if it was killed by a Zombie.Methods inherited from interface org.bukkit.entity.AbstractVillagergetInventory, resetOffersMethods inherited from interface org.bukkit.entity.AgeablegetAge, isAdult, setAdult, setAge, setBabyMethods inherited from interface org.bukkit.attribute.AttributablegetAttribute, registerAttributeMethods inherited from interface net.kyori.adventure.audience.AudienceclearTitle, 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, stopSoundMethods inherited from interface org.bukkit.entity.BreedablecanBreed, getAgeLock, setAgeLock, setBreedMethods inherited from interface org.bukkit.command.CommandSendergetName, name, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlainMessage, sendRichMessage, sendRichMessageMethods inherited from interface org.bukkit.entity.Damageabledamage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealthMethods inherited from interface org.bukkit.entity.EntityaddPassenger, addScoreboardTag, asHoverEvent, collidesAt, eject, fromMobSpawner, getBoundingBox, getChunk, getEntityId, getEntitySpawnReason, getFacing, getFallDistance, getFireTicks, getFreezeTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getMaxFreezeTicks, getNearbyEntities, getOrigin, getPassenger, getPassengers, getPistonMoveReaction, getPitch, getPortalCooldown, getPose, getScheduler, getScoreboardEntryName, getScoreboardTags, getServer, getSpawnCategory, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTicksLived, getTrackedPlayers, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, getX, getY, getYaw, getZ, hasFixedPose, hasGravity, isCustomNameVisible, isDead, isEmpty, isFreezeTickingLocked, isFrozen, isGlowing, isInBubbleColumn, isInLava, isInPowderedSnow, isInRain, isInsideVehicle, isInvulnerable, isInWater, isInWaterOrBubbleColumn, isInWaterOrRain, isInWaterOrRainOrBubbleColumn, isOnGround, isPersistent, isSilent, isSneaking, isTicking, isUnderWater, isValid, isVisibleByDefault, isVisualFire, leaveVehicle, lockFreezeTicks, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setFreezeTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setPose, setPose, setRotation, setSilent, setSneaking, setTicksLived, setVelocity, setVisibleByDefault, setVisualFire, spawnAt, spawnAt, spigot, teamDisplayName, teleport, teleport, teleport, teleport, teleport, teleport, teleportAsync, teleportAsync, wouldCollideUsingMethods inherited from interface io.papermc.paper.entity.FrictionalgetFrictionState, setFrictionStateMethods inherited from interface net.kyori.adventure.text.event.HoverEventSourceasHoverEventMethods inherited from interface org.bukkit.entity.LivingEntityaddPotionEffect, addPotionEffect, addPotionEffects, attack, broadcastSlotBreak, broadcastSlotBreak, canBreatheUnderwater, clearActiveItem, clearActivePotionEffects, damageItemStack, damageItemStack, getActiveItem, getActivePotionEffects, getArrowCooldown, getArrowsInBody, getArrowsStuck, getBeeStingerCooldown, getBeeStingersInBody, getBodyYaw, 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, getNoActionTicks, getNoDamageTicks, getPotionEffect, getRemainingAir, getRemoveWhenFarAway, getShieldBlockingDelay, getTargetBlock, getTargetBlock, getTargetBlock, getTargetBlockExact, getTargetBlockExact, getTargetBlockFace, getTargetBlockFace, getTargetBlockFace, getTargetBlockInfo, getTargetBlockInfo, getTargetEntity, getTargetEntity, getTargetEntityInfo, getTargetEntityInfo, hasAI, hasLineOfSight, hasLineOfSight, hasPotionEffect, isClimbing, isCollidable, isGliding, isHandRaised, isInvisible, isJumping, isLeashed, isRiptiding, isSleeping, isSwimming, knockback, playHurtAnimation, playPickupItemAnimation, playPickupItemAnimation, rayTraceBlocks, rayTraceBlocks, rayTraceEntities, rayTraceEntities, removePotionEffect, setAI, setArrowCooldown, setArrowsInBody, setArrowsInBody, setArrowsStuck, setBeeStingerCooldown, setBeeStingersInBody, setBodyYaw, setCanPickupItems, setCollidable, setGliding, setHurtDirection, setInvisible, setJumping, setKiller, setLastDamage, setLeashHolder, setMaximumAir, setMaximumNoDamageTicks, setMemory, setNoActionTicks, setNoDamageTicks, setRemainingAir, setRemoveWhenFarAway, setShieldBlockingDelay, setSwimming, swingHand, swingMainHand, swingOffHandMethods inherited from interface org.bukkit.loot.LootableclearLootTable, getLootTable, getSeed, hasLootTable, setLootTable, setLootTable, setSeedMethods inherited from interface org.bukkit.inventory.MerchantgetRecipe, getRecipeCount, getRecipes, getTrader, isTrading, setRecipe, setRecipesMethods inherited from interface org.bukkit.metadata.MetadatablegetMetadata, hasMetadata, removeMetadata, setMetadataMethods inherited from interface org.bukkit.entity.MobgetAmbientSound, getEquipment, getHeadRotationSpeed, getMaxHeadPitch, getPathfinder, getPossibleExperienceReward, getTarget, isAware, isInDaylight, isLeftHanded, lookAt, lookAt, lookAt, lookAt, lookAt, lookAt, setAware, setLeftHanded, setTargetMethods inherited from interface org.bukkit.NameablecustomName, customName, getCustomName, setCustomNameMethods inherited from interface org.bukkit.permissions.PermissibleaddAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, permissionValue, permissionValue, recalculatePermissions, removeAttachmentMethods inherited from interface org.bukkit.persistence.PersistentDataHoldergetPersistentDataContainerMethods inherited from interface net.kyori.adventure.pointer.Pointeredget, getOrDefault, getOrDefaultFrom, pointersMethods inherited from interface org.bukkit.projectiles.ProjectileSourcelaunchProjectile, launchProjectile, launchProjectileMethods inherited from interface org.bukkit.permissions.ServerOperatorisOp, setOp
- 
Method Details- 
getProfessionGets the current profession of this villager.- Returns:
- Current profession.
 
- 
setProfessionSets the new profession of this villager.- Parameters:
- profession- New profession.
 
- 
getVillagerTypeGets the current type of this villager.- Returns:
- Current type.
 
- 
setVillagerTypeSets the new type of this villager.- Parameters:
- type- New type.
 
- 
getVillagerLevelint 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
 
- 
setVillagerLevelvoid 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:
 
- 
getVillagerExperienceint getVillagerExperience()Gets the trading experience of this villager.- Returns:
- trading experience
 
- 
setVillagerExperiencevoid setVillagerExperience(int experience) Sets the trading experience of this villager.- Parameters:
- experience- new experience
- Throws:
- IllegalArgumentException- if experience < 0
 
- 
increaseLevelboolean increaseLevel(int amount) Increases the level of this villager. The villager will also unlock new recipes unlike the raw methodsetVillagerLevel(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:
 
- 
addTradesboolean 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
 
- 
getRestocksTodayint getRestocksToday()Gets the amount of times a villager has restocked their trades today- Returns:
- The amount of trade restocks.
 
- 
setRestocksTodayvoid setRestocksToday(int restocksToday) Sets the amount of times a villager has restocked their trades today- Parameters:
- restocksToday- new restock count
 
- 
sleepAttempts 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
 
- 
wakeupvoid wakeup()Causes this villager to wake up if he's currently sleeping.- Throws:
- IllegalStateException- if not sleeping
 
- 
shakeHeadvoid shakeHead()Causes this villager to shake his head.
- 
zombifyConvert this Villager into a ZombieVillager as if it was killed by a Zombie. Note: this will fire a EntityTransformEvent- Returns:
- the converted entity ZombieVillageror null if the conversion its cancelled
 
- 
getReputationGet thereputationfor a specific player byUUID.- Parameters:
- uniqueId- The- UUIDof the player to get the reputation of.
- Returns:
- The player's copied reputation with this villager.
 
- 
getReputationsGet allreputationsfor all players mapped by theirunique IDs.- Returns:
- All reputationsfor all players in a copied map.
 
- 
setReputationSet thereputationfor a specific player byUUID.- Parameters:
- uniqueId- The- UUIDof the player to set the reputation of.
- reputation- The- reputationto set.
 
- 
setReputationsSet allreputationsfor all players mapped by theirunique IDs.- Parameters:
- reputations- All- reputationsfor all players mapped by their- unique IDs.
 
- 
clearReputationsvoid clearReputations()Clear all reputations from this villager. This removes every single reputation regardless of its impact and the player associated.
 
-