diff --git a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java index 7d0c01b82..b6f4a9c5f 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintClipboard.java @@ -257,8 +257,8 @@ public class BlueprintClipboard { } // Banners - if (blockState instanceof Banner) { - b.setBannerPatterns(((Banner) blockState).getPatterns()); + if (blockState instanceof Banner banner) { + b.setBannerPatterns(banner.getPatterns()); } return b; @@ -282,8 +282,8 @@ public class BlueprintClipboard { BlueprintEntity bpe = new BlueprintEntity(); bpe.setType(entity.getType()); bpe.setCustomName(entity.getCustomName()); - if (entity instanceof Villager) { - setVillager(entity, bpe); + if (entity instanceof Villager villager) { + setVillager(villager, bpe); } if (entity instanceof Colorable c) { if (c.getColor() != null) { @@ -321,11 +321,10 @@ public class BlueprintClipboard { /** * Set the villager stats - * @param entity - villager + * @param v - villager * @param bpe - Blueprint Entity */ - private void setVillager(LivingEntity entity, BlueprintEntity bpe) { - Villager v = (Villager)entity; + private void setVillager(Villager v, BlueprintEntity bpe) { bpe.setExperience(v.getVillagerExperience()); bpe.setLevel(v.getVillagerLevel()); bpe.setProfession(v.getProfession()); diff --git a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java index c91cc14b0..a3be6906c 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java @@ -305,8 +305,8 @@ public class BlueprintPaster { writeSign(block, bpBlock.getSignLines(), bpBlock.isGlowingText()); } // Chests, in general - if (bs instanceof InventoryHolder) { - Inventory ih = ((InventoryHolder)bs).getInventory(); + if (bs instanceof InventoryHolder holder) { + Inventory ih = holder.getInventory(); // 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); diff --git a/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintEntity.java b/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintEntity.java index e173f6b86..6a5927ddb 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintEntity.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/dataobjects/BlueprintEntity.java @@ -56,23 +56,23 @@ public class BlueprintEntity { * @since 1.8.0 */ public void configureEntity(Entity e) { - if (e instanceof Villager) { - setVillager(e); + if (e instanceof Villager villager) { + setVillager(villager); } - if (e instanceof Colorable) { - ((Colorable) e).setColor(color); + if (e instanceof Colorable c) { + c.setColor(color); } - if (tamed != null && e instanceof Tameable) { - ((Tameable)e).setTamed(tamed); + if (tamed != null && e instanceof Tameable tameable) { + tameable.setTamed(tamed); } - if (chest != null && e instanceof ChestedHorse) { - ((ChestedHorse)e).setCarryingChest(chest); + if (chest != null && e instanceof ChestedHorse chestedHorse) { + chestedHorse.setCarryingChest(chest); } - if (adult != null && e instanceof Ageable) { + if (adult != null && e instanceof Ageable ageable) { if (adult) { - ((Ageable)e).setAdult(); + ageable.setAdult(); } else { - ((Ageable)e).setBaby(); + ageable.setBaby(); } } if (e instanceof AbstractHorse horse) { @@ -81,18 +81,17 @@ public class BlueprintEntity { inventory.forEach(horse.getInventory()::setItem); } } - if (style != null && e instanceof Horse) { - ((Horse)e).setStyle(style); + if (style != null && e instanceof Horse horse) { + horse.setStyle(style); } } /** - * @param e - villager + * @param v - villager * @since 1.16.0 */ - private void setVillager(Entity e) { - Villager v = (Villager)e; + private void setVillager(Villager v) { v.setProfession(profession == null ? Profession.NONE : profession); v.setVillagerExperience(experience == null ? 0 : experience); v.setVillagerLevel(level == null ? 0 : level);