开始准备工作
需要安装以下插件
/papi ecloud download Math
/papi ecloud download Server
/papi ecloud download Servertime
/papi reload
#添加权限到 default 默认为 true
/lp group default permission set check_daily_task true
文件位置:PlaceholderAPI/config.yml
math:
Disable-Warnings: false
Rounding: half-up
Decimals: 0
Debug: false
#需要向上取整,不设置后面lp 在使用math变量的时候会出现问题
任务配置
任务文件:core/quest/random_tasks.yml
#任务A:破坏10个石头
break_stone_10:
meta:
name: "破坏10个石头"
objective:
1:
event: "block break"
node:
material:
- "STONE"
amount: 10
addon:
time: #次日 0 点后超时
cycle: day 00 00
ui:
display:
- "&r目标:破坏10个石头"
- "&7- 进度:{progress_1}/10 {is_complete_1}"
trigger:
accept: |
tell "你已接取任务:破坏10个石头,24小时内完成!"
complete: |
tell "任务完成,奖励已发放!"
command papi "give %player_name% minecraft:apple 1" as console
timeout: |
tell "任务超时,未完成任务。"
#任务B:破坏20个石头
break_stone_20:
meta:
name: "破坏20个石头"
objective:
1:
event: "block break"
node:
material:
- "STONE"
amount: 20
addon:
time:
cycle: day 00 00
ui:
display:
- "&r目标:破坏20个石头"
- "&7- 进度:{progress_1}/20 {is_complete_1}"
trigger:
accept: |
tell "你已接取任务:破坏20个石头,24小时内完成!"
complete: |
tell "任务完成,奖励已发放!"
command papi "give %player_name% minecraft:iron_ingot 2" as console
timeout: |
tell "任务超时,未完成任务。"
#任务C:破坏30个石头
break_stone_30:
meta:
name: "破坏30个石头"
objective:
1:
event: "block break"
node:
material:
- "STONE"
amount: 30
addon:
time:
cycle: day 00 00
ui:
display:
- "&r目标:破坏30个石头"
- "&7- 进度:{progress_1}/30 {is_complete_1}"
trigger:
accept: |
tell "你已接取任务:破坏30个石头,24小时内完成!"
complete: |
tell "任务完成,奖励已发放!"
command papi "give %player_name% minecraft:diamond 1" as console
timeout: |
tell "任务超时,未完成任务。"
对话设置
对话文件:core/conversation/npc_dialogue.yml
#绑定 npc 对话,检测之后自动跳转对应的对话框
check_daily_task:
when:
#检测有 check_daily_task 拥有权限
- if: permission check_daily_task
open: daily_task_dialogue
#检测没有 check_daily_task 权限,跳转到任务完成对话框
- open: task_completed_dialogue
daily_task_dialogue:
content:
- "你好,今天的任务是随机的!"
- "你可以每天来领取一个任务,去完成后领取奖励吧!"
answer:
- text: "领取任务!"
action: |
set randomTask to random2 1 to 3
case &randomTask [
when 1 -> {
choose quest break_stone_10 quest accept
tell "你今天的任务是:破坏10个石头!"
command papi "lp user %player_name% permission settemp check_daily_task false %math_86400-({server_time_HH}*3600+{server_time_mm}*60+{server_time_ss})%s" as console
}
when 2 -> {
choose quest break_stone_20 quest accept
tell "你今天的任务是:破坏20个石头!"
command papi "lp user %player_name% permission settemp check_daily_task false %math_86400-({server_time_HH}*3600+{server_time_mm}*60+{server_time_ss})%s" as console
}
when 3 -> {
choose quest break_stone_30 quest accept
tell "你今天的任务是:破坏30个石头!"
command papi "lp user %player_name% permission settemp check_daily_task false %math_86400-({server_time_HH}*3600+{server_time_mm}*60+{server_time_ss})%s" as console
}
]
task_completed_dialogue:
content:
- "请明天再来领取新的任务吧!"
answer:
- text: "好的,谢谢!"
action: |
tell "记得明天再来哦!"
总结
LuckPerms 临时权限关键点
- 作用:防止玩家在同一天内重复领取任务
- 实现:
通过 server_time 获取当前时间,计算当日剩余秒数:
%math_86400-({server_time_HH}*3600+{server_time_mm}*60+{server_time_ss})%
使用 LuckPerms 临时权限:(仅限文本中输入指令
/lp user %player_name% permission settemp check_daily_task false <秒数>s
- 说明:设置权限在当天结束时自动恢复,玩家次日可以领取新任务