Skip to content

Menu Spell

MomoPewpew edited this page Nov 5, 2024 · 21 revisions

Source Code

spell-class: ".MenuSpell"

Description:

A spell that opens a GUI with options.

Configuration:

Option Description Default Value
title The title of the menu. Supports variable replacement. "Window Title <spellName>"
delay Delay the open event by server ticks. You should set this to at least 1 when chaining menu spells. 0
require-entity-target If set to true targets entities to cast the spell on. false
require-location-target If set to true targets locations to cast the spell at. false
target-opens-menu-instead If set to true, open the GUI for the targeted entity if require-entity-target is true. false
bypass-normal-cast If set to false, all sub-spells in all options will not be be cast as a sub-spell, but as a main spell. By default, sub-spells are cast in partial mode, ignoring cooldowns and other things listed. Using this spell option ignores all other cast arguments, and it is the equivalent of configuring all sub-spells to be cast in full mode. true
bypass-normal-cast If set to false it will check for Reagents/Modifiers/Messages/Cooldowns. true
filler An item to fill slots without items. Uses the Cast Items format. null
stay-open-non-option If set to true, when empty slots or fillers are clicked, the menu will stay open. false
min-rows If set to true, a menu with pre-set size will be created and filled. If false, the menu rows will automatically expand depending on if an item is located inside it or not. false
options It's a section with multiple menu option sections. The key can be named whatever.
auto-arrange When this is true, the slot config on your options will be ignored and the menu is automatically squished into the smallest space (ignoring options that fail their modifiers). This also adds page buttons if the MenuSpell wants to show more than 50 options. false
previous-page-item The item that is used to display the "Previous Page" button in auto-arrange mode.
next-page-item The item that is used to display the "Next Page" button in auto-arrange mode.
spacer-item The item that is shown in slot 51 in auto-arrange mode. Used to add UI elements or other tooltips.

Option configuration:

Option Description
slot The slot to put this item in. If two items have the same slot, the latest will override the previous item. Option modifiers can be used to control this and have a specific item appear based on the condition.
slots A list of slots to put the item in. The behaviour is the same as above. If both slot and slots are defined, slot will be ignored.
item Magic item to display. Can be in string format using the Cast Items format or a configuration section using the Magic Items format. Custom name and lore support variable replacement.
items List of magic items, using the Cast Items format, to pick one random item from. If this is defined, it will ignore item.
quantity Quantity of the specified item. This can be a variable name.
modifiers Modifiers which determine whether the item is displayed in the slot.
spell Sub-spell casted if item is left clicked.
spell-right Sub-spell casted if item is right clicked.
spell-middle Sub-spell casted if item is middle mouse clicked.
spell-sneak-left Sub-spell casted if item is left clicked while sneaking.
spell-sneak-right Sub-spell casted if item is right clicked while sneaking.
power The spell power of the clicked spell.
stay-open Defaults to false. Determines whether the menu should stay open when an item is clicked. The menu is reopened (refreshed) if the item clicked cast a spell which was cast successfully. If it didn't cast successfully, it doesn't close the menu.
variable-mods-click Variable-Modification A list of variables to be modified on click. These are processed before the spell is cast.
variable-mods-clicked Variable-Modification A list of variables to be modified on click. These are processed after the spell is cast, and require the spell cast to be successful.

Examples:

Menu:
    spell-class: ".MenuSpell"
    cooldown: 2
    bypass-normal-cast: false
    options: # You can have more than one defined option
        option1: # The name of the option can be anything
            slot: 0 # The first slot starts from 0 to 53
            item: stone
            quantity: 64
            stay-open: false
        option2:
            slot: 1
            item: stone
            quantity: 32
            stay-open: true # Leave the menu open if you select this
CoordsMenu: # A simple example yet a great way to use variable replacement in a MenuSpell
    spell-class: ".MenuSpell"
    cast-item: compass
    title: "&4This GUI shows your coordinates!"
    options:
        coordinates:
            slot: 1
            item: # In this case the item option is a configuration section
              type: compass
              name: "&7&lCoordinates"
              lore:
                - "&9You are now at..."
                - "&cX: &4%var:meta_location_x:0% &cY: &4%var:meta_location_y:0% &cZ: &4%var:meta_location_z:0%"
            stay-open: true
        bedcordinates:
            slot: 7
            item:
              type: bed
              name: "&b&lBed Coordinates"
              lore:
                - "&9You are now at..."
                - "&cX: &4%var:meta_bed_location_x:0% &cY: &4%var:meta_bed_location_y:0% &cZ: &4%var:meta_bed_location_z:0%"
            stay-open: true
Clone this wiki locally