1
mirror of https://github.com/carm-outsource/TimeReward.git synced 2024-09-19 11:15:52 +00:00

feat(time): 新增秒、分、小时、天数的变量。

This commit is contained in:
Carm Jos 2024-05-11 00:56:49 +08:00
parent 1078c7e03d
commit 52f8f7bd3a
2 changed files with 29 additions and 2 deletions

View File

@ -18,7 +18,7 @@
<groupId>cc.carm.plugin</groupId>
<artifactId>timereward</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<name>TimeReward</name>
<description>在线时长自动领奖插件通过指令发放奖励基于EasyPlugin实现。</description>

View File

@ -19,13 +19,40 @@ public class PAPIExpansion extends EasyPlaceholder {
public PAPIExpansion(@NotNull JavaPlugin plugin, @NotNull String rootIdentifier) {
super(plugin, rootIdentifier);
handle("time", userHandler((user, args) -> {
handle("seconds", userHandler((user, args) -> {
if (args.length < 1) return "请填写时间类型";
IntervalType type = IntervalType.parse(args[0]);
if (type == null) return "时间类型不存在";
return user.getOnlineDuration(type).getSeconds();
}), Collections.singletonList("<时间类型>"), "time");
handle("minutes", userHandler((user, args) -> {
if (args.length < 1) return "请填写时间类型";
IntervalType type = IntervalType.parse(args[0]);
if (type == null) return "时间类型不存在";
return user.getOnlineDuration(type).toMinutes();
}), Collections.singletonList("<时间类型>"));
handle("hours", userHandler((user, args) -> {
if (args.length < 1) return "请填写时间类型";
IntervalType type = IntervalType.parse(args[0]);
if (type == null) return "时间类型不存在";
return user.getOnlineDuration(type).toHours();
}), Collections.singletonList("<时间类型>"));
handle("days", userHandler((user, args) -> {
if (args.length < 1) return "请填写时间类型";
IntervalType type = IntervalType.parse(args[0]);
if (type == null) return "时间类型不存在";
return user.getOnlineDuration(type).toDays();
}), Collections.singletonList("<时间类型>"));
handle("reward",