• 欢迎来到Minecraft插件百科!
  • 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
  • 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289

Magic/Shops

来自Minecraft插件百科
炫宙菌留言 | 贡献2021年6月6日 (日) 02:34的版本
跳转到导航 跳转到搜索

Magic支持多种形式的服务器GUI 商店。请参考商店 action. Like all scripted events in Magic, shops exist in the form of spells.

查看 ItemShop以获取简单范例。 还有这里也有一些范例There are also many examples included in the elMakers dev 服务器配置

在后台,商店这一动作基于拓展的选择器参数运行

添加一个商店NPC

NPCs can cast any spell, including shops. You can set one up with these commands:

/mnpc add Magic Items!
/mnpc cast magicitemshop

创建一个自定义商店

制作一个自定义商店相当容易,只要使用继承功能参考购买商店出售商店

看看这一段示例也有帮助饰品商店:

(翻译者:Magic插件的商店也是一种形式的法术,或者说有一类法术就是商店)

trinketshop:
    inherit: buyshop #继承哪个商店
    hidden: true #隐藏
    parameters: #参数
        items:
        - skull_ale
        - skull_apple
        - skull_aquarium
        - skull_arrowdown
        - ...

此法术只存在三个设置:

  • inherit 【继承】这一条告诉法术采用其他法术的全部设置。如果你想使用 buyshop 作为玩家可以购买物品的商店,或者 sellshop 作为玩家可以出售物品的商店。如果你想尝试一些更复杂的东西,请查看选择器下面的部分
  • hidden 【隐藏】这一条告诉法术让它不要出现在/spell列表、技能书或网页中。如果要做一个你自己的专属法术可能需要这么做
  • parameters Here is where you will specify what items can be bought or sold in this shop.

Parameters

The parameters section of a shop spell is mainly used for the items parameter, which specifies what items are in the shop.

You can also optionally have a scale parameter in a shop, such as in the lootshop, this will scale prices up or down. In the case of sellshops, I use a scale to make items worth consistently less when sold back then they cost to buy.

Other parameters include:

  • confirm: true/false, whether or not there should be confirmation screen before the purchase is finalized.
  • confirm_filler: A Material type used to fill in empty space in the confirmation screen.
  • auto_close: true/false, whether the shop should automatically close after a purchase is complete. Set this to false to make shops where large amounts of items can be bought or sold quickly.
  • sell: Set to true to have this shop sell items rather than buy items. Under the hood this re-writes many of the Selector parameters to flip around costs and results.

The Items List

The items parameter in a shop can take two different forms:

List of items

Just a simple list of items. The prices of the items must be defined for each item in the items config. This can be done in items.yml, or in-game using /mitem save <worth> to specify how much an item is worth.

If an item does not have a worth specified it will be offered for free.

The format itemname@amount can be used to offer multiple items in one slot.

List of configuration sections

For more complex shops, items can be specified in configuration sections. See fieldshop from the elMakers dev server configs as an example.

Each item in a shop can have a few different properties:

  • item: The Material type of the item sold in this slot.
  • slot: A specific slot of the item GUI to put this item. Omit this to just fill in order.
  • cost: The cost of this item, if omitted the saved item worth will be used.
  • name: A custom display name for this item. Will be used by the icon as well as the item given.
  • lore: A custom list of lore for this item. Will be used by the icon as well as the item given.

Empty slots

A simple none can be put in the item list for an empty slot, allowing you to organize your shops.

修改价格

Changing prices on the default builtin shops can be done two different ways.

Item Shops

For simple item shops, it's best to change the value of the item rather than change the cost in each shop that sells it. This way your server has consistent prices across shops.

This can be done in items.yml, by adding a config like this:

emerald:
  worth: 1000

or in-game, by holding the item you want to set the value for, and typing /mitem save emerald 1000

Wands and other complex shops

For non-items, such as wands or spells, the shop most likely has the prices built in. In this case you override the prices like you would any other spells' parameters- find the default configs, copy it to your Magic/spells folder and edit it.

For instance, look at the magicitemshop, it has prices listed for each item. Simply copy that file to your spells folder (or paste it in spells.yml if you prefer) and edit the prices as you wish.

This is also how you can add and remove items from a shop.

The Selector Action

The Shop action extend Selector, providing a more simplified way to set up shops that mirrors the now-deprecated ItemShop action.

However, this means that all of the parameters available to a Selector action and its options are also available to shops and shop items.

See the the Selector action section for more information on setting up complex shops or completely custom GUIs using the Selector action.