Merge pull request 'Limit maximum number of sent in Schematics' (#74) from SchematicSystem/no-more-than-three into main

Reviewed-on: https://steamwar.de/devlabs/SteamWar/SteamWar/pulls/74
Reviewed-by: Lixfel <lixfel@steamwar.de>
This commit is contained in:
2024-12-09 19:02:46 +01:00
3 changed files with 11 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_DONE=§aChange schematic type
UTIL_TYPE_FIGHT_ALREADY=§cYou have already submitted this schematic 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_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_ERROR=§cThe Schematic is not compliant with the rules
UTIL_TYPE_EXTEND=§aThe preparation server is starting UTIL_TYPE_EXTEND=§aThe preparation server is starting
UTIL_SUBMIT_TITLE=Extend Schematic 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_DONE=§aSchematictyp geändert
UTIL_TYPE_FIGHT_ALREADY=§cDu hast diese Schematic bereits eingesendet 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_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_ERROR=§cDie Schematic ist nicht regelkonform
UTIL_TYPE_EXTEND=§aDer Vorbereitungsserver wird gestartet UTIL_TYPE_EXTEND=§aDer Vorbereitungsserver wird gestartet
UTIL_SUBMIT_TITLE=Schematic ausfahren UTIL_SUBMIT_TITLE=Schematic ausfahren
@@ -435,6 +435,15 @@ public class SchematicCommandUtils {
return; 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); CheckSchemType checkSchemType = CheckSchemType.get(type);
if (checkSchemType.isAfterDeadline()) { if (checkSchemType.isAfterDeadline()) {
SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.getDeadline()); SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.getDeadline());