Skip to content

GUI 模板

AIOShop 使用模板系统来定义商店的界面布局,一个模板可以被多个商店复用。

模板文件位置

模板文件存放在 plugins/AIOShop/templates/ 目录下。

基础结构

yaml
# templates/my-template.yml
name: "自定义模板"
description: "我的自定义商店模板"
category: "custom"
size: 54
title: "&2&l%shop_name%"

item-slots: [10, 11, 12, 13, 14, 15, 16]

empty:
  name: "&7空位"
  material: GRAY_STAINED_GLASS_PANE

unknown:
  name: "&c商品已下架"
  material: RED_STAINED_GLASS_PANE

items-lore:
  - "%description%"
  - "%base_lore%"
  - ""
  - "%price_display%"

formats:
  price:
    buy_and_sell: "&7价格: &a买 %buy_price% &7| &c卖 %sell_price%"
    # ...

custom-items:
  close:
    name: "&c关闭"
    material: BARRIER
    slots: [49]
    action: "CLOSE"

配置项详解

基础属性

属性说明
name模板名称
description模板描述
category分类
size界面大小(9/18/27/36/45/54)
title界面标题,支持变量

商品槽位

item-slots 定义商品显示的位置:

yaml
# 6 行界面的槽位编号:
# 0  1  2  3  4  5  6  7  8
# 9  10 11 12 13 14 15 16 17
# 18 19 20 21 22 23 24 25 26
# 27 28 29 30 31 32 33 34 35
# 36 37 38 39 40 41 42 43 44
# 45 46 47 48 49 50 51 52 53

item-slots: [10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25]

空位和未知物品

yaml
empty:
  name: "&7空位"
  material: GRAY_STAINED_GLASS_PANE
  lore:
    - "&7该位置当前没有商品"

unknown:
  name: "&c商品已下架"
  material: RED_STAINED_GLASS_PANE
  lore:
    - "&c该商品信息已失效"

商品 Lore 模板

yaml
items-lore:
  - "%description%"        # 商品描述
  - "%base_lore%"          # 物品原有 Lore
  - ""
  - "%price_display%"      # 价格显示
  - "%limit_display%"      # 限购显示
  - "%status_display%"     # 状态显示

价格格式

yaml
formats:
  price:
    buy_and_sell: "&7价格: &a买入 %buy_price% %buy_currency_name% &7| &c卖出 %sell_price% %sell_currency_name%"
    buy_only: "&7价格: &a买入 %buy_price% %buy_currency_name%"
    sell_only: "&7价格: &c卖出 %sell_price% %sell_currency_name%"
    buy_with_discount: "&7原价: &m%original_price%&r &7| &6折扣价: &a%buy_price% &e(--%discount_percent%%)"
    not_tradeable: "&7价格: &8不可交易"
    default: "&7价格: &f未配置"

限购格式

yaml
formats:
  limit:
    limited: "&7限购: &c%current%/%max%"
    unlimited: ""

自定义按钮

yaml
custom-items:
  close:
    name: "&c&l关闭"
    material: BARRIER
    slots: [49]
    action: "CLOSE"
    lore:
      - "&7点击关闭商店"

  border:
    name: " "
    material: BLACK_STAINED_GLASS_PANE
    slots: [0, 1, 2, 3, 5, 6, 7, 8]
    action: "NULL"

  info:
    name: "&e&l商店信息"
    material: BOOK
    slots: [4]
    action: "NULL"
    lore:
      - "&7欢迎光临!"

按钮操作

操作说明
CLOSE关闭界面
NULL无操作(装饰用)
PREVIOUS_PAGE上一页
NEXT_PAGE下一页
REFRESH刷新商店(随机商店)

分页按钮

yaml
custom-items:
  previous:
    name: "&a上一页"
    material: ARROW
    slots: [45]
    action: "PREVIOUS_PAGE"
    lore:
      - "&7点击查看上一页"

  next:
    name: "&a下一页"
    material: ARROW
    slots: [53]
    action: "NEXT_PAGE"
    lore:
      - "&7点击查看下一页"

随机商店刷新按钮

yaml
custom-items:
  refresh:
    name: "&6&l刷新商店"
    material: SUNFLOWER
    slots: [4]
    action: "REFRESH"
    lore:
      - "&7消耗 1 点刷新点数"
      - "&7获取新的商品"

可用变量

标题变量

变量说明
%shop_name%商店名称
%page%当前页码
%total_pages%总页数

Lore 变量

变量说明
%description%商品描述
%base_lore%物品原有 Lore
%price_display%价格显示
%limit_display%限购显示
%status_display%状态显示
%buy_price%购买价格
%sell_price%出售价格
%buy_currency_name%购买货币名称
%sell_currency_name%出售货币名称
%discount_percent%折扣百分比
%original_price%原价

预置模板

AIOShop 提供了几个预置模板:

模板说明
general-store普通商店,适合基础交易
random-shop随机商店,带刷新按钮
compact紧凑型,适合少量商品
advanced-flexible高级灵活模板

使用模板

在商店配置中引用模板:

yaml
# shops/my-shop.yml
display-name: "&2我的商店"
gui-template: "general-store"  # 引用模板名称

items:
  # ...

基于 CC0 1.0 许可发布