Skip to content
JasperLorelai edited this page May 19, 2024 · 8 revisions

Source Code

This spell extends its options from Spell.

spell-class: ".PassiveSpell"

Description:

Passive spells are different from the rest of the spells in a way that they cannot be cast by the cast command, by cast items (clicking) or as sub-spells (by another spell like the Multi spell). Instead, Passive spells are considered as main spells, and they are only cast successfully when the listener listed in triggers happens. Only then will the Passive spell process its sub-spells listed in spells.

Based on the trigger specified the sub-spells cast can target entities that have caused them. For instance, a takedamage trigger fires whenever the caster is attacked. Attaching a pain spell with this trigger will hurt the attacker.

Configuration:

Since 4.0 Beta 13 some of these options support dynamic values through numeric or string expressions.

Option Description Type Default Supports expression
chance The likelihood that the passive spell will cast its sub-spells. Float 100 true
delay The amount of time in ticks the passive spell will wait before casting spells. Integer -1 true
can-trigger Target list String List players false
ignore-cancelled Even if the trigger was cancelled, for instance through other plugins, the passive spell's sub-spells will still be cast when enabled. Boolean true false
send-failure-messages If the casting failed due to the passive's cooldown or reagents (cost) missing, this controls whether the str-on-cooldown, str-missing-reagents & str-cost should be sent. Boolean false false
cancel-default-action Cancel the event that activated this passive spell. For example, cancelling a takedamage trigger would negate the damage. Boolean false false
require-cancelled-event If enabled the trigger must be cancelled for the passive spell to cast its sub-spells. Boolean false false
cancel-default-action-when-cast-fails Cancels the event even if the passive spell failed. Boolean false false
triggers A list of triggers that the passive spell will attach itself to. String List false
spells A list of sub-spells to cast. Some triggers pass a targeted entity or location involved in the trigger event the spell, if targeted, would be cast on. Note that before 4.0 Beta 14 Buff spells with targeted: false (default) and ExternalCommandSpell with require-player-target: false (default) on targeted triggers were cast on the caster instead of the target, which is no longer the case. String List false
cast-without-target When true, any targeted spells cast by the passive are cast without a targeted entity or location, even if one is available. Boolean false false

Additional Placeholders:

  • str-on-cooldown:
    • %c: Returns rounded cooldown.

Triggers:

TriggerVar references the string after the listener is separated by a space. Some listeners have extra data which can be configured there (e.g. ticks 1).

triggers:
    - ListenerName TriggerVar
    # No trigger var:
    - startsneak
    # With:
    - ticks 1
Listener Name Description TriggerVar Cancellable Has Entity Target Has Location Target
anvil Fires whenever a player puts an item in a slot of an anvil and attempts to repair it. (firstItems) (secondItems) (resultItems) where arguments can be any or items with the Magic Item String format separated by a |. true false false
blockbreak Fires whenever a player breaks a block. Comma-separated list of block materials. true false true
blockplace Fires whenever a player places a block. Comma-separated list of block materials. true false true
buff Ensures the buff spells specified in spells are always active. Since 4.0 Beta 13 non-buff spells listed are also cast on enable.

Enables spells on:
- MagicSpells reloads
- Entity caster spawns
- Chunk where the entity caster is is loaded
- GameMode is switched to survival or adventure
- Player caster joins
- Player caster respawns
- Player caster learns this passive spell

