SteamWar/BungeeCore
Archiviert
13
2

Improve reworked ChecklistChannel
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Lixfel 2024-06-27 15:51:25 +02:00
Ursprung a15bd4aa83
Commit 755ca15cca
3 geänderte Dateien mit 28 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -20,16 +20,17 @@
package de.steamwar.velocitycore.commands; package de.steamwar.velocitycore.commands;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import de.steamwar.velocitycore.ArenaMode;
import de.steamwar.persistent.Bauserver;
import de.steamwar.velocitycore.ServerStarter;
import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.discord.util.DiscordAlert;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.messages.Chatter; import de.steamwar.messages.Chatter;
import de.steamwar.messages.Message; import de.steamwar.messages.Message;
import de.steamwar.messages.PlayerChatter; import de.steamwar.messages.PlayerChatter;
import de.steamwar.persistent.Bauserver;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import de.steamwar.velocitycore.ArenaMode;
import de.steamwar.velocitycore.ServerStarter;
import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.discord.DiscordBot;
import de.steamwar.velocitycore.discord.util.DiscordAlert;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -65,6 +66,15 @@ public class CheckCommand extends SWCommand {
return currentCheckers.get(player.getUniqueId()).schematic; return currentCheckers.get(player.getUniqueId()).schematic;
} }
public static Message getWaitTime(SchematicNode schematic) {
long waitedMillis = Timestamp.from(Instant.now()).getTime() - schematic.getLastUpdate().getTime();
String ce = waitedMillis > 86400000 ? "c" : "e";
String color = waitedMillis > 14400000 ? ce : "a";
long hours = waitedMillis / 3600000;
long minutes = (waitedMillis - hours * 3600000) / 60000;
return new Message("CHECK_LIST_WAIT", color, hours, (minutes < 10) ? "0" + minutes : minutes);
}
public CheckCommand() { public CheckCommand() {
super("check", UserPerm.CHECK); super("check", UserPerm.CHECK);
@ -87,23 +97,17 @@ public class CheckCommand extends SWCommand {
for (SchematicNode schematic : schematicList) { for (SchematicNode schematic : schematicList) {
CheckSession current = currentSchems.get(schematic.getId()); CheckSession current = currentSchems.get(schematic.getId());
long waitedMillis = Timestamp.from(Instant.now()).getTime() - schematic.getLastUpdate().getTime();
String ce = waitedMillis > 86400000 ? "c" : "e";
String color = waitedMillis > 14400000 ? ce : "a";
long hours = waitedMillis / 3600000;
long minutes = (waitedMillis - hours * 3600000) / 60000;
Message waitTime = new Message("CHECK_LIST_WAIT", color, hours, (minutes < 10) ? "0" + minutes : minutes);
if (current == null) { if (current == null) {
sender.prefixless("CHECK_LIST_TO_CHECK", sender.prefixless("CHECK_LIST_TO_CHECK",
new Message("CHECK_LIST_TO_CHECK_HOVER"), new Message("CHECK_LIST_TO_CHECK_HOVER"),
ClickEvent.runCommand("/check schematic " + schematic.getId()), ClickEvent.runCommand("/check schematic " + schematic.getId()),
waitTime, getWaitTime(schematic),
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName()); schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName());
} else { } else {
sender.prefixless("CHECK_LIST_CHECKING", sender.prefixless("CHECK_LIST_CHECKING",
new Message("CHECK_LIST_CHECKING_HOVER"), new Message("CHECK_LIST_CHECKING_HOVER"),
ClickEvent.runCommand("/join " + current.checker.user().getUserName()), ClickEvent.runCommand("/join " + current.checker.user().getUserName()),
waitTime, getWaitTime(schematic),
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName(), current.checker.user().getUserName()); schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName(), current.checker.user().getUserName());
} }
} }
@ -243,7 +247,7 @@ public class CheckCommand extends SWCommand {
player -> owner.system("CHECK_ACCEPTED", schematic.getSchemtype().name(), schematic.getName()), player -> owner.system("CHECK_ACCEPTED", schematic.getSchemtype().name(), schematic.getName()),
() -> DiscordAlert.send(owner, Color.GREEN, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_ACCEPT", schematic.getName()), true) () -> DiscordAlert.send(owner, Color.GREEN, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_ACCEPT", schematic.getName()), true)
); );
Chatter.serverteam().system("CHECK_ACCEPTED_TEAM", schematic.getName(), owner.user().getUserName()); notifyTeam(new Message("CHECK_ACCEPTED_TEAM", schematic.getName(), owner.user().getUserName()));
} }
} }
@ -254,10 +258,15 @@ public class CheckCommand extends SWCommand {
player -> owner.system("CHECK_DECLINED", schematic.getSchemtype().name(), schematic.getName(), reason), player -> owner.system("CHECK_DECLINED", schematic.getSchemtype().name(), schematic.getName(), reason),
() -> DiscordAlert.send(owner, Color.RED, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_DECLINE", schematic.getName(), reason), false) () -> DiscordAlert.send(owner, Color.RED, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_DECLINE", schematic.getName(), reason), false)
); );
Chatter.serverteam().system("CHECK_DECLINED_TEAM", schematic.getName(), owner.user().getUserName(), reason); notifyTeam(new Message("CHECK_DECLINED_TEAM", schematic.getName(), owner.user().getUserName(), reason));
} }
} }
private void notifyTeam(Message message) {
Chatter.serverteam().system(message);
DiscordBot.withBot(bot -> bot.getChecklistChannel().system(message));
}
private void abort(){ private void abort(){
concludeCheckSession("Prüfvorgang abgebrochen", null); concludeCheckSession("Prüfvorgang abgebrochen", null);
} }

