Skip to main content

Actions & Triggers

Actions are a set of features that are applied to players, teams, or matches, similiar to Kits. Multiple actions can be started by one trigger.

info

In the future, some features that are currently used in Kits may be transferred to be used as an Action instead.

Action Elements

ElementDescription
<action> </action>A group of actions running in a sequence.
<switch-scope> </switch-scope>Changes the scope that an action applies to.
<repeat> </repeat>Loop actions without recursions.
<message/>A message that is sent to the player.
<sound/>A sound that is played for the player.
<set/>Sets a new value for a Variable.
<schedule> </schedule>Adds a delay between actions.
<kill-entities/>Removes entities based on a filter.
<kit/>Applies a Kit.
<fill/>Places blocks in a block-bounded region.
<paste-structure/>Places a structure at a specified location when triggered.
<open-shop/>Open a shop menu when triggered.
<replace-item> </replace-item>Finds and replaces certain items.
<enchant-item> </enchant-item>Enchants the targeted item.
<take-payment> </take-payment>Allow players to pay with items in their inventory to trigger an action.
<team-alias/> Dynamically change a team's name during a match.
<velocity/>A player-scoped kit that applies velocity to the player.
<teleport/>Teleport a player to a specific location.
<weather/>The weather to set for the map's environment.

Action Attributes

AttributeDescriptionValueDefault
idUnique identifier used to reference this action from other places in the XML.String
scopeSets the scope target an action should operate against.player, team, or match
filterA filter that is tested before running actions inside.Filter
untrigger-filterA filter that is tested before deactivating the actions inside, similar to kit lending.
Most actions do not have explicit untrigger logic and will do nothing on untrigger.
Filternever
exposeAllows an action to be triggered by /action.
Actions must have an ID and support the match scope for expose to work. Moderators require the GAMEPLAY permission to use the action command.
true/falsefalse

Switch-Scope Attributes

AttributeDescriptionValueDefault
idUnique identifier used to reference this switch-scope from other places in the XML.String
innerSpecify the scope of the inner action.player, team, or match
outerSpecify the scope outside of an action.
In some cases, this can be omitted as PGM will automatically infer the outer scope.
player, team, or match
observersToggle if non-participant players should be included in the scope.
Note: This is only relevant when inner scope is player.
true/falsefalse

Repeat Attributes

AttributeDescriptionValue
timesThe amount of time to repeat.
Non-whole numbers will be rounded down. Negative numbers will cause no iterations.
Expression
filterFilters when this loop should be active. This will be checked as many time as the loop is ran.Filter

Message

Attributes

AttributeDescriptionValueDefault
textPropertyThe text that will be sent in the chat to a player.Formatted Text
actionbarPropertyThe text above the hotbar.Formatted Text
titlePropertyThe title text that will appear in the center of the player's screen.Formatted Text
subtitlePropertyThe subtitle text that will appear below the title text.Formatted Text
fade-inHow long the title and subtitle text will fade in.Time Period0.5s
stayHow long the title and subtitle text will display for.Time Period3.5s
fade-outHow long the title and subtitle text will fade out.Time Period1s

Sub-elements

Sub-elementDescriptionValue
<replacements>A list of replacements. They can be referred to in the message text using curly braces ({replacement-id}).Replacements

Sound Attributes

AttributeDescriptionValueDefault
presetAllows you to reuse a pre-existing sound with predefined volume and pitch.Sounds PresetCUSTOM
keyThe sound type that will be played for a player.Sound Keys
volumeHow loud or quiet a sound should be.Decimal1.0
pitchThe tone of the sound.Decimal1.0

Set Attributes

AttributeDescriptionValue
varRequiredThe variable to update.Variable
indexIf setting an array-type variable, the expression to be evaluated.
Required when using array-type variables.
Expression
valueRequiredSets a new value for the variable.Expression

Alternative Inline Syntax: Variable assignments can be written using the := operator as variable_name := value or variable_name[index] := value for array variables.

<trigger filter="some-condition" action="player_score := player_score + 10" scope="player"/>

Schedule Attributes

AttributeDescriptionValue
afterThe time, in seconds, to wait before triggering an action.
Note: The value must be between 0 and 60.
Number
<action id="schedule-action-example" scope="match">
<!-- No delay -->
<message text="Message one"/>
<sound preset="alert" volume="0.75" pitch="1.5"/>
<!-- Two seconds delay -->
<schedule after="2s">
<message text="Message two"/>
<sound preset="alert" volume="0.75" pitch="1.5"/>
</schedule>
<!-- Five seconds delay -->
<schedule after="5s">
<message text="Message three"/>
<sound preset="alert" volume="0.75" pitch="1.5"/>
</schedule>
</action>

Kill-Entities Attributes

AttributeDescriptionValue
filterFilters which entities to remove.Filter