Disables buffs on: chunk where entity caster is is unloaded
- GameMode of the player caster is switched to creative or spectator
- Player caster leaves
- Player caster dies
- Caster is forced to forget this passive spell
false false false
craft Fires whenever a player crafts an item. item1|item2|... where item can be in the Magic Item String format. true false false
death Fires whenever an entity dies. true false false
dismount Fires whenever the caster dismounts from an entity. true false false
dropitem Fires whenever a player drops an item. item1|item2|... where item follows the Magic Item String format. true false false
enchant item1|item2|... where item follows the Magic Item String format. true false false
entitytarget Fires when an entity targets another entity. Pipe separated list of target reasons. true true false
enterbed Fires whenever a player enters a bed. true false false
equip/unequip Fires whenever a player equips or removes their armor. item1|item2|... where item follows the Magic Item String format. false false false
fataldamage Fires whenever an entity is dealt fatal damage. Since 4.0 Beta 13, you can optionally list damage causes: cause_1|cause_2|... true false false
fish Fires whenever a player is fishing. Comma separated list of fishing states or entity types. true true true
foodlevelchange Fires whenever a player's food level changes. item1|item2|... where item follows the Magic Item String format. true true false
gamemodechange Fires whenever a player's game mode changes. Comma-separated list of game modes. true false false
givedamage Fires whenever an entity deals damage to another entity. item1|item2|... (where item follows the Magic Item String format). Along with items you can put damage causes too. true true false
grindstone Fires whenever a player puts an item in a grindstone slot. (upperItems) (lowerItems) (resultItems) where arguments can be any or items using the Magic Item String format separated by a |. true false false
hitarrow Fires whenever an entity hits an arrow shot on another entity. item1|item2|... where item follows the Magic Item String format. true true false
hotbardeselect Fires whenever a player deselects an item on their hotbar. item1|item2|... where item follows the Magic Item String format. true false false
hotbarselect Fires whenever a player selects an item on their hotbar. item1|item2|... where item follows the Magic Item String format. true false false
insideblock Since 4.0 Beta 14. Fires whenever an entity enters a block as specified here. List of Block Data, separated by a comma. true false true
inventoryaction Fires whenever a player opens or closes an inventory (excluding opening the player inventory). Comma-separated list of OPEN or CLOSE. Only the opening action can be cancelled. true false false
inventoryclick Fires whenever a player performs an inventory action. <inventory action> <magic item> <magic item> - <inventory action> can either be null (all inventory actions) or action as listed here. The first item (defined using the Magic Item String format) filters the item in the clicked inventory slot (if any), and the second filters the item on the player's cursor (if any). Use null in either case to match any item. true false false
inventoryclose Fires whenever a player closes an inventory. Comma-separated list of valid inventory names. false false false
inventoryopen Fires whenever a player opens an inventory (excluding the player's inventory). Comma-separated list of valid inventory names. true false false
join Fires whenever a player logs in to the server. false false false
jump Fires whenever an entity jumps. Cancelling the jump causes the entity to be teleported back to the location it jumped from. Teleport is not visible to players, but if the event is triggered by a player, it will be visible to the jumping player. true false false
kill Fires whenever a player kills an entity. Comma-separated list of entity types that can activate this passive trigger (should instead the use option can-trigger). true true false
leavebed Fires whenever a player leaves a bed. true false false
leftclickblockcoord Fires whenever a player left-clicks a block at a specified location. Semicolon-separated list of locations to listen to, with the format worldname,x,y,z. true false true
leftclickblocktype Fires whenever a player left-clicks a block. Comma-separated list of block materials. true false true
leftclickitem Fires whenever a player left-clicks. item1|item2|... where item follows the Magic Item String format. true false false
magicspellsloaded Fires whenever the plugin finishes loading. false false false
manachange Fires whenever a player's mana changes. Comma-separated list of mana change reasons true false false
missarrow Fires whenever an entity misses an arrow shot. item1|item2|... where item follows the Magic Item String format. false true false
mount Fires whenever the caster mounts an entity. Comma-separated list of mountable entities true false false
offhandswap Fires whenever a player swaps their items between their main hand and offhand. true false false
pickupitem Fires whenever a player picks up an item. item1|item2|... where item follows the Magic Item String format. true false false
playeranimate Fires whenever a player's arm animates due to performing an action. item1|item2|... where item follows the Magic Item String format. true false false
playermove Fires whenever a player moves. Tolerance value that dictates how big a movement has to be to activate the passive trigger. true false false
playermovetoblock Fires whenever a player moves from one block location to another. true false false
portalenter Since 4.0 Beta 14. Fires whenever an entity enters a portal created by the Portal Spell. String-based Spell Filter. true false false
portaleave Since 4.0 Beta 14. Fires whenever an entity exits a portal created by the Portal Spell. String-based Spell Filter. true false false
potioneffect Fires whenever the state of an entity's potion effect status changes. (type) (action) (cause). Each option is a comma separated list. type is a list of potion effect types, action is a list of actions that caused the change in status of the potion effect and cause is the cause of why the potion effect status changed. Each option can be replaced with a wildcard (*), which matches all types/actions/causes. true false false
prepareenchant Fires whenever a player puts an item in an enchantment table slot. item1|item2|... where item follows the Magic Item String format. true false false
quit Fires whenever a player logs off the server. false false false
regainhealth Fires whenever an entity regenerates health. Comma-separated list of health regain reasons true false false
resourcepack Fires whenever a player's resource pack status changes. Comma-separated list of resource pack statuses false false false
respawn Fires whenever a player respawns. false false false
rightclickblockcoord Fires whenever a player right-clicks a block at a specified location. Semi-colon-separated list of locations to listen to, with the format worldname,x,y,z. true false true
rightclickblocktype Fires whenever a player right-clicks a block. Comma-separated list of block materials to listen to. true false true
rightclickentity Fires whenever a player right-clicks an entity. Comma-separated list of entity types to listen to. true true true
rightclickitem Fires whenever a player right-clicks. item1|item2|... where item follows the Magic Item String format. true false false
sheepshear Fires whenever a player shears a sheep. Comma-separated list of dye colors. true true false
shoot Fires whenever an entity shoots a bow. true false false
signbook Fires whenever a player edits a book. Comma-separated list of pages. If specified, the trigger will only activate if the edited book contains a page specified in the TriggerVar. true false false
smith Fires whenever a player puts an item in a smithing table slot. (firstItems) (secondItems) (resultItems) where arguments can be any or items following the Magic Item String format separated by a |. true false false
spellcast Fires whenever an entity has started casting a spell. String-based Spell Filter. true false false
spellcasted Fires whenever an entity has finished casting a spell. String-based Spell Filter. false false false
spellselect Fires whenever a player has selected a spell on a cast item or bound item. String-based Spell Filter. false false false
spelltarget Fires whenever an entity has targeted another entity with a spell. String-based Spell Filter. true true false
spelltargeted Fires whenever an entity has been targeted by another entity with a spell. String-based Spell Filter. true true false
startfly Fires whenever a player starts flying. true false false
startglide Fires whenever an entity starts gliding. true false false
startpose Since 4.0 Beta 14. Fires whenever an entity starts posing with a specific pose. pose_1,pose_2,... (list of Poses) false false false
startsneak Fires whenever a player starts sneaking. true false false
startsprint Fires whenever a player starts sprinting. true false false
startswim Fires whenever an entity starts swimming. Bugged. Removed since 4.0 Beta 14. false false
stopfly Fires whenever a player stops flying. true false false
stopglide Fires whenever an entity stops gliding. true false false
stoppose Since 4.0 Beta 14. Fires whenever an entity stops posing with a specific pose. pose_1,pose_2,... (list of Poses) false false false
stopsneak Fires whenever a player stops sneaking. true false false
stopsprint Fires whenever a player stops sprinting. true false false
stopswim Fires whenever an entity stops swimming. Bugged. Removed since 4.0 Beta 14. false false
takedamage Fires whenever an entity takes damage from another entity. item1|item2|... (where item follows the Magic Item String format). Among items you can put damage causes. true true false
teleport Fires whenever a player teleports. Comma separated list of teleport causes. true false false
ticks Fires on a tick interval defined. Server ticks false false false
worldchange Fires whenever a player teleports to another world. Comma-separated list of world names. true false false

Event Priority:

An event priority can be appended to your TriggerVar. This will let your server know in which order of priority to handle all event listeners (not just PassiveSpells, but events from other sources too). E.g. dismount_highestpriority

Priority Description
highpriority Event call is of high importance.
highestpriority Event call is critical and must have the final say in what happens to the event.
lowpriority Event call is of low importance.
lowestpriority Event call is of very low importance and should be run first, to allow other plugins to customise the outcome further.
monitorpriority Event is listened to purely for monitoring the outcome of an event.
normalpriority Event call is neither important nor unimportant and may run normally.

Example:

darkcloak:
    spell-class: ".PassiveSpell"
    triggers:
        - ticks 20
    spells:
        - darkcloak_invis
    modifiers:
        - lightlevel <7 required
Clone this wiki locally