Class SentinelTrait

java.lang.Object
net.citizensnpcs.api.trait.Trait
org.mcmonkey.sentinel.SentinelTrait
All Implemented Interfaces:
Runnable, org.bukkit.event.Listener

public class SentinelTrait extends net.citizensnpcs.api.trait.Trait
The main Sentinel trait.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
    The NPC's accuracy value (0 = perfectly accurate).
     
     
    boolean
    Whether the NPC can receive knockback.
     
    double
    The NPC's armor value (-1 means automatically calculated from equipment, 0 means no armor and 1 means invincible armor...
    int
    Ticks since last removal of arrows from the NPC.
    Helper for attacking.
    int
    How long (in ticks) between using melee attacks.
    static final int
    Constant: the maximum attack rate value (in ticks).
    int
    How long (in ticks) between firing ranged shots.
    boolean
    Whether this NPC automatically switches weapons.
    double
    How far to stay from avoid targets.
    org.bukkit.Location
    The NPC's avoid return point (null = just run away).
    boolean
    Whether the NPC has chased a target during the most recent update.
    double
    The maximum distance from a guard point the NPC can run (when chasing a target).
    org.bukkit.entity.LivingEntity
    The target entity this NPC is chasing (if any).
    boolean
    Whether the NPC chases targets when using melee weapons.
    int
    Tick counter for the run method.
    double
    The NPC's damage value (-1 means automatically calculated from weapon, anything else is equal to the HP lost by an unarmored target).
    int
    How much XP to drop when the NPC dies.
    boolean
    If set 'true', the NPC will never teleport through Sentinel logic.
    Chances of item drops, matched to the 'drops' list.
    ArrayList<org.bukkit.inventory.ItemStack>
    What the NPC drops when dead.
    boolean
    Whether mob targets killed by the NPC can drop items.
    long
    How long (in ticks) to retain an enemy target when out-of-view.
    boolean
    Whether the NPC "fights back" against attacks (targets anyone that damages it).
    Players in range of the NPC that have already been greeted.
    The text to greet friendly players with (empty string = no greeting).
    double
    The range this NPC gives greetings or warnings at.
    int
    The rate in ticks this NPC gives greetings or warnings at.
    double
    Minimum distance before choosing a new point (relative to guarded player).
    int
    ID of an NPC to guard, if any.
    long
    Lower 64 bits of the guarded player's UUID.
    long
    Upper 64 bits of the guarded player's UUID.
    double
    Maximum possible distance of point to choose (relative to the guarded player).
    int
    How long (in ticks) before the NPC heals by 1 HP (when damaged).
    static final int
    Constant: the maximum heal rate value (in ticks).
    double
    The NPC's maximum health (NOT its current health when the NPC is spawned and injured).
    static final double
    Constant: the smallest health value that can be given to an NPC.
    boolean
    Whether this NPC should ignore Line of Sight requirement.
    boolean
    Whether the NPC cannot be harmed (true = no harm, false = receives damage normally).
    boolean
    Whether the NPC is currently trying to block with a shield.
    Helper for items.
    Last known entity UUID for this Sentinel NPC.
    Map of player UUIDs to the last ticks-alive stamp they were greeted at.
    boolean
    Whether the NPC needs ammo to fire ranged weapons (otherwise, infinite ammo).
    Entities that will need their drops cleared if they die soon (because they were killed by this NPC).
    boolean
    Indicates that the NPC needs to return to safety when next possible.
    boolean
    Set true when waypoints are paused by Sentinel, to indicate that an unpause is needed (to avoid over-doing the unpause call, which can disrupt unrelated unpauses).
    boolean
    If true: other behavior (unrelated to Sentinel) should be paused, as Sentinel is engaged in combat.
    org.bukkit.Location
    Special case for where the NPC has been forced to run to in certain situations.
    double
    How far this NPC is willing to fire projectiles.
    boolean
    Whether the NPC should be protected from damage by ignore targets.
    double
    Maximum distance after which damage starts being ignored.
    double
    Maximum range to trigger attacks from.
    boolean
    Whether the NPC chases targets when using ranged weapons.
    double
    How far this NPC's punches can reach.
    int
    Ticks before a new target is properly noticed.
    boolean
    Whether this NPC should have 'realistic' targeting.
    org.bukkit.scheduler.BukkitRunnable
    Runnable for respawning, if needed.
    long
    How long (in ticks) after death before the NPC respawns.
    boolean
     
    boolean
    Whether the NPC runs away when attacked.
    boolean
    Whether to protect NPC arrow shots from damaging targets that weren't meant to be hit.
    long
    When the shield can next be used (based on tick timer), if it has been disabled via axe strike.
    org.bukkit.Location
    The NPC's respawn location (null = respawn where the NPC died at).
    double
    How fast the NPC moves when chasing (1 = normal speed).
    The name of the squad this NPC is in (null for no squad).
    long
    Statistics value: how many arrows this NPC has fired.
    long
    Statistics value: how many attacks this NPC has attempted.
    double
    Statistics value: how much damage this NPC has given.
    double
    Statistics value: how much damage this NPC has taken.
    long
    Statistics value: how many eggs this NPC has thrown.
    long
    Statistics value: how many evoker fangs this NPC has spawned.
    long
    Statistics value: how many fireballs this NPC has fired.
    long
    Statistics value: how many llama spits this NPC has spit.
    long
    Statistics value: how many pearls this NPC has used.
    long
    Statistics value: how many potions this NPC has thrown.
    long
    Statistics value: how many times this NPC has punched a target.
    long
    Statistics value: how many shulker bullets this NPC has shot.
    long
    Statistics value: how many skulls this NPC has thrown.
    long
    Statistics value: how many snowballs this NPC has thrown.
    long
    Statistics value: how long (in ticks) this NPC has ever been in the world, in total.
    long
    Statistics value: how many times this NPC has spawned into the world.
    Helper for targeting logic.
    int
    Tick counter for the NPC guarding a player (to avoid updating positions too quickly).
    int
    How long ago (in ticks) the NPC was last burned.
    long
    Time since the last attack.
    long
    Time since the last heal.
    The text to warn enemy players with (empty string = no greeting).
    Map of weapon material names to custom damage amount.
    Helper for weapons.
    Map of held weapon material names to redirect 'work like' material names.
    The name of a WorldGuard region this Sentinel must stay within (if any).
    Cache object, refer to 'worldguardRegion'.

    Fields inherited from class net.citizensnpcs.api.trait.Trait

    npc
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs the Sentinel Trait object - should only be called by the Citizens API internal functionality.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAvoid(String target)
    Adds a new avoid-target (by target description string).
    void
    addIgnore(String target)
    Adds a new ignore (by target description string).
    void
    addTarget(String target)
    Adds a new target (by target description string).
    void
    Sets the NPC's local parameter speed modifier to its proper current value.
    boolean
    canPathTo(org.bukkit.Location loc)
    Determines whether the NPC is allowed to path to a location, by checking chase range and firing an event.
    void
    debug(String message)
    Outputs a debug message (if debug is enabled).
    void
    faceLocation(org.bukkit.Location l)
    Rotates an NPC to face a target location.
    double
    Gets the minimum distance from the NPC's head to launch a projectile from (to avoid it colliding with the NPC's own collision box).
    org.bukkit.util.Vector
    fixForAcc(org.bukkit.util.Vector input)
    Alters a vector per accuracy potential (makes the vector less accurate).
    void
    generalDeathHandler(org.bukkit.entity.LivingEntity entity)
    Handles some basics for when the NPC died.
    double
    getArmor(org.bukkit.entity.LivingEntity ent)
    Gets the NPC's current armor value (based on worn armor if calculation is required).
    double
    Gets the NPC's current damage value (based on held weapon if calculation is required).
    double
    getDamage(boolean forRangedAttacks)
    Gets the NPC's current damage value (based on held weapon if calculation is required).
    double
    getDamage(boolean forRangedAttacks, org.bukkit.inventory.ItemStack weapon)
    Gets the NPC's current damage value (based on a specific weapon if calculation is required).
    List<org.bukkit.inventory.ItemStack>
    Gets a list of items to drop (factoring in the drop chance values).
    Gets the UUID of the player this Sentinel is set to be guarding.
    org.bukkit.entity.LivingEntity
    Gets the entity this NPC is guarding, or null.
    org.bukkit.Location
    Gets the location this NPC is guarding (the NPC's own location if nothing else to guard).
    AbstractMap.SimpleEntry<org.bukkit.Location,org.bukkit.util.Vector>
    getLaunchDetail(org.bukkit.Location target, org.bukkit.util.Vector lead)
    Gets a 'launch detail' (starting location for the projectile position, and a vector holding the exact launch vector, scaled to the correct speed).
    org.bukkit.entity.LivingEntity
    Gets the living entity for the NPC.
    boolean
    hitIsBlocked(org.bukkit.entity.Entity damager)
    Returns a boolean indicating whether a hit from the given damager should be blocked by a shield.
    void
    load(net.citizensnpcs.api.util.DataKey key)
    Updater for older Sentinel saves (up to 1.7.2)
    org.bukkit.Location
    Gets the nearest pathing point to this NPC.
    void
    Called when the Sentinel trait is attached to the NPC - fills all default values from config.
    void
    Handler for when the NPC died.
    void
    Called when the NPC despawns.
    void
    onPlayerMovesInRange(org.bukkit.event.player.PlayerMoveEvent event)
    Called every time a player moves at all, for use with monitoring if players move into range of an NPC.
    void
    onPlayerTeleports(org.bukkit.event.player.PlayerTeleportEvent event)
    Called whenever a player teleports, for use with NPC guarding logic.
    void
    Called when the Sentinel trait is removed from an NPC.
    void
    Called when the NPC spawns in.
    void
    pathTo(org.bukkit.Location target)
    Causes the NPC to immediately path over to a position.
    void
    Pauses waypoint navigation if currrently navigating, and fires the pause event.
    double
    Returns a random decimal number within acceptable accuracy range (can be negative).
    void
    Removes an avoid-target (by target description string).
    void
    Removes an ignore (by target description string).
    void
    Removes a target (by target description string).
    void
    run()
    Called every tick to run Sentinel updates if needed.
    void
    Runs a full update cycle on the NPC.
    void
    save(net.citizensnpcs.api.util.DataKey key)
     
    void
    sayTo(org.bukkit.entity.Player player, String message)
    Causes the NPC to speak a message to a player.
    void
    setGuarding(int npcID)
    Sets the NPC to be guarding an NPC.
    void
    Sets the NPC to be guarding an entity.
    void
    setHealth(double heal)
    Sets the NPC's maximum health.
    void
    setInvincible(boolean inv)
    Sets whether the NPC is invincible.
    void
    Marks that the NPC can see a target (Changes the state of some entity types, eg opening a shulker box).
    void
    Marks that the NPC can no longer see a target (Changes the state of some entity types, eg closing a shulker box).
    void
    Causes the NPC to start blocking with a shield (if it has one).
    void
    Causes the NPC to stop blocking with a shield (if it has one).
    void
    Swings the NPC's weapon (plays an ARM_SWING animation if possible - otherwise, does nothing).
    boolean
    tryUpdateChaseTarget(org.bukkit.entity.LivingEntity newTarget)
    Attempts to update the chasing target, calling the needed events and checking for modifications.
    void
    Un-Pauses (resumes) waypoint navigation if currrently navigating, and fires the un-pause event.
    void
    updateOld(net.citizensnpcs.api.util.DataKey key)
    Updater for older Sentinel saves (up to 1.7.2)
    void
    Animates the NPC using their item, and stops the animation 10 ticks later (useful for replicating bow draws, etc).
    boolean
    Validates this Sentinel NPC's presence on the current NPCs list.
    void
    Called when a target dies to remove them from the target list.
    void
    whenAttacksAreHappeningFromMe(org.bukkit.event.entity.EntityDamageByEntityEvent event)
    Called when this sentinel attacks something, to correct damage handling.
    void
    whenAttacksAreHappeningFromMyArrow(org.bukkit.event.entity.EntityDamageByEntityEvent event)
    Called when this sentinel attacks something with a projectile, to correct damage handling.
    void
    whenAttacksAreHappeningToMe(org.bukkit.event.entity.EntityDamageByEntityEvent event)
    Called when this sentinel gets attacked, to correct the armor handling.
    void
    whenAttacksHappened(org.bukkit.event.entity.EntityDamageByEntityEvent event)
     
    void
    whenImHurt(org.bukkit.event.entity.EntityDamageEvent event)
    Called when this sentinel gets hurt.
    void
    whenSomethingDies(org.bukkit.event.entity.EntityDeathEvent event)
    Called when any entity dies.
    void
    Called when an entity might die from damage (called before Sentinel detects that an NPC might have killed an entity).
    void
    whenWeDie(org.bukkit.event.entity.EntityDeathEvent event)
    Called when the NPC dies.

    Methods inherited from class net.citizensnpcs.api.trait.Trait

    getName, getNPC, isRunImplemented, linkToNPC, onCopy, onDespawn, onPreSpawn, onRemove

    Methods inherited from class java.lang.Object

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

    • healthMin

      public static final double healthMin
      Constant: the smallest health value that can be given to an NPC.
      See Also:
    • attackRateMax

      public static final int attackRateMax
      Constant: the maximum attack rate value (in ticks).
      See Also:
    • healRateMax

      public static final int healRateMax
      Constant: the maximum heal rate value (in ticks).
      See Also:
    • targetingHelper

      public SentinelTargetingHelper targetingHelper
      Helper for targeting logic.
    • itemHelper

      public SentinelItemHelper itemHelper
      Helper for items.
    • weaponHelper

      public SentinelWeaponHelper weaponHelper
      Helper for weapons.
    • attackHelper

      public SentinelAttackHelper attackHelper
      Helper for attacking.
    • stats_ticksSpawned

      public long stats_ticksSpawned
      Statistics value: how long (in ticks) this NPC has ever been in the world, in total.
    • stats_timesSpawned

      public long stats_timesSpawned
      Statistics value: how many times this NPC has spawned into the world.
    • stats_arrowsFired

      public long stats_arrowsFired
      Statistics value: how many arrows this NPC has fired.
    • stats_potionsThrown

      public long stats_potionsThrown
      Statistics value: how many potions this NPC has thrown.
    • stats_fireballsFired

      public long stats_fireballsFired
      Statistics value: how many fireballs this NPC has fired.
    • stats_snowballsThrown

      public long stats_snowballsThrown
      Statistics value: how many snowballs this NPC has thrown.
    • stats_eggsThrown

      public long stats_eggsThrown
      Statistics value: how many eggs this NPC has thrown.
    • stats_skullsThrown

      public long stats_skullsThrown
      Statistics value: how many skulls this NPC has thrown.
    • stats_llamaSpitShot

      public long stats_llamaSpitShot
      Statistics value: how many llama spits this NPC has spit.
    • stats_shulkerBulletsShot

      public long stats_shulkerBulletsShot
      Statistics value: how many shulker bullets this NPC has shot.
    • stats_evokerFangsSpawned

      public long stats_evokerFangsSpawned
      Statistics value: how many evoker fangs this NPC has spawned.
    • stats_pearlsUsed

      public long stats_pearlsUsed
      Statistics value: how many pearls this NPC has used.
    • stats_punches

      public long stats_punches
      Statistics value: how many times this NPC has punched a target.
    • stats_attackAttempts

      public long stats_attackAttempts
      Statistics value: how many attacks this NPC has attempted.
    • stats_damageTaken

      public double stats_damageTaken
      Statistics value: how much damage this NPC has taken.
    • stats_damageGiven

      public double stats_damageGiven
      Statistics value: how much damage this NPC has given.
    • allTargets

      public SentinelTargetList allTargets
    • allIgnores

      public SentinelTargetList allIgnores
    • allAvoids

      public SentinelTargetList allAvoids
    • avoidRange

      public double avoidRange
      How far to stay from avoid targets.
    • range

      public double range
      Maximum range to trigger attacks from.
    • damage

      public double damage
      The NPC's damage value (-1 means automatically calculated from weapon, anything else is equal to the HP lost by an unarmored target).
    • armor

      public double armor
      The NPC's armor value (-1 means automatically calculated from equipment, 0 means no armor and 1 means invincible armor... decimals between 0 and 1 are normal).
    • health

      public double health
      The NPC's maximum health (NOT its current health when the NPC is spawned and injured).
    • rangedChase

      public boolean rangedChase
      Whether the NPC chases targets when using ranged weapons.
    • closeChase

      public boolean closeChase
      Whether the NPC chases targets when using melee weapons.
    • invincible

      public boolean invincible
      Whether the NPC cannot be harmed (true = no harm, false = receives damage normally).
    • protectFromIgnores

      public boolean protectFromIgnores
      Whether the NPC should be protected from damage by ignore targets.
    • protectFromRange

      public double protectFromRange
      Maximum distance after which damage starts being ignored.
    • fightback

      public boolean fightback
      Whether the NPC "fights back" against attacks (targets anyone that damages it).
    • runaway

      public boolean runaway
      Whether the NPC runs away when attacked.
    • attackRate

      public int attackRate
      How long (in ticks) between using melee attacks.
    • attackRateRanged

      public int attackRateRanged
      How long (in ticks) between firing ranged shots.
    • healRate

      public int healRate
      How long (in ticks) before the NPC heals by 1 HP (when damaged).
    • guardingUpper

      public long guardingUpper
      Upper 64 bits of the guarded player's UUID.
    • guardingLower

      public long guardingLower
      Lower 64 bits of the guarded player's UUID.
    • guardedNPC

      public int guardedNPC
      ID of an NPC to guard, if any.
    • needsAmmo

      public boolean needsAmmo
      Whether the NPC needs ammo to fire ranged weapons (otherwise, infinite ammo).
    • safeShot

      public boolean safeShot
      Whether to protect NPC arrow shots from damaging targets that weren't meant to be hit.
    • respawnTime

      public long respawnTime
      How long (in ticks) after death before the NPC respawns.
    • chaseRange

      public double chaseRange
      The maximum distance from a guard point the NPC can run (when chasing a target).
    • spawnPoint

      public org.bukkit.Location spawnPoint
      The NPC's respawn location (null = respawn where the NPC died at).
    • avoidReturnPoint

      public org.bukkit.Location avoidReturnPoint
      The NPC's avoid return point (null = just run away).
    • drops

      public ArrayList<org.bukkit.inventory.ItemStack> drops
      What the NPC drops when dead.
    • dropChances

      public ArrayList<Double> dropChances
      Chances of item drops, matched to the 'drops' list.
    • enemyDrops

      public boolean enemyDrops
      Whether mob targets killed by the NPC can drop items.
    • enemyTargetTime

      public long enemyTargetTime
      How long (in ticks) to retain an enemy target when out-of-view.
    • speed

      public double speed
      How fast the NPC moves when chasing (1 = normal speed).
    • warningText

      public String warningText
      The text to warn enemy players with (empty string = no greeting).
    • greetingText

      public String greetingText
      The text to greet friendly players with (empty string = no greeting).
    • greetRange

      public double greetRange
      The range this NPC gives greetings or warnings at.
    • greetRate

      public int greetRate
      The rate in ticks this NPC gives greetings or warnings at.
    • autoswitch

      public boolean autoswitch
      Whether this NPC automatically switches weapons.
    • squad

      public String squad
      The name of the squad this NPC is in (null for no squad).
    • accuracy

      public double accuracy
      The NPC's accuracy value (0 = perfectly accurate).
    • realistic

      public boolean realistic
      Whether this NPC should have 'realistic' targeting.
    • ignoreLOS

      public boolean ignoreLOS
      Whether this NPC should ignore Line of Sight requirement. If set true, the NPC can see targets through walls.
    • reach

      public double reach
      How far this NPC's punches can reach.
    • projectileRange

      public double projectileRange
      How far this NPC is willing to fire projectiles.
    • guardDistanceMinimum

      public double guardDistanceMinimum
      Minimum distance before choosing a new point (relative to guarded player).
    • guardSelectionRange

      public double guardSelectionRange
      Maximum possible distance of point to choose (relative to the guarded player).
    • retainTarget

      public boolean retainTarget
    • weaponDamage

      public HashMap<String,Double> weaponDamage
      Map of weapon material names to custom damage amount.
    • weaponRedirects

      public HashMap<String,String> weaponRedirects
      Map of held weapon material names to redirect 'work like' material names.
    • disableTeleporting

      public boolean disableTeleporting
      If set 'true', the NPC will never teleport through Sentinel logic. When enabling this, you should set the Citizens "stuckAction" NavigatorParameter to "null" as well.
    • reactionSlowdown

      public int reactionSlowdown
      Ticks before a new target is properly noticed. 0 = no slowdown applied.
    • allowKnockback

      public boolean allowKnockback
      Whether the NPC can receive knockback.
    • worldguardRegion

      public String worldguardRegion
      The name of a WorldGuard region this Sentinel must stay within (if any).
    • deathXP

      public int deathXP
      How much XP to drop when the NPC dies.
    • worldguardRegionCache

      public Object worldguardRegionCache
      Cache object, refer to 'worldguardRegion'.
    • chasing

      public org.bukkit.entity.LivingEntity chasing
      The target entity this NPC is chasing (if any). Do not alter directly, prefer attackHelper.chase(...)
    • isBlocking

      public boolean isBlocking
      Whether the NPC is currently trying to block with a shield.
    • ticksSinceLastBurn

      public int ticksSinceLastBurn
      How long ago (in ticks) the NPC was last burned.
    • shieldAxeCooldown

      public long shieldAxeCooldown
      When the shield can next be used (based on tick timer), if it has been disabled via axe strike.
    • greetedAlready

      public HashSet<UUID> greetedAlready
      Players in range of the NPC that have already been greeted.
    • lastGreetTime

      public HashMap<UUID,Long> lastGreetTime
      Map of player UUIDs to the last ticks-alive stamp they were greeted at.
    • timeSinceAttack

      public long timeSinceAttack
      Time since the last attack.
    • timeSinceHeal

      public long timeSinceHeal
      Time since the last heal.
    • chased

      public boolean chased
      Whether the NPC has chased a target during the most recent update. Do not alter directly, prefer attackHelper.chase(...)
    • ticksCountGuard

      public int ticksCountGuard
      Tick counter for the NPC guarding a player (to avoid updating positions too quickly).
    • needsToUnpause

      public boolean needsToUnpause
      Set true when waypoints are paused by Sentinel, to indicate that an unpause is needed (to avoid over-doing the unpause call, which can disrupt unrelated unpauses).
    • otherBehaviorPaused

      public boolean otherBehaviorPaused
      If true: other behavior (unrelated to Sentinel) should be paused, as Sentinel is engaged in combat. Consider also listening to event 'SentinelCombatStateChangeEvent'.
    • pathingTo

      public org.bukkit.Location pathingTo
      Special case for where the NPC has been forced to run to in certain situations.
    • needsSafeReturn

      public boolean needsSafeReturn
      Indicates that the NPC needs to return to safety when next possible.
    • arrowResetTicker

      public int arrowResetTicker
      Ticks since last removal of arrows from the NPC.
    • cTick

      public int cTick
      Tick counter for the run method.
    • respawnMe

      public org.bukkit.scheduler.BukkitRunnable respawnMe
      Runnable for respawning, if needed.
    • lastEntityUUID

      public UUID lastEntityUUID
      Last known entity UUID for this Sentinel NPC.
    • needsDropsClear

      public HashSet<UUID> needsDropsClear
      Entities that will need their drops cleared if they die soon (because they were killed by this NPC).
  • Constructor Details

    • SentinelTrait

      public SentinelTrait()
      Constructs the Sentinel Trait object - should only be called by the Citizens API internal functionality. To add Sentinel to an NPC, use npc.addTrait(SentinelTrait.class).
  • Method Details

    • load

      public void load(net.citizensnpcs.api.util.DataKey key)
      Updater for older Sentinel saves (up to 1.7.2)
      Overrides:
      load in class net.citizensnpcs.api.trait.Trait
    • save

      public void save(net.citizensnpcs.api.util.DataKey key)
      Overrides:
      save in class net.citizensnpcs.api.trait.Trait
    • updateOld

      public void updateOld(net.citizensnpcs.api.util.DataKey key)
      Updater for older Sentinel saves (up to 1.7.2)
    • addTarget

      public void addTarget(String target)
      Adds a new target (by target description string).
    • addIgnore

      public void addIgnore(String target)
      Adds a new ignore (by target description string).
    • addAvoid

      public void addAvoid(String target)
      Adds a new avoid-target (by target description string).
    • removeTarget

      public void removeTarget(String target)
      Removes a target (by target description string).
    • removeIgnore

      public void removeIgnore(String target)
      Removes an ignore (by target description string).
    • removeAvoid

      public void removeAvoid(String target)
      Removes an avoid-target (by target description string).
    • startBlocking

      public void startBlocking()
      Causes the NPC to start blocking with a shield (if it has one).
    • stopBlocking

      public void stopBlocking()
      Causes the NPC to stop blocking with a shield (if it has one).
    • autoSpeedModifier

      public void autoSpeedModifier()
      Sets the NPC's local parameter speed modifier to its proper current value.
    • getGuarding

      public UUID getGuarding()
      Gets the UUID of the player this Sentinel is set to be guarding. Null indicates not guarding anyone.
    • setGuarding

      public void setGuarding(int npcID)
      Sets the NPC to be guarding an NPC. -1 indicates not guarding anyone.
    • setGuarding

      public void setGuarding(UUID uuid)
      Sets the NPC to be guarding an entity. Null indicates not guarding anyone.
    • whenImHurt

      public void whenImHurt(org.bukkit.event.entity.EntityDamageEvent event)
      Called when this sentinel gets hurt.
    • hitIsBlocked

      public boolean hitIsBlocked(org.bukkit.entity.Entity damager)
      Returns a boolean indicating whether a hit from the given damager should be blocked by a shield.
    • whenAttacksAreHappeningToMe

      public void whenAttacksAreHappeningToMe(org.bukkit.event.entity.EntityDamageByEntityEvent event)
      Called when this sentinel gets attacked, to correct the armor handling.
    • whenAttacksAreHappeningFromMe

      public void whenAttacksAreHappeningFromMe(org.bukkit.event.entity.EntityDamageByEntityEvent event)
      Called when this sentinel attacks something, to correct damage handling.
    • whenAttacksAreHappeningFromMyArrow

      public void whenAttacksAreHappeningFromMyArrow(org.bukkit.event.entity.EntityDamageByEntityEvent event)
      Called when this sentinel attacks something with a projectile, to correct damage handling.
    • whenAttacksHappened

      public void whenAttacksHappened(org.bukkit.event.entity.EntityDamageByEntityEvent event)
    • whenAnEnemyDies

      public void whenAnEnemyDies(UUID dead)
      Called when a target dies to remove them from the target list.
    • onAttach

      public void onAttach()
      Called when the Sentinel trait is attached to the NPC - fills all default values from config.
      Overrides:
      onAttach in class net.citizensnpcs.api.trait.Trait
    • onRemove

      public void onRemove()
      Called when the Sentinel trait is removed from an NPC.
      Overrides:
      onRemove in class net.citizensnpcs.api.trait.Trait
    • useItem

      public void useItem()
      Animates the NPC using their item, and stops the animation 10 ticks later (useful for replicating bow draws, etc).
    • swingWeapon

      public void swingWeapon()
      Swings the NPC's weapon (plays an ARM_SWING animation if possible - otherwise, does nothing).
    • firingMinimumRange

      public double firingMinimumRange()
      Gets the minimum distance from the NPC's head to launch a projectile from (to avoid it colliding with the NPC's own collision box).
    • getLaunchDetail

      public AbstractMap.SimpleEntry<org.bukkit.Location,org.bukkit.util.Vector> getLaunchDetail(org.bukkit.Location target, org.bukkit.util.Vector lead)
      Gets a 'launch detail' (starting location for the projectile position, and a vector holding the exact launch vector, scaled to the correct speed).
    • randomAcc

      public double randomAcc()
      Returns a random decimal number within acceptable accuracy range (can be negative).
    • fixForAcc

      public org.bukkit.util.Vector fixForAcc(org.bukkit.util.Vector input)
      Alters a vector per accuracy potential (makes the vector less accurate).
    • faceLocation

      public void faceLocation(org.bukkit.Location l)
      Rotates an NPC to face a target location.
    • getDamage

      public double getDamage()
      Gets the NPC's current damage value (based on held weapon if calculation is required).
    • getDamage

      public double getDamage(boolean forRangedAttacks)
      Gets the NPC's current damage value (based on held weapon if calculation is required).
    • getDamage

      public double getDamage(boolean forRangedAttacks, org.bukkit.inventory.ItemStack weapon)
      Gets the NPC's current damage value (based on a specific weapon if calculation is required).
    • getArmor

      public double getArmor(org.bukkit.entity.LivingEntity ent)
      Gets the NPC's current armor value (based on worn armor if calculation is required).
    • getLivingEntity

      public org.bukkit.entity.LivingEntity getLivingEntity()
      Gets the living entity for the NPC.
    • specialMarkVision

      public void specialMarkVision()
      Marks that the NPC can see a target (Changes the state of some entity types, eg opening a shulker box).
    • specialUnmarkVision

      public void specialUnmarkVision()
      Marks that the NPC can no longer see a target (Changes the state of some entity types, eg closing a shulker box).
    • canPathTo

      public boolean canPathTo(org.bukkit.Location loc)
      Determines whether the NPC is allowed to path to a location, by checking chase range and firing an event.
    • pathTo

      public void pathTo(org.bukkit.Location target)
      Causes the NPC to immediately path over to a position.
    • pauseWaypoints

      public void pauseWaypoints()
      Pauses waypoint navigation if currrently navigating, and fires the pause event.
    • unpauseWaypoints

      public void unpauseWaypoints()
      Un-Pauses (resumes) waypoint navigation if currrently navigating, and fires the un-pause event.
    • getGuardingEntity

      public org.bukkit.entity.LivingEntity getGuardingEntity()
      Gets the entity this NPC is guarding, or null.
    • runUpdate

      public void runUpdate()
      Runs a full update cycle on the NPC.
    • getGuardZone

      public org.bukkit.Location getGuardZone()
      Gets the location this NPC is guarding (the NPC's own location if nothing else to guard).
    • nearestPathPoint

      public org.bukkit.Location nearestPathPoint()
      Gets the nearest pathing point to this NPC.
    • run

      public void run()
      Called every tick to run Sentinel updates if needed.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class net.citizensnpcs.api.trait.Trait
    • onSpawn

      public void onSpawn()
      Called when the NPC spawns in.
      Overrides:
      onSpawn in class net.citizensnpcs.api.trait.Trait
    • sayTo

      public void sayTo(org.bukkit.entity.Player player, String message)
      Causes the NPC to speak a message to a player.
    • onPlayerTeleports

      public void onPlayerTeleports(org.bukkit.event.player.PlayerTeleportEvent event)
      Called whenever a player teleports, for use with NPC guarding logic.
    • onPlayerMovesInRange

      public void onPlayerMovesInRange(org.bukkit.event.player.PlayerMoveEvent event)
      Called every time a player moves at all, for use with monitoring if players move into range of an NPC.
    • whenSomethingMightDie

      public void whenSomethingMightDie(UUID mightDie)
      Called when an entity might die from damage (called before Sentinel detects that an NPC might have killed an entity).
    • debug

      public void debug(String message)
      Outputs a debug message (if debug is enabled).
    • getDrops

      public List<org.bukkit.inventory.ItemStack> getDrops()
      Gets a list of items to drop (factoring in the drop chance values).
    • whenWeDie

      public void whenWeDie(org.bukkit.event.entity.EntityDeathEvent event)
      Called when the NPC dies.
    • generalDeathHandler

      public void generalDeathHandler(org.bukkit.entity.LivingEntity entity)
      Handles some basics for when the NPC died.
    • whenSomethingDies

      public void whenSomethingDies(org.bukkit.event.entity.EntityDeathEvent event)
      Called when any entity dies.
    • onDeath

      public void onDeath()
      Handler for when the NPC died.
    • onDespawn

      public void onDespawn()
      Called when the NPC despawns.
      Overrides:
      onDespawn in class net.citizensnpcs.api.trait.Trait
    • setHealth

      public void setHealth(double heal)
      Sets the NPC's maximum health.
    • setInvincible

      public void setInvincible(boolean inv)
      Sets whether the NPC is invincible.
    • validateOnList

      public boolean validateOnList()
      Validates this Sentinel NPC's presence on the current NPCs list.
    • tryUpdateChaseTarget

      public boolean tryUpdateChaseTarget(org.bukkit.entity.LivingEntity newTarget)
      Attempts to update the chasing target, calling the needed events and checking for modifications.