From ca5859e5bc5b4d0e07926b81e6b4fbe7fc7c25e3 Mon Sep 17 00:00:00 2001 From: CarmJos Date: Mon, 28 Feb 2022 04:54:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A4=BA=E4=BE=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timereward/data/RewardContents.java | 63 +++++++++++++++++++ src/main/resources/config.yml | 24 +++++++ 2 files changed, 87 insertions(+) create mode 100644 src/main/java/cc/carm/plugin/timereward/data/RewardContents.java diff --git a/src/main/java/cc/carm/plugin/timereward/data/RewardContents.java b/src/main/java/cc/carm/plugin/timereward/data/RewardContents.java new file mode 100644 index 0000000..5b57bbb --- /dev/null +++ b/src/main/java/cc/carm/plugin/timereward/data/RewardContents.java @@ -0,0 +1,63 @@ +package cc.carm.plugin.timereward.data; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Objects; + +public class RewardContents { + + public final @NotNull String id; + + private final long time; + private final @Nullable String name; + private final @Nullable String permission; + private final @NotNull List commands; + + + public RewardContents(@NotNull String id, long time, + @Nullable String name, @Nullable String permission, + @NotNull List commands) { + this.id = id; + this.time = time; + this.name = name; + this.permission = permission; + this.commands = commands; + } + + public String getRewardID() { + return id; + } + + public long getTime() { + return time; + } + + public @Nullable String getName() { + return name; + } + + public @Nullable String getPermission() { + return permission; + } + + public @NotNull List getCommands() { + return commands; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RewardContents that = (RewardContents) o; + return id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ed82743..b44ce7f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -21,3 +21,27 @@ database: claimed: "tr_user_claimed" # 用于记录用户奖励领取情况的表 time: "tr_user_times" # 用于记录用户在线时间的表 +# 奖励相关配置 +rewards: + + # 配置键名即奖励ID,支持英文、数字与下划线。 + # 确定后请不要更改,因为该键值用于存储玩家是否领取的数据 + # 如果更改,原先领取过该奖励的玩家将会自动再领取一次! + "example": + + # 奖励的显示名称,可以是任意字符串 + # 可以在commands 中使用 %(name) 来获取该奖励的名称 + # 也可以使用变量 %TimeReward_<奖励ID>_name% 来获取对应奖励的名称 + name: "&f[初级奖励] &e总在线时长 2小时" + + # 该奖励自动领取需要的在线时长,单位为秒 + time: 7200 + + # 该奖励领取权限,可以不设置。 + # 若为空则所有人都可以领取;若不为空,则需要拥有该权限的玩家才能领取。 + permission: "servername.vip" + + # 领取奖励时后台执行的指令 + # 支持PlaceholderAPI变量,指令中可以使用 %(name) 来获取该奖励的名称 + commands: + - "say &f恭喜 &b%player_name% &f领取了奖励 &r%(name) &f! " \ No newline at end of file