diff --git a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java index 6b7d5f888..6642fb942 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java @@ -190,6 +190,91 @@ public class BlueprintClipboard { Vector pos = new Vector(x, y, z); // Set entities + List bpEnts = setEntities(entities); + // Store + if (!bpEnts.isEmpty()) { + bpEntities.put(pos, bpEnts); + } + + // Return if this is just air block + if (!copyAir && block.getType().equals(Material.AIR) && !entities.isEmpty()) { + return true; + } + + + BlueprintBlock b = bluePrintBlock(pos, block); + if (b != null) { + this.bpBlocks.put(pos, b); + } + return true; + } + + private BlueprintBlock bluePrintBlock(Vector pos, Block block) { + // Block state + BlockState blockState = block.getState(); + BlueprintBlock b = new BlueprintBlock(block.getBlockData().getAsString()); + // Biome + b.setBiome(block.getBiome()); + // Signs + if (blockState instanceof Sign sign) { + b.setSignLines(Arrays.asList(sign.getLines())); + b.setGlowingText(sign.isGlowingText()); + } + // Set block data + if (blockState.getData() instanceof Attachable) { + // Placeholder for attachment + bpBlocks.put(pos, new BlueprintBlock("minecraft:air")); + bpAttachable.put(pos, b); + return null; + } + + if (block.getType().equals(Material.BEDROCK)) { + // Find highest bedrock + if(blueprint.getBedrock() == null) { + blueprint.setBedrock(pos); + } else { + if (pos.getBlockY() > blueprint.getBedrock().getBlockY()) { + blueprint.setBedrock(pos); + } + } + } + + // Chests + if (blockState instanceof InventoryHolder ih) { + b.setInventory(new HashMap<>()); + for (int i = 0; i < ih.getInventory().getSize(); i++) { + ItemStack item = ih.getInventory().getItem(i); + if (item != null) { + b.getInventory().put(i, item); + } + } + } + + if (blockState instanceof CreatureSpawner spawner) { + b.setCreatureSpawner(getSpawner(spawner)); + } + + // Banners + if (blockState instanceof Banner) { + b.setBannerPatterns(((Banner) blockState).getPatterns()); + } + + return b; + } + + private BlueprintCreatureSpawner getSpawner(CreatureSpawner spawner) { + BlueprintCreatureSpawner cs = new BlueprintCreatureSpawner(); + cs.setSpawnedType(spawner.getSpawnedType()); + cs.setDelay(spawner.getDelay()); + cs.setMaxNearbyEntities(spawner.getMaxNearbyEntities()); + cs.setMaxSpawnDelay(spawner.getMaxSpawnDelay()); + cs.setMinSpawnDelay(spawner.getMinSpawnDelay()); + cs.setRequiredPlayerRange(spawner.getRequiredPlayerRange()); + cs.setSpawnRange(spawner.getSpawnRange()); + return cs; + } + + private List setEntities(Collection entities) { List bpEnts = new ArrayList<>(); for (LivingEntity entity: entities) { BlueprintEntity bpe = new BlueprintEntity(); @@ -229,74 +314,7 @@ public class BlueprintClipboard { } bpEnts.add(bpe); } - // Store - if (!bpEnts.isEmpty()) { - bpEntities.put(pos, bpEnts); - } - - // Return if this is just air block - if (!copyAir && block.getType().equals(Material.AIR) && !entities.isEmpty()) { - return true; - } - - // Block state - BlockState blockState = block.getState(); - BlueprintBlock b = new BlueprintBlock(block.getBlockData().getAsString()); - // Biome - b.setBiome(block.getBiome()); - // Signs - if (blockState instanceof Sign sign) { - b.setSignLines(Arrays.asList(sign.getLines())); - } - // Set block data - if (blockState.getData() instanceof Attachable) { - // Placeholder for attachment - bpBlocks.put(pos, new BlueprintBlock("minecraft:air")); - bpAttachable.put(pos, b); - return true; - } - - if (block.getType().equals(Material.BEDROCK)) { - // Find highest bedrock - if(blueprint.getBedrock() == null) { - blueprint.setBedrock(pos); - } else { - if (pos.getBlockY() > blueprint.getBedrock().getBlockY()) { - blueprint.setBedrock(pos); - } - } - } - - // Chests - if (blockState instanceof InventoryHolder ih) { - b.setInventory(new HashMap<>()); - for (int i = 0; i < ih.getInventory().getSize(); i++) { - ItemStack item = ih.getInventory().getItem(i); - if (item != null) { - b.getInventory().put(i, item); - } - } - } - - if (blockState instanceof CreatureSpawner spawner) { - BlueprintCreatureSpawner cs = new BlueprintCreatureSpawner(); - cs.setSpawnedType(spawner.getSpawnedType()); - cs.setDelay(spawner.getDelay()); - cs.setMaxNearbyEntities(spawner.getMaxNearbyEntities()); - cs.setMaxSpawnDelay(spawner.getMaxSpawnDelay()); - cs.setMinSpawnDelay(spawner.getMinSpawnDelay()); - cs.setRequiredPlayerRange(spawner.getRequiredPlayerRange()); - cs.setSpawnRange(spawner.getSpawnRange()); - b.setCreatureSpawner(cs); - } - - // Banners - if (blockState instanceof Banner) { - b.setBannerPatterns(((Banner) blockState).getPatterns()); - } - - this.bpBlocks.put(pos, b); - return true; + return bpEnts; } /** diff --git a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java index 3960fd45e..34b1b32d1 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java @@ -290,26 +290,19 @@ public class BlueprintPaster { // Get the block state BlockState bs = block.getState(); // Signs - if (bs instanceof org.bukkit.block.Sign) { - writeSign(block, bpBlock.getSignLines()); + if (bs instanceof org.bukkit.block.Sign sign) { + writeSign(block, bpBlock.getSignLines(), bpBlock.isGlowingText()); } // Chests, in general if (bs instanceof InventoryHolder) { Inventory ih = ((InventoryHolder)bs).getInventory(); - // Double chests are pasted as two blocks so inventory is filled twice. This code stops over filling for the first block. + // Double chests are pasted as two blocks so inventory is filled twice. + // This code stops over-filling for the first block. bpBlock.getInventory().forEach(ih::setItem); } // Mob spawners if (bs instanceof CreatureSpawner spawner) { - BlueprintCreatureSpawner s = bpBlock.getCreatureSpawner(); - spawner.setSpawnedType(s.getSpawnedType()); - spawner.setMaxNearbyEntities(s.getMaxNearbyEntities()); - spawner.setMaxSpawnDelay(s.getMaxSpawnDelay()); - spawner.setMinSpawnDelay(s.getMinSpawnDelay()); - spawner.setDelay(s.getDelay()); - spawner.setRequiredPlayerRange(s.getRequiredPlayerRange()); - spawner.setSpawnRange(s.getSpawnRange()); - bs.update(true, false); + setSpawner(spawner, bpBlock.getCreatureSpawner()); } // Banners if (bs instanceof Banner banner && bpBlock.getBannerPatterns() != null) { @@ -319,6 +312,17 @@ public class BlueprintPaster { } } + private void setSpawner(CreatureSpawner spawner, BlueprintCreatureSpawner s) { + spawner.setSpawnedType(s.getSpawnedType()); + spawner.setMaxNearbyEntities(s.getMaxNearbyEntities()); + spawner.setMaxSpawnDelay(s.getMaxSpawnDelay()); + spawner.setMinSpawnDelay(s.getMinSpawnDelay()); + spawner.setDelay(s.getDelay()); + spawner.setRequiredPlayerRange(s.getRequiredPlayerRange()); + spawner.setSpawnRange(s.getSpawnRange()); + spawner.update(true, false); + } + /** * Sets any entity that is in this location * @param location - location @@ -383,7 +387,7 @@ public class BlueprintPaster { } } - private void writeSign(final Block block, final List lines) { + private void writeSign(final Block block, final List lines, boolean glow) { BlockFace bf; if (block.getType().name().contains("WALL_SIGN")) { WallSign wallSign = (WallSign)block.getBlockData(); @@ -422,6 +426,7 @@ public class BlueprintPaster { s.setLine(i, lines.get(i)); } } + s.setGlowingText(glow); // Update the sign s.update(); } diff --git a/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintBlock.java b/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintBlock.java index 4aa327bdf..7b2584087 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintBlock.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintBlock.java @@ -34,6 +34,8 @@ public class BlueprintBlock { */ @Expose private List bannerPatterns; + @Expose + private boolean glowingText; public BlueprintBlock(String blockData) { this.blockData = blockData; @@ -124,4 +126,20 @@ public class BlueprintBlock { public void setBiome(Biome biome) { this.biome = biome; } + + /** + * @return the glowingText + */ + public boolean isGlowingText() { + return glowingText; + } + + /** + * @param glowingText the glowingText to set + */ + public void setGlowingText(boolean glowingText) { + this.glowingText = glowingText; + } + + }