Triggers

In our scripting language, triggers are essential for executing specific blocks of code based on various events occurring in the game.

Triggers can be initiated by player actions, game mechanics, or specific conditions, enabling you to create dynamic interactions and gameplay experiences.

Yaml Syntax

When working with our plugins, you can expect to define triggers and actions in a simple, readable format. For instance, you might configure something like this in YAML:

cool-thing:
  trigger: "onTick:20"
  actions:
  - 'player.send_message("&aA second just passed!")'

In this example, the trigger is set to activate every 20 ticks (which is approximately one second in Minecraft). When the trigger is activated, the actions specified will be executed, sending a message to the player. This straightforward approach makes it easy to customize and extend functionality within your scripts.

Below are the types of triggers available, categorized with their respective descriptions and associated variables.

Timer

The onTick trigger executes code at specified intervals, making it useful for periodic actions.

This requires an extra data which is the interval. Example: onTick:20

Available Variables:

  • event: Access the actual Spigot Event object.

  • interval: Represents the time interval since the last tick.


Take Entity Damage

The onEntityDamage trigger fires when an entity takes damage from any source.

Available Variables:

  • event: Access the actual Spigot Event object.

  • entity: The entity that received damage.

  • damage: The amount of damage dealt.


Take Damage

The onDamage trigger fires when a player or entity takes damage.

Available Variables:

  • event: Access the actual Spigot Event object.

  • entity: The entity taking damage.

  • damage: The amount of damage inflicted.

  • cause: The reason for the damage.


Attack

The onAttack trigger fires when a player attacks another entity.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player who initiated the attack.

  • target: The entity that was attacked.

  • damage: The damage inflicted by the player.


Arrow Hit

Description: The onArrowHit trigger fires when an arrow hits an entity or block.

Available Variables:

  • event: Access the actual Spigot Event object.

  • shooter: The entity that shot the arrow.

  • hit_block: The block that was hit by the arrow.

  • hit_entity: The entity that was hit by the arrow.


Brew Potion

The onBrewPotion trigger fires when a potion is brewed.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player who brewed the potion.

  • item: The type of potion brewed.


Catch Fish

The onCatchFish trigger fires when a player catches a fish.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player who caught the fish.

  • state: The state of the fishing event (e.g., whether the player caught something).

  • caught: The item that was caught (if applicable).


Consume Item

The onConsume trigger fires when a player consumes an item.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player consuming the item.

  • item: The item being consumed.

  • hand: The hand from which the item was consumed (main or off-hand).


Craft

The onCraft trigger fires when a player crafts an item.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player crafting the item.

  • recipe: The recipe used for crafting.

  • result: The item result of the crafting action.


Fall Damage

The onFallDamage trigger fires when an entity takes fall damage.

Available Variables:

  • event: Access the actual Spigot Event object.

  • entity: The entity that took fall damage.

  • damage: The amount of fall damage inflicted.


Harvest

The onHarvest trigger fires when a player harvests a crop or breaks a block.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player performing the harvest action.

  • block: The block being harvested or broken.


Kill Entity

The onKillEntity trigger fires when an entity is killed.

Available Variables:

  • event: Access the actual Spigot Event object.

  • killer: The entity responsible for the kill.

  • entity: The entity that was killed.

  • drops: The items dropped by the killed entity.


Kill Player

The onKillPlayer trigger fires when a player is killed.

Available Variables:

  • event: Access the actual Spigot Event object.

  • killer: The entity responsible for the player's death.

  • player: The player who was killed.

  • drops: The items dropped by the killed player.


Move

The onMove trigger fires when a player moves from one location to another.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player who moved.

  • from: The location from where the player moved.

  • to: The location to which the player moved.


Break Block

The onBreak trigger fires when a player breaks a block.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player breaking the block.

  • block: The block being broken.


Place Block

The onPlace trigger fires when a player places a block.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player placing the block.

  • block: The block being placed.

  • block_against: The block against which the new block is placed.


Smelt

The onSmelt trigger fires when an item is smelted in a furnace.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player performing the smelting action.

  • block: The furnace block being used.

  • result: The item produced from the smelting process.

  • amount: The number of items produced.


Sprint

The onSprint trigger fires when a player starts or stops sprinting.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player who started or stopped sprinting.


Take Damage

The onDamage trigger fires when an entity takes damage.

Available Variables:

  • event: Access the actual Spigot Event object.

  • entity: The entity that took damage.

  • damage: The amount of damage taken.

  • cause: The cause of the damage.


Take Entity Damage

The onEntityDamage trigger fires when an entity takes damage from another entity.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player receiving damage.

  • damager: The entity that inflicted the damage.

  • damage: The amount of damage dealt.


Trade Entity

The onTradeEntity trigger fires when a player trades with a villager or another entity.

Available Variables:

  • event: Access the actual Spigot Event object.

  • player: The player engaged in the trade.

  • current_item: The item currently being traded.

  • offered_items: The items offered by the player for trade.

Last updated