feat: added scrim search function, started working on implementing weapons

This commit is contained in:
limited_dev 2022-10-08 02:02:16 +02:00
parent 455ba04935
commit 4a8b2640f4
19 changed files with 571 additions and 15 deletions

View file

@ -14,6 +14,7 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
implementation("net.dv8tion:JDA:5.0.0-alpha.20") implementation("net.dv8tion:JDA:5.0.0-alpha.20")
implementation("org.json:json:20220924")
} }
tasks.getByName<Test>("test") { tasks.getByName<Test>("test") {

BIN
loading.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 KiB

View file

@ -2,6 +2,7 @@ package de.limited_dev.lil_judd;
import de.limited_dev.lil_judd.commands.components.CommandManager; import de.limited_dev.lil_judd.commands.components.CommandManager;
import de.limited_dev.lil_judd.features.TimePlanner; import de.limited_dev.lil_judd.features.TimePlanner;
import de.limited_dev.lil_judd.features.WeaponManager;
import de.limited_dev.lil_judd.features.storage.GuildTimePlannerStorage; import de.limited_dev.lil_judd.features.storage.GuildTimePlannerStorage;
import de.limited_dev.lil_judd.listeners.GuildStateListener; import de.limited_dev.lil_judd.listeners.GuildStateListener;
import de.limited_dev.lil_judd.listeners.ReadyListener; import de.limited_dev.lil_judd.listeners.ReadyListener;
@ -16,6 +17,8 @@ import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.interactions.commands.build.Commands; import net.dv8tion.jda.api.interactions.commands.build.Commands;
import java.io.IOException;
public class Main { public class Main {
private static JDA jda; private static JDA jda;
private static Logger lgr = new Logger(); private static Logger lgr = new Logger();

View file

@ -0,0 +1,31 @@
package de.limited_dev.lil_judd.commands;
import de.limited_dev.lil_judd.commands.components.Command;
import de.limited_dev.lil_judd.commands.components.Option;
import de.limited_dev.lil_judd.features.ScrimMaker;
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
public class EndScrimCommand extends Command {
public EndScrimCommand() {
super("endscrim", "Quit a scrum / Leave the queue", null);
}
@Override
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
Guild g = event.getGuild();
User u = event.getUser();
if(!ScrimMaker.IsInGameOrQueue(g)){
EmbeddedMessageHelper.sendSimpleOneLiner(event, "Error", "The Guild wasn't in a scrim.", null);
return;
}
if(!ScrimMaker.IsUserInGameOrQueue(g, u)){
EmbeddedMessageHelper.sendSimpleOneLiner(event, "Error", "There is a game running, but you are not part of it.", null);
return;
}
ScrimMaker.LeaveQueue(g);
EmbeddedMessageHelper.sendSimpleOneLiner(event, "The Scrim has ended.", "You ended the Scrim.", null);
}
}

View file

@ -0,0 +1,32 @@
package de.limited_dev.lil_judd.commands;
import de.limited_dev.lil_judd.commands.components.Command;
import de.limited_dev.lil_judd.commands.components.Option;
import de.limited_dev.lil_judd.features.ScrimMaker;
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
public class MessageScrimCommand extends Command {
public MessageScrimCommand() {
super("msgscrim", "Msg the enemy team", null);
}
@Override
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
Guild g = event.getGuild();
User u = event.getUser();
if(!ScrimMaker.IsInGameOrQueue(g)){
EmbeddedMessageHelper.sendSimpleOneLiner(event, "Error", "The Guild is not in a scrim.", null);
return;
}
if(!ScrimMaker.IsUserInGame(g, u)){
EmbeddedMessageHelper.sendSimpleOneLiner(event, "Error", "You are not in the current game.", null);
return;
}
ScrimMaker.sendMessageToEnemy(g, u, event.getOption("message").getAsString());
EmbeddedMessageHelper.sendSimpleOneLiner(event, "Message to " + ScrimMaker.getEnemyGuild(g).getName(), u.getName() + "#" + u.getDiscriminator() + " >> " + event.getOption("message").getAsString(), u.getAvatarUrl());
//EmbeddedMessageHelper.sendSimpleOneLiner(this.enemyGuildInQueue.getGuild(), this.enemyGuildInQueue.getResponseChannel().getIdLong(), "Message from " + this.enemyGuildInQueue.getGuild().getName(), u.getName() + "#" + u.getDiscriminator() + " >> " + msg, u.getAvatarUrl());
}
}

View file

@ -0,0 +1,21 @@
package de.limited_dev.lil_judd.commands;
import de.limited_dev.lil_judd.commands.components.Command;
import de.limited_dev.lil_judd.commands.components.Option;
import de.limited_dev.lil_judd.features.ScrimMaker;
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
public class ScrimInfoCommand extends Command {
public ScrimInfoCommand() {
super("scriminfo", "", null);
}
@Override
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
EmbeddedMessageHelper.sendSimpleOneLiner(event, "ScrimMaker info",
"Guilds in queue: " + ScrimMaker.getQueueSize() + "\n" +
"Guild in game: " + ScrimMaker.getGameSize() + "\n" +
"Currently Active Users in Scrim: " + (ScrimMaker.getQueueSize() * 4 + ScrimMaker.getGameSize() * 4),null);
}
}

View file

@ -0,0 +1,35 @@
package de.limited_dev.lil_judd.commands;
import de.limited_dev.lil_judd.commands.components.Command;
import de.limited_dev.lil_judd.features.ScrimMaker;
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
public class SearchScrimCommand extends Command {
public SearchScrimCommand() {
super("searchscrim", "Search for a scrim", null);
}
@Override
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
User u1 = event.getOption("player1").getAsUser();
User u2 = event.getOption("player2").getAsUser();
User u3 = event.getOption("player3").getAsUser();
User u4 = event.getOption("player4").getAsUser();
Guild g = event.getGuild();
int div = event.getOption("div").getAsInt();
ScrimMaker.EnterQueue(g, event.getChannel().asTextChannel(), div, u1, u2, u3, u4);
//MessageEmbed eb = EmbeddedMessageHelper.getEmbeddedMessageAutomated(false, "Adding...", "We are adding you to the queue", null, false ).build();
//event.replyEmbeds(eb).queue();
EmbeddedMessageHelper.sendSimpleOneLiner(event, "<a:loading:1028062794018476093> Queuing... ",
g.getName() + " has been added to the Scrim Queue for Division " + div + "\n\n" +
"Player 1 >> " + u1.getAsMention() + "\n" +
"Player 2 >> " + u2.getAsMention() + "\n" +
"Player 3 >> " + u3.getAsMention() + "\n" +
"Player 4 >> " + u4.getAsMention(),
null);
}
}

