Package simplexity.villagerinfo.events
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
ConstructorDescriptionVillagerOutputEvent
(org.bukkit.entity.Villager villager, org.bukkit.entity.Player player) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 enumvoid
Checks player's output toggle state and sets playerOutputToggleEnabledGets how many ticks until the villager becomes an adult
Returns 0 if the villager is already an adultnet.kyori.adventure.text.Component
Gets the Component for the Child Villager Age Message
Uses BABY_VILLAGER_AGE message from VillagerMessage enumGets the current game timestatic org.bukkit.event.HandlerList
Gets the handler list for this evene@NotNull org.bukkit.event.HandlerList
Gets the handler list for this eveneGets whether the villager has been lobotomized by Purpur's lobotomize settingnet.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 enumnet.kyori.adventure.text.Component
Get the Component that is to be sent to the playerorg.bukkit.entity.Player
Gets the player involved in this eventManually calculates the player's reputationnet.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 enumorg.bukkit.entity.Villager
Gets this villagerorg.bukkit.Location
Gets the location of this villager's bednet.kyori.adventure.text.Component
Gets the Component for the Villager Bed Location message
Uses VILLAGER_BED_LOCATION from VillagerMessage enumGets the villager's current healthnet.kyori.adventure.text.Component
Gets the Component for the Villager Health message
Uses VILLAGER_HEALTH message from VillagerMessage enumorg.bukkit.inventory.Inventory
Gets this villager's inventory objectnet.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 Componentsorg.bukkit.Location
Gets the location of this villager's workstationnet.kyori.adventure.text.Component
Gets the GameTime tick when the villager last slept
Returns 0L if they have never sleptnet.kyori.adventure.text.Component
Gets the Component for the Villager Last Slept message
Uses VILLAGER_LAST_SLEPT from VillagerMessage enumGets the GameTime tick when the villager last worked at a workstation
Returns 0L if they have never worked at a workstationnet.kyori.adventure.text.Component
Gets the Component for the Villager Last Worked message
Uses VILLAGER_LAST_WORKED message from VillagerMessage enumGets the villager's max healthorg.bukkit.entity.Villager.Profession
Gets this villager's professionnet.kyori.adventure.text.Component
Gets the Component for the Villager Profession message
Uses VILLAGER_PROFESSION message from VillagerMessage enumGets the number of times the villager has restocked todaynet.kyori.adventure.text.Component
Gets the Component for the Villager Restocks Today message
Uses the VILLAGER_RESTOCKS_TODAY message from VillagerMessage enumboolean
Gets whether this event has been cancelledboolean
Gets playerOutputToggleEnabledvoid
Sends outputComponent to player if the player's toggle is enabledvoid
setCancelled
(boolean cancel) Sets whether this event should be cancelledvoid
setOutputComponent
(net.kyori.adventure.text.Component outputComponent) Set the component that should be sent to the playervoid
setOverridePlayerOutputToggleEnabled
(boolean playerOutputToggleEnabled) Overrides the playerOutputToggleEnabled value, sets it to a new value regardless of the player's settingsnet.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 enumMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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 classorg.bukkit.event.Event
- Returns:
- HandlerList
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Gets the handler list for this evene- Returns:
- HandlerList
-
getCurrentGameTime
Gets the current game time- Returns:
- Long
-
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
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
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
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
Gets the villager's current health- Returns:
- 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
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
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 interfaceorg.bukkit.event.Cancellable
- Returns:
- boolean
-
setCancelled
public void setCancelled(boolean cancel) Sets whether this event should be cancelled- Specified by:
setCancelled
in interfaceorg.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
-