Fill Attributes

AttributeDescriptionValueDefault
regionPropertyRequiredThe region to fill in. Multiple regions will be treated as an union.Region
materialRequiredThe filling material.Single Material Pattern
filterFilters which blocks get affected. May impact performance for large fills.Filter
eventsCalls events for block placements and removals, which will make it affected by other filters and PGM features. May impact performance for large fills.true/falsefalse
updatePlaced blocks will update upon interaction, e.g., redstone, and invalid block placements such as floating ladders, "popping" off. May impact performance for large fills.true/falsetrue

Paste-Structure Attributes

AttributeDescriptionValueDefault
xThe X coordinate of the location to paste the structure, measured in east-west.Expression
yThe Y coordinate of the location to paste the structure, measured in altitude.Expression
zThe Z coordinate of the location to paste the structure, measured in north-south.Expression
structureThe structure to paste.Structure ID
updatePlaced blocks will update upon interaction, e.g., redstone, and invalid block placements such as floating ladders, "popping" off. May impact performance for large fills.true/falsetrue

Open-Shop Attributes

AttributeDescriptionValue
shopThe individual shop to open.Shop ID

Replace-Item

Sub-elements

Sub-elementsDescriptionValue
<find/>The item to find in a player's inventory.Item Attributes
<replace/>The new item to replace with.Item Attributes

Attributes

AttributeDescriptionValue
keep-amountPlayer recives the same amount of the new item as they had of the old item.true/false
keep-enchantsEnchantments on the old item will be applied to the new item.true/false
ignore-metadataIgnore the metadata of the item when matching.true/false
amountMatch for item stacks that have a certain amount of items in a range.Range

Enchant-Item Attributes

AttributeDescriptionValue
enchantmentAn item enchantment.Enchantment Name
levelThe specified enchantment's level.Expression
ignore-metadataIgnore the metadata of the item when matching.true/false

Take-Payment

Sub-elements

Sub-elementsDescriptionValue
<payment/>PropertyRequiredAn individual payment.Item Attributes
<success-action/>PropertyThe action to trigger upon a successful payment.Action
<fail-action/>PropertyThe action to trigger upon a failed payment.Action

Attributes

AttributeDescriptionValue
materialRequiredThe item to display as an icon.Material Name
priceThe amount of a currency needed to purchase.Number
currencyThe currency needed to purchase.Filter

Team-Alias Attributes

AttributeDescriptionValue
teamThe team for the action to rename.
Note: This is required if the action's scope is match; otherwise, the team will be assumed.
Team ID
aliasThe new team's name.String

Velocity & Teleport Attributes

AttributeDescriptionValue
regionThe destination region to teleport the user to.
This is available only for teleport action.
Region
xThe X coordinate, measured in east-west.Expression
yThe Y coordinate, measured in altitude.Expression
zThe Z coordinate, measured in north-south.Expression
yawThe horizontal angle a user looks to.Expression
pitchThe vertical angle a user looks to.Expression

Weather Attributes

AttributeDescriptionValue
stateThe weather type to transition into.clear, rain, thunder

Trigger Element

The trigger element waits for a dynamic filter to activate it, and afterwards it will trigger an action.

Trigger Attributes

AttributeDescriptionValueDefault
filterPropertyA dynamic filter that activates the trigger.Dynamic Filter
actionPropertySets the action to run when the filter allows.Action
scopeSpecify the scope for which to test the filter.player, team, or match
observersToggle if non-participant players can activate this trigger.
Note: This is only relevant when scope is player.
true/falsefalse

Example

<kits>
<kit id="spawn">
<item slot="0" unbreakable="true" material="stone sword"/>
<action>
<message text="You were given a kit!"/>
</action>
</kit>
</kits>
<actions>
<action id="do-stuff" scope="player">
<!-- Gives the player who activated the trigger a diamond -->
<message text="You've been given a diamond!"/>
<kit>
<item material="diamond"/>
</kit>
<!-- Sends a message to the player's team -->
<switch-scope outer="player" inner="team">
<message text="Your team has been given the spawn kit!"/>
<!-- Gives each player in the team a kit (Kits are applied per player) -->
<switch-scope outer="team" inner="player">
<kit id="spawn"/>
</switch-scope>
</switch-scope>
</action>
<trigger filter="some-dynamic-filter" action="do-stuff" scope="player"/>
<message id="standalone-text" text="This is a standalone text trigger"/>
<trigger filter="another-dynamic-filter" action="standalone-text" scope="player"/>
</actions>

Replacements

Replacement Types

TypeDescription
<decimal/>ScopedA numerical placeholder.
<player/>A player's name placeholder.
<switch>ScopedA switch-case replacement.
<replacement>A reference to a replacement in the global registry.

Global Replacement Registry