View file

@ -1,9 +1,6 @@
package de.limited_dev.lil_judd.commands.components; package de.limited_dev.lil_judd.commands.components;
import de.limited_dev.lil_judd.commands.InfoCommand; import de.limited_dev.lil_judd.commands.*;
import de.limited_dev.lil_judd.commands.PingCommand;
import de.limited_dev.lil_judd.commands.RemoveFeatureCommand;
import de.limited_dev.lil_judd.commands.SetupFeatureCommand;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -16,6 +13,10 @@ public class CommandManager {
commands.add(new InfoCommand()); commands.add(new InfoCommand());
commands.add(new SetupFeatureCommand()); commands.add(new SetupFeatureCommand());
commands.add(new RemoveFeatureCommand()); commands.add(new RemoveFeatureCommand());
commands.add(new SearchScrimCommand());
commands.add(new EndScrimCommand());
commands.add(new MessageScrimCommand());
commands.add(new ScrimInfoCommand());
} }
public static CopyOnWriteArrayList<Command> getCommands() { public static CopyOnWriteArrayList<Command> getCommands() {

View file

@ -0,0 +1,131 @@
package de.limited_dev.lil_judd.features;
import de.limited_dev.lil_judd.features.components.scrims.GuildInQueue;
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class ScrimMaker {
private static List<GuildInQueue> queueList = new CopyOnWriteArrayList<>();
private static List<GuildInQueue> gameList = new CopyOnWriteArrayList<>();
public static void EnterQueue(Guild g, TextChannel channel, int div, User u1, User u2, User u3, User u4){
if(IsInGameOrQueue(g)){
EmbeddedMessageHelper.sendSimpleOneLiner(g, channel.getIdLong(), "Error", "You are already in a scrim or are already searching. Please stop searching first.", null);
return;
}
boolean b = false;
for(GuildInQueue gq : queueList){
if(gq.getDiv() == div || b){
b = true;
EnterGame(gq, new GuildInQueue(g, channel, div, u1, u2, u3, u4));
}
}
if(b)
return;
queueList.add(new GuildInQueue(g, channel, div, u1, u2, u3, u4));
}
public static void LeaveQueue(Guild g){
for(GuildInQueue gq : queueList){
if(gq.getGuild().equals(g)){
EndGame(gq, null);
return;
}
}
for(GuildInQueue gq : gameList){
if(gq.getGuild().equals(g)){
EndGame(gq, gq.getEnemy());
}
}
}
public static void sendMessageToEnemy(Guild g, User u, String msg){
for(GuildInQueue gq : gameList){
if(gq.getGuild().equals(g)){
gq.getEnemy().sendMessageInResponseChannel(msg, u);
}
}
}
public static boolean IsInQueue(Guild g){
for(GuildInQueue gq : queueList)
if(gq.getGuild().equals(g))
return true;
return false;
}
public static boolean IsInGame(Guild g){
for(GuildInQueue gq : gameList)
if(gq.getGuild().equals(g))
return true;
return false;
}
public static boolean IsInGameOrQueue(Guild g){
return IsInQueue(g) || IsInGame(g);
}
public static boolean IsUserInGame(Guild g, User u){
for(GuildInQueue gq : gameList){
if(gq.getGuild().equals(g)){
return gq.hasUserInIt(u);
}
}
return false;
}
public static boolean IsUserInGameOrQueue(Guild g, User u){
for(GuildInQueue gq : queueList){
if(gq.getGuild().equals(g)){
return gq.hasUserInIt(u);
}
}
for(GuildInQueue gq : gameList){
if(gq.getGuild().equals(g)){
return gq.hasUserInIt(u);
}
}
return false;
}
public static Guild getEnemyGuild(Guild g){
for(GuildInQueue gq : gameList){
if(gq.getGuild().equals(g))
return gq.getEnemy().getGuild();
}
return null;
}
private static void EnterGame(GuildInQueue gq1, GuildInQueue gq2){
queueList.remove(gq1);
gameList.add(gq1);
gameList.add(gq2);
gq1.startScrimWith(gq2);
gq2.startScrimWith(gq1);
}
private static void EndGame(GuildInQueue self, GuildInQueue withGuildinQueue){
if(withGuildinQueue != null){
withGuildinQueue.endScrim();
gameList.remove(self);
gameList.remove(withGuildinQueue);
return;
}
queueList.remove(self);
self.sendMessageInResponseChannel("You have been removed from the Queue.", null);
}
public static int getQueueSize(){
return queueList.size();
}
public static int getGameSize(){
return gameList.size();
}
}

View file

@ -33,18 +33,18 @@ public class TimePlanner {
public static void registerMessageThread(){ public static void registerMessageThread(){
// get the current ZonedDateTime of your TimeZone // get the current ZonedDateTime of your TimeZone
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(8).withMinute(0); ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Berlin"));
ZonedDateTime nextNotifyDay = now.plusDays(DayUtil.getDelay(now.getDayOfWeek().name())); ZonedDateTime nextNotifyDay = now.plusDays(DayUtil.getDelay(now.getDayOfWeek().name())).withHour(8).withMinute(0).withSecond(0);
//ZonedDateTime nextNotifyDay = now.plusSeconds(10); //ZonedDateTime nextNotifyDay = now.plusSeconds(10);
lgr.info(nextNotifyDay.getDayOfWeek() + ", " + nextNotifyDay.getDayOfMonth() + "." + nextNotifyDay.getMonth() + "." + nextNotifyDay.getYear() + " / " + nextNotifyDay.getHour() + ":" + nextNotifyDay.getMinute()); lgr.info(nextNotifyDay.getDayOfWeek() + ", " + nextNotifyDay.getDayOfMonth() + "." + nextNotifyDay.getMonth() + "." + nextNotifyDay.getYear() + " / " + nextNotifyDay.getHour() + ":" + nextNotifyDay.getMinute() + ":" + nextNotifyDay.getSecond());
//lgr.info(now.getDayOfWeek().name() + " " + nextNotifyDay.getDayOfWeek().name()); //lgr.info(now.getDayOfWeek().name() + " " + nextNotifyDay.getDayOfWeek().name());
// if it's already past the time (in this case 8:05) the first lesson will be scheduled for the next day // if it's already past the time (in this case 8:05) the first lesson will be scheduled for the next day
if (now.compareTo(nextNotifyDay) > 0) { if (now.compareTo(nextNotifyDay) > 0) {
nextNotifyDay = nextNotifyDay.plusDays(7); nextNotifyDay = nextNotifyDay.plusDays(7).withHour(8).withMinute(0);
lgr.info("See you next week"); lgr.info("See you next week");
} }
@ -65,8 +65,8 @@ public class TimePlanner {
Thread thr = new Thread(){ Thread thr = new Thread(){
@Override @Override
public void run() { public void run() {
ZonedDateTime then = ZonedDateTime.now(ZoneId.of("Europe/Berlin"));
for(Long l : gs) { for(Long l : gs) {
ZonedDateTime then;
EmbeddedMessageHelper.sendSimpleOneLiner(jda.getGuildById(l), gtps.guildsWithPlanner.get(l), "Timeplanning System", "Do you have time on the following Days?", null); EmbeddedMessageHelper.sendSimpleOneLiner(jda.getGuildById(l), gtps.guildsWithPlanner.get(l), "Timeplanning System", "Do you have time on the following Days?", null);
try { try {
Thread.sleep(2000); Thread.sleep(2000);
@ -74,7 +74,7 @@ public class TimePlanner {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
for(int i = 0; i < 7; ++i){ for(int i = 0; i < 7; ++i){
then = now.plusDays(i); then = then.plusDays(i);
MessageEmbed eb = EmbeddedMessageHelper.getEmbeddedMessageAutomated(false, null, then.getDayOfWeek() + ", " + then.getDayOfMonth() + "." + then.getMonthValue() + "." + then.getYear(), null, false).build(); MessageEmbed eb = EmbeddedMessageHelper.getEmbeddedMessageAutomated(false, null, then.getDayOfWeek() + ", " + then.getDayOfMonth() + "." + then.getMonthValue() + "." + then.getYear(), null, false).build();
jda.getGuildById(l).getTextChannelById(gtps.guildsWithPlanner.get(l)).sendMessageEmbeds(eb).queue(message -> addReactions(message)); jda.getGuildById(l).getTextChannelById(gtps.guildsWithPlanner.get(l)).sendMessageEmbeds(eb).queue(message -> addReactions(message));
try { try {
@ -92,6 +92,11 @@ public class TimePlanner {
} }
private void addReactions(Message msg){ private void addReactions(Message msg){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
msg.addReaction(Emoji.fromUnicode("")).queue(); msg.addReaction(Emoji.fromUnicode("")).queue();
try { try {
Thread.sleep(500); Thread.sleep(500);

View file

@ -0,0 +1,15 @@
package de.limited_dev.lil_judd.features;
import de.limited_dev.lil_judd.Main;
import org.json.JSONObject;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class WeaponManager {
}

View file

@ -0,0 +1,77 @@
package de.limited_dev.lil_judd.features.components.scrims;
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
import de.limited_dev.lil_judd.util.TimeUtil;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class GuildInQueue {
private final Guild g;
private GuildInQueue enemyGuildInQueue;
private final TextChannel responseChannel;
private final int div;
private final List<User> users;
private final long startedSearching;
private long startedScrim;
public GuildInQueue(Guild g, TextChannel responseChannel, int div, User u1, User u2, User u3, User u4){
this.g = g;
this.responseChannel = responseChannel;
this.div = div;
this.users = new CopyOnWriteArrayList<>(){{
add(u1);
add(u2);
add(u3);
add(u4);
}};
this.startedSearching = System.currentTimeMillis();
}
public void startScrimWith(GuildInQueue g2){
this.enemyGuildInQueue = g2;
this.startedScrim = System.currentTimeMillis();
EmbeddedMessageHelper.sendSimpleOneLiner(this.g, this.responseChannel.getIdLong(), "Team found.", "A Scrim has been found!\nTime spent queuing: " + TimeUtil.getTimeFormatedRaw(this.startedScrim - this.startedSearching) + "\nYou will play against: " + this.enemyGuildInQueue.getGuild().getName() + "\n" +
"Please communicate with the other team with /msgscrim <Msg>; end the scrim with /endscrim", this.enemyGuildInQueue.getGuild().getIconUrl(), 2);
}
public void endScrim(){
EmbeddedMessageHelper.sendSimpleOneLiner(this.g, this.responseChannel.getIdLong(), "The Scrim has ended.", "The Scrim with " + this.enemyGuildInQueue.getGuild().getName() + " was ended.", this.enemyGuildInQueue.getGuild().getIconUrl());
}
public void sendMessageInResponseChannel(String msg, User u){
if(u == null){
EmbeddedMessageHelper.sendSimpleOneLiner(this.g, this.responseChannel.getIdLong(), "Info", "System >> " + msg, null);
return;
}
EmbeddedMessageHelper.sendSimpleOneLiner(this.g, this.responseChannel.getIdLong(), "Message from " + this.enemyGuildInQueue.getGuild().getName(), u.getName() + "#" + u.getDiscriminator() + " >> " + msg, u.getAvatarUrl());
}
public boolean hasUserInIt(User u){
return users.contains(u);
}
public List<User> getUsers() {
return users;
}
public GuildInQueue getEnemy(){
return this.enemyGuildInQueue;
}
public int getDiv(){
return this.div;
}
public Guild getGuild() {
return g;
}
public TextChannel getResponseChannel(){
return this.responseChannel;
}
}

View file

@ -0,0 +1,23 @@
package de.limited_dev.lil_judd.features.components.weapon;
import de.limited_dev.lil_judd.features.components.weapon.enums.MainType;
import de.limited_dev.lil_judd.features.components.weapon.enums.SubType;
import de.limited_dev.lil_judd.features.components.weapon.enums.SpecialType;
public class WeaponKit {
private final String weaponName;
private final int reqiredLevel;
private final int pointsForSpecial;
private final MainType mainType;
private final SubType subType;
private final SpecialType specialType;
public WeaponKit(String name,int requiredLvl, int pointsForSpecial, MainType mainType, SubType subType, SpecialType specialType){
this.reqiredLevel = requiredLvl;
this.weaponName = name;
this.pointsForSpecial = pointsForSpecial;
this.mainType = mainType;
this.subType = subType;
this.specialType = specialType;
}
}

View file

@ -0,0 +1,15 @@
package de.limited_dev.lil_judd.features.components.weapon.enums;
public enum MainType {
SHOOTER,
CHARGER,
ROLLER,
BLASTER,
SLOSHER,
DUALIE,
SPLATLING,
BRUSH,
STRINGER,
BRELLA,
SPLATANA
}

View file

@ -0,0 +1,19 @@
package de.limited_dev.lil_judd.features.components.weapon.enums;
public enum SpecialType {
TRIZOOKA,
BIG_BUBBLER,
INK_VAC,
TRIPLE_INKSTRIKE,
CRAB_TANK,
WAVE_BREAKER,
ZIPCASTER,
KILLER_WAIL_5_1,
REEFSLIDER,
ULTRA_STAMP,
TACTICOOLER,
INKJET,
BOOYAH_BOMB,
INK_STORM,
TENTA_MISSILS
}

View file

@ -0,0 +1,18 @@
package de.limited_dev.lil_judd.features.components.weapon.enums;
public enum SubType {
SUCTION_BOMB,
SPLAT_BOMB,
CURLING_BOMB,
AUTO_BOMB,
SPRINKLER,
TOXIC_MIST,
FIZZY_BOMB,
TORPEDO,
INK_MINE,
POINT_SENSOR,
ANGLE_SHOOTER,
SPLASH_WALL,
BURST_BOMB,
SQUID_BEAKON
}

View file

@ -10,6 +10,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
import java.awt.*; import java.awt.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
public class EmbeddedMessageHelper { public class EmbeddedMessageHelper {
private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy @ HH:mm:ss"); private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy @ HH:mm:ss");
@ -42,6 +43,20 @@ public class EmbeddedMessageHelper {
g.getTextChannelById(channelID).sendMessageEmbeds(eb.build()).queue(); g.getTextChannelById(channelID).sendMessageEmbeds(eb.build()).queue();
} }
public static void sendSimpleOneLiner(Guild g, long channelID, String title, String description, String thumbnailURL, int delay){
LocalDateTime now = LocalDateTime.now();
EmbedBuilder eb = new EmbedBuilder();
eb.setAuthor(Main.getJda().getSelfUser().getName());
eb.setTitle(title);
eb.setColor(Color.ORANGE);
eb.setDescription(description);
if(thumbnailURL != null)
eb.setThumbnail(thumbnailURL);
eb.setFooter(">" + dtf.format(now) + " - Automated Message");
g.getTextChannelById(channelID).sendMessageEmbeds(eb.build()).queueAfter(delay, TimeUnit.SECONDS);
}
public static EmbedBuilder getEmbeddedMessageAutomated(boolean doAuthor, String title, String description, String thumbnailURL, boolean shouldAddFooter){ public static EmbedBuilder getEmbeddedMessageAutomated(boolean doAuthor, String title, String description, String thumbnailURL, boolean shouldAddFooter){
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
EmbedBuilder eb = new EmbedBuilder(); EmbedBuilder eb = new EmbedBuilder();

View file

@ -18,16 +18,31 @@ public class SlashCommandHelper {
Commands.slash("info", "Shows Info about me"), Commands.slash("info", "Shows Info about me"),
Commands.slash("setup", "Setup a feature") Commands.slash("setup", "Setup a feature")
.addOptions( .addOptions(
new OptionData(OptionType.STRING, "feature", "The Feature you want to setup") new OptionData(OptionType.STRING, "feature", "The Feature you want to setup", true)
.addChoice("Send Time finder", "timefinder") .addChoice("Send Time finder", "timefinder")
, new OptionData(OptionType.CHANNEL, "channel", "The Channel the feature will post in.") , new OptionData(OptionType.CHANNEL, "channel", "The Channel the feature will post in.", true)
), ),
Commands.slash("remove", "Remove a feature") Commands.slash("remove", "Remove a feature")
.addOptions( .addOptions(
new OptionData(OptionType.STRING, "feature", "The Feature you want to remove") new OptionData(OptionType.STRING, "feature", "The Feature you want to remove", true)
.addChoice("Send Time finder", "timefinder") .addChoice("Send Time finder", "timefinder")
, new OptionData(OptionType.CHANNEL, "channel", "The Channel with the feature") , new OptionData(OptionType.CHANNEL, "channel", "The Channel with the feature", true)
) ),
Commands.slash("searchscrim", "Search for a scrim")
.addOptions(
new OptionData(OptionType.INTEGER, "div", "The Division you want to search in", true)
, new OptionData(OptionType.USER, "player1", "The first Player of the team", true)
, new OptionData(OptionType.USER, "player2", "The second Player of the team", true)
, new OptionData(OptionType.USER, "player3", "The third Player of the team", true)
, new OptionData(OptionType.USER, "player4", "The fourth Player of the team", true)
),
Commands.slash("endscrim", "Quit a scrum / Leave the queue"),
Commands.slash("msgscrim", "Msg the enemy team")
.addOptions(
new OptionData(OptionType.STRING, "message", "Message content", true)
),
Commands.slash("scriminfo", "Show info about the scrim system.")
).queue(); ).queue();
} }

View file

@ -0,0 +1,99 @@
package de.limited_dev.lil_judd.util;
import de.limited_dev.lil_judd.Main;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
public class TimeUtil {
public static String getTimeFormatedShortend(long time) {
long days = TimeUnit.MILLISECONDS
.toDays(time);
time -= TimeUnit.DAYS.toMillis(days);
long hours = TimeUnit.MILLISECONDS
.toHours(time);
time -= TimeUnit.HOURS.toMillis(hours);
long minutes = TimeUnit.MILLISECONDS
.toMinutes(time);
time -= TimeUnit.MINUTES.toMillis(minutes);
long seconds = TimeUnit.MILLISECONDS
.toSeconds(time);
String s = "";
if(days >= 1){
s += days + "d ";
}
if (hours >= 1) {
s += hours + "h ";
}
if (minutes >= 1) {
s += minutes + "m ";
}
if (seconds >= 1 && hours < 1) {
s += seconds + "s";
}
if (s.isEmpty() || s.isBlank()) {
s = "None";
}
return s;
}
public static String getTimeFormatedRaw(long time) {
long days = TimeUnit.MILLISECONDS
.toDays(time);
time -= TimeUnit.DAYS.toMillis(days);
long hours = TimeUnit.MILLISECONDS
.toHours(time);
time -= TimeUnit.HOURS.toMillis(hours);
long minutes = TimeUnit.MILLISECONDS
.toMinutes(time);
time -= TimeUnit.MINUTES.toMillis(minutes);
long seconds = TimeUnit.MILLISECONDS
.toSeconds(time);
String s = "";
if (days >= 1) {
s += days + "d ";
}
if (hours >= 1) {
s += hours + "h ";
}
if (minutes >= 1) {
s += minutes + "m ";
}
if (seconds >= 1) {
s += seconds + "s";
}
if (s.isEmpty() || s.isBlank()) {
s = "None";
}
return s;
}
//This 100000%ly can be improved, I wrote this at 2am
public static long getTimeUnformated(String timeStr) {
long days = 0, hours = 0, minutes = 0, seconds = 0;
String[] timeArr = timeStr.split(" ");
for (String s : timeArr) {
Main.getLgr().info(s);
if (s.endsWith("d")) {
days = Long.parseLong(s.split("d")[0]);
} else if (s.endsWith("h")) {
hours = Long.parseLong(s.split("h")[0]);
} else if (s.endsWith("m")) {
minutes = Long.parseLong(s.split("m")[0]);
} else if (s.endsWith("s")) {
seconds = Long.parseLong(s.split("s")[0]);
}
}
Main.getLgr().info(Duration.ofSeconds(seconds).plus(Duration.ofMinutes(minutes)).plus(Duration.ofHours(hours)).plus(Duration.ofDays(days)).toMillis() + "");
return Duration.ofSeconds(seconds).plus(Duration.ofMinutes(minutes)).plus(Duration.ofHours(hours)).plus(Duration.ofDays(days)).toMillis();
}
}