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,Pointered,ProjectileSource,ServerOperator,Sound.Emitter
Represents a villager NPC
-
Nested Class Summary
Nested 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.Entity
Entity.Spigot -
Method Summary
Modifier and TypeMethodDescriptionvoidClear 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.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.AbstractVillager
getInventory, resetOffersMethods inherited from interface org.bukkit.entity.Ageable
getAge, isAdult, setAdult, setAge, setBabyMethods inherited from interface org.bukkit.attribute.Attributable
getAttribute, registerAttributeMethods inherited from interface net.kyori.adventure.audience.Audience
clearTitle, filterAudience, forEachAudience, hideBossBar, openBook, openBook, playSound, playSound, playSound, resetTitle, sendActionBar, sendActionBar, 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.Breedable
canBreed, getAgeLock, setAgeLock, setBreedMethods inherited from interface org.bukkit.command.CommandSender
getName, name, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlainMessage, sendRichMessageMethods inherited from interface org.bukkit.entity.Damageable
damage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealthMethods inherited from interface org.bukkit.entity.Entity
addPassenger, addScoreboardTag, asHoverEvent, 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, 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, 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, teleportAsyncMethods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEventMethods inherited from interface org.bukkit.entity.LivingEntity
addPotionEffect, addPotionEffect, addPotionEffects, attack, clearActiveItem, getActiveItem, getActivePotionEffects, getArrowCooldown, getArrowsInBody, getArrowsStuck, getBeeStingerCooldown, getBeeStingersInBody, getCanPickupItems, getCategory, getCollidableExemptions, 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, isClimbing, isCollidable, isGliding, isHandRaised, isInvisible, isJumping, isLeashed, isRiptiding, isSleeping, isSwimming, 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, swingMainHand, swingOffHandMethods inherited from interface org.bukkit.loot.Lootable
clearLootTable, getLootTable, getSeed, hasLootTable, setLootTable, setLootTable, setSeedMethods inherited from interface org.bukkit.inventory.Merchant
getRecipe, getRecipeCount, getRecipes, getTrader, isTrading, setRecipe, setRecipesMethods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadataMethods inherited from interface org.bukkit.entity.Mob
getEquipment, getHeadRotationSpeed, getMaxHeadPitch, getPathfinder, getTarget, isAware, isInDaylight, isLeftHanded, lookAt, lookAt, lookAt, lookAt, lookAt, lookAt, setAware, setLeftHanded, setTargetMethods inherited from interface org.bukkit.Nameable
customName, customName, getCustomName, setCustomNameMethods inherited from interface org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, permissionValue, permissionValue, recalculatePermissions, removeAttachmentMethods inherited from interface org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainerMethods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom, pointersMethods inherited from interface org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectileMethods 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
-
shakeHead
void shakeHead()Causes this villager to shake his head. -
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
ZombieVillageror null if the conversion its cancelled
-
getReputation
Get thereputationfor a specific player byUUID.- Parameters:
uniqueId- TheUUIDof the player to get the reputation of.- Returns:
- The player's copied reputation with this villager.
-
getReputations
Get allreputationsfor all players mapped by theirunique IDs.- Returns:
- All
reputationsfor all players in a copied map.
-
setReputation
Set thereputationfor a specific player byUUID.- Parameters:
uniqueId- TheUUIDof the player to set the reputation of.reputation- Thereputationto set.
-
setReputations
Set allreputationsfor all players mapped by theirunique IDs.- Parameters:
reputations- Allreputationsfor 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.
-