diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/slaves/MaterialUtils_15.java b/BauSystem_15/src/de/steamwar/bausystem/features/slaves/MaterialUtils_15.java new file mode 100644 index 00000000..26b8cf9b --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/features/slaves/MaterialUtils_15.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 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.bausystem.features.slaves; + +import lombok.experimental.UtilityClass; +import org.bukkit.Material; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +@UtilityClass +public class MaterialUtils_15 { + + private static Set unpushable = new HashSet<>(Arrays.asList(Material.BARRIER, Material.BEACON, Material.COMMAND_BLOCK, Material.CHAIN_COMMAND_BLOCK, Material.REPEATING_COMMAND_BLOCK, Material.ENCHANTING_TABLE, Material.END_GATEWAY, Material.END_PORTAL, Material.ENDER_CHEST, Material.GRINDSTONE, Material.JIGSAW, Material.JUKEBOX, Material.NETHER_PORTAL, Material.OBSIDIAN, Material.STRUCTURE_VOID, Material.BARREL, Material.BEEHIVE, Material.BEE_NEST, Material.BLAST_FURNACE, Material.BREWING_STAND, Material.CHEST, Material.DAYLIGHT_DETECTOR, Material.DISPENSER, Material.DROPPER, Material.FURNACE, Material.HOPPER, Material.LECTERN, Material.SMOKER, Material.TRAPPED_CHEST)); + + static boolean isUnpusheable(Material material) { + if (unpushable.contains(material)) { + return true; + } + String name = material.name(); + return name.contains("BANNER") || name.contains("SIGN"); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/MaterialUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/MaterialUtils.java new file mode 100644 index 00000000..4ff1695f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/MaterialUtils.java @@ -0,0 +1,32 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 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.bausystem.features.slaves; + +import de.steamwar.core.VersionedCallable; +import org.bukkit.Material; + +public class MaterialUtils { + + public static boolean isUnpusheable(Material material) { + return VersionedCallable.call( + new VersionedCallable<>(() -> MaterialUtils_15.isUnpusheable(material), 15) + ); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java index 9a0193b7..e8f84e84 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java @@ -19,6 +19,9 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; +import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.registry.BlockRegistry; +import de.steamwar.bausystem.features.slaves.MaterialUtils; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; import de.steamwar.bausystem.linkage.LinkageType; @@ -28,6 +31,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Piston; +import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock; import java.util.Map; import java.util.Set; @@ -45,6 +49,9 @@ public class PistonLine implements PanzernAlgorithm { } BlockData blockData = relativeBlock.getBlockData(); if (!(blockData instanceof Piston)) { + if (MaterialUtils.isUnpusheable(relativeBlock.getType())) { + break; + } continue; } Piston piston = (Piston) blockData;