From 4f2732054826c500f82a588f8f9fed6ecc6a69e8 Mon Sep 17 00:00:00 2001 From: Manuel Frohn Date: Thu, 30 Apr 2026 14:44:54 +0200 Subject: [PATCH] Implement hardcoded windcharge check --- .../SchematicSystem_21/build.gradle.kts | 2 +- .../autocheck/AutoChecker21.java | 16 ++++++----- .../src/SchematicSystem.properties | 2 ++ .../src/SchematicSystem_de.properties | 2 ++ .../autocheck/AutoChecker.java | 1 + .../autocheck/AutoCheckerResult.java | 27 ++++++++++++++++++- settings.gradle.kts | 4 ++- 7 files changed, 45 insertions(+), 9 deletions(-) diff --git a/SchematicSystem/SchematicSystem_21/build.gradle.kts b/SchematicSystem/SchematicSystem_21/build.gradle.kts index ea8298e7..b9bfe6c9 100644 --- a/SchematicSystem/SchematicSystem_21/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_21/build.gradle.kts @@ -25,7 +25,7 @@ dependencies { compileOnly(project(":SpigotCore", "default")) compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) - compileOnly(libs.spigotapi) + compileOnly(libs.spigotapi21) compileOnly(libs.nms21) compileOnly(libs.fawe21) diff --git a/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoChecker21.java b/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoChecker21.java index 831f7cbc..e2b43bce 100644 --- a/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoChecker21.java +++ b/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoChecker21.java @@ -33,7 +33,7 @@ import java.util.stream.Collectors; public class AutoChecker21 implements AutoChecker.IAutoChecker { - public AutoChecker.BlockScanResult scan(Clipboard clipboard) { + public AutoChecker.BlockScanResult scan(Clipboard clipboard, GameModeConfig type) { AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult(); BlockVector3 min = clipboard.getMinimumPoint(); BlockVector3 max = clipboard.getMaximumPoint(); @@ -49,7 +49,7 @@ public class AutoChecker21 implements AutoChecker.IAutoChecker { result.getBlockCounts().merge(material, 1, Integer::sum); if (AutoCheckerItems.impl.getInventoryMaterials().contains(material)) { - checkInventory(result, block, material, new BlockPos(x, y, z)); + checkInventory(result, block, material, new BlockPos(x, y, z), type); } if (x == min.getBlockX() || x == max.getBlockX() || y == max.getBlockY() || z == min.getBlockZ() || z == max.getBlockZ()) { @@ -71,11 +71,10 @@ public class AutoChecker21 implements AutoChecker.IAutoChecker { Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX)); itemsInInv.put(Material.FIRE_CHARGE, EnumSet.of(Material.DISPENSER)); itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER)); - itemsInInv.put(Material.WIND_CHARGE, EnumSet.of(Material.DISPENSER)); AutoCheckerItems.impl.getAllowedMaterialsInInventory().forEach(material -> itemsInInv.put(material, AutoCheckerItems.impl.getInventoryMaterials())); } - private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) { + private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos, GameModeConfig type) { CompoundTag nbt = block.getNbtData(); if (nbt == null) { result.getDefunctNbt().add(pos); @@ -93,6 +92,7 @@ public class AutoChecker21 implements AutoChecker.IAutoChecker { return; // Leeres Inventar int counter = 0; + int windChargeCount = 0; for (CompoundTag item : items) { if (!item.containsKey("id")) { result.getDefunctNbt().add(pos); @@ -103,7 +103,10 @@ public class AutoChecker21 implements AutoChecker.IAutoChecker { if (itemType == null) // Leere Slots continue; - if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) { + if(type.Schematic.Type.equals("wargearseason26") && material == Material.DISPENSER && itemType == Material.WIND_CHARGE) { + windChargeCount += item.getInt("count"); + } + else if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) { result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); } else if (material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) { counter += Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); @@ -113,12 +116,13 @@ public class AutoChecker21 implements AutoChecker.IAutoChecker { } } result.getDispenserItems().put(pos, counter); + result.getWindChargeCount().put(pos, windChargeCount); } @Override public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().getBlockY()).width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()).blockScanResult(scan(clipboard)) + .depth(clipboard.getDimensions().getBlockZ()).blockScanResult(scan(clipboard, type)) .entities(clipboard.getEntities().stream().map(Entity::getLocation) .map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())) .collect(Collectors.toList())) diff --git a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties index 0ff05daa..da86e45c 100644 --- a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties +++ b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties @@ -262,6 +262,8 @@ AUTO_CHECKER_RESULT_BLOCKS=§7Blocks: §c{0}§7, Max: §e{1} AUTO_CHECKER_RESULT_UNKNOWN_MATERIAL=§7Unknown block: §c{0} AUTO_CHECKER_RESULT_TOO_MANY_BLOCK=§7{0}: §c{1}§7, Max: §e{2} AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Forbidden block: §c{0} +AUTO_CHECKER_RESULT_WIND_CHARGES=§7Windcharges: §c{0}§7, Max: §e2048 +AUTO_CHECKER_RESULT_WIND_CHARGES_DISPENSER=§7Dispenser: §c[{0}, {1}, {2}]§7, Windcharges: §c{3}§7 AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Forbidden Item: [{0}, {1}, {2}] -> §c{3} AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Defunct NBT: §7[{0}, {1}, {2}] AUTO_CHECKER_RESULT_DESIGN_BLOCK=§7{0} in Design: [{1}, {2}, {3}] diff --git a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties index 12030a2f..aa72936e 100644 --- a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties +++ b/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties @@ -242,6 +242,8 @@ AUTO_CHECKER_RESULT_BLOCKS=§7Blöcke: §c{0}§7, Max: §e{1} AUTO_CHECKER_RESULT_UNKNOWN_MATERIAL=§7Unbekannter Block: §c{0} AUTO_CHECKER_RESULT_TOO_MANY_BLOCK=§7{0}: §c{1}§7, Max: §e{2} AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Verbotener Block: §c{0} +AUTO_CHECKER_RESULT_WIND_CHARGES=§7Windcharges: §c{0}§7, Max: §e2048 +AUTO_CHECKER_RESULT_WIND_CHARGES_DISPENSER=§7Werfer: §c[{0}, {1}, {2}]§7, Windcharges: §c{3}§7 AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Verbotener gegenstand: [{0}, {1}, {2}] -> §c{3} AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Keine NBT-Daten: §c[{0}, {1}, {2}] AUTO_CHECKER_RESULT_DESIGN_BLOCK=§7{0} im Design: [{1}, {2}, {3}] diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java index eb464553..7d17e8f9 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java @@ -55,6 +55,7 @@ public class AutoChecker { private final List records = new ArrayList<>(); private final Map> designBlocks = new EnumMap<>(Material.class); private final Map dispenserItems = new HashMap<>(); + private final Map windChargeCount = new HashMap<>(); private final Map> forbiddenItems = new HashMap<>(); private final Map> forbiddenNbt = new HashMap<>(); } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java index e6ba4728..d96a9557 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java @@ -52,6 +52,7 @@ public class AutoCheckerResult { isBlockCountOk() && isLimitedBlocksOK() && isDispenserItemsOK() && + isWindchargeCountOK() && !type.isAfterDeadline() && entities.isEmpty() && isDesignBlastResistanceOK(); @@ -62,8 +63,18 @@ public class AutoCheckerResult { !type.isAfterDeadline(); } + public boolean isWindchargeCountOK() { + if(type.Schematic.Type.equals("wargearseason26")) { + int windChargesCount = blockScanResult.getWindChargeCount().values().stream().reduce(Integer::sum).orElse(0); + return windChargesCount <= 2048; + } + else { + return true; + } + } + public boolean isDispenserItemsOK() { - return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.Schematic.MaxDispenserItems); + return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.Schematic.MaxDispenserItems); } public boolean hasWarnings() { @@ -127,6 +138,19 @@ public class AutoCheckerResult { } }); } + + if(!isWindchargeCountOK()) { + int windChargesCount = blockScanResult.getWindChargeCount().values().stream().reduce(Integer::sum).orElse(0); + SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIND_CHARGES", p, windChargesCount, 2048); + blockScanResult.getWindChargeCount().entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > 0).forEach(blockVector3IntegerEntry -> { + SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIND_CHARGES_DISPENSER", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3IntegerEntry.getKey()), + blockVector3IntegerEntry.getKey().getBlockX(), + blockVector3IntegerEntry.getKey().getBlockY(), + blockVector3IntegerEntry.getKey().getBlockZ(), + blockVector3IntegerEntry.getValue()); + }); + } + blockScanResult.getDispenserItems().entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > type.Schematic.MaxDispenserItems).forEach(blockVector3IntegerEntry -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3IntegerEntry.getKey()), blockVector3IntegerEntry.getKey().getBlockX(), @@ -135,6 +159,7 @@ public class AutoCheckerResult { blockVector3IntegerEntry.getValue(), type.Schematic.MaxDispenserItems); }); + blockScanResult.getRecords().forEach(blockVector3 -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_RECORD", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()); }); diff --git a/settings.gradle.kts b/settings.gradle.kts index 0862fdce..9b228792 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -101,7 +101,9 @@ dependencyResolutionManagement { library("hamcrest", "org.hamcrest:hamcrest:2.2") library("classindex", "org.atteo.classindex:classindex:3.13") - library("spigotapi", "org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT") + + library("spigotapi", "org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") + library("spigotapi21", "org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT") library("spigotannotations", "org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT") library("paperapi", "io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT") library("paperapi21", "io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT")