ExternalCommandSpell - TheComputerGeek2/MagicSpells GitHub Wiki

Source Code

This spell extends its options from Instant Spell.

spell-class: ".ExternalCommandSpell"
  • disabled - Plays the effect at the caster's position after all commands in command-to-execute-later are executed.
Value Supported
entity true
location false
entity_from_location false

Description:

Spell executes the specified commands. It can be configured to run the commands as the caster, targeted player, or console.

Configuration:

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

Option Description Type Default Supports expressions
command-to-block Leave out the first /. The command is blocked if it starts with a listed item. String List false
command-to-execute Leave out the first /. You may list DELAY <ticks> to delay listed commands. String List Depends on do-variable-replacement
command-to-execute-later Works just like command-to-execute after command-delay. The only placeholders this option supports are %a for the caster's Entity Name, and %t for the target's if they exist. String List false
temporary-permissions A list of temporary permission nodes to grant for casting specific commands they won't have permission to execute. Using temporary-op is easier. String List false
command-delay The delay in server ticks to execute the commands in command-to-execute-later. Integer 0 true
temporary-op It's almost instant, so you don't have to worry about players using commands they are not supposed to while they are opped. Boolean false true
block-chat-output This blocks message chat output from commands, when enabled. There are two variants of this handler: one with the ProtocolLib plugin installed and one without. The one without is unreliable, as it only works for certain commands, and below 4.0 Beta 14 will send str-blocked-output instead, even if it's empty (a blank chat line). The one with ProtocolLib was broken since 1.19 for versions below 4.0 Beta 13. Boolean false false
store-chat-output Since 4.0 Beta 14. String variable name to store the command output in. Requires ProtocolLib. String false
require-player-target Boolean false false
do-variable-replacement Lets you use string expressions in commands. Before 4.0 Beta 14 %a & %t worked regardless of this option. Boolean false true
execute-as-target-instead Executes specified commands as the targeted player if require-player-target is set to true. Boolean false true
execute-on-console-instead Boolean false true
use-target-variables-instead If do-variable-replacement and require-player-target are set to true, it will parse the targeted player's variable values for the %var parameter. Boolean false true
str-blocked-output block-chat-output describes when this message will be sent. Due to a limitation, it has to be sent even if it's an empty line. String false
str-cant-use-command The message sent when the player attempts to execute a command from command-to-block. Rich Text "&4You don't have permission to do that." true

Additional Placeholders:

  • command-to-execute - always supported:
    • %<index> starting from %1: Passed spell cast arguments.

Example:

hello:
    spell-class: ".ExternalCommandSpell"
    execute-on-console-instead: true
    do-variable-replacement: true
    command-to-execute: ['say %a says "hello"!']
version:
    spell-class: ".ExternalCommandSpell"
    temporary-op: true
    command-to-execute: [version]
    command-delay: 20
    command-to-execute-later: [version MagicSpells]
maxhp:
    # Set max health to a value with:
    # /c maxhp (number)
    spell-class: ".ExternalCommandSpell"
    temporary-op: true
    do-variable-replacement: true
    command-to-execute: ["ms variable modify meta_max_health %a =%1"]
tpToBed:
    spell-class: ".ExternalCommandSpell"
    incantations: ["/home bed"]
    temporary-op: true
    do-variable-replacement: true
    command-to-execute: ["minecraft:teleport %a %var:meta_bed_location_x:0% %var:meta_bed_location_y:0% %var:meta_bed_location_z:0%"]
    str-cast-self: "Teleported to bed location. If nothing happened, your bed location is not set, and you should see an error in the console."
⚠️ **GitHub.com Fallback** ⚠️