Replacements can be defined globally by including them in <replacements> in the root <map> element. In that case, defining a scope for scoped replacements is required:

<map proto="1.5.1">
<replacements>
<decimal id="example-decimal" value="points" scope="player"/>
<switch id="example-switch" scope="team">
<case filter="team-a" result="`9Team A"/>
<case filter="team-b" result="`cTeam B"/>
</switch>
</replacements>
</map>

Globally defined replacements can be accessed in message actions using the <replacement> element.

Decimal Replacement

Displays a numerical value according to the provided format.

Attributes

AttributeDescriptionValue
idUnique identifier used to reference this decimal placeholder from other places in the XML.String
valueRequiredThe variable this decimal should evaluate. It can be used with formulas.Expression
formatCustomize how the decimal should be displayed, e.g. #.00.Java DecimalFormat pattern

Player Replacement

Displays the name of a player who has an exclusive player-scoped variable assigned to them.

Attributes

AttributeDescriptionValueDefault
idRequiredUnique identifier used to reference this player placeholder from other places in the XML.String
varRequiredThe exclusive player-scoped variable to check for.Variable
styleThe style to display the player's name in.Player Replacement Styleverbose
fallbackIf no player has been assigned this variable, set the text to display instead.String

Player Replacement Styles

TypeDescriptionExampleExample (server operator view)
plainDisplays the player name without any formatting.
username
username
simple_colorDisplays the player name with team color formatting. Using this style is discouraged.
username
username
colorDisplays the player name with team color, and a click-to-teleport action. Recommended for chat messages.
username
username
fancyDisplays the player name with team color, a click-to-teleport action, flairs (prefix, suffix, etc.), and fancy formatting.
*username
*username
tabDisplays the player name formatted as a tab list entry with team color, flairs, death status, self-highlighting, etc. Using this style is discouraged.
*username
*username
verboseDisplays the player name in a manner similar to fancy, along with an alternative nickname (if present) to server operators and friends of the player.
*username
*username nickname

Switch Replacement

Selects the first matching value from a list of candidate case branches.

<switch id="player-health-state" value="player.health">
<case match="(0, 5]" result="`cAlmost dead"/>
<case match="5..10" result="`eUnwell"/>
<case match="10..15" result="`6Not great, not terrible"/>
<case match="[15, 20)" result="`4OK"/>
<case match="20" filter="blue-team" result="`aHealthy `9blue`a player"/>
<case match="20" filter="red-team" result="`aHealthy `9red`a player"/>
</switch>

Attributes

AttributeDescriptionType
idRequiredUnique identifier used to reference this switch replacement from other places in the XML.String
valuePropertyAn optional value to match against in individual switch cases. Formulas are supported.Expression

Sub-elements

Sub-elementDescriptionType
<case>Case branches to match against.Case Branch
<fallback>The fallback text to display if none of the <case> branches match. Defaults to empty text.Formatted Text

Case Branch Properties

A case branch describes the requirements for the text to be displayed. At least one of the match and filter properties must be specified. If both are specified, the filter acts as a "case guard" – meaning that the case branch will match only if the value matches the range specified by match and the filter allows.

PropertyDescriptionType
matchPropertyThe value to match against.Number Range
filterPropertyThe filter to match against.
Requiredif value is not specified in the parent <switch> element.
Filter
resultPropertyRequiredThe text to display when matched.Formatted Text

Replacement Reference

Refers to a replacement in the global registry. Takes in an id attribute, which serves as the local identifier of the replacement to be used in message text, and the global replacement ID as an inner value.

<message text="{local-id}">
<replacements>
<replacement id="local-id">global-id</replacements>
</replacements>
</message>

Examples

Enabling Blitz Mode

This example uses the expose attribute in Action to allow moderators to enable a "Blitz Mode" using the /action command. Moderators must have the GAMEPLAY permissions in order to use /action. See Commands for more details.

<actions>
<!-- Moderator uses "/action trigger start-blitz" to start this Action -->
<action id="start-blitz" expose="true" scope="match">
<!-- Sends notification to chat -->
<message text="Blitz mode has been enabled!"/>
<!-- Sets blitz_enabled to 1 -->
<set var="blitz_enabled" value="1"/>
</action>

<!-- Moderator uses "/action trigger end-blitz" to start this Action -->
<action id="end-blitz" expose="true" scope="match">
<message text="Blitz mode has been disabled!"/>
<set var="blitz_enabled" value="0"/>
</action>
</actions>
<!-- Creates the blitz_enabled variable -->
<variables>
<variable id="blitz_enabled" scope="match"/>
</variables>
<blitz>
<!-- Matches for a condition where a player loses a life -->
<filter>
<!-- If a player dies when blitz_enabled is 1, they lose a life -->
<variable var="blitz_enabled">1</variable>
</filter>
</blitz>