From 69251f42a6e540d57d50d8bf6a8424f6dce593ef Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sat, 17 May 2025 23:40:48 +0200 Subject: [PATCH 1/4] Add music disks to autochecker --- .../SchematicSystem_19/build.gradle.kts | 32 +++ .../autocheck/AutoChecker19.java | 213 ++++++++++++++++++ .../schematiccommand/SchematicCommand19.java | 147 ++++++++++++ SchematicSystem/build.gradle.kts | 1 + settings.gradle.kts | 1 + 5 files changed, 394 insertions(+) create mode 100644 SchematicSystem/SchematicSystem_19/build.gradle.kts create mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java create mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java diff --git a/SchematicSystem/SchematicSystem_19/build.gradle.kts b/SchematicSystem/SchematicSystem_19/build.gradle.kts new file mode 100644 index 00000000..d1baf622 --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/build.gradle.kts @@ -0,0 +1,32 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +plugins { + steamwar.java +} + +dependencies { + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) + + compileOnly(libs.spigotapi) + + compileOnly(libs.nms19) + compileOnly(libs.fawe18) +} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java new file mode 100644 index 00000000..92b06c0d --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java @@ -0,0 +1,213 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2023 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.schematicsystem.autocheck; + +import com.sk89q.jnbt.CompoundTag; +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.schematicsystem.CheckSchemType; +import org.bukkit.Material; + +import java.util.*; +import java.util.stream.Collectors; + +public class AutoChecker19 implements AutoChecker.IAutoChecker { + private static final Set INVENTORY = EnumSet.of( + Material.BARREL, + Material.BLAST_FURNACE, + Material.BREWING_STAND, + Material.CAMPFIRE, + Material.CHEST, + Material.DISPENSER, + Material.DROPPER, + Material.FURNACE, + Material.HOPPER, + Material.JUKEBOX, + Material.SHULKER_BOX, + Material.WHITE_SHULKER_BOX, + Material.ORANGE_SHULKER_BOX, + Material.MAGENTA_SHULKER_BOX, + Material.LIGHT_BLUE_SHULKER_BOX, + Material.YELLOW_SHULKER_BOX, + Material.LIME_SHULKER_BOX, + Material.PINK_SHULKER_BOX, + Material.GRAY_SHULKER_BOX, + Material.LIGHT_GRAY_SHULKER_BOX, + Material.CYAN_SHULKER_BOX, + Material.PURPLE_SHULKER_BOX, + Material.BLUE_SHULKER_BOX, + Material.BROWN_SHULKER_BOX, + Material.GREEN_SHULKER_BOX, + Material.RED_SHULKER_BOX, + Material.BLACK_SHULKER_BOX, + Material.SMOKER, + Material.TRAPPED_CHEST); + + private static final Set FLOWERS = EnumSet.of( + // 64-stackable Items + Material.CORNFLOWER, + Material.POPPY, + Material.FERN, + Material.DANDELION, + Material.BLUE_ORCHID, + Material.ALLIUM, + Material.AZURE_BLUET, + Material.RED_TULIP, + Material.ORANGE_TULIP, + Material.WHITE_TULIP, + Material.PINK_TULIP, + Material.OXEYE_DAISY, + Material.LILY_OF_THE_VALLEY, + Material.WITHER_ROSE, + Material.SUNFLOWER, + // 16-stackable Items + Material.HONEY_BOTTLE, + // Non-stackable items + Material.DIAMOND_HORSE_ARMOR, + Material.IRON_HORSE_ARMOR, + Material.GOLDEN_HORSE_ARMOR, + // Disks + Material.MUSIC_DISC_11, + Material.MUSIC_DISC_13, + Material.MUSIC_DISC_CAT, + Material.MUSIC_DISC_BLOCKS, + Material.MUSIC_DISC_CHIRP, + Material.MUSIC_DISC_FAR, + Material.MUSIC_DISC_MALL, + Material.MUSIC_DISC_MELLOHI, + Material.MUSIC_DISC_STAL, + Material.MUSIC_DISC_STRAD, + Material.MUSIC_DISC_WAIT, + Material.MUSIC_DISC_WARD, + Material.MUSIC_DISC_OTHERSIDE, + Material.MUSIC_DISC_PIGSTEP, + Material.MUSIC_DISC_RELIC, + Material.MUSIC_DISC_5 + ); + + public AutoChecker.BlockScanResult scan(Clipboard clipboard) { + AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult(); + BlockVector3 min = clipboard.getMinimumPoint(); + BlockVector3 max = clipboard.getMaximumPoint(); + for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ + for(int y = min.getBlockY(); y <= max.getBlockY(); y++) { + for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { + final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z)); + final Material material = Material.matchMaterial(block.getBlockType().getId()); + if(material == null) { + continue; + } + + result.getBlockCounts().merge(material, 1, Integer::sum); + + if(INVENTORY.contains(material)) { + checkInventory(result, block, material, new BlockPos(x, y, z)); + } + + if(x == 0 || x == max.getBlockX() - 1 || y == max.getBlockY() - 1 || z == 0 || z == max.getBlockZ() - 1) { + result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z)); + } + } + } + } + return result; + } + + private static final Map> itemsInInv = new EnumMap<>(Material.class); + + static { + itemsInInv.put(Material.BUCKET, EnumSet.of(Material.DISPENSER)); + itemsInInv.put(Material.TNT, EnumSet.of( + Material.CHEST, Material.BARREL, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, + Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, + Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, + Material.LIGHT_GRAY_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, + Material.ORANGE_SHULKER_BOX, 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)); + FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY)); + } + + private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) { + CompoundTag nbt = block.getNbtData(); + if(nbt == null) { + result.getDefunctNbt().add(pos); + return; + } + + + if(material == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")){ + result.getRecords().add(pos); + return; + } + + List items = nbt.getList("Items", CompoundTag.class); + if(items.isEmpty()) + return; //Leeres Inventar + + int counter = 0; + for(CompoundTag item : items){ + if(!item.containsKey("id")){ + result.getDefunctNbt().add(pos); + continue; + } + + Material itemType = Material.matchMaterial(item.getString("id")); + if(itemType == null) //Leere Slots + continue; + + 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"); + } + if (item.containsKey("tag")) { + result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); + } + } + result.getDispenserItems().put(pos, counter); + } + + @Override + public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) { + return AutoCheckerResult.builder() + .type(type) + .height(clipboard.getDimensions().getBlockY()) + .width(clipboard.getDimensions().getBlockX()) + .depth(clipboard.getDimensions().getBlockZ()) + .blockScanResult(scan(clipboard)) + .entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList())) + .build(); + } + + @Override + public AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) { + return AutoCheckerResult.builder() + .type(type) + .height(clipboard.getDimensions().getBlockY()) + .width(clipboard.getDimensions().getBlockX()) + .depth(clipboard.getDimensions().getBlockZ()) + .build(); + } +} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java new file mode 100644 index 00000000..2fecb87d --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java @@ -0,0 +1,147 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2023 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.schematicsystem.commands.schematiccommand; + +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.CompoundTagBuilder; +import com.sk89q.jnbt.ListTag; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.function.operation.ForwardExtentCopy; +import com.sk89q.worldedit.function.operation.Operations; +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.schematicsystem.CheckSchemType; +import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; +import de.steamwar.schematicsystem.autocheck.BlockPos; +import org.bukkit.Material; + +import java.util.*; +import java.util.stream.Collectors; + +public class SchematicCommand19 implements SchematicCommand.ISchematicCommand { + @Override + public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception { + for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { + BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap()))); + } + + Map> toBeCheckedInvs = new HashMap<>(); + + toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenItems()); + toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenNbt()); + + for (Map.Entry> entry: toBeCheckedInvs.entrySet()) { + BlockPos pos = entry.getKey(); + Set materials = entry.getValue(); + BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); + BaseBlock block = clipboard.getFullBlock(vector); + CompoundTag tag = block.getNbtData(); + CompoundTagBuilder builder = CompoundTagBuilder.create(); + List list = new ArrayList<>(); + for (CompoundTag items : tag.getList("Items", CompoundTag.class)) { + if(materials.contains(Material.matchMaterial(items.getString("id")))) { + continue; + } + + if(items.containsKey("tag")) { + continue; + } + + list.add(items); + } + builder.put("Items", new ListTag(CompoundTag.class, list)); + clipboard.setBlock(vector, block.toBaseBlock(builder.build())); + } + + if(type.getMaxDispenserItems() > 0 ) { + for (Map.Entry entry : result.getBlockScanResult().getDispenserItems().entrySet()) { + if(entry.getValue() <= type.getMaxDispenserItems()) { + continue; + } + + BlockPos pos = entry.getKey(); + BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); + BaseBlock block = clipboard.getFullBlock(vector); + CompoundTag tag = block.getNbtData(); + CompoundTagBuilder builder = tag.createBuilder(); + List items = 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.getMaxDispenserItems(); + for (CompoundTag item : items) { + if(item == null) { + continue; + } + + if(diff == 0) { + list.add(item); + continue; + } + + if(diff > item.getByte("Count")) { + diff -= item.getByte("Count"); + continue; + } + + item = item.createBuilder().putByte("Count", (byte) (item.getByte("Count") - diff)).build(); + diff = 0; + list.add(item); + } + + builder.put("Items", new ListTag(CompoundTag.class, list)); + clipboard.setBlock(vector, block.toBaseBlock(builder.build())); + } + } + + if(!result.isLimitedBlocksOK()) { + Set toReplace = type.getLimits().entrySet().stream() + .filter(setIntegerEntry -> setIntegerEntry.getValue() == 0) + .flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream()) + .map(Material::matchMaterial) + .collect(Collectors.toSet()); + BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState(); + BlockVector3 min = clipboard.getMinimumPoint(); + BlockVector3 max = clipboard.getMaximumPoint(); + for (int i = min.getBlockX(); i <= max.getBlockX(); i++) { + for (int j = min.getBlockY(); j <= max.getBlockY(); j++) { + for (int k = min.getBlockZ(); k <= max.getBlockZ(); k++) { + BlockVector3 vector = BlockVector3.at(i, j, k); + BaseBlock block = clipboard.getFullBlock(vector); + if(toReplace.contains(Material.matchMaterial(block.getBlockType().getId()))) { + clipboard.setBlock(vector, replaceType.toBaseBlock()); + } + } + } + } + } + + return clipboard; + } + + @Override + public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException { + Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint())); + } +} diff --git a/SchematicSystem/build.gradle.kts b/SchematicSystem/build.gradle.kts index f9871adc..813550b2 100644 --- a/SchematicSystem/build.gradle.kts +++ b/SchematicSystem/build.gradle.kts @@ -30,4 +30,5 @@ dependencies { implementation(project(":SchematicSystem:SchematicSystem_Core")) implementation(project(":SchematicSystem:SchematicSystem_8")) implementation(project(":SchematicSystem:SchematicSystem_15")) + implementation(project(":SchematicSystem:SchematicSystem_19")) } diff --git a/settings.gradle.kts b/settings.gradle.kts index dc94bc0c..cd2550dd 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -218,6 +218,7 @@ include( "SchematicSystem", "SchematicSystem:SchematicSystem_8", "SchematicSystem:SchematicSystem_15", + "SchematicSystem:SchematicSystem_19", "SchematicSystem:SchematicSystem_Core" ) From bf5eef2ebd7bcb936ac5eea5268cedb5b1447050 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 10:28:32 +0200 Subject: [PATCH 2/4] Fix copyright nit Remove SchematicCommand19 --- .../SchematicSystem_19/build.gradle.kts | 2 +- .../autocheck/AutoChecker19.java | 2 +- .../schematiccommand/SchematicCommand19.java | 147 ------------------ 3 files changed, 2 insertions(+), 149 deletions(-) delete mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java diff --git a/SchematicSystem/SchematicSystem_19/build.gradle.kts b/SchematicSystem/SchematicSystem_19/build.gradle.kts index d1baf622..99b982c8 100644 --- a/SchematicSystem/SchematicSystem_19/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_19/build.gradle.kts @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2024 SteamWar.de-Serverteam + * Copyright (C) 2025 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java index 92b06c0d..0f456ee2 100644 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2023 SteamWar.de-Serverteam + Copyright (C) 2025 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java deleted file mode 100644 index 2fecb87d..00000000 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2023 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ - -package de.steamwar.schematicsystem.commands.schematiccommand; - -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.CompoundTagBuilder; -import com.sk89q.jnbt.ListTag; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.function.operation.ForwardExtentCopy; -import com.sk89q.worldedit.function.operation.Operations; -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.schematicsystem.CheckSchemType; -import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; -import de.steamwar.schematicsystem.autocheck.BlockPos; -import org.bukkit.Material; - -import java.util.*; -import java.util.stream.Collectors; - -public class SchematicCommand19 implements SchematicCommand.ISchematicCommand { - @Override - public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception { - for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { - BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap()))); - } - - Map> toBeCheckedInvs = new HashMap<>(); - - toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenItems()); - toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenNbt()); - - for (Map.Entry> entry: toBeCheckedInvs.entrySet()) { - BlockPos pos = entry.getKey(); - Set materials = entry.getValue(); - BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); - BaseBlock block = clipboard.getFullBlock(vector); - CompoundTag tag = block.getNbtData(); - CompoundTagBuilder builder = CompoundTagBuilder.create(); - List list = new ArrayList<>(); - for (CompoundTag items : tag.getList("Items", CompoundTag.class)) { - if(materials.contains(Material.matchMaterial(items.getString("id")))) { - continue; - } - - if(items.containsKey("tag")) { - continue; - } - - list.add(items); - } - builder.put("Items", new ListTag(CompoundTag.class, list)); - clipboard.setBlock(vector, block.toBaseBlock(builder.build())); - } - - if(type.getMaxDispenserItems() > 0 ) { - for (Map.Entry entry : result.getBlockScanResult().getDispenserItems().entrySet()) { - if(entry.getValue() <= type.getMaxDispenserItems()) { - continue; - } - - BlockPos pos = entry.getKey(); - BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); - BaseBlock block = clipboard.getFullBlock(vector); - CompoundTag tag = block.getNbtData(); - CompoundTagBuilder builder = tag.createBuilder(); - List items = 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.getMaxDispenserItems(); - for (CompoundTag item : items) { - if(item == null) { - continue; - } - - if(diff == 0) { - list.add(item); - continue; - } - - if(diff > item.getByte("Count")) { - diff -= item.getByte("Count"); - continue; - } - - item = item.createBuilder().putByte("Count", (byte) (item.getByte("Count") - diff)).build(); - diff = 0; - list.add(item); - } - - builder.put("Items", new ListTag(CompoundTag.class, list)); - clipboard.setBlock(vector, block.toBaseBlock(builder.build())); - } - } - - if(!result.isLimitedBlocksOK()) { - Set toReplace = type.getLimits().entrySet().stream() - .filter(setIntegerEntry -> setIntegerEntry.getValue() == 0) - .flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream()) - .map(Material::matchMaterial) - .collect(Collectors.toSet()); - BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState(); - BlockVector3 min = clipboard.getMinimumPoint(); - BlockVector3 max = clipboard.getMaximumPoint(); - for (int i = min.getBlockX(); i <= max.getBlockX(); i++) { - for (int j = min.getBlockY(); j <= max.getBlockY(); j++) { - for (int k = min.getBlockZ(); k <= max.getBlockZ(); k++) { - BlockVector3 vector = BlockVector3.at(i, j, k); - BaseBlock block = clipboard.getFullBlock(vector); - if(toReplace.contains(Material.matchMaterial(block.getBlockType().getId()))) { - clipboard.setBlock(vector, replaceType.toBaseBlock()); - } - } - } - } - } - - return clipboard; - } - - @Override - public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException { - Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint())); - } -} From 8132e4fca08b020795b43f453b21bf9d59cc990e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 10:34:41 +0200 Subject: [PATCH 3/4] Remove code duplication --- .../autocheck/AutoChecker15.java | 55 +---- .../autocheck/AutoCheckerItems15.java | 90 ++++++++ .../autocheck/AutoChecker19.java | 213 ------------------ .../autocheck/AutoCheckerItems19.java | 111 +++++++++ .../autocheck/AutoCheckerItems.java | 34 +++ 5 files changed, 237 insertions(+), 266 deletions(-) create mode 100644 SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java delete mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java create mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java create mode 100644 SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java 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 9dd5e456..a97cb133 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java @@ -31,57 +31,6 @@ import java.util.*; import java.util.stream.Collectors; public class AutoChecker15 implements AutoChecker.IAutoChecker { - private static final Set INVENTORY = EnumSet.of( - Material.BARREL, - Material.BLAST_FURNACE, - Material.BREWING_STAND, - Material.CAMPFIRE, - Material.CHEST, - Material.DISPENSER, - Material.DROPPER, - Material.FURNACE, - Material.HOPPER, - Material.JUKEBOX, - Material.SHULKER_BOX, - Material.WHITE_SHULKER_BOX, - Material.ORANGE_SHULKER_BOX, - Material.MAGENTA_SHULKER_BOX, - Material.LIGHT_BLUE_SHULKER_BOX, - Material.YELLOW_SHULKER_BOX, - Material.LIME_SHULKER_BOX, - Material.PINK_SHULKER_BOX, - Material.GRAY_SHULKER_BOX, - Material.LIGHT_GRAY_SHULKER_BOX, - Material.CYAN_SHULKER_BOX, - Material.PURPLE_SHULKER_BOX, - Material.BLUE_SHULKER_BOX, - Material.BROWN_SHULKER_BOX, - Material.GREEN_SHULKER_BOX, - Material.RED_SHULKER_BOX, - Material.BLACK_SHULKER_BOX, - Material.SMOKER, - Material.TRAPPED_CHEST); - - private static final Set FLOWERS = EnumSet.of( - Material.CORNFLOWER, - Material.POPPY, - Material.FERN, - Material.DANDELION, - Material.BLUE_ORCHID, - Material.ALLIUM, - Material.AZURE_BLUET, - Material.RED_TULIP, - Material.ORANGE_TULIP, - Material.WHITE_TULIP, - Material.PINK_TULIP, - Material.OXEYE_DAISY, - Material.LILY_OF_THE_VALLEY, - Material.WITHER_ROSE, - Material.SUNFLOWER, - Material.DIAMOND_HORSE_ARMOR, - Material.IRON_HORSE_ARMOR, - Material.GOLDEN_HORSE_ARMOR, - Material.HONEY_BOTTLE); public AutoChecker.BlockScanResult scan(Clipboard clipboard) { AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult(); @@ -98,7 +47,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { result.getBlockCounts().merge(material, 1, Integer::sum); - if(INVENTORY.contains(material)) { + if(AutoCheckerItems.impl.getInventoryMaterials().contains(material)) { checkInventory(result, block, material, new BlockPos(x, y, z)); } @@ -125,7 +74,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { )); itemsInInv.put(Material.FIRE_CHARGE, EnumSet.of(Material.DISPENSER)); itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER)); - FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY)); + AutoCheckerItems.impl.getAllowedMaterialsInInventory().forEach(material -> itemsInInv.put(material, AutoCheckerItems.impl.getInventoryMaterials())); } private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) { diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java new file mode 100644 index 00000000..0d853c16 --- /dev/null +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java @@ -0,0 +1,90 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.schematicsystem.autocheck; + +import org.bukkit.Material; + +import java.util.EnumSet; +import java.util.Set; + +public class AutoCheckerItems15 implements AutoCheckerItems { + + private static final Set INVENTORY = EnumSet.of( + Material.BARREL, + Material.BLAST_FURNACE, + Material.BREWING_STAND, + Material.CAMPFIRE, + Material.CHEST, + Material.DISPENSER, + Material.DROPPER, + Material.FURNACE, + Material.HOPPER, + Material.JUKEBOX, + Material.SHULKER_BOX, + Material.WHITE_SHULKER_BOX, + Material.ORANGE_SHULKER_BOX, + Material.MAGENTA_SHULKER_BOX, + Material.LIGHT_BLUE_SHULKER_BOX, + Material.YELLOW_SHULKER_BOX, + Material.LIME_SHULKER_BOX, + Material.PINK_SHULKER_BOX, + Material.GRAY_SHULKER_BOX, + Material.LIGHT_GRAY_SHULKER_BOX, + Material.CYAN_SHULKER_BOX, + Material.PURPLE_SHULKER_BOX, + Material.BLUE_SHULKER_BOX, + Material.BROWN_SHULKER_BOX, + Material.GREEN_SHULKER_BOX, + Material.RED_SHULKER_BOX, + Material.BLACK_SHULKER_BOX, + Material.SMOKER, + Material.TRAPPED_CHEST); + + private static final Set FLOWERS = EnumSet.of( + Material.CORNFLOWER, + Material.POPPY, + Material.FERN, + Material.DANDELION, + Material.BLUE_ORCHID, + Material.ALLIUM, + Material.AZURE_BLUET, + Material.RED_TULIP, + Material.ORANGE_TULIP, + Material.WHITE_TULIP, + Material.PINK_TULIP, + Material.OXEYE_DAISY, + Material.LILY_OF_THE_VALLEY, + Material.WITHER_ROSE, + Material.SUNFLOWER, + Material.DIAMOND_HORSE_ARMOR, + Material.IRON_HORSE_ARMOR, + Material.GOLDEN_HORSE_ARMOR, + Material.HONEY_BOTTLE); + + @Override + public Set getInventoryMaterials() { + return INVENTORY; + } + + @Override + public Set getAllowedMaterialsInInventory() { + return FLOWERS; + } +} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java deleted file mode 100644 index 0f456ee2..00000000 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2025 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ - -package de.steamwar.schematicsystem.autocheck; - -import com.sk89q.jnbt.CompoundTag; -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.schematicsystem.CheckSchemType; -import org.bukkit.Material; - -import java.util.*; -import java.util.stream.Collectors; - -public class AutoChecker19 implements AutoChecker.IAutoChecker { - private static final Set INVENTORY = EnumSet.of( - Material.BARREL, - Material.BLAST_FURNACE, - Material.BREWING_STAND, - Material.CAMPFIRE, - Material.CHEST, - Material.DISPENSER, - Material.DROPPER, - Material.FURNACE, - Material.HOPPER, - Material.JUKEBOX, - Material.SHULKER_BOX, - Material.WHITE_SHULKER_BOX, - Material.ORANGE_SHULKER_BOX, - Material.MAGENTA_SHULKER_BOX, - Material.LIGHT_BLUE_SHULKER_BOX, - Material.YELLOW_SHULKER_BOX, - Material.LIME_SHULKER_BOX, - Material.PINK_SHULKER_BOX, - Material.GRAY_SHULKER_BOX, - Material.LIGHT_GRAY_SHULKER_BOX, - Material.CYAN_SHULKER_BOX, - Material.PURPLE_SHULKER_BOX, - Material.BLUE_SHULKER_BOX, - Material.BROWN_SHULKER_BOX, - Material.GREEN_SHULKER_BOX, - Material.RED_SHULKER_BOX, - Material.BLACK_SHULKER_BOX, - Material.SMOKER, - Material.TRAPPED_CHEST); - - private static final Set FLOWERS = EnumSet.of( - // 64-stackable Items - Material.CORNFLOWER, - Material.POPPY, - Material.FERN, - Material.DANDELION, - Material.BLUE_ORCHID, - Material.ALLIUM, - Material.AZURE_BLUET, - Material.RED_TULIP, - Material.ORANGE_TULIP, - Material.WHITE_TULIP, - Material.PINK_TULIP, - Material.OXEYE_DAISY, - Material.LILY_OF_THE_VALLEY, - Material.WITHER_ROSE, - Material.SUNFLOWER, - // 16-stackable Items - Material.HONEY_BOTTLE, - // Non-stackable items - Material.DIAMOND_HORSE_ARMOR, - Material.IRON_HORSE_ARMOR, - Material.GOLDEN_HORSE_ARMOR, - // Disks - Material.MUSIC_DISC_11, - Material.MUSIC_DISC_13, - Material.MUSIC_DISC_CAT, - Material.MUSIC_DISC_BLOCKS, - Material.MUSIC_DISC_CHIRP, - Material.MUSIC_DISC_FAR, - Material.MUSIC_DISC_MALL, - Material.MUSIC_DISC_MELLOHI, - Material.MUSIC_DISC_STAL, - Material.MUSIC_DISC_STRAD, - Material.MUSIC_DISC_WAIT, - Material.MUSIC_DISC_WARD, - Material.MUSIC_DISC_OTHERSIDE, - Material.MUSIC_DISC_PIGSTEP, - Material.MUSIC_DISC_RELIC, - Material.MUSIC_DISC_5 - ); - - public AutoChecker.BlockScanResult scan(Clipboard clipboard) { - AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult(); - BlockVector3 min = clipboard.getMinimumPoint(); - BlockVector3 max = clipboard.getMaximumPoint(); - for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ - for(int y = min.getBlockY(); y <= max.getBlockY(); y++) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { - final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z)); - final Material material = Material.matchMaterial(block.getBlockType().getId()); - if(material == null) { - continue; - } - - result.getBlockCounts().merge(material, 1, Integer::sum); - - if(INVENTORY.contains(material)) { - checkInventory(result, block, material, new BlockPos(x, y, z)); - } - - if(x == 0 || x == max.getBlockX() - 1 || y == max.getBlockY() - 1 || z == 0 || z == max.getBlockZ() - 1) { - result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z)); - } - } - } - } - return result; - } - - private static final Map> itemsInInv = new EnumMap<>(Material.class); - - static { - itemsInInv.put(Material.BUCKET, EnumSet.of(Material.DISPENSER)); - itemsInInv.put(Material.TNT, EnumSet.of( - Material.CHEST, Material.BARREL, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, - Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, - Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, - Material.LIGHT_GRAY_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, - Material.ORANGE_SHULKER_BOX, 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)); - FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY)); - } - - private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) { - CompoundTag nbt = block.getNbtData(); - if(nbt == null) { - result.getDefunctNbt().add(pos); - return; - } - - - if(material == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")){ - result.getRecords().add(pos); - return; - } - - List items = nbt.getList("Items", CompoundTag.class); - if(items.isEmpty()) - return; //Leeres Inventar - - int counter = 0; - for(CompoundTag item : items){ - if(!item.containsKey("id")){ - result.getDefunctNbt().add(pos); - continue; - } - - Material itemType = Material.matchMaterial(item.getString("id")); - if(itemType == null) //Leere Slots - continue; - - 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"); - } - if (item.containsKey("tag")) { - result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); - } - } - result.getDispenserItems().put(pos, counter); - } - - @Override - public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) { - return AutoCheckerResult.builder() - .type(type) - .height(clipboard.getDimensions().getBlockY()) - .width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()) - .blockScanResult(scan(clipboard)) - .entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList())) - .build(); - } - - @Override - public AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) { - return AutoCheckerResult.builder() - .type(type) - .height(clipboard.getDimensions().getBlockY()) - .width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()) - .build(); - } -} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java new file mode 100644 index 00000000..556d354f --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java @@ -0,0 +1,111 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.schematicsystem.autocheck; + +import org.bukkit.Material; + +import java.util.EnumSet; +import java.util.Set; + +public class AutoCheckerItems19 implements AutoCheckerItems { + + private static final Set INVENTORY = EnumSet.of( + Material.BARREL, + Material.BLAST_FURNACE, + Material.BREWING_STAND, + Material.CAMPFIRE, + Material.CHEST, + Material.DISPENSER, + Material.DROPPER, + Material.FURNACE, + Material.HOPPER, + Material.JUKEBOX, + Material.SHULKER_BOX, + Material.WHITE_SHULKER_BOX, + Material.ORANGE_SHULKER_BOX, + Material.MAGENTA_SHULKER_BOX, + Material.LIGHT_BLUE_SHULKER_BOX, + Material.YELLOW_SHULKER_BOX, + Material.LIME_SHULKER_BOX, + Material.PINK_SHULKER_BOX, + Material.GRAY_SHULKER_BOX, + Material.LIGHT_GRAY_SHULKER_BOX, + Material.CYAN_SHULKER_BOX, + Material.PURPLE_SHULKER_BOX, + Material.BLUE_SHULKER_BOX, + Material.BROWN_SHULKER_BOX, + Material.GREEN_SHULKER_BOX, + Material.RED_SHULKER_BOX, + Material.BLACK_SHULKER_BOX, + Material.SMOKER, + Material.TRAPPED_CHEST); + + private static final Set ALLOWED_ITEMS_IN_INVENTORY = EnumSet.of( + // 64-stackable Items + Material.CORNFLOWER, + Material.POPPY, + Material.FERN, + Material.DANDELION, + Material.BLUE_ORCHID, + Material.ALLIUM, + Material.AZURE_BLUET, + Material.RED_TULIP, + Material.ORANGE_TULIP, + Material.WHITE_TULIP, + Material.PINK_TULIP, + Material.OXEYE_DAISY, + Material.LILY_OF_THE_VALLEY, + Material.WITHER_ROSE, + Material.SUNFLOWER, + // 16-stackable Items + Material.HONEY_BOTTLE, + // Non-stackable items + Material.DIAMOND_HORSE_ARMOR, + Material.IRON_HORSE_ARMOR, + Material.GOLDEN_HORSE_ARMOR, + // Disks + Material.MUSIC_DISC_11, + Material.MUSIC_DISC_13, + Material.MUSIC_DISC_CAT, + Material.MUSIC_DISC_BLOCKS, + Material.MUSIC_DISC_CHIRP, + Material.MUSIC_DISC_FAR, + Material.MUSIC_DISC_MALL, + Material.MUSIC_DISC_MELLOHI, + Material.MUSIC_DISC_STAL, + Material.MUSIC_DISC_STRAD, + Material.MUSIC_DISC_WAIT, + Material.MUSIC_DISC_WARD, + Material.MUSIC_DISC_OTHERSIDE, + Material.MUSIC_DISC_PIGSTEP, + Material.MUSIC_DISC_RELIC, + Material.MUSIC_DISC_5 + ); + + @Override + public Set getInventoryMaterials() { + return INVENTORY; + } + + @Override + public Set getAllowedMaterialsInInventory() { + return ALLOWED_ITEMS_IN_INVENTORY; + } +} diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java new file mode 100644 index 00000000..fb103f67 --- /dev/null +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java @@ -0,0 +1,34 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.schematicsystem.autocheck; + +import de.steamwar.core.VersionDependent; +import de.steamwar.schematicsystem.SchematicSystem; +import org.bukkit.Material; + +import java.util.Set; + +public interface AutoCheckerItems { + + AutoCheckerItems impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance()); + + Set getInventoryMaterials(); + Set getAllowedMaterialsInInventory(); +} From 380506542f2df4db70769dbccfd13eb14ded37d1 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 23 May 2025 09:13:23 +0200 Subject: [PATCH 4/4] Remove some more duplicates --- .../SchematicSystem_19/build.gradle.kts | 1 + .../autocheck/AutoCheckerItems19.java | 38 +------------------ 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/SchematicSystem/SchematicSystem_19/build.gradle.kts b/SchematicSystem/SchematicSystem_19/build.gradle.kts index 99b982c8..38fcd471 100644 --- a/SchematicSystem/SchematicSystem_19/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_19/build.gradle.kts @@ -24,6 +24,7 @@ plugins { dependencies { compileOnly(project(":SpigotCore", "default")) compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) + compileOnly(project(":SchematicSystem:SchematicSystem_15", "default")) compileOnly(libs.spigotapi) diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java index 556d354f..0c004cfe 100644 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java @@ -24,38 +24,7 @@ import org.bukkit.Material; import java.util.EnumSet; import java.util.Set; -public class AutoCheckerItems19 implements AutoCheckerItems { - - private static final Set INVENTORY = EnumSet.of( - Material.BARREL, - Material.BLAST_FURNACE, - Material.BREWING_STAND, - Material.CAMPFIRE, - Material.CHEST, - Material.DISPENSER, - Material.DROPPER, - Material.FURNACE, - Material.HOPPER, - Material.JUKEBOX, - Material.SHULKER_BOX, - Material.WHITE_SHULKER_BOX, - Material.ORANGE_SHULKER_BOX, - Material.MAGENTA_SHULKER_BOX, - Material.LIGHT_BLUE_SHULKER_BOX, - Material.YELLOW_SHULKER_BOX, - Material.LIME_SHULKER_BOX, - Material.PINK_SHULKER_BOX, - Material.GRAY_SHULKER_BOX, - Material.LIGHT_GRAY_SHULKER_BOX, - Material.CYAN_SHULKER_BOX, - Material.PURPLE_SHULKER_BOX, - Material.BLUE_SHULKER_BOX, - Material.BROWN_SHULKER_BOX, - Material.GREEN_SHULKER_BOX, - Material.RED_SHULKER_BOX, - Material.BLACK_SHULKER_BOX, - Material.SMOKER, - Material.TRAPPED_CHEST); +public class AutoCheckerItems19 extends AutoCheckerItems15 { private static final Set ALLOWED_ITEMS_IN_INVENTORY = EnumSet.of( // 64-stackable Items @@ -99,11 +68,6 @@ public class AutoCheckerItems19 implements AutoCheckerItems { Material.MUSIC_DISC_5 ); - @Override - public Set getInventoryMaterials() { - return INVENTORY; - } - @Override public Set getAllowedMaterialsInInventory() { return ALLOWED_ITEMS_IN_INVENTORY;