Archiviert
1
0

Merge pull request 'Add schem deadline message to /event' (#359) from deadline into master

Reviewed-on: SteamWar/BungeeCore#359
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-06-23 10:02:48 +02:00
Commit b4fb2dcedf
5 geänderte Dateien mit 40 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -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,13 @@ public class EventCommand extends BasicCommand {
if(now.isBefore(e.getDeadline().toInstant())) {
Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline());
}
String schemType = e.getSchemType();
if (schemType != null) {
SchematicType schematicType = SchematicType.fromDB(schemType);
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){

Datei anzeigen

@ -41,6 +41,7 @@ public class Event {
private final boolean publicSchemsOnly;
private final boolean spectateSystem;
private final Timestamp deadline;
private final String schemType;
private static Event current = null;
@ -53,6 +54,7 @@ public class Event {
this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly");
this.spectateSystem = rs.getBoolean("SpectateSystem");
this.deadline = rs.getTimestamp("Deadline");
this.schemType = rs.getString("SchemType");
}
public static Event get(){
@ -123,4 +125,7 @@ public class Event {
public Timestamp getDeadline() {
return deadline;
}
public String getSchemType() {
return schemType;
}
}

Datei anzeigen

@ -27,10 +27,12 @@ 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<String, SchematicType> fromDB;
private static final Map<SchematicType, SchematicType> fightType;
@ -68,13 +70,26 @@ 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);
@ -91,13 +106,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 +157,10 @@ public class SchematicType {
return name.toLowerCase();
}
public Date deadline() {
return deadline;
}
public static SchematicType fromDB(String input){
return fromDB.getOrDefault(input.toLowerCase(), null);
}

Datei anzeigen

@ -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 Submission deadline§8: §7{0}
EVENT_COMING_TEAMS=§7 With§8:{0}
EVENT_COMING_TEAM= §{0}{1}
EVENT_CURRENT_EVENT=§e§l{0}

Datei anzeigen

@ -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}