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 9e00c6b7..fb32c023 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java @@ -62,6 +62,9 @@ public class AttributesCopyCommand extends SWCommand { } BlockData blockData = block.getBlockData(); List attributesToCopy = new ArrayList<>(); + if (needsType(block)) { + attributesToCopy.add("§8-§7 type " + block.getType().name().toLowerCase()); + } for (BlockAttribute blockAttribute : blockAttributeList) { if (blockAttribute.type().isInstance(blockData)) { blockAttribute.copy(attributesToCopy, blockData); @@ -98,7 +101,23 @@ public class AttributesCopyCommand extends SWCommand { if (itemStack.getType() == Material.WITHER_SKELETON_SKULL && block.getType() == Material.WITHER_SKELETON_WALL_SKULL) return true; if (itemStack.getType() == Material.TORCH && block.getType() == Material.WALL_TORCH) return true; if (itemStack.getType() == Material.SOUL_TORCH && block.getType() == Material.SOUL_WALL_TORCH) return true; + if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) return true; if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true; return false; } + + private boolean needsType(Block block) { + if (block.getType().name().contains("WALL")) return true; + if (block.getType() == Material.PLAYER_HEAD) return true; + if (block.getType() == Material.ZOMBIE_HEAD) return true; + if (block.getType() == Material.CREEPER_HEAD) return true; + if (block.getType() == Material.DRAGON_HEAD) return true; + if (block.getType() == Material.SKELETON_SKULL) return true; + if (block.getType() == Material.WITHER_SKELETON_SKULL) return true; + if (block.getType() == Material.TORCH) return true; + if (block.getType() == Material.SOUL_TORCH) return true; + if (block.getType() == Material.REDSTONE_TORCH) return true; + if (block.getType().name().contains("_BANNER")) return true; + return false; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java index 810597d2..7976e5cd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java @@ -24,13 +24,16 @@ import de.steamwar.linkage.Linked; import de.steamwar.linkage.MinVersion; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; +import org.bukkit.block.Skull; import org.bukkit.block.data.BlockData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.profile.PlayerProfile; import java.util.HashSet; import java.util.List; @@ -53,12 +56,32 @@ public class AttributesPlaceListener implements Listener { if (strings.isEmpty()) return; if (!strings.get(0).equals("§eAttributes§8:")) return; Material type = event.getBlock().getType(); + OfflinePlayer offlinePlayer = null; + if (event.getBlock().getState() instanceof Skull) { + Skull skull = (Skull) event.getBlock().getState(); + offlinePlayer = skull.getOwningPlayer(); + } + OfflinePlayer finalPlayerProfile = offlinePlayer; event.setCancelled(true); Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - event.getBlock().setType(type, false); + Material material = strings.stream() + .filter(s -> s.startsWith("§8-§7 type ")) + .map(s -> s.replace("§8-§7 type ", "")) + .map(String::toUpperCase) + .map(Material::valueOf) + .findFirst() + .orElse(type); + event.getBlock().setType(material, false); Set attributesToPaste = new HashSet<>(strings); Block block = event.getBlock(); BlockData blockData = block.getBlockData(); + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + if (block.getState() instanceof Skull && finalPlayerProfile != null) { + Skull skull = (Skull) block.getState(); + skull.setOwningPlayer(finalPlayerProfile); + skull.update(true, false); + } + }, 1); for (BlockAttribute blockAttribute : blockAttributeList) { if (blockAttribute.type().isInstance(blockData)) { blockAttribute.paste(attributesToPaste, blockData); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/MultipleFacingAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/MultipleFacingAttribute.java index 999fb0df..262de53c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/MultipleFacingAttribute.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/MultipleFacingAttribute.java @@ -47,7 +47,6 @@ public class MultipleFacingAttribute implements BlockAttribute { @Override public void paste(Set attributes, MultipleFacing blockData) { for (BlockFace blockFace : BlockFace.values()) { - if (!blockData.getAllowedFaces().contains(blockFace)) continue; blockData.setFace(blockFace, attributes.contains(attribute + blockFace.name().toLowerCase())); } }