From ad3bd054982a90ac9e4773c2e1e218d732fd117d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 28 Jul 2021 17:11:00 +0200 Subject: [PATCH] Fix EventManager --- .../bungeecore/bot/events/EventManager.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/bot/events/EventManager.java b/src/de/steamwar/bungeecore/bot/events/EventManager.java index 7db9fd6d..28f63454 100644 --- a/src/de/steamwar/bungeecore/bot/events/EventManager.java +++ b/src/de/steamwar/bungeecore/bot/events/EventManager.java @@ -33,6 +33,7 @@ import net.dv8tion.jda.api.entities.TextChannel; import java.awt.*; import java.sql.Timestamp; import java.time.Instant; +import java.time.temporal.ChronoUnit; @UtilityClass public class EventManager { @@ -66,9 +67,9 @@ public class EventManager { Event.getComing().forEach(event -> { StringBuilder st = new StringBuilder(); if (event.getDeadline().after(now)) { - st.append("Deadline: \n"); + st.append("Deadline: \n"); } - st.append("Start: "); + st.append("Start: "); embedBuilder.addField(event.getEventName(), st.toString(), false); }); @@ -89,8 +90,23 @@ public class EventManager { embedBuilder.setTitle("Event: " + event.getEventName()); embedBuilder.setAuthor("SteamWar", "https://www.steamwar.de"); + Instant now = Instant.now(); EventFight.getEvent(event.getEventID()).forEach(eventFight -> { - embedBuilder.addField(Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs. " + Team.get(eventFight.getTeamRed()).getTeamKuerzel(), "", true); + Team teamBlue = Team.get(eventFight.getTeamBlue()); + Team teamRed = Team.get(eventFight.getTeamRed()); + + StringBuilder st = new StringBuilder(); + st.append("Fightbeginn: "); + if(now.isAfter(eventFight.getStartTime().toInstant().plus(35, ChronoUnit.MINUTES))) { + if (eventFight.getErgebnis() == 1) { + st.append("Sieg ").append(teamBlue.getTeamKuerzel()); + } else if (eventFight.getErgebnis() == 2) { + st.append("Sieg ").append(teamRed.getTeamKuerzel()); + } else { + st.append("Unentschieden"); + } + } + embedBuilder.addField(teamBlue.getTeamKuerzel() + " vs. " + teamRed.getTeamKuerzel(), st.toString(), true); }); MessageBuilder messageBuilder = new MessageBuilder();