Datei anzeigen

@ -79,6 +79,8 @@ public class DiscordBot {
private DiscordChatRoom serverTeamChat; private DiscordChatRoom serverTeamChat;
@Getter @Getter
private StaticMessageChannel eventChannel; private StaticMessageChannel eventChannel;
@Getter
private ChecklistChannel checklistChannel;
@Getter @Getter
private final DiscordConfig config; private final DiscordConfig config;
@ -147,7 +149,7 @@ public class DiscordBot {
.build()) .build())
.setActionRows(ActionRow.of(Arrays.stream(DiscordTicketType.values()).map(DiscordTicketType::toButton).toArray(Button[]::new))), DiscordTicketHandler::openTicket); .setActionRows(ActionRow.of(Arrays.stream(DiscordTicketType.values()).map(DiscordTicketType::toButton).toArray(Button[]::new))), DiscordTicketHandler::openTicket);
eventChannel = new StaticMessageChannel(config.channel("events"), EventChannel::get); eventChannel = new StaticMessageChannel(config.channel("events"), EventChannel::get);
ChecklistChannel checklistChannel = new ChecklistChannel(config.channel("checklist")); checklistChannel = new ChecklistChannel(config.channel("checklist"));
announcementChannel = new DiscordChannel(config.channel("announcement")) { announcementChannel = new DiscordChannel(config.channel("announcement")) {
@Override @Override

Datei anzeigen

@ -22,9 +22,7 @@ package de.steamwar.velocitycore.discord.channels;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.velocitycore.commands.CheckCommand; import de.steamwar.velocitycore.commands.CheckCommand;
import net.dv8tion.jda.api.EmbedBuilder;
import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -38,18 +36,12 @@ public class ChecklistChannel extends DiscordChannel {
public void update() { public void update() {
List<SchematicNode> schems = CheckCommand.getSchemsToCheck(); List<SchematicNode> schems = CheckCommand.getSchemsToCheck();
int currentListSize = schems.size();
lastSchematics.removeIf(id -> schems.stream().noneMatch(schem -> schem.getId() == id)); lastSchematics.removeIf(id -> schems.stream().noneMatch(schem -> schem.getId() == id));
schems.removeIf(schem -> lastSchematics.contains(schem.getId())); schems.removeIf(schem -> lastSchematics.contains(schem.getId()));
for(SchematicNode schem : schems) { for(SchematicNode schem : schems) {
send(StaticMessageChannel.toMessageBuilder(new EmbedBuilder() system("CHECK_LIST_TO_CHECK", CheckCommand.getWaitTime(schem), schem.getSchemtype().getKuerzel(), SteamwarUser.get(schem.getOwner()).getUserName(), schem.getName());
.setColor(Color.GRAY)
.setTitle("Check List (" + currentListSize + ")")
.setAuthor("SteamWar", "https://www.steamwar.de")
.addField(schem.getName(), "Typ: " + schem.getSchemtype().getKuerzel() + "\nVon: " + SteamwarUser.get(schem.getOwner()).getUserName(), true)));
lastSchematics.add(schem.getId()); lastSchematics.add(schem.getId());
} }
} }