HyCitizens fires four events that other plugins can listen to viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ElectroGamesDev/HyCitizens/llms.txt
Use this file to discover all available pages before exploring further.
CitizensManager. Every listener interface is annotated @FunctionalInterface, so you can register lambdas directly without implementing a named class. Listeners are invoked synchronously on the same thread that fires the event.
Registering a Listener
CitizenInteractEvent
CitizenInteractEvent is fired whenever a player interacts with a Citizen — either by left-clicking the NPC or pressing the F-key when prompted.
Cancellable: calling event.setCancelled(true) prevents the Citizen’s commands and messages from executing. The interaction is consumed but no actions are taken.
Methods
getCitizen() → CitizenData
getCitizen() → CitizenData
Returns the
CitizenData of the Citizen that was interacted with.getPlayer() → PlayerRef
getPlayer() → PlayerRef
Returns the
PlayerRef of the player who triggered the interaction.isCancelled() → boolean
isCancelled() → boolean
Returns
true if the event has been cancelled.setCancelled(boolean)
setCancelled(boolean)
Set to
true to suppress all commands and messages that would normally fire from this interaction.Registration
Example
CitizenInteractEvent
CitizenAddedEvent
CitizenAddedEvent is fired immediately after a new Citizen is registered in the manager via CitizensManager.addCitizen(...). The NPC entity may not yet be spawned in the world at the moment this event fires.
Not cancellable.
Methods
getCitizen() → CitizenData
getCitizen() → CitizenData
Returns the
CitizenData of the newly added Citizen.Registration
Example
CitizenAddedEvent
CitizenRemovedEvent
CitizenRemovedEvent is fired after a Citizen has been fully removed from the manager — the NPC and hologram are already despawned and the config entry has been deleted by the time this event fires.
Not cancellable.
Methods
getCitizen() → CitizenData
getCitizen() → CitizenData
Returns the
CitizenData of the Citizen that was removed. The object is still populated with its last known state, but the Citizen is no longer accessible through the manager.Registration
Example
CitizenRemovedEvent
CitizenDeathEvent
CitizenDeathEvent is fired when a Citizen’s NPC entity health reaches zero. This event only fires for Citizens that have takesDamage set to true.
Cancellable: calling event.setCancelled(true) prevents the full death sequence — loot drops, death commands/messages, and respawn scheduling are all suppressed. The NPC entity will still have taken lethal damage in the ECS.
Methods
getCitizen() → CitizenData
getCitizen() → CitizenData
Returns the
CitizenData of the Citizen that died.getKiller() → PlayerRef (nullable)
getKiller() → PlayerRef (nullable)
Returns the
PlayerRef of the player who delivered the killing blow, or null if the Citizen was killed by the environment or a non-player source.isCancelled() → boolean
isCancelled() → boolean
Returns
true if the death event has been cancelled.setCancelled(boolean)
setCancelled(boolean)
Set to
true to suppress drops, death commands, death messages, and respawn scheduling.Registration
Example
CitizenDeathEvent
Event Summary
CitizenInteractEvent
Fired on player interaction (left-click or F-key). Cancellable — prevents commands and messages from executing.
CitizenAddedEvent
Fired when a new Citizen is registered via
addCitizen. Not cancellable.CitizenRemovedEvent
Fired after a Citizen is permanently deleted. Not cancellable.
CitizenDeathEvent
Fired when a damageable Citizen’s NPC dies. Cancellable — prevents drops, death commands, and respawn scheduling.