From 87a5b82551a7a8303f6825e875f9fb7a4bf57a7a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 20 Aug 2020 20:51:33 +0200 Subject: [PATCH] Deny custom tag in items during check in Signed-off-by: Lixfel --- .../schematicsystem/CheckSchemType_12.java | 2 ++ .../schematicsystem/CheckSchemType_15.java | 2 ++ .../steamwar/schematicsystem/AutoCheckResult.java | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java b/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java index c4eda79..5d5766f 100644 --- a/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java +++ b/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java @@ -165,6 +165,8 @@ class CheckSchemType_12 { counter += item.getByte("Count"); else if(!FLOWERS.contains(itemType) && !(blockId == CHEST && itemType.equals(Material.TNT))) result.foundForbiddenItem(Material.getMaterial(blockId).name(), itemType.name(), item.getByte("Count")); + else if(item.containsKey("tag")) + result.foundItemWithTag(Material.getMaterial(blockId).name(), itemType.name(), item.getByte("Count")); } result.dispenserItems(counter); diff --git a/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java b/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java index 2642f50..6de01b5 100644 --- a/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java +++ b/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java @@ -160,6 +160,8 @@ class CheckSchemType_15 { counter += item.getByte("Count"); else if(!FLOWERS.contains(itemType) && !(blockMaterial == Material.CHEST && itemType.equals(Material.TNT))) result.foundForbiddenItem(blockMaterial.name(), itemType.name(), item.getByte("Count")); + else if(item.containsKey("tag")) + result.foundItemWithTag(blockMaterial.name(), itemType.name(), item.getByte("Count")); } result.dispenserItems(counter); diff --git a/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java b/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java index 308812e..7b5ea2f 100644 --- a/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java +++ b/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java @@ -26,6 +26,7 @@ public class AutoCheckResult { private Map defunctNbt = new HashMap<>(); // Anzahl an defekten NBT-Blöcken nach Materialname private int records = 0; // Gefundene Schallplatten private Map> forbiddenItems = new HashMap<>(); // Anzahl verbotener Items nach Inventartyp + private Map> itemsWithTag = new HashMap<>(); // Anzahl an Items mit Tag nach Inventartyp private int tooManyDispenserItems = 0; // Gefundene Überschreitungen von DispenserItems AutoCheckResult(ICheckSchemType type){ @@ -79,6 +80,9 @@ public class AutoCheckResult { 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) @@ -100,9 +104,6 @@ public class AutoCheckResult { return warnings; } - void setWrongVersionException(){ - wrongVersionException = true; - } void setErrorLoadingSchematic(){ errorLoadingSchematic = true; } @@ -150,6 +151,14 @@ public class AutoCheckResult { return v; }); } + void foundItemWithTag(String material, String item, int count){ + itemsWithTag.compute(material, (k1, v) -> { + if(v == null) + v = new HashMap<>(); + v.compute(item, (k2, v2) -> v2 == null ? count : v2 + count); + return v; + }); + } void dispenserItems(int counter){ assert type != null; if(counter > type.getMaxDispenserItems())