随机商店
随机商店是 AIOShop 的特色功能,商品会根据配置随机生成,为玩家带来抽奖般的体验。
基础配置
yaml
# shops/my-random-shop.yml
display-name: "&e&l随机商店"
gui-template: "random-shop"
random-generation:
enabled: true
generation-mode: "ITEM_BY_ITEM"
period: "PERSONAL_DAILY"
count: 8
allow-duplicates: false
manual-refresh-enabled: true
items:
# 商品池...生成模式
ITEM_BY_ITEM 模式
逐个随机挑选商品,适合希望稀有物品有机会出现但不保证的场景。
yaml
random-generation:
enabled: true
generation-mode: "ITEM_BY_ITEM"
count: 8 # 生成 8 个商品
allow-duplicates: false # 不允许重复工作原理:
- 计算所有商品的稀有度权重总和
- 根据权重随机选择一个商品
- 重复步骤 2 直到达到
count数量 - 如果
allow-duplicates: false,已选商品不会再次被选中
RARITY_FIRST 模式
先确定每种稀有度的商品数量,再从对应池中随机选择。
yaml
random-generation:
enabled: true
generation-mode: "RARITY_FIRST"
rarity-counts:
普通: 4
稀有: 2
史诗: 1
传说: 1工作原理:
- 根据
rarity-counts确定每种稀有度需要的商品数量 - 从每个稀有度的商品池中随机选择对应数量的商品
- 如果某稀有度商品池不足,会尽可能多地选择
刷新周期
| 周期 | 说明 | 适用场景 |
|---|---|---|
PERSONAL_DAILY | 每个玩家每天独立刷新 | 每日特惠 |
PERSONAL_WEEKLY | 每个玩家每周独立刷新 | 周常奖励 |
GLOBAL_DAILY | 全服每天统一刷新 | 限时抢购 |
GLOBAL_WEEKLY | 全服每周统一刷新 | 周末特卖 |
手动刷新
启用手动刷新后,玩家可以消耗刷新点数提前刷新商店。
yaml
random-generation:
manual-refresh-enabled: true刷新点数管理
bash
# 查询刷新点数
/shop refreshpoints Steve my-random-shop
# 设置刷新点数
/shop refreshpoints Steve my-random-shop 5
# 管理员强制刷新
/shop refresh Steve my-random-shop
# 为全服刷新商店
/shop refreshshop my-random-shop稀有度配置
在 rarities.yml 中定义稀有度:
yaml
rarities:
普通:
chance: 0.5 # 50% 权重
稀有:
chance: 0.3 # 30% 权重
史诗:
chance: 0.15 # 15% 权重
传说:
chance: 0.05 # 5% 权重权重说明
chance 值不需要加起来等于 1,插件会自动计算相对权重。
例如上述配置,传说物品的实际概率为:0.05 / (0.5 + 0.3 + 0.15 + 0.05) = 5%
商品配置
随机商店中的商品需要指定稀有度:
yaml
items:
legendary_nether_star:
item-id: "nether_star"
rarity: "传说"
display-name: "&e&l下界之星"
description:
- "&7传说中的材料"
- "&7稀有度:&6传说"
buy-price:
amount: 2000
currency: "VAULT"
buy-rewards:
self:
type: "ITEM"
item: "nether_star"
amount: 1
limit-type: "PERSONAL_DAILY"
limit-amount: 1随机限购数量
可以为商品配置随机的限购数量:
yaml
items:
common_bread:
rarity: "普通"
limit-type: "PERSONAL_DAILY"
limit-amount-range: "10-20" # 每次刷新随机在 10-20 之间完整示例
yaml
# shops/treasure-shop.yml
display-name: "&6&l宝藏商店"
description:
- "&7每日刷新的神秘商店"
- "&7包含各种稀有物品"
gui-template: "random-shop"
random-generation:
enabled: true
generation-mode: "RARITY_FIRST"
period: "PERSONAL_DAILY"
rarity-counts:
普通: 3
稀有: 2
史诗: 1
manual-refresh-enabled: true
items:
# 普通物品
bread:
item-id: "bread"
rarity: "普通"
display-name: "&f面包"
buy-price:
amount: 5
currency: "VAULT"
buy-rewards:
self:
type: "ITEM"
item: "bread"
amount: 1
limit-type: "PERSONAL_DAILY"
limit-amount-range: "10-20"
# 稀有物品
golden_apple:
item-id: "golden_apple"
rarity: "稀有"
display-name: "&6金苹果"
buy-price:
amount: 100
currency: "VAULT"
buy-rewards:
self:
type: "ITEM"
item: "golden_apple"
amount: 1
limit-type: "PERSONAL_DAILY"
limit-amount: 5
# 史诗物品
diamond_sword:
item-id: "diamond_sword"
rarity: "史诗"
display-name: "&b&l钻石剑"
buy-price:
amount: 500
currency: "VAULT"
buy-rewards:
self:
type: "ITEM"
item: "diamond_sword"
amount: 1
limit-type: "PERSONAL_DAILY"
limit-amount: 1