欢迎来到Minecraft插件百科!
对百科编辑一脸懵逼?
帮助:快速入门
带您快速熟悉百科编辑!
因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289
查看“Magic/Selector”的源代码
←
Magic/Selector
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于这些用户组的用户执行:
用户
、
自动确认用户
、
巡查者
您可以查看和复制此页面的源代码。
== Custom GUIs with the [http://reference.elmakers.com/#actions.selector Selector] action == The Selector action can be used to create custom GUIs that can buy/sell/trade items, buff players, cast spells, modify wands and items or do anything else a spell could do. Selectors can specify a range of requirements for the entire GUI or for individual options. == Examples == The default survival configs come with several examples of using the Selector. The GUI players see when right-clicking an enchant table is in the [https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/resources/examples/survival/spells/progressmenu.yml progressmenu] configuration, for instance. Each option in the progressmenu is also another Selector, contained in its own file. The stars configs also have an example of a class-chosing mechanic in the [https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/resources/examples/stars/spells/starshop.yml starshop]. == Custom GUIs == Creating a new GUI starts by creating a new spell with a Selector action, like this: <pre class="">starshop: icon: sulphur category: shop hidden: true actions: cast: - class: Selector</pre> The first three properties aren't strictly necessary, but may be nice for testing, spell books or general organization: * <code>icon</code>: An icon used if this spell appears on a wand or as an option in some other Selector. * <code>category</code>: Organization for the /spells command, web pages or spell books. * <code>hidden</code>: Will hide this spell from the /spells command, web pages and spell book. The <code>actions</code> section, as always, specifies what the spell does. In this case it's just the Selector action. === Parameters === There are a few top-level parameters that can be used in a selector: <pre class=""> parameters: show_unavailable: true confirm: true confirm_filler: glass auto_close: true options: - .... see options section below!</pre> * <code>show_unavailable</code>: true/false, whether or not unavailable options should be shown or hidden entirely. * <code>confirm</code>: true/false, whether or not there should be confirmation screen before the selection is finalized. * <code>confirm_filler</code>: A Material type used to fill in empty space in the confirmation screen. * <code>auto_close</code>: true/false, whether the shop should automatically close after the player has selected an opion. * <code>scale</code>: A multiplier used to scale any costs in the options. * <code>earn_scale</code>: A multiplier used to scale anything earned from the options. * <code>title</code>: The title to use for the GUI inventory. This can also be specified in messages.yml * <code>confirm_title</code>: The title to use for the confirmation screen GUI inventory. This can also be specified in messages.yml * <code>unlock_confirm_title</code>: The title to use for the confirmation screen GUI inventory when unlocking an option (paying for that option to be free forever). This can also be specified in messages.yml === Options === The <code>options</code> parameter will be a list of configuration sections that specify how each inventory slot in the GUI should behave. Any properties of an option can also be specified in the base Selector parameters. In this case they will serve as the default values for all options. Each option can have any of the following properties: * <code>icon</code>: An item to use as the icon for this option. If omitted the option will automatically choose an icon based on the items or spells it offers. * <code>name</code>: The title of this option's icon, seen when hovering over it. If omitted the option will attempt to determine the name automatically for the items, classes or spells offered by the option. * <code>lore</code>: The lore to use for the icon, seen when hovering over it. If omitted the option will attempt to determine the name automatically for the items, classes or spells offered by the option. * <code>slot</code>: A specific inventory slot to put this option in. Omit to have slots filled in order. * <code>item</code>: A single item to offer. This can be an item name or a configuration section. See "Items" below. * <code>items</code>: A list of items to offer. Each item can be an item name or a configuration section. See "Items" below. * <code>cast_spell</code>: A spell to force the player to cast. This can be used to open another GUI, or make the player perform any kind of action Magic supports. * <code>commands</code>: A list of commands to run as the console. A variety of parameters can be used here, See the [http://reference.elmakers.com/#actions.command.command Command] action for details. * <code>unlock_class</code>: A [https://github.com/elBukkit/MagicPlugin/wiki/Classes class] the player will unlock * <code>switch_class</code>: A [https://github.com/elBukkit/MagicPlugin/wiki/Classes class] the player will switch to. The player's current class will be locked, and a new class will be unlocked. * <code>actions</code>: A list of actions to run when this option is selected. This can be used to make self-contained multi-level GUIs, instead of using <code>cast_spell</code> to refer to a separate spell config. * <code>effects</code>: A list of special FX to play when this option is selected. * <code>earn</code>: An amount of money (or some other currency) to give to the player on selection. * <code>earn_type</code>: The type of currency earned by this option. * <code>costs</code>: A list of costs for this option. Can be mana, money, items or any other registered currency type. (These are shown in your server logs at startup) * <code>limit</code>: Mainly used for unlock_class, specifies how many classes a player is allowed to unlock. This is used to make "choose a class" type of GUIs, where a player has to choose only one of a set number of classes. * <code>unlock</code>: A unique key used for unlocking this option. If present, the first time a player chooses this option it will unlock. Afterwards that option is available for free. This is used in the wand [https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/resources/examples/survival/spells/appearanceshop.yml appearanceshop] to allow players to collect unique wand appearances and switch to them at any time. * <code>apply_to_caster</code>: Set to true to apply the item directly to the caster, preventing the caster from being able to get this option as a physical item. * <code>apply_to_wand</code>: Set to true to apply the item directly to the caster's wand, preventing the caster from being able to get this option as a physical item. * <code>confirm</code>: true/false, whether or not there should be confirmation screen before the selection is finalized. * <code>show_unavailable</code>: true/false, whether this option should be shown if unavailable (telling the player why it is not available), or hidden completely. * <code>free</code>: Set to true to simply make this option free. Can be used with <code>/cast</code> to make a selector free for testing purposes. * <code>selected</code>: The message to to send to the player when they select this option. * <code>cost_modifiers</code>: Used to make dynamic pricing based on player attributes. See below for more info. * <code>requirements</code>: A list of requirements the player must fulfill for this option to be available. === Items === The <code>items</code> and <code>item</code> properties in an option can take two different forms for each item specified: ==== List of items ==== Just a simple list of items. Costs can not be specified here. If an item does not have a worth specified in the items configuration (e.g. <code>/mitem save <itemname> <worth></code>), it will be offered for free. The format <code>itemname@amount</code> can be used to offer multiple items in one slot. ==== List of configuration sections ==== For more complex shops, items can be specified as configuration sections. Each item can have a few different properties: * <code>item</code>: The Material type of the item sold in this slot. * <code>slot</code>: A specific slot of the item GUI to put this item. Omit this to just fill in order. * <code>cost</code>: The cost of this item, if omitted the saved item worth will be used. * <code>name</code>: A custom display name for this item. Will be used by the icon as well as the item given. * <code>lore</code>: A custom list of lore for this item. Will be used by the icon as well as the item given. === Cost Modifiers === Cost modifiers can be used to make an options' costs depend on player or wand attributes. For instance: <pre class=""> cost_modifiers: - scale: "1 + 9 * (x ^ 3)" type: wand property: protection.overall</pre> This is used for wand buffs to make the buffs progressively more expensive as they are added to the wand. The <code>type</code> property can be wand, mage, class or attribute. The first 3 types use properties on wands, mages (player data) or mage classes. The <code>attribute</code> type will use mage class attributes. The <code>property</code> property specifies which property is used. For <code>attribute</code> type modifiers, <code>attribute</code> should be used instead. The <code>scale</code> property is an equation using the specified property as the <code>x</code> variable. This equation is computed to determine a cost multiplier to use on the option's cost. See the [https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/resources/examples/survival/spells/wandbuffs.yml#L22 wandbuffs] for a full example. === Requirements === A list of requirements can be specified on each option to determine whether or not the player is allowed to select this option. Requirements can be added by external plugins, and Magic contains a variety of built in options. Each requirement can specify any of the following: * <code>permission</code>: The player must have a specific permission. * <code>path</code>: The player must have attained at least this path. * <code>path_exact</code>: The player must be on a specific path. * <code>path_end</code>: The must be on a specific path, and have no more spells available. * <code>wand</code>: The player must be holding a specific wand. * <code>wands</code>: The player must be holding one out of a list of specific wands. * <code>class</code>: The player must have a specific class unlocked. * <code>active_class</code>: The player must have a specific class currently active. * <code>holding_wand</code>: Set to true to require the player be holding a wand, though it doesn't matter what kind. * <code>wand_properties</code>: A player must be holding a wand with some specific properties. See below. * <code>class_properties</code>: A player must be have some specific properties on their active class. See below. * <code>attributes</code>: A player must have some specific attributes. See below. ==== Properties and Attributes ==== Requirements for properties and attributes are specified in a configuration section. This section specifies: * <code>property</code>/<code>attribute</code>: The property or attribute to check. * <code>min</code>: The minimum value allowed for this property or attribute. * <code>max</code>: The maximum value allowed for this property or attribute. * <code>value</code>: An exact value this property or attribute must have. For example, to stop offering a particular option once a wand's overall protection level is at 1 or higher: <pre class=""> requirements: - wand_properties: - property: protection.overall max: 1</pre> === Empty space === A simple <code>none</code> can be put in the options list for an empty slot, allowing you to organize your GUIs. You can also give each option a <code>slot</code> parameter to organize, but this may be more difficult to manage in the future when you wand to add or remove options.
返回
Magic/Selector
。
导航菜单
个人工具
登录
命名空间
页面
讨论
大陆简体
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
编辑相关
百科公告
编辑帮助
互助客栈
贡献分数
测试沙盒
发布条目
插件分类
管理
安全
聊天
编程
经济
修正
娱乐
综合
信息
机械
角色
传送
网页
整地
创世
付费
其它
工具
链入页面
相关更改
特殊页面
页面信息
相关网站
MCMOD百科
Minecraft中文百科
Minecraft纪念论坛
Minecraft百度贴吧
虚无世界Wiki