From 60dc00fd929cad011356d6f50603ddf060928806 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 8 Dec 2024 23:29:13 +0100 Subject: [PATCH 1/2] Limit maximum number of sent in Schematics --- .../src/SchematicSystem.properties | 1 + .../src/SchematicSystem_de.properties | 1 + .../schematiccommand/SchematicCommandUtils.java | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties index b5e1c15f..808d12e3 100644 --- a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties +++ b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties @@ -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 diff --git a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties index cf370bcb..3a3ae70a 100644 --- a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties +++ b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties @@ -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 diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java index 753cd3b9..83a62325 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java @@ -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()); From df4cd12d2a2de3ff489edbbdc50e0d6494ac1262 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 8 Dec 2024 23:29:57 +0100 Subject: [PATCH 2/2] Unused Import --- .../commands/schematiccommand/SchematicCommandUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java index 83a62325..3471673c 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java @@ -44,7 +44,6 @@ 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;