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

public interface Villager extends AbstractVillager
Represents a villager NPC
  • Method Details

    • 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.
      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

      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

      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.