SteamWar/BungeeCore
Archiviert
13
2

Velocity #516

Zusammengeführt
Lixfel hat 24 Commits von velocity nach master 2024-06-28 08:39:05 +02:00 zusammengeführt
3 geänderte Dateien mit 28 neuen und 25 gelöschten Zeilen
Nur Änderungen aus Commit 755ca15cca werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -20,16 +20,17 @@
package de.steamwar.velocitycore.commands;
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.messages.Chatter;
import de.steamwar.messages.Message;
import de.steamwar.messages.PlayerChatter;
import de.steamwar.persistent.Bauserver;
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.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@ -65,6 +66,15 @@ public class CheckCommand extends SWCommand {
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() {
super("check", UserPerm.CHECK);
@ -87,23 +97,17 @@ public class CheckCommand extends SWCommand {
for (SchematicNode schematic : schematicList) {
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) {
sender.prefixless("CHECK_LIST_TO_CHECK",
new Message("CHECK_LIST_TO_CHECK_HOVER"),
ClickEvent.runCommand("/check schematic " + schematic.getId()),
waitTime,
getWaitTime(schematic),
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName());
} else {
sender.prefixless("CHECK_LIST_CHECKING",
new Message("CHECK_LIST_CHECKING_HOVER"),
ClickEvent.runCommand("/join " + current.checker.user().getUserName()),
waitTime,
getWaitTime(schematic),
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()),
() -> 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),
() -> 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(){
concludeCheckSession("Prüfvorgang abgebrochen", null);
}

Datei anzeigen

@ -79,6 +79,8 @@ public class DiscordBot {
private DiscordChatRoom serverTeamChat;
@Getter
private StaticMessageChannel eventChannel;
@Getter
private ChecklistChannel checklistChannel;
@Getter
private final DiscordConfig config;
@ -147,7 +149,7 @@ public class DiscordBot {
.build())
.setActionRows(ActionRow.of(Arrays.stream(DiscordTicketType.values()).map(DiscordTicketType::toButton).toArray(Button[]::new))), DiscordTicketHandler::openTicket);
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")) {
@Override

Datei anzeigen

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