diff --git a/src/de/steamwar/bungeecore/commands/EventCommand.java b/src/de/steamwar/bungeecore/commands/EventCommand.java index c6ed4484..3719ed24 100644 --- a/src/de/steamwar/bungeecore/commands/EventCommand.java +++ b/src/de/steamwar/bungeecore/commands/EventCommand.java @@ -20,10 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; -import de.steamwar.bungeecore.sql.Event; -import de.steamwar.bungeecore.sql.EventFight; -import de.steamwar.bungeecore.sql.Team; -import de.steamwar.bungeecore.sql.TeamTeilnahme; +import de.steamwar.bungeecore.sql.*; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -84,6 +81,10 @@ public class EventCommand extends BasicCommand { if(now.isBefore(e.getDeadline().toInstant())) { Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline()); } + SchematicType schematicType = SchematicType.get(e); + if (schematicType != null && schematicType.deadline() != null && now.isBefore(schematicType.deadline().toInstant())) { + Message.send("EVENT_COMING_SCHEM_DEADLINE", player, e.getDeadline()); + } if(!teams.isEmpty()){ StringBuilder tline = new StringBuilder(); for(Team t : teams){ diff --git a/src/de/steamwar/bungeecore/sql/SchematicType.java b/src/de/steamwar/bungeecore/sql/SchematicType.java index 978ab94a..1ccb33ca 100644 --- a/src/de/steamwar/bungeecore/sql/SchematicType.java +++ b/src/de/steamwar/bungeecore/sql/SchematicType.java @@ -27,14 +27,17 @@ import net.md_5.bungee.config.YamlConfiguration; import java.io.File; import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; public class SchematicType { - public static final SchematicType Normal = new SchematicType("Normal", "", null, Type.NORMAL, null); //Has to stay publicly availible + public static final SchematicType Normal = new SchematicType("Normal", "", null, Type.NORMAL, null, null); //Has to stay publicly availible private static final Map fromDB; private static final Map fightType; private static final List types; + private static final Map eventSchematicTypes; static { File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem"); @@ -42,6 +45,7 @@ public class SchematicType { List tmpTypes = new LinkedList<>(); Map tmpFromDB = new HashMap<>(); Map tmpFightType = new HashMap<>(); + Map tmpEventType = new HashMap<>(); tmpTypes.add(Normal); tmpFromDB.put(Normal.name().toLowerCase(), Normal); @@ -68,22 +72,41 @@ public class SchematicType { SchematicType checktype = null; if(!config.getStringList("CheckQuestions").isEmpty()) { - checktype = new SchematicType("C" + type, "C" + shortcut, material, Type.CHECK_TYPE, null); + checktype = new SchematicType("C" + type, "C" + shortcut, material, Type.CHECK_TYPE, null, null); tmpTypes.add(checktype); tmpFromDB.put(checktype.toDB(), checktype); CheckCommand.setCheckQuestions(checktype, config); } - SchematicType current = new SchematicType(type, shortcut, material, config.getKeys().contains("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype); + Date deadline; + String deadlineString = config.getString("deadline", null); + if (deadlineString != null) { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); + deadline = dateFormat.parse(deadlineString); + } catch (ParseException e) { + throw new SecurityException(e.getMessage(), e); + } + } else { + deadline = null; + } + + SchematicType current = new SchematicType(type, shortcut, material, config.getKeys().contains("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype, deadline); if(checktype != null) tmpFightType.put(checktype, current); tmpFromDB.put(type.toLowerCase(), current); + + Integer eventID = config.get("eventID", null); + if (eventID != null) { + tmpEventType.put(eventID, current); + } } } fromDB = Collections.unmodifiableMap(tmpFromDB); fightType = Collections.unmodifiableMap(tmpFightType); types = Collections.unmodifiableList(tmpTypes); + eventSchematicTypes = Collections.unmodifiableMap(tmpEventType); } private final String name; @@ -91,13 +114,15 @@ public class SchematicType { private final String material; private final Type type; private final SchematicType checkType; + private final Date deadline; - private SchematicType(String name, String kuerzel, String material, Type type, SchematicType checkType){ + private SchematicType(String name, String kuerzel, String material, Type type, SchematicType checkType, Date deadline){ this.name = name; this.kuerzel = kuerzel; this.material = material != null && !"".equals(material) ? material : "STONE_BUTTON"; this.type = type; this.checkType = checkType; + this.deadline = deadline; } public boolean isAssignable(){ @@ -140,6 +165,10 @@ public class SchematicType { return name.toLowerCase(); } + public Date deadline() { + return deadline; + } + public static SchematicType fromDB(String input){ return fromDB.getOrDefault(input.toLowerCase(), null); } @@ -148,6 +177,10 @@ public class SchematicType { return types; } + public static SchematicType get(Event event) { + return eventSchematicTypes.get(event.getEventID()); + } + enum Type{ NORMAL, CHECK_TYPE, diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index e18f608f..6f187dd2 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -238,6 +238,7 @@ EVENT_NO_CURRENT=§cThere is no event taking place currently EVENT_COMING=§eUpcoming events§8: EVENT_COMING_EVENT=§7{0}§8-§7{1}§8: §e{2} EVENT_COMING_DEADLINE=§7 Registration deadline§8: §7{0} +EVENT_COMING_SCHEM_DEADLINE=§7 Schematic deadline§8: §7{0} EVENT_COMING_TEAMS=§7 With§8:{0} EVENT_COMING_TEAM= §{0}{1} EVENT_CURRENT_EVENT=§e§l{0} diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index d3f7d227..6fc780bc 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -222,6 +222,7 @@ 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_SCHEM_DEADLINE=§7 Einsendeschluss§8: §7{0} EVENT_COMING_TEAMS=§7 Mit§8:{0} EVENT_COMING_TEAM= §{0}{1} EVENT_CURRENT_EVENT=§e§l{0}