Documentation 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 is the primary API class in HyCitizens. Every operation that creates, queries, modifies, or removes a Citizen NPC goes through this single entry point. Retrieve the singleton instance at any time through the plugin accessor:
Citizen CRUD
Methods for adding, updating, and removing Citizens from the world and from persistent storage.addCitizen
CitizenData object, spawns the NPC entity in its configured world, and fires a CitizenAddedEvent. When save is true the Citizen is also written to disk immediately.
The fully-configured Citizen to add. The
id field must be unique across all loaded Citizens.When
true, persists the Citizen to disk before spawning.updateCitizen
The updated CitizenData. The
id must match an already-loaded Citizen.When
true, persists changes to disk.updateCitizenNPC
updateCitizen when only combat stats or equipment changed.
The updated CitizenData.
When
true, persists changes to disk.updateCitizenHologram
name, hideNametag, nametagOffset, or model-nametag settings.
The updated CitizenData.
When
true, persists changes to disk after the hologram update.removeCitizen
CitizenRemovedEvent. This operation is irreversible.
The unique ID of the Citizen to remove.
saveCitizen
CitizenData object to disk without respawning anything. Call this after mutating fields directly on a Citizen when you do not need to refresh the in-world entity.
The Citizen whose state should be persisted.
Querying Citizens
getCitizen
CitizenData for the given ID, or null if no Citizen with that ID is loaded.
The unique Citizen ID to look up.
getAllCitizens
CitizenData objects. The returned list is a copy and may be iterated freely without external synchronisation.
getCitizenCount
citizenExists
true if a Citizen with the given ID is present in the manager.
The unique Citizen ID to check.
getCitizensNear
maxDistance blocks of position. The check uses the configured spawn position, not the NPC’s current live position.
The origin point for the distance check.
Maximum inclusive distance in blocks.
getCitizensByGroup
group field exactly matches groupName (case-sensitive, slash-normalised). Does not return Citizens in child groups — use respawnCitizensInGroup with includeChildren = true for hierarchical traversal.
The exact group path to match, e.g.
"Town/Guards".Spawning & Respawning
spawnCitizen
The Citizen to spawn. Must already exist in the manager.
When
true, saves the spawned UUID to disk after spawn.respawnAllCitizens
When
true, persists each Citizen after respawning.respawnCitizensInGroup
includeChildren is true, Citizens in sub-groups (e.g. Town/Guards/Elite) are also included. Passing null or an empty string for groupName respawns every Citizen. Returns the number of Citizens queued.
The group path to target. Pass
null or "" to target all Citizens.When
true, Citizens in child group paths are also respawned.When
true, persists each Citizen after respawning.scheduleCitizenRespawn
delayMs milliseconds. The pending timestamp is persisted so respawns survive server restarts. Any previously scheduled respawn for this Citizen is cancelled first.
The Citizen to schedule a respawn for.
Delay in milliseconds before the Citizen is respawned. Values below
0 are clamped to 0.Teleporting
teleportCitizen
position. If rotation is non-null, the entity’s facing direction is also updated. The Citizen’s leash point is moved to the new position. Has no effect if the Citizen has no live NPC entity.
The Citizen to teleport.
The target world-space position.
Optional new rotation (pitch/yaw/roll in radians). Pass
null to keep the current rotation.teleportCitizenToSpawn
position and rotation as stored in CitizenData.
The Citizen to return to its spawn location.
Movement Control
startCitizenPatrol
PATROL; otherwise the call is ignored.
The ID of the Citizen to start patrolling.
The name of the patrol path as defined in the patrol configuration.
stopCitizenPatrol
The ID of the Citizen whose patrol should be stopped.
isCitizenPatrolling
true if the specified Citizen is currently executing a patrol path.
The ID of the Citizen to check.
getCitizenActivePatrolPath
null if the Citizen is not patrolling.
The ID of the Citizen to query.
moveCitizenToPosition
position. This works through the patrol manager’s move-target mechanism.
The ID of the Citizen to move.
The world-space destination.
stopCitizenMovement
The ID of the Citizen to halt.
Runtime Configuration
setCitizenCombatConfig
CombatConfig, saves, and respawns the NPC entity to apply the new settings. Has no effect if no Citizen with citizenId is loaded.
The ID of the target Citizen.
The new combat configuration to apply.
setCitizenDetectionConfig
DetectionConfig, saves, and respawns the NPC entity. Has no effect if no Citizen with citizenId is loaded.
The ID of the target Citizen.
The new detection configuration to apply.
setCitizenPathConfig
PathConfig, saves, and respawns the NPC entity. Has no effect if no Citizen with citizenId is loaded.
The ID of the target Citizen.
The new path configuration to apply.
forceAttackEntity
The Citizen to override the attack for.
The interaction asset ID of the attack to force, e.g.
"Root_NPC_Attack_Melee".autoResolveAttackType
modelId using the built-in model-to-interaction map and writes the result directly to citizen.getCombatConfig().setAttackType(...). Call saveCitizen and updateCitizenNPC afterward if you want the change to be persisted and applied in-world.
The Citizen whose attack type should be resolved.
Combat State
isCitizenInCombat
true if the Citizen’s current AI state name contains "combat" (case-insensitive). Returns false if the NPC entity is not valid or has no state.
The Citizen to inspect.
isCitizenInAiBusyState
true if the Citizen is in any of the following AI states: combat, alerted, investigate, returnhome, or search. Useful for blocking interactions or follow-citizen ticks during active AI engagement.
The Citizen to inspect.
Group Management
getAllGroups
createGroup
The slash-delimited group path to create, e.g.
"Town/Guards".deleteGroup
group matches the deleted path (or any child path) have their group reset to "" and are saved immediately.
The group path to delete.
renameGroup
false if oldName does not exist, newName already exists, or either name is blank.
The current group path.
The desired new group path.
groupExists
true if the normalised form of groupName is registered as a group.
The group path to check.
Events
Register listeners to be notified when Citizens are added, removed, interacted with, or killed. All listener interfaces are@FunctionalInterface, so lambdas work directly.
| Method | Event fired when… |
|---|---|
addCitizenAddedListener(CitizenAddedListener) / removeCitizenAddedListener | A new Citizen is registered via addCitizen. |
addCitizenRemovedListener(CitizenRemovedListener) / removeCitizenRemovedListener | A Citizen is permanently deleted via removeCitizen. |
addCitizenInteractListener(CitizenInteractListener) / removeCitizenInteractListener | A player left-clicks or presses F on a Citizen. Cancellable. |
addCitizenDeathListener(CitizenDeathListener) / removeCitizenDeathListener | A Citizen’s NPC entity dies. Cancellable. |