From 52f8f7bd3a0d8e440984aaa7dad6c19b51551c5d Mon Sep 17 00:00:00 2001 From: carm Date: Sat, 11 May 2024 00:56:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(time):=20=E6=96=B0=E5=A2=9E=E7=A7=92?= =?UTF-8?q?=E3=80=81=E5=88=86=E3=80=81=E5=B0=8F=E6=97=B6=E3=80=81=E5=A4=A9?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E5=8F=98=E9=87=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../timereward/hooker/PAPIExpansion.java | 29 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4fad6c3..c5a3dcd 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ cc.carm.plugin timereward - 3.1.0 + 3.1.1 TimeReward 在线时长自动领奖插件,通过指令发放奖励,基于EasyPlugin实现。 diff --git a/src/main/java/cc/carm/plugin/timereward/hooker/PAPIExpansion.java b/src/main/java/cc/carm/plugin/timereward/hooker/PAPIExpansion.java index 280f117..6c0fdf2 100644 --- a/src/main/java/cc/carm/plugin/timereward/hooker/PAPIExpansion.java +++ b/src/main/java/cc/carm/plugin/timereward/hooker/PAPIExpansion.java @@ -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",