Spell chaining - TheComputerGeek2/MagicSpells GitHub Wiki

Basics:

A spell system is multiple spells chained together. There's always one or multiple entry-point main spells that casts sub-spells, which might cast its sub-spells and such.

Main spells:

  • Main spells are the entry point of a spell chain like Passive spells, spells with cast-item-<type>, spells cast by commands, etc.
  • They are cast with the full cast mode.
  • If a chain's sub-spells are configured to be helper spells and the main spell is not, permissions to cast the spell are only checked for the main spell, meaning you only need to grant (teach or give grant permissions) the main spell.

Sub-spells:

  • All sub-spells (non-entry-point spells) are cast with the partial cast mode, skipping some processing, but the mode can be overridden as the cast arguments page covers.
  • Usually, all spells generate 5 spell permissions, which takes a toll on plugin load time. For that reason, it is recommended that all sub-spells should be configured as helper spells to skip unnecessary checks.

Helper spells:

  • They are spells that are configured with helper-spell: true.
  • They cannot be listed in ListSpell or bound with BindSpell.
  • They will not generate any spell permissions at all.
  • All players can cast them without having them in their spell book (taught or granted). They cannot be cast by the /cast command by default by non-ops because the magicspells.command.cast.self.helper permission is not given by default. If you do give it out, an alternative to preventing command casting is can-cast-by-command: false.
  • Since 4.0 Beta 17 Passive Spells marked as Helper Spells will trigger for all players.

Example:

main_spell:
    spell-class: ".MultiSpell"
    # granted to everyone
    always-granted: true
    # or we remove the above and set
    permission-name: pyro
    spells:
      # default "partial" cast mode, no msg
      - sub_spell_dummy
      # full mode
      - sub_spell_msg(mode=full)

sub_spell_dummy:
    spell-class: ".instant.DummySpell"
    helper-spell: true
    str-cast-self: "<red>this won't be sent</red>"

sub_spell_msg:
    spell-class: ".instant.DummySpell"
    helper-spell: true
    str-cast-self: "<lime>this will be sent</lime>"

Magic without writing Java

This is just some padding so that the header linking experience is better.

MagicSpells Icon
⚠️ **GitHub.com Fallback** ⚠️