worked on storage but it still doesn't work

This commit is contained in:
2022-08-04 03:52:02 +02:00
parent 8b4178122e
commit 4818f0b509
3 changed files with 34 additions and 6 deletions
@@ -20,10 +20,13 @@ 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.minimessage.MiniMessage;
import java.text.DateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@@ -57,17 +60,22 @@ public class BoosterCommand {
.map(BoosterType::getBoosterName)
.collect(Collectors.toList())))
.then(RequiredArgumentBuilder.<CommandSource, Integer>argument("time", IntegerArgumentType.integer(0, 525960))
.suggests((context, builder) -> buildRemainingString(builder, List.of("60", "120", "180", "240", "300", "360",
"420", "480", "540", "600", "660", "720", "780", "840", "900", "960", "1020", "1080", "1140", "1200", "1260", "1320", "1380", "1440")))
.then(RequiredArgumentBuilder.<CommandSource, Double>argument("multiplier", DoubleArgumentType.doubleArg(0, 10))
.suggests((context, builder) -> buildRemainingString(builder, List.of("0.5", "1", "1.5", "2")))
.executes(context -> {
String username = context.getArgument("username", String.class);
BoosterType boosterType = BoosterType.getByName(context.getArgument("booster", String.class));
long duration = context.getArgument("time", Integer.class) * 60;
double multiplier = context.getArgument("multiplier", Double.class);
VelocityBoosters.getPlugin().getBoosterManager().addBooster(new VelocityBooster(boosterType, username, duration, multiplier));
String msg = "[" + username + "] activated booster of type [" + Utils.capitalize(boosterType.getBoosterName()) + "] until <t:"
+ (new Date().getTime() + duration) + ":f>."; //TODO check if there was a booster active already and change message based on that
DiscordSendMessage.sendEmbed(Config.BOOST_ANNOUNCE_CHANNEL, "Booster Activated", msg);
VelocityBoosters.getPlugin().getLogger().info(msg);
long expiryTime = new Date().getTime() + duration;
String msg = "[" + username + "] activated booster of type [" + Utils.capitalize(boosterType.getBoosterName()) + "] until %date%."; //TODO check if there was a booster active already and change message based on that
DiscordSendMessage.sendEmbed(Config.BOOST_ANNOUNCE_CHANNEL, "Booster Activated", msg.replaceAll("%date%", "<t:" + expiryTime + ":f>"));
String mcMessage = msg.replaceAll("%date%", DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT).format(expiryTime));
VelocityBoosters.getPlugin().getProxy().sendMessage(MiniMessage.markdown().parse(mcMessage));
VelocityBoosters.getPlugin().getLogger().info(mcMessage);
return 1;
})
)
@@ -6,6 +6,7 @@ import com.alttd.vboosters.storage.VelocityBoosterStorage;
import java.util.Collection;
import java.util.List;
import java.util.Date;
import java.util.UUID;
public class VelocityBooster implements Booster {
@@ -27,6 +28,7 @@ public class VelocityBooster implements Booster {
this.multiplier = multiplier;
this.active = false;
this.finished = false;
this.startingTime = new Date().getTime();
saveBooster();
}