hebbinkpro / magiccrates
将可自定义的宝箱添加到您的服务器。
Requires
- php: ^8.1
- ifera-mc/config-updater: dev-master
- muqsit/simple-packet-handler: dev-pm5
- pocketmine/pocketmine-mp: ^5.0.0
- sof3/libasynql: 4.2.2
- vecnavium/formsui: dev-master
Requires (Dev)
- paroxity/commando: dev-master
README
将可自定义的宝箱添加到您的服务器。
- 添加您想要的任何宝箱类型
- 物品和命令奖励
- 以精美动画打开宝箱
- 游戏内预览菜单,显示宝箱内容,包括每个物品的稀有度
- 动态奖励
- 支持Customies
下载
- 稳定版本:
- 最新版本:Poggit CI
如何使用
命令和权限
命令别名:/magiccrates
,/mc
创建一个新的宝箱
- 使用命令
/mc create
- 点击您想放置宝箱的箱子。 (双箱子无法使用)
- 在下拉菜单中选择宝箱类型,然后点击 提交。
- 点击 保存宝箱
删除现有的宝箱
您可以使用命令删除宝箱
- 使用命令
/mc remove
- 点击您想删除的宝箱
- 点击 删除宝箱
您还可以通过破坏宝箱来删除宝箱
- 销毁宝箱
- 点击 删除宝箱
创建宝箱钥匙
您只能使用宝箱钥匙打开宝箱。每种宝箱类型都有自己的钥匙。
您可以使用命令 /mc key <crate_type> [amount] [player]
创建钥匙
当您有宝箱钥匙时,您可以点击宝箱来打开匹配的宝箱。
宝箱
同一类型的所有宝箱具有完全相同的内容,当打开某种类型的宝箱时,玩家将获得随机奖励。
宝箱类型
您可以在crate_types.json中自定义或添加自己的宝箱。
宝箱奖励
在宝箱类型中,您可以指定多个奖励。然而,并非每个奖励的表现都相同。
普通奖励在宝箱中具有固定的数量,从而使得获得物品的概率固定。
但是,您也可以创建 动态 奖励。获得这些奖励的概率和数量取决于奖励被玩家或所有玩家接收的次数。
宝箱奖励必须添加到crate_types.json,在那里您可以找到有关创建奖励的更多信息。
配置
version
- [请勿触摸] 配置文件的版本delay
- 箱子打开动画开始前的延迟prefix
- 插件发送的所有消息前缀key
- 应用于钥匙的物品show-crate-info
- 当玩家在没有钥匙的情况下点击宝箱时,玩家能否看到宝箱的内容show-reward-info
- 当玩家在宝箱信息表单中点击奖励时,玩家能否看到宝箱奖励的详细信息database
- libasynql数据库的设置
钥匙
钥匙遵循与crate reward items相同的结构。
唯一的区别是项目的name
支持一些参数,用于区分不同类型宝箱的键。
prefix
- 在 config.yml 中定义的prefix
前缀。crate
- 宝箱类型的名称。crate_id
- 宝箱类型的 ID。更多关于参数的信息可以在这里找到。
默认值
version: 1 delay: 20 prefix: §r[§6Magic§cCrates§r] key: id: minecraft:paper name: §r[§6Crate §cKey§r] §e{crate} lore: - §r[§6Magic§cCrates§r] enchantments: - name: unbreaking level: 1 show-crate-info: true show-reward-info: true database: type: sqlite sqlite: file: data.sqlite mysql: host: 127.0.0.1 username: root password: "" schema: your_schema worker-limit: 1
变更日志
v3.x 版本中最重要的变更列表。
v3.1.0
- + 使用 libasynql 实现了一个数据库。
- + 将 JSON 文件
crates.json
和rewarded_players.json
的内容分别移动到数据库的 Crates 和 Rewards 表中。 - + 添加了
Migrator
以将所有旧的 JSON 文件迁移到数据库中。 - + 添加了支持在玩家库存满或玩家在动画结束前登出时使用未收到的奖励来恢复奖励。
v3.0.0
- + 添加了奖励 ID。
- + 添加了动态奖励。
- + 添加了
keyall
命令。 - + 改进了宝箱开启动画。
- 宝箱现在将打开,并播放声音。
- 如果奖励内有多个物品,所有物品将悬停在宝箱外。
- 仅命令奖励现在将以命令方块的形式显示物品。
- | 已弃用无 ID 的奖励
- - 移除了 2.2.1 之前插件使用的 crate_type yaml->json 转换。
待办事项
- 用于管理宝箱类型的游戏内 UI。
致谢
文档
权限
宝箱类型
crate_types.json
文件包含所有宝箱类型,包括奖励。您可以在以下部分找到有关如何创建自己的自定义宝箱类型的所有规格。
如果文件有问题(例如,无效的 json、缺少必需的值或提供了无效的数据值),则插件将在启动时在服务器控制台上通知您错误的原因,以便您可以修复错误。
宝箱类型
crate_types.json
中的基本结构定义如下
{ "<type_id>": "CrateType", ... }
您可以根据需要添加尽可能多的宝箱类型(<type_id>: CrateType
)到该文件中,但每个 CrateType
都需要一个 ID!
宝箱类型
{ // the name shown above the crate "name": "string", // the crate rewards "rewards": "CrateReward[]", // commands executed after a player opened the crate "commands": "Command[]", // [optional] a reward or reward id that should be used as the replacement reward "replacement": "CrateReward|string" }
在 CrateType
中定义的替换将用作所有 DynamicCrateReward
的全局替换(除非在 DynamicCrateReward
中指定了替换)。
注册宝箱奖励
从 v3.0.0 版本开始,可以使用唯一 ID 注册宝箱奖励。建议使用唯一 ID,因为它们可以防止在重新命名无 ID 的动态奖励时出现的问题。
但由于所有 3.0.0 之前的版本都没有使用此系统,我决定使其与 v4.0.0 发布前的版本向后兼容。
推荐
{ "rewards": { "<reward_id>": "CrateReward", ... } }
弃用:(将在 v4.0.0 中删除)
{ "rewards": [ "CrateReward", ... ] }
命令
命令是一个字符串,表示您想要 CONSOLE 执行的命令,但可以在命令中包含一些参数。
命令参数
要使用参数,在字符串中包含 {<parameter>}
。
一个命令看起来可能像这样:"say {player} received {reward} from a {crate}"
。
执行此命令将在 Hebbinkpro
打开 Rare Crate
并赢得 Unique Diamond
时,产生 say Hebbinkpro received Unique Diamond from a Rare Crate
。
宝箱奖励
这是 CrateReward
的数据结构。
{ // name of the reward "name": "string", // amount of this reward inside the crate. "amount": "int", // the item(s) the player gets "items": "Item[]", // commands executed when the player wins this reward "commands": "string[]", // [optional] path/url to an image that will be displayed in the crate UI "icon": "string" }
至少应提供一个物品或命令。
这是 DynamicCrateReward
的数据结构。
{ // name of the reward "name": "string", // [optional] amount of this reward inside the crate. "amount": "int", // [optional] maximum amount of this reward the player can get "player_max": "int", // [optional] maximum amount of this reward that can be awarded server wide "global_max": "int", // [optional] amount of the replacement reward inside the crate "replace_amount": "int", // [optional] if the reward should be replaced by a replacment reward when the maximum is reached "replace": "bool", // the item(s) the player gets "items": "Item[]", // commands executed when the player wins this reward "commands": "string[]", // [optional] path/url to an image that will be displayed in the crate UI "icon": "string", // [optional] a reward or reward id that should be used as the replacement reward "replacement": "CrateReward|string" }
动态奖励是默认奖励的更复杂版本。
- 应该指定
player_max
和/或global_max
(>0),否则它是一个正常的CrateReward
。 - 如果给出了
amount
,将使用该数量进行奖励分配,否则将使用玩家可以获取奖励的次数。 - 如果给出了
replace_amount
,这将用于最大替换数量。 - 如果
replace
为false
,则奖励不会被替换。 - 如果给出了
replacement
,则将其用作奖励的替代品。 - 如果没有指定
amount
,则箱子中将包含一些基于玩家获得奖励次数的replacement
奖励。
警告:您只能使用正常的CrateReward
作为替代奖励。
图标
图标用于在没有钥匙的情况下与箱子交互时的UI。在这个UI中,箱子里所有可用的物品都会显示其图标。
默认情况下,将显示奖励物品的图标,但您可以通过提供URL来自定义此设置。
您可以使用Minecraft纹理,在这种情况下,您只需要提供指向texture pack
中纹理的路径(例如textures/items/diamond
或textures/blocks/dirt
)。
物品
这是CrateReward
中Item
的数据结构。
支持使用Customies注册的物品,但请确保您正确识别它们。
{ // id of the item (e.g. minecraft:dirt or customies:example) "id": "string", // [optional] custom name of the item "name": "string", // [optional] amount of the item the player will receive "amount": "int", // [optional] add one or more lines of lore to the item "lore": "string | string[]", // [optional] list of enchantments applied to the item "enchantments": "Enchantment | Enchantment[]" }
附魔
这是Item
中Enchantment
的数据结构。
{ // name of the enchantment "name": "string", // level of the enchantment "level": "int" }
注意:附魔名称应在PMMP中注册,否则将不会加载箱子类型。
示例箱子类型
普通箱子
{ "common": { "name": "§cCommon §6Crate", "rewards": { "iron": { "name": "Common Iron", "amount": 5, "item": { "id": "iron_ingot" } }, "dirt": { "name": "Dirt", "amount": 15, "item": { "id": "dirt", "amount": 2 } } } } }
如果玩家打开这个箱子
- 在这个普通箱子中有5x
铁
和15x泥土
。 - 箱子中奖励的总数量是20。
- 获得
铁
的概率是5/20 * 100% = 25%
。
稀有箱子
{ "rare": { "name": "§bRare §6Crate", "rewards": { "diamond": { "name": "Unique Diamond", "global_max": 1, "replacement": "dirt", "item": { "id": "diamond", "name": "Unique Diamond", "amount": 1, "lore": "The only Unique Diamond available in the server", "enchantments": [ { "name": "efficiency", "level": 1 } ] }, "commands": [ "msg {player} you are the only player in the server with this diamond." ] }, "dirt": { "name": "Dirt", "amount": 9, "item": { "id": "dirt", "amount": 2 } } }, "commands": [ "say {player} won {reward} from a {crate} crate" ] } }
如果玩家打开这个箱子
- 在这个稀有箱子中有1x
钻石
和9x泥土
。 - 如果其他用户(或自己)已经获得了
钻石
,则用1x泥土
替换钻石
。- 如果没有给出
amount
或replacement_amount
,则使用global_max
或player_max
。 - 因此现在我们有10x
泥土
。
- 如果没有给出
魔法箱子
{ "magic": { "name": "§cMagic §6Crate", "replacement": "dirt", "rewards": { "shard": { "name": "Magic Shard", "player_max": 1, "amount": 5, "replace_amount": 10, "item": { "id": "amethyst_shard", "name": "Magic Amethyst", "amount": 1, "lore": "A Shard full of Magic" }, "commands": [ "msg {player} you have received your only magic shared." ] }, "dirt": { "name": "Dirt", "amount": 40, "item": { "id": "dirt", "amount": 2 } } }, "commands": [ "say {player} won {reward} from a {crate} crate" ] } }
如果玩家打开这个箱子
- 在这个魔法箱子中有5x
碎片
和40x泥土
。 - 如果玩家已经获得了1x
碎片
,则用10x泥土
(replace_amount
xreplacement
)替换碎片。- 现在箱子中有50x
泥土
而没有碎片。
- 现在箱子中有50x