From c795692e7905c39805ace504f257e9a3d43b6e8a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 1 Mar 2021 20:53:32 +0100 Subject: [PATCH] Event deadline Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/EventCommand.java | 4 ++++ src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- src/de/steamwar/bungeecore/sql/Event.java | 5 +++++ src/de/steamwar/messages/BungeeCore.properties | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/EventCommand.java b/src/de/steamwar/bungeecore/commands/EventCommand.java index a60ea0a..680b0a9 100644 --- a/src/de/steamwar/bungeecore/commands/EventCommand.java +++ b/src/de/steamwar/bungeecore/commands/EventCommand.java @@ -78,12 +78,16 @@ public class EventCommand extends BasicCommand { private void noCurrentEvent(ProxiedPlayer player){ Message.send("EVENT_NO_CURRENT", player); List coming = Event.getComing(); + Instant now = Instant.now(); if(!coming.isEmpty()){ DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player)); Message.send("EVENT_COMING", player); for(Event e : coming){ Message.send("EVENT_COMING_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEnd().toLocalDateTime().format(dateFormat), e.getEventName()); Set teams = TeamTeilnahme.getTeams(e.getEventID()); + if(now.isBefore(e.getDeadline().toInstant())) { + Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline()); + } if(!teams.isEmpty()){ StringBuilder tline = new StringBuilder(); for(Team t : teams){ diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 85093c4..a1ca995 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -509,7 +509,7 @@ public class TeamCommand extends BasicCommand { return; } - if(Instant.now().isAfter(event.getEnd().toInstant())){ + if(Instant.now().isAfter(event.getDeadline().toInstant())){ Message.send("TEAM_EVENT_OVER", player); return; } diff --git a/src/de/steamwar/bungeecore/sql/Event.java b/src/de/steamwar/bungeecore/sql/Event.java index 336128e..72db065 100644 --- a/src/de/steamwar/bungeecore/sql/Event.java +++ b/src/de/steamwar/bungeecore/sql/Event.java @@ -37,6 +37,7 @@ public class Event { private final int maximumTeamMembers; private final boolean publicSchemsOnly; private final boolean spectateSystem; + private final Timestamp deadline; private static Event current = null; @@ -48,6 +49,7 @@ public class Event { this.maximumTeamMembers = rs.getInt("MaximumTeamMembers"); this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly"); this.spectateSystem = rs.getBoolean("SpectateSystem"); + this.deadline = rs.getTimestamp("Deadline"); } public static Event get(){ @@ -133,4 +135,7 @@ public class Event { public boolean spectateSystem(){ return spectateSystem; } + public Timestamp getDeadline() { + return deadline; + } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 9c2dc8e..71ff3ca 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -177,6 +177,7 @@ EVENT_NO_FIGHT_TEAM=§cDas Team kämpft derzeit nicht EVENT_NO_CURRENT=§cDerzeit findet kein Event statt EVENT_COMING=§eKommende Events§8: EVENT_COMING_EVENT=§7{0}§8-§7{1}§8: §e{2} +EVENT_COMING_DEADLINE=§7 Anmeldeschluss§8: §7{0} EVENT_COMING_TEAMS=§7 Mit§8:{0} EVENT_COMING_TEAM= §{0}{1} EVENT_CURRENT_EVENT=§e§l{0} @@ -400,7 +401,7 @@ TEAM_EVENT_USAGE=§8/§7team event §8[§eEvent§8] - §7um daran teilzunehmen TEAM_EVENT_HEADER=§7Dein Team nimmt an folgenden Events teil§8: TEAM_EVENT_EVENT=§7{0}§8: §e{1} TEAM_EVENT_NO_EVENT=§cDieses Event gibt es nicht -TEAM_EVENT_OVER=§cDieses Event ist bereits vorbei +TEAM_EVENT_OVER=§cDie Anmeldephase für dieses Event ist bereits vorbei TEAM_EVENT_LEFT=§7Dein Team nimmt nicht mehr am Event teil TEAM_EVENT_JOINED=§7Dein Team nimmt nun am Event §e{0} §7 teil! TEAM_EVENT_HOW_TO_LEAVE=§7Um die Teilnahme abzusagen, wiederhole den Befehl