From 834bcb5428f7a9493f594f35cbb89d515eae46f5 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 21 May 2022 13:26:38 +0200 Subject: [PATCH] :art: Add AutoCheckResult and SafeSchematicNode to Multilang --- .../src/SchematicSystem.properties | 22 +++++- .../schematicsystem/AutoCheckResult.java | 70 +++++++++++-------- .../schematicsystem/SafeSchematicNode.java | 14 ++-- 3 files changed, 69 insertions(+), 37 deletions(-) diff --git a/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem_Core/src/SchematicSystem.properties index ab82e1e..c7d3ebb 100644 --- a/SchematicSystem_Core/src/SchematicSystem.properties +++ b/SchematicSystem_Core/src/SchematicSystem.properties @@ -1 +1,21 @@ -PREFIX=§eSchematic§8» §7 \ No newline at end of file +PREFIX=§eSchematic§8» §7 + +AUTO_CHECK_RESULT_NOT_LOAD=Die Schematic konnte nicht geladen werden +AUTO_CHECK_RESULT_TOO_WIDE=Die Schematic ist zu breit ({0} > {1}) +AUTO_CHECK_RESULT_TOO_LONG=Die Schematic ist zu lang ({0} > {1}) +AUTO_CHECK_RESULT_TOO_HIGH=Die Schematic ist zu hoch ({0} > {1}) +AUTO_CHECK_RESULT_TOO_MANY_BLOCK=Der Block {0} wurde {1} mal zu häufig verbaut +AUTO_CHECK_RESULT_TOO_MANY_BLOCKS=Die Blockkombination {0} wurde {1} mal zu häufig verbaut +AUTO_CHECK_RESULT_TOO_MANY_ALL_BLOCKS=Zu viele Blöcke ({0} > {1}) +AUTO_CHECK_RESULT_TOO_MANY_RECORDS=Keine Schallplatten erlaubt ({0} gefunden) +AUTO_CHECK_RESULT_FORBIDDEN_ITEM=In {0}s wurde das verbotene Item {1} {2} mal gefunden +AUTO_CHECK_RESULT_FORBIDDEN_ITEM_NBT=In {0}s wurde das verbotene Item {1} {2} mal mit Custom-Tag gefunden +AUTO_CHECK_RESULT_TOO_MANY_DISPENSER_ITEMS=Ein Werfer enthält mehr als {0} Pfeile und Feuerbälle +AUTO_CHECK_RESULT_TOO_MANY_DISPENSERS_ITEMS={0} Werfer enthält mehr als {1} Pfeile und Feuerbälle +AUTO_CHECK_RESULT_NBTS_WARNING={0} {1}s enthalten keine oder inkorrekte NBT-Daten +AUTO_CHECK_RESULT_NBT_WARNING=Ein(e) {0} enthält keine oder inkorrekte NBT-Daten + +SAFE_NODE_NOT_A_DIR=§cDie ausgewählte Schematic ist kein Ordner +SAFE_NODE_ALREADY_IN_DIRECTORY=§cDie Schematic gibt es bereits in diesem Ordner +SAFE_NODE_INVALID_NAME=§cDieser Name ist unzulässig +SAFE_NODE_NOT_OWNER=§cDu bist nicht der Besitzer dieser Schematic diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/AutoCheckResult.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/AutoCheckResult.java index d3760a9..2f69c9e 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/AutoCheckResult.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/AutoCheckResult.java @@ -47,53 +47,67 @@ public class AutoCheckResult { this.limitedMaterials = type.getLimits(); } - public Collection errors() { - List errors = new LinkedList<>(); + public Map errors() { + Map errors = new HashMap<>(); - if(errorLoadingSchematic) - errors.add("Die Schematic konnte nicht geladen werden"); + if(errorLoadingSchematic) { + errors.put("AUTO_CHECK_RESULT_NOT_LOAD", new Object[0]); + } assert type != null; + // SW Quality Code, Check the Comments! if(width > type.getDepth()) - errors.add("Die Schematic ist zu breit (" + width + " > " + type.getDepth() + ")"); + // Width + errors.put("AUTO_CHECK_RESULT_TOO_WIDE", new Object[]{width, type.getDepth()}); if(length > type.getWidth()) - errors.add("Die Schematic ist zu lang (" + length + " > " + type.getWidth() + ")"); + // Length + errors.put("AUTO_CHECK_RESULT_TOO_LONG", new Object[]{width, type.getWidth()}); if(height > type.getHeight()) - errors.add("Die Schematic ist zu hoch (" + height + " > " + type.getHeight() + ")"); + errors.put("AUTO_CHECK_RESULT_TOO_HIGH", new Object[]{height, type.getHeight()}); for(Map.Entry, Integer> entry : limitedMaterials.entrySet()) { - if(entry.getValue() < 0) - errors.add((entry.getKey().size() == 1 ? "Der Block " : "Die Blockkombination") + String.join(" ", entry.getKey()) + " wurde " + (-entry.getValue()) + " mal zu häufig verbaut"); + if(entry.getValue() < 0) { + errors.put((entry.getKey().size() == 1 ? "AUTO_CHECK_RESULT_TOO_MANY_BLOCK " : "AUTO_CHECK_RESULT_TOO_MANY_BLOCKS"), new Object[]{String.join(" ", entry.getKey()), -entry.getValue()}); + } } if(type.getMaxBlocks() != 0 && blocks > type.getMaxBlocks()) { - errors.add("Zu viele Blöcke (" + blocks + " > " + type.getMaxBlocks() + ")"); + errors.put("AUTO_CHECK_RESULT_TOO_MANY_ALL_BLOCKS", new Object[]{blocks, type.getMaxBlocks()}); } - if(records > 0) - errors.add("Keine Schallplatten erlaubt (" + records + " gefunden)"); - for(Map.Entry> block : forbiddenItems.entrySet()) - for(Map.Entry item : block.getValue().entrySet()) - errors.add("In " + block.getKey() + "s wurde das verbotene Item " + item.getKey() + " " + item.getValue() + " mal gefunden"); - for(Map.Entry> block : itemsWithTag.entrySet()) - for(Map.Entry item : block.getValue().entrySet()) - errors.add("In " + block.getKey() + "s wurde das Item " + item.getKey() + " " + item.getValue() + " mal mit Custom-Tag gefunden"); - if(tooManyDispenserItems == 1) - errors.add("Ein Werfer enthält mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle"); - else if(tooManyDispenserItems > 1) - errors.add(tooManyDispenserItems + " Werfer enthalten mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle"); + if(records > 0) { + errors.put("AUTO_CHECK_RESULT_TOO_MANY_RECORDS", new Object[]{records}); + } + + for(Map.Entry> block : forbiddenItems.entrySet()) { + for (Map.Entry item : block.getValue().entrySet()) { + errors.put("AUTO_CHECK_RESULT_FORBIDDEN_ITEM", new Object[]{block.getKey(), item.getKey(), item.getValue()}); + } + } + for(Map.Entry> block : itemsWithTag.entrySet()) { + for (Map.Entry item : block.getValue().entrySet()) { + errors.put("AUTO_CHECK_RESULT_FORBIDDEN_ITEM_NBT", new Object[]{block.getKey(), item.getKey(), item.getValue()}); + } + } + if(tooManyDispenserItems == 1) { + errors.put("AUTO_CHECK_RESULT_TOO_MANY_DISPENSER_ITEMS", new Object[]{type.getMaxDispenserItems()}); + } + else if(tooManyDispenserItems > 1) { + errors.put("AUTO_CHECK_RESULT_TOO_MANY_DISPENSERS_ITEMS", new Object[]{tooManyDispenserItems, type.getMaxDispenserItems()}); + } return errors; } - public Collection warnings(){ - List warnings = new LinkedList<>(); + public Map warnings(){ + Map warnings = new HashMap<>(); for(Map.Entry nbtBlock : defunctNbt.entrySet()){ - if(nbtBlock.getValue() > 1) - warnings.add(nbtBlock.getValue() + " " + nbtBlock.getKey() + "s enthalten keine oder inkorrekte NBT-Daten"); - else - warnings.add("Ein(e) " + nbtBlock.getKey() + " enthält keine oder inkorrekte NBT-Daten"); + if(nbtBlock.getValue() > 1) { + warnings.put("AUTO_CHECK_RESULT_NBTS_WARNING", new Object[]{nbtBlock.getValue(), nbtBlock.getKey()}); + } else { + warnings.put("AUTO_CHECK_RESULT_NBT_WARNING", new Object[]{nbtBlock.getKey()}); + } } return warnings; diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java index db3b85b..a91ce52 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java @@ -72,16 +72,14 @@ public class SafeSchematicNode { @AllArgsConstructor public enum Result { - DONE("No"), - NOT_A_DIR(SchematicSystem.PREFIX + "§cDie ausgewählte Schematic ist kein Ordner"), - ALREADY_IN_DIRECTORY(SchematicSystem.PREFIX + "§cDie Schematic gibt es bereits in diesem Ordner"), - INVALID_NAME(SchematicSystem.PREFIX + "§cDieser Name ist unzulässig"), - NOT_OWNER(SchematicSystem.PREFIX + "§cDu bist nicht der Besitzer dieser Schematic"); - - private final String errorMessage; + DONE, + NOT_A_DIR, + ALREADY_IN_DIRECTORY, + INVALID_NAME, + NOT_OWNER; public void sendError(Player player) { - player.sendMessage(errorMessage); + SchematicSystem.MESSAGE.send("SAFE_SCHEMATIC_NODE_" + this.name(), player); } public boolean isSuccessful() {