Class VillagerOutputEvent

java.lang.Object
org.bukkit.event.Event
simplexity.villagerinfo.events.VillagerOutputEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class VillagerOutputEvent extends org.bukkit.event.Event implements org.bukkit.event.Cancellable
Called when preparing output on a villager. Requires a Bukkit Villager object and Bukkit Player object
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    VillagerOutputEvent(org.bukkit.entity.Villager villager, org.bukkit.entity.Player player)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Builds Output Component from getLobotomizedMessageComponent(), getChildVillagerAgeMessageComponent(), getVillagerHealthMessageComponent(), getVillagerProfessionMessageComponent(), getVillagerJobsiteLocationMessageComponent(), getVillagerLastWorkedGameTimeMessageComponent(), getVillagerRestocksTodayMessageComponent(), getVillagerBedLocationMessageComponent(), getVillagerLastSleptGameTimeMessageComponent(), getVillagerInventoryMessageComponent(), and getPlayerReputationMessageComponent()
    Uses PLUGIN_PREFIX from ServerMessage enum
    If all those methods return null, uses NO_INFORMATION_TO_DISPLAY from VillagerMessage enum
    void
    Checks player's output toggle state and sets playerOutputToggleEnabled
    Gets how many ticks until the villager becomes an adult
    Returns 0 if the villager is already an adult
    net.kyori.adventure.text.Component
    Gets the Component for the Child Villager Age Message
    Uses BABY_VILLAGER_AGE message from VillagerMessage enum
    Gets the current game time
    static org.bukkit.event.HandlerList
    Gets the handler list for this evene
    @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this evene
    Gets whether the villager has been lobotomized by Purpur's lobotomize setting
    net.kyori.adventure.text.Component
    Gets the Component for the Lobotomized Message
    Uses PURPUR_LOBOTOMIZED from VillagerMessage enum
    Uses TRUE_MESSAGE_FORMAT and FALSE_MESSAGE_FORMAT from MessageInsert enum
    net.kyori.adventure.text.Component
    Get the Component that is to be sent to the player
    org.bukkit.entity.Player
    Gets the player involved in this event
    Manually calculates the player's reputation
    net.kyori.adventure.text.Component
    Gets the Component for the Player Reputation message
    Uses REPUTATION_TOTAL_FORMAT message from MessageInsert enum
    Uses PLAYER_REPUTATION_MESSAGE message from VillagerMessage enum
    org.bukkit.entity.Villager
    Gets this villager
    org.bukkit.Location
    Gets the location of this villager's bed
    net.kyori.adventure.text.Component
    Gets the Component for the Villager Bed Location message
    Uses VILLAGER_BED_LOCATION from VillagerMessage enum
    Gets the villager's current health
    net.kyori.adventure.text.Component
    Gets the Component for the Villager Health message
    Uses VILLAGER_HEALTH message from VillagerMessage enum
    org.bukkit.inventory.Inventory
    Gets this villager's inventory object
    net.kyori.adventure.text.Component
    Gets the Component for the Villager Inventory message
    Uses VILLAGER_INVENTORY from VillagerMessage enum
    Uses EMPTY_MESSAGE_FORMAT from MessageInsert enum if the inventory is empty
    Uses villagerInventoryItem() to format item Components
    org.bukkit.Location
    Gets the location of this villager's workstation
    net.kyori.adventure.text.Component
     
    Gets the GameTime tick when the villager last slept
    Returns 0L if they have never slept
    net.kyori.adventure.text.Component
    Gets the Component for the Villager Last Slept message
    Uses VILLAGER_LAST_SLEPT from VillagerMessage enum
    Gets the GameTime tick when the villager last worked at a workstation
    Returns 0L if they have never worked at a workstation
    net.kyori.adventure.text.Component
    Gets the Component for the Villager Last Worked message
    Uses VILLAGER_LAST_WORKED message from VillagerMessage enum
    Gets the villager's max health
    org.bukkit.entity.Villager.Profession
    Gets this villager's profession
    net.kyori.adventure.text.Component
    Gets the Component for the Villager Profession message
    Uses VILLAGER_PROFESSION message from VillagerMessage enum
    Gets the number of times the villager has restocked today
    net.kyori.adventure.text.Component
    Gets the Component for the Villager Restocks Today message
    Uses the VILLAGER_RESTOCKS_TODAY message from VillagerMessage enum
    boolean
    Gets whether this event has been cancelled
    boolean
    Gets playerOutputToggleEnabled
    void
    Sends outputComponent to player if the player's toggle is enabled
    void
    setCancelled(boolean cancel)
    Sets whether this event should be cancelled
    void
    setOutputComponent(net.kyori.adventure.text.Component outputComponent)
    Set the component that should be sent to the player
    void
    setOverridePlayerOutputToggleEnabled(boolean playerOutputToggleEnabled)
    Overrides the playerOutputToggleEnabled value, sets it to a new value regardless of the player's settings
    net.kyori.adventure.text.Component
    villagerInventoryItem(org.bukkit.inventory.ItemStack itemStack)
    Gets the Component for an item in a villager's inventory
    Uses VILLAGER_INVENTORY_ITEM_FORMAT from VillagerMessage enum

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VillagerOutputEvent

      public VillagerOutputEvent(org.bukkit.entity.Villager villager, org.bukkit.entity.Player player)
  • Method Details

    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Gets the handler list for this evene
      Specified by:
      getHandlers in class org.bukkit.event.Event
      Returns:
      HandlerList
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Gets the handler list for this evene
      Returns:
      HandlerList
    • getCurrentGameTime

      public Long getCurrentGameTime()
      Gets the current game time
      Returns:
      Long
    • getLobotomized

      public Boolean getLobotomized()
      Gets whether the villager has been lobotomized by Purpur's lobotomize setting
      Returns:
      Boolean
    • getLobotomizedMessageComponent

      public net.kyori.adventure.text.Component getLobotomizedMessageComponent()
      Gets the Component for the Lobotomized Message
      Uses PURPUR_LOBOTOMIZED from VillagerMessage enum
      Uses TRUE_MESSAGE_FORMAT and FALSE_MESSAGE_FORMAT from MessageInsert enum
      Returns:
      Component
    • getChildVillagerAge

      public Long getChildVillagerAge()
      Gets how many ticks until the villager becomes an adult
      Returns 0 if the villager is already an adult
      Returns:
      Long
    • getChildVillagerAgeMessageComponent

      public net.kyori.adventure.text.Component getChildVillagerAgeMessageComponent()
      Gets the Component for the Child Villager Age Message
      Uses BABY_VILLAGER_AGE message from VillagerMessage enum
      Returns:
      Component
    • getVillagerLastWorkedGameTime

      public Long getVillagerLastWorkedGameTime()
      Gets the GameTime tick when the villager last worked at a workstation
      Returns 0L if they have never worked at a workstation
      Returns:
      Long
    • getVillagerLastWorkedGameTimeMessageComponent

      public net.kyori.adventure.text.Component getVillagerLastWorkedGameTimeMessageComponent()
      Gets the Component for the Villager Last Worked message
      Uses VILLAGER_LAST_WORKED message from VillagerMessage enum
      Returns:
      Component
    • getVillagerLastSleptGameTime

      public Long getVillagerLastSleptGameTime()
      Gets the GameTime tick when the villager last slept
      Returns 0L if they have never slept
      Returns:
      Long
    • getVillagerLastSleptGameTimeMessageComponent

      public net.kyori.adventure.text.Component getVillagerLastSleptGameTimeMessageComponent()
      Gets the Component for the Villager Last Slept message
      Uses VILLAGER_LAST_SLEPT from VillagerMessage enum
      Returns:
      Component
    • getVillagerCurrentHealth

      public Double getVillagerCurrentHealth()
      Gets the villager's current health
      Returns:
      Double
    • getVillagerMaxHealth

      public Double getVillagerMaxHealth()
      Gets the villager's max health
      Returns:
      Double
    • getVillagerHealthMessageComponent

      public net.kyori.adventure.text.Component getVillagerHealthMessageComponent()
      Gets the Component for the Villager Health message
      Uses VILLAGER_HEALTH message from VillagerMessage enum
      Returns:
      Component
    • getVillagerRestocksToday

      public Integer getVillagerRestocksToday()
      Gets the number of times the villager has restocked today
      Returns:
      Integer
    • getVillagerRestocksTodayMessageComponent

      public net.kyori.adventure.text.Component getVillagerRestocksTodayMessageComponent()
      Gets the Component for the Villager Restocks Today message
      Uses the VILLAGER_RESTOCKS_TODAY message from VillagerMessage enum
      Returns:
      Component
    • getPlayerReputation

      public Integer getPlayerReputation()
      Manually calculates the player's reputation
      Returns:
      Integer
    • getPlayerReputationMessageComponent

      public net.kyori.adventure.text.Component getPlayerReputationMessageComponent()
      Gets the Component for the Player Reputation message
      Uses REPUTATION_TOTAL_FORMAT message from MessageInsert enum
      Uses PLAYER_REPUTATION_MESSAGE message from VillagerMessage enum
      Returns:
      Component
    • getVillagerProfession

      public org.bukkit.entity.Villager.Profession getVillagerProfession()
      Gets this villager's profession
      Returns:
      Villager.Profession
    • getVillagerProfessionMessageComponent

      public net.kyori.adventure.text.Component getVillagerProfessionMessageComponent()
      Gets the Component for the Villager Profession message
      Uses VILLAGER_PROFESSION message from VillagerMessage enum
      Returns:
      Component
    • getVillagerInventory

      public org.bukkit.inventory.Inventory getVillagerInventory()
      Gets this villager's inventory object
      Returns:
      Inventory
    • villagerInventoryItem

      public net.kyori.adventure.text.Component villagerInventoryItem(org.bukkit.inventory.ItemStack itemStack)
      Gets the Component for an item in a villager's inventory
      Uses VILLAGER_INVENTORY_ITEM_FORMAT from VillagerMessage enum
      Parameters:
      itemStack - ItemStack
      Returns:
      Component
    • getVillagerInventoryMessageComponent

      public net.kyori.adventure.text.Component getVillagerInventoryMessageComponent()
      Gets the Component for the Villager Inventory message
      Uses VILLAGER_INVENTORY from VillagerMessage enum
      Uses EMPTY_MESSAGE_FORMAT from MessageInsert enum if the inventory is empty
      Uses villagerInventoryItem() to format item Components
      Returns:
      Component
    • getVillagerJobsiteLocation

      public org.bukkit.Location getVillagerJobsiteLocation()
      Gets the location of this villager's workstation
      Returns:
      Location
    • getVillagerJobsiteLocationMessageComponent

      public net.kyori.adventure.text.Component getVillagerJobsiteLocationMessageComponent()
    • getVillagerBedLocation

      public org.bukkit.Location getVillagerBedLocation()
      Gets the location of this villager's bed
      Returns:
      Location
    • getVillagerBedLocationMessageComponent

      public net.kyori.adventure.text.Component getVillagerBedLocationMessageComponent()
      Gets the Component for the Villager Bed Location message
      Uses VILLAGER_BED_LOCATION from VillagerMessage enum
      Returns:
      Component
    • buildOutputComponent

      public void buildOutputComponent()
      Builds Output Component from getLobotomizedMessageComponent(), getChildVillagerAgeMessageComponent(), getVillagerHealthMessageComponent(), getVillagerProfessionMessageComponent(), getVillagerJobsiteLocationMessageComponent(), getVillagerLastWorkedGameTimeMessageComponent(), getVillagerRestocksTodayMessageComponent(), getVillagerBedLocationMessageComponent(), getVillagerLastSleptGameTimeMessageComponent(), getVillagerInventoryMessageComponent(), and getPlayerReputationMessageComponent()
      Uses PLUGIN_PREFIX from ServerMessage enum
      If all those methods return null, uses NO_INFORMATION_TO_DISPLAY from VillagerMessage enum
    • sendOutputToPlayer

      public void sendOutputToPlayer()
      Sends outputComponent to player if the player's toggle is enabled
    • getVillager

      public org.bukkit.entity.Villager getVillager()
      Gets this villager
      Returns:
      org.bukkit.entity.Villager
    • getPlayer

      public org.bukkit.entity.Player getPlayer()
      Gets the player involved in this event
      Returns:
      org.bukkit.entity.Player
    • checkPlayerPDC

      public void checkPlayerPDC()
      Checks player's output toggle state and sets playerOutputToggleEnabled
    • isPlayerOutputToggleEnabled

      public boolean isPlayerOutputToggleEnabled()
      Gets playerOutputToggleEnabled
      Returns:
      boolean
    • setOverridePlayerOutputToggleEnabled

      public void setOverridePlayerOutputToggleEnabled(boolean playerOutputToggleEnabled)
      Overrides the playerOutputToggleEnabled value, sets it to a new value regardless of the player's settings
      Parameters:
      playerOutputToggleEnabled - boolean
    • isCancelled

      public boolean isCancelled()
      Gets whether this event has been cancelled
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
      Returns:
      boolean
    • setCancelled

      public void setCancelled(boolean cancel)
      Sets whether this event should be cancelled
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
    • setOutputComponent

      public void setOutputComponent(net.kyori.adventure.text.Component outputComponent)
      Set the component that should be sent to the player
      Parameters:
      outputComponent - Component
    • getOutputComponent

      public net.kyori.adventure.text.Component getOutputComponent()
      Get the Component that is to be sent to the player
      Returns:
      Component