forked from SteamWar/SteamWar
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:
@@ -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
|
||||
|
||||
+9
@@ -435,6 +435,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());
|
||||
|
||||
Reference in New Issue
Block a user