From 2b959228dbe62734dac52e7f573973b485d3e6f3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 8 Dec 2022 20:38:58 +0100 Subject: [PATCH] Hotfix AttributeRemoveCommand Signed-off-by: yoyosource --- .../attributescopy/AttributesCopyCommand.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java index 6c158793..9224d0a3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java @@ -25,6 +25,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import de.steamwar.linkage.MinVersion; import org.bukkit.FluidCollisionMode; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; @@ -53,9 +54,10 @@ public class AttributesCopyCommand extends SWCommand { linkIfNeeded(); Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS); + if (block == null) return; ItemStack mainHand = player.getInventory().getItemInMainHand(); - if (mainHand.getType() != block.getType()) { - BauSystem.MESSAGE.send("ATTRIBUTES_CANT_COPY", player); + if (!isSame(block, mainHand)) { + BauSystem.MESSAGE.send("ATTRIBUTE_COPY_NOT_SAME", player); return; } BlockData blockData = block.getBlockData(); @@ -84,4 +86,10 @@ public class AttributesCopyCommand extends SWCommand { LinkageUtils.linkBlockAttributes(); isLinked = true; } + + private boolean isSame(Block block, ItemStack itemStack) { + if (block.getType() == itemStack.getType()) return true; + if (itemStack.getType() == Material.REDSTONE && block.getType() == Material.REDSTONE_WIRE) return true; + return false; + } }