Limit maximum number of sent in Schematics

This commit is contained in:
2024-12-08 23:29:13 +01:00
parent e1010f79e9
commit 60dc00fd92
3 changed files with 12 additions and 0 deletions
@@ -90,6 +90,7 @@ UTIL_TYPE_ALREADY=§cThe Schematic already has this type
UTIL_TYPE_DONE=§aChange schematic type
UTIL_TYPE_FIGHT_ALREADY=§cYou have already submitted this schematic
UTIL_TYPE_AFTER_DEADLINE=§cSchematics of this type can no longer be submitted. Deadline was: {0}
UTIL_TYPE_TOO_MANY=§cYou have sent in too many Schematics
UTIL_TYPE_ERROR=§cThe Schematic is not compliant with the rules
UTIL_TYPE_EXTEND=§aThe preparation server is starting
UTIL_SUBMIT_TITLE=Extend Schematic
@@ -77,6 +77,7 @@ UTIL_TYPE_ALREADY=§cDie Schematic hat schon diesen Typen
UTIL_TYPE_DONE=§aSchematictyp geändert
UTIL_TYPE_FIGHT_ALREADY=§cDu hast diese Schematic bereits eingesendet
UTIL_TYPE_AFTER_DEADLINE=§cVon diesem Typen können keine Schematics mehr eingesendet werden. Einsendeschluss war: {0}
UTIL_TYPE_TOO_MANY=§cDu hast zu viele Schematics eingesendet
UTIL_TYPE_ERROR=§cDie Schematic ist nicht regelkonform
UTIL_TYPE_EXTEND=§aDer Vorbereitungsserver wird gestartet
UTIL_SUBMIT_TITLE=Schematic ausfahren
@@ -44,6 +44,7 @@ import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.*;
import java.util.function.BinaryOperator;
import java.util.function.IntFunction;
import java.util.function.UnaryOperator;
import java.util.logging.Level;
@@ -435,6 +436,15 @@ public class SchematicCommandUtils {
return;
}
if (SchematicType.values().stream().filter(SchematicType::check)
.map(schematicType -> SchematicNode.getAllSchematicsOfType(user.getId(), schematicType.toDB()))
.map(List::size)
.reduce(Integer::sum)
.orElse(0) >= 3) {
SchematicSystem.MESSAGE.send("UTIL_TYPE_TOO_MANY", player);
return;
}
CheckSchemType checkSchemType = CheckSchemType.get(type);
if (checkSchemType.isAfterDeadline()) {
SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.getDeadline());