From a154e073bd0c23130a66989807200cea40cabfe9 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Fri, 5 Aug 2022 22:49:17 +0200 Subject: [PATCH] Tried to add a way to see active boosters --- .../vboosters/commands/BoosterCommand.java | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/velocity/src/main/java/com/alttd/vboosters/commands/BoosterCommand.java b/velocity/src/main/java/com/alttd/vboosters/commands/BoosterCommand.java index 9c6fa8f..16e9e5f 100755 --- a/velocity/src/main/java/com/alttd/vboosters/commands/BoosterCommand.java +++ b/velocity/src/main/java/com/alttd/vboosters/commands/BoosterCommand.java @@ -1,11 +1,13 @@ package com.alttd.vboosters.commands; +import com.alttd.boosterapi.Booster; import com.alttd.boosterapi.BoosterType; import com.alttd.boosterapi.config.Config; import com.alttd.boosterapi.util.Utils; import com.alttd.proxydiscordlink.bot.api.DiscordSendMessage; import com.alttd.vboosters.VelocityBoosters; import com.alttd.vboosters.data.VelocityBooster; +import com.alttd.vboosters.storage.VelocityBoosterStorage; import com.mojang.brigadier.arguments.DoubleArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; @@ -20,13 +22,12 @@ import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.util.GameProfile; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.Template; import java.text.DateFormat; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -46,11 +47,42 @@ public class BoosterCommand { return builder.buildFuture(); } + private static MiniMessage miniMessage = MiniMessage.get(); public BoosterCommand(ProxyServer proxyServer) { LiteralCommandNode command = LiteralArgumentBuilder .literal("booster") .requires(ctx -> ctx.hasPermission("command.proxy.booster")) + .executes(context -> { //TODO put these messages in config + String message = "Active boosters:\n\n\nQueued boosters:\n"; + String activeBooster = " activated by until [UTC], boosts times"; + String queuedBooster = " queued by starts at [UTC] and will be active for , boosts times"; + List activeBoosterComponents = new ArrayList<>(); + List queuedBoosterComponents = new ArrayList<>(); + for (Booster booster : VelocityBoosterStorage.getVelocityBoosterStorage().getBoosters().values()) { + long expiryTime = new Date().getTime() + booster.getDuration(); + ArrayList