Skip to content

Commit

Permalink
feat(time): 新增秒、分、小时、天数的变量。
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed May 10, 2024
1 parent 1078c7e commit 52f8f7b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 52f8f7b

Please sign in to comment.