Merge branch 'master' into message
Dieser Commit ist enthalten in:
Commit
b15cca62cb
@ -30,6 +30,10 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -45,6 +49,8 @@ public class CheckSchemType {
|
|||||||
private final Map<Set<String>, Integer> limits;
|
private final Map<Set<String>, Integer> limits;
|
||||||
private final int maxBlocks;
|
private final int maxBlocks;
|
||||||
|
|
||||||
|
private final Date deadline;
|
||||||
|
|
||||||
private CheckSchemType(ConfigurationSection section) {
|
private CheckSchemType(ConfigurationSection section) {
|
||||||
String name = section.getString("Schematic.Type");
|
String name = section.getString("Schematic.Type");
|
||||||
width = section.getInt("Schematic.Size.x");
|
width = section.getInt("Schematic.Size.x");
|
||||||
@ -65,6 +71,18 @@ public class CheckSchemType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String deadlineString = section.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;
|
||||||
|
}
|
||||||
|
|
||||||
types.put(SchematicType.fromDB(name.toLowerCase()), this);
|
types.put(SchematicType.fromDB(name.toLowerCase()), this);
|
||||||
types.put(SchematicType.fromDB("c" + name.toLowerCase()), this);
|
types.put(SchematicType.fromDB("c" + name.toLowerCase()), this);
|
||||||
}
|
}
|
||||||
@ -126,6 +144,14 @@ public class CheckSchemType {
|
|||||||
return new HashMap<>(limits);
|
return new HashMap<>(limits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAfterDeadline() {
|
||||||
|
return deadline != null && deadline.before(Date.from(Instant.now()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeadline() {
|
||||||
|
return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.GERMAN).format(deadline);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final ICheckSchemType impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
public static final ICheckSchemType impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.schematicsystem.commands;
|
package de.steamwar.schematicsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.AbstractTypeMapper;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
@ -49,7 +50,7 @@ import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*;
|
|||||||
|
|
||||||
public class SchematicCommand extends SWCommand {
|
public class SchematicCommand extends SWCommand {
|
||||||
|
|
||||||
private static final Map<String, TypeMapper<?>> searchMapper = new HashMap<>();
|
private static final Map<String, AbstractTypeMapper<CommandSender, ?>> searchMapper = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
||||||
@ -657,8 +658,8 @@ public class SchematicCommand extends SWCommand {
|
|||||||
public TypeMapper<SchematicNode> publicDirNodeTypeMapper() {
|
public TypeMapper<SchematicNode> publicDirNodeTypeMapper() {
|
||||||
return new TypeMapper<SchematicNode>() {
|
return new TypeMapper<SchematicNode>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
List<String> list = publicCommandTypeMapper.tabCompletes(commandSender, strings, s);
|
Collection<String> list = publicCommandTypeMapper.tabCompletes(commandSender, strings, s);
|
||||||
list.removeIf(s1 -> !s1.endsWith("/"));
|
list.removeIf(s1 -> !s1.endsWith("/"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -731,7 +732,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
if (strings.length == 0) {
|
if (strings.length == 0) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
list.add(s);
|
list.add(s);
|
||||||
@ -740,7 +741,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
String last = strings[strings.length - 1];
|
String last = strings[strings.length - 1];
|
||||||
if (searchMapper.containsKey(last)) {
|
if (searchMapper.containsKey(last)) {
|
||||||
TypeMapper<?> mapper = searchMapper.get(last);
|
AbstractTypeMapper<CommandSender, ?> mapper = searchMapper.get(last);
|
||||||
if (mapper == null) {
|
if (mapper == null) {
|
||||||
List<String> list = new ArrayList<>(searchMapper.keySet());
|
List<String> list = new ArrayList<>(searchMapper.keySet());
|
||||||
list.add(s);
|
list.add(s);
|
||||||
|
@ -392,7 +392,13 @@ public class SchematicCommandUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoCheckResult result = CheckSchemType.get(type).autoCheck(node);
|
CheckSchemType checkSchemType = CheckSchemType.get(type);
|
||||||
|
if (checkSchemType.isAfterDeadline()) {
|
||||||
|
player.sendMessage("§cVon diesem Typen können keine Schematics mehr eingesendet werden. Einsendeschluss war: " + checkSchemType.getDeadline());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoCheckResult result = checkSchemType.autoCheck(node);
|
||||||
Collection<String> errors = result.errors();
|
Collection<String> errors = result.errors();
|
||||||
for (String warning : result.warnings()) {
|
for (String warning : result.warnings()) {
|
||||||
player.sendMessage(" §e" + warning);
|
player.sendMessage(" §e" + warning);
|
||||||
|
@ -6,5 +6,3 @@ main: de.steamwar.schematicsystem.SchematicSystem
|
|||||||
website: steamwar.de
|
website: steamwar.de
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
description: Schematic-Frontend
|
description: Schematic-Frontend
|
||||||
|
|
||||||
commands:
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren