From 5243cf850e709e5b00c7cefbe19f5a2695dc874e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 28 Oct 2025 23:46:42 +0100 Subject: [PATCH] =?UTF-8?q?Hotfix:=201.21=20Autopr=C3=BCfer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaoscaot --- .../autocheck/AutoChecker15.java | 3 ++- .../schematiccommand/SchematicCommand15.java | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java index 97cf6de3..d6189931 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; +import de.steamwar.core.Core; import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import org.bukkit.Material; @@ -109,7 +110,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { 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 += item.getByte("Count"); + counter += Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); } if (item.containsKey("tag")) { result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java index 62fa611e..05036a9a 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; +import de.steamwar.core.Core; import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.schematicsystem.autocheck.BlockPos; @@ -38,9 +39,17 @@ import de.steamwar.sql.SchematicType; import org.bukkit.Material; import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; import java.util.stream.Collectors; public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { + private static final Function getCount = item -> Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); + private static final BiFunction setCount = (item, count) -> Core.getVersion() >= 21 ? + item.createBuilder().putInt("count", count).build() : + item.createBuilder().putByte("Count", count.byteValue()).build(); + @Override public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { @@ -87,7 +96,7 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { BaseBlock block = clipboard.getFullBlock(vector); CompoundTag tag = block.getNbtData(); CompoundTagBuilder builder = tag.createBuilder(); - List items = tag.getList("Items", CompoundTag.class); + List items = new ArrayList<>(tag.getList("Items", CompoundTag.class)); Collections.reverse(items); // To let the first item be in the Dispenser List list = new ArrayList<>(); int diff = entry.getValue() - type.Schematic.MaxDispenserItems; @@ -101,12 +110,12 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { continue; } - if(diff > item.getByte("Count")) { - diff -= item.getByte("Count"); + if(diff > getCount.apply(item)) { + diff -= getCount.apply(item); continue; } - item = item.createBuilder().putByte("Count", (byte) (item.getByte("Count") - diff)).build(); + item = setCount.apply(item, getCount.apply(item) - diff); diff = 0; list.add(item); }