Archiviert
1
0

Add schem deadline message to /event

Dieser Commit ist enthalten in:
yoyosource 2022-05-30 12:16:07 +02:00 committet von Lixfel
Ursprung 352497f658
Commit e7b7cc01bc
4 geänderte Dateien mit 44 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,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){

Datei anzeigen

@ -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<String, SchematicType> fromDB;
private static final Map<SchematicType, SchematicType> fightType;
private static final List<SchematicType> types;
private static final Map<Integer, SchematicType> eventSchematicTypes;
static {
File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem");
@ -42,6 +45,7 @@ public class SchematicType {
List<SchematicType> tmpTypes = new LinkedList<>();
Map<String, SchematicType> tmpFromDB = new HashMap<>();
Map<SchematicType, SchematicType> tmpFightType = new HashMap<>();
Map<Integer, SchematicType> 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,

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