From b5019f821b90f27832c5a857e283a3846a40c5ea Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 9 Apr 2020 18:31:43 +0200 Subject: [PATCH] Added #49 --- .../src/de/steamwar/schematicsystem/CheckSchemType_12.java | 6 ++++++ .../src/de/steamwar/schematicsystem/CheckSchemType_15.java | 5 +++++ .../src/de/steamwar/schematicsystem/AutoCheckResult.java | 7 +++++++ .../src/de/steamwar/schematicsystem/ICheckSchemType.java | 1 + .../src/de/steamwar/schematicsystem/CheckSchemType.java | 7 +++++++ 5 files changed, 26 insertions(+) diff --git a/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java b/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java index e9db93f..c4eda79 100644 --- a/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java +++ b/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java @@ -23,6 +23,7 @@ class CheckSchemType_12 { private static final int OBSIDIAN = Material.OBSIDIAN.getId(); private static final int BEDROCK = Material.BEDROCK.getId(); private static final int DISPENSER = Material.DISPENSER.getId(); + private static final int AIR = Material.AIR.getId(); private static final int JUKEBOX = Material.JUKEBOX.getId(); private static final int CHEST = Material.CHEST.getId(); private static final Set INVENTORY; @@ -89,6 +90,7 @@ class CheckSchemType_12 { int tnt = 0; int slime = 0; + int blocks = 0; int dispenser = 0; for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ @@ -106,6 +108,9 @@ class CheckSchemType_12 { if(blockId == DISPENSER) dispenser++; + if (blockId != AIR) + blocks++; + if(INVENTORY.contains(blockId)){ checkInventory(result, block, blockId, type); } @@ -118,6 +123,7 @@ class CheckSchemType_12 { result.setTNT(tnt); result.setSlime(slime); result.setDispenser(dispenser); + result.setBlocks(blocks); return result; } diff --git a/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java b/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java index ff83339..7bc902d 100644 --- a/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java +++ b/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java @@ -90,6 +90,7 @@ class CheckSchemType_15 { int tnt = 0; int slime = 0; int dispenser = 0; + int blocks = 0; for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ for(int y = min.getBlockY(); y <= max.getBlockY(); y++){ @@ -110,6 +111,9 @@ class CheckSchemType_15 { if(blockMaterial == Material.DISPENSER) dispenser++; + if(blockMaterial != Material.AIR) + blocks++; + if(INVENTORY.contains(blockMaterial)) checkInventory(result, block, blockMaterial); } @@ -119,6 +123,7 @@ class CheckSchemType_15 { result.setTNT(tnt); result.setSlime(slime); result.setDispenser(dispenser); + result.setBlocks(blocks); return result; } diff --git a/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java b/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java index b453e51..308812e 100644 --- a/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java +++ b/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java @@ -19,6 +19,7 @@ public class AutoCheckResult { private int tnt = 0; private int slime = 0; private int dispenser = 0; + private int blocks = 0; private Map forbiddenMaterials = new HashMap<>(); // Anzahl verbotener Blöcke nach Material @@ -66,6 +67,9 @@ public class AutoCheckResult { errors.add("Zu viele Werfer (" + dispenser + " > " + type.getMaxDispenser() + ")"); if(type.getMaxTNTSlime() != 0 && errorTNTSlime > type.getMaxTNTSlime()) errors.add("Zu viel Schleim+TNT" + errorTNTSlime + " > " + type.getMaxTNTSlime() + ")"); + if(type.getMaxBlocks() != 0 && blocks > type.getMaxBlocks()) { + errors.add("Zu viele Blöcke (" + blocks + " > " + type.getMaxBlocks() + ")"); + } for(Map.Entry block : forbiddenMaterials.entrySet()) errors.add("Der Block " + block.getKey() + " ist verboten (" + block.getValue() + " verbaut)"); @@ -122,6 +126,9 @@ public class AutoCheckResult { void setDispenser(int dispenser){ this.dispenser = dispenser; } + void setBlocks(int blocks) { + this.blocks = blocks; + } void checkMaterial(String name){ assert type != null; diff --git a/SchematicSystem_API/src/de/steamwar/schematicsystem/ICheckSchemType.java b/SchematicSystem_API/src/de/steamwar/schematicsystem/ICheckSchemType.java index e6c9c63..b4a33d5 100644 --- a/SchematicSystem_API/src/de/steamwar/schematicsystem/ICheckSchemType.java +++ b/SchematicSystem_API/src/de/steamwar/schematicsystem/ICheckSchemType.java @@ -13,6 +13,7 @@ interface ICheckSchemType { int getMaxTNT(); int getMaxTNTSlime(); int getMaxSlime(); + int getMaxBlocks(); List getForbidden(); } diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java index 5ae4e34..48c1c85 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java @@ -23,6 +23,7 @@ public class CheckSchemType implements ICheckSchemType { private final int maxSlime; private final int maxTNTSlime; private final int maxDispenser; + private final int maxBlocks; private final LinkedList checkList; CheckSchemType(ConfigurationSection section) { @@ -36,6 +37,7 @@ public class CheckSchemType implements ICheckSchemType { maxTNTSlime = section.getInt("maxTNTSlime"); maxDispenser = section.getInt("maxDispenser"); maxDispenserItems = section.getInt("maxDispenserItems"); + maxBlocks = section.getInt("maxBlocks"); forbiddenMaterials = section.getStringList("forbiddenMaterials"); checkList = new LinkedList<>(section.getStringList("checkList")); @@ -117,6 +119,11 @@ public class CheckSchemType implements ICheckSchemType { return maxSlime; } + @Override + public int getMaxBlocks(){ + return maxBlocks; + } + @Override public List getForbidden() { return forbiddenMaterials;