Skip to content

PlayerMenuSpell

MomoPewpew edited this page Jul 28, 2023 · 10 revisions

Source Code

spell-class: ".PlayerMenuSpell"

Description:

This spell opens a menu with player heads of the current online players. Spells can be cast targeting selected players. Most options are "optional", as in they aren't required. For instance, you can specifically use the function of the spell to store the clicked player's name in a variable. You can limit who shows up in the menu using special modifiers or ranges.

Configuration Options:

Options Description Default Value
title Supports color codes, variable replacement, and replaces %a with caster's username.
delay Delay in server ticks. 1
radius When set to 0, shows all online players, otherwise all in radius. 0
stay-open When a player is selected in the menu, this defines if the menu should close. false
skull-name Supports color codes, variable replacement, replaces %a with caster's name, and %t with target's name.
skull-lore String list. Supports the above.
skull-name-radius Skull name displayed if the player is outside of the radius if radius is used.
skull-name-offline Supports the above, except %t replacement.
spell-offline Sub-spell cast if the selected player is offline.
spell-range Sub-spell casted if selected player is out of range.
spell-on-left Sub-spell casted when skull is left clicked. If they are targeted spells, they will target the selected player. Otherwise, they'll be cast normally.
spell-on-right Same as above, but for right-click.
spell-on-middle Same as above, but for the middle click.
spell-on-sneak-left Same as above, but for sneak left click.
spell-on-sneak-right Same as above, but for sneak right click.
player-modifiers If these modifiers don't pass, the player won't be shown in the menu.
variable-target Stores the selected player's username in this variable.

Examples:

damagePlayerMenu:
    spell-class: ".PlayerMenuSpell"
    always-granted: true
    title: "L - Smite | R - Teleport"
    # Menu opens for the target. We need the caster to open it here.
    target-self: true
    # If false, closes the menu on click.
    stay-open: true
    spell-on-left: lightning
    # Click spells don't have to be specified. If they aren't, that click won't do anything.
    spell-on-right: teleport
    # Conditions are checked against the target. If empty or not specified, they aren't checked.
    player-modifiers: [sneaking deny]

lightning:
    spell-class: ".targeted.PainSpell"
    helper-spell: true
    damage: 5
    effects:
      Lightning:
          position: target
          effect: lightning

teleport:
    spell-class: ".targeted.ShadowstepSpell"
    helper-spell: true
    distance: 0
    str-no-landing-spot: "Cannot teleport to that player."
variables:
    username: {type: playerstring}

selectPlayerMenu:
    spell-class: ".PlayerMenuSpell"
    always-granted: true
    target-self: true
    title: "&9Select to teleport"
    add-opener: true
    # ExternalCommandSpell extends Targeted, and we don't want it to be treated so.
    cast-spells-on-target: false
    spell-on-left: teleport
    # The value of the string variable can be used in further spells.
    variable-target: username

teleport:
    spell-class: ".ExternalCommandSpell"
    helper-spell: true
    do-variable-replacement: true
    command-to-execute: ["minecraft:tp %a %var:username%"]
Clone this wiki locally