Skip to content

Commit

Permalink
feat(time): 尝试支持按日/周/月/总时长判别奖励。
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Sep 6, 2023
1 parent dd80c5c commit 9a85f84
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>

<deps.easyplugin.version>1.5.7</deps.easyplugin.version>
<deps.easyplugin.version>1.5.8</deps.easyplugin.version>
<deps.easysql.version>0.4.7</deps.easysql.version>
<deps.mineconfig.version>2.8.0</deps.mineconfig.version>
<deps.mineconfig.version>2.8.2</deps.mineconfig.version>
</properties>

<groupId>cc.carm.plugin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) {

for (RewardContents reward : awards) {
if (reward.getPermission() != null) {
PluginMessages.LIST.OBJECT_PERM.send(sender,
PluginMessages.LIST.OBJECT_PERM.prepare(
reward.getRewardID(), reward.getDisplayName(), reward.getType().name(),
reward.getTime(), reward.getPermission()
);
).to(sender);
} else {
PluginMessages.LIST.OBJECT.send(sender,
reward.getRewardID(), reward.getDisplayName(), reward.getType().name(), reward.getTime()
);
PluginMessages.LIST.OBJECT_PERM.prepare(
reward.getRewardID(), reward.getDisplayName(),
reward.getType().name(), reward.getTime()
).to(sender);
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) thro
Main.getInstance().getMessageProvider().reload();
Main.getInstance().getRewardProvider().reload();

PluginMessages.RELOAD.COMPLETE.send(sender, System.currentTimeMillis() - s1, TimeRewardAPI.getRewardManager().listRewards().size());
PluginMessages.RELOAD.COMPLETE.prepare(
System.currentTimeMillis() - s1,
TimeRewardAPI.getRewardManager().listRewards().size()
).to(sender);
} catch (Exception e) {
PluginMessages.RELOAD.ERROR.send(sender);
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) thro
}

UserRewardData user = TimeRewardAPI.getUserManager().get(player);
PluginMessages.USER_INFO.send(sender,
PluginMessages.USER_INFO.prepare(
player.getName(),
user.getOnlineDuration(IntervalType.DAILY).getSeconds(),
user.getOnlineDuration(IntervalType.WEEKLY).getSeconds(),
user.getOnlineDuration(IntervalType.MONTHLY).getSeconds(),
user.getOnlineDuration(IntervalType.TOTAL).getSeconds(),
user.getClaimedRewards().size()
);
).to(sender);

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
user.getClaimedRewards().forEach((id, time) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import de.themoep.minedown.MineDown;
import me.clip.placeholderapi.PlaceholderAPI;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
Expand All @@ -29,7 +28,7 @@ public class PluginMessages extends ConfigurationRoot {
return ConfiguredMessageList.create(getParser())
.whenSend((sender, message) -> {
if (sender instanceof ConsoleCommandSender) {
message.forEach(m -> sender.sendMessage(TextComponent.toLegacyText(m)));
message.forEach(m -> sender.sendMessage(BaseComponent.toLegacyText(m)));
return;
}
Player player = (Player) sender;
Expand Down

0 comments on commit 9a85f84

Please sign in to comment.