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

“Magic/Shops”的版本间的差异

来自Minecraft插件百科
跳转至: 导航搜索
添加一个商店NPC
创建一个自定义商店
第35行: 第35行:
 
* '''inherit''' 【继承】这一条告诉法术采用其他法术的全部设置。如果你想使用 <code>buyshop</code> 作为玩家可以购买物品的商店,或者 <code>sellshop</code> 作为玩家可以出售物品的商店。如果你想尝试一些更复杂的东西,请查看选择器下面的部分
 
* '''inherit''' 【继承】这一条告诉法术采用其他法术的全部设置。如果你想使用 <code>buyshop</code> 作为玩家可以购买物品的商店,或者 <code>sellshop</code> 作为玩家可以出售物品的商店。如果你想尝试一些更复杂的东西,请查看选择器下面的部分
 
* '''hidden''' 【隐藏】这一条告诉法术让它不要出现在/spell列表、技能书或网页中。如果要做一个你自己的专属法术可能需要这么做
 
* '''hidden''' 【隐藏】这一条告诉法术让它不要出现在/spell列表、技能书或网页中。如果要做一个你自己的专属法术可能需要这么做
* '''parameters''' Here is where you will specify what items can be bought or sold in this shop.
+
* '''parameters'''【参数】 此处可以设置你要买卖什么物品
  
=== Parameters ===
+
=== 参数 ===
  
The parameters section of a shop spell is mainly used for the <code>items</code> parameter, which specifies what items are in the shop.
+
参数部分通常使用 <code>items</code> 参数,它可以指定商店内的物品
  
You can also optionally have a <code>scale</code> parameter in a shop, such as in the [https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/resources/examples/survival/spells/lootshop.yml 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.
+
你也可以使用 <code>scale</code> 参数来设置商店,例如在 [https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/resources/examples/survival/spells/lootshop.yml 战利品商店]的设置(似乎链接已挂), 可以设置价格范围,在出售商店的设置中使用<code>scale</code>始终使出售价格低于购买价格
  
Other parameters include:
+
其他参数还有:
  
* <code>confirm</code>: true/false, whether or not there should be confirmation screen before the purchase is finalized.
+
* <code>confirm</code>:【确认】 true/false,可以设置玩家在交易之前是否有一个确认的操作
* <code>confirm_filler</code>: A Material type used to fill in empty space in the confirmation screen.
+
* <code>confirm_filler</code>: 【填充确认】填充空的确认界面位置的材质
* <code>auto_close</code>: 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.
+
* <code>auto_close</code>: 【自动关闭】true/false,当一次交易结束后是否自动关闭商店。设置为false可以应对大量物品的交易
* <code>sell</code>: 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.
+
* <code>sell</code>: 【出售】设置为true可以让商店出售物品而非购买物品。 在后台会重新写入一些选择器参数以实现效果的反转
  
 
== The Items List ==
 
== The Items List ==

2021年6月6日 (日) 10:45的版本

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

NPC可以释放任何法术,包括商店法术。你可以用这些指令设置一个

/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【参数】 此处可以设置你要买卖什么物品

参数

参数部分通常使用 items 参数,它可以指定商店内的物品

你也可以使用 scale 参数来设置商店,例如在 战利品商店的设置(似乎链接已挂), 可以设置价格范围,在出售商店的设置中使用scale始终使出售价格低于购买价格

其他参数还有:

  • confirm:【确认】 true/false,可以设置玩家在交易之前是否有一个确认的操作
  • confirm_filler: 【填充确认】填充空的确认界面位置的材质
  • auto_close: 【自动关闭】true/false,当一次交易结束后是否自动关闭商店。设置为false可以应对大量物品的交易
  • sell: 【出售】设置为true可以让商店出售物品而非购买物品。 在后台会重新写入一些选择器参数以实现效果的反转

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.