using java 16 syntax (#1958)

This commit is contained in:
Invvk 2022-04-01 00:12:47 +03:00 committed by GitHub
parent 36751d5573
commit c02e566266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 25 deletions

View File

@ -257,8 +257,8 @@ public class BlueprintClipboard {
} }
// Banners // Banners
if (blockState instanceof Banner) { if (blockState instanceof Banner banner) {
b.setBannerPatterns(((Banner) blockState).getPatterns()); b.setBannerPatterns(banner.getPatterns());
} }
return b; return b;
@ -282,8 +282,8 @@ public class BlueprintClipboard {
BlueprintEntity bpe = new BlueprintEntity(); BlueprintEntity bpe = new BlueprintEntity();
bpe.setType(entity.getType()); bpe.setType(entity.getType());
bpe.setCustomName(entity.getCustomName()); bpe.setCustomName(entity.getCustomName());
if (entity instanceof Villager) { if (entity instanceof Villager villager) {
setVillager(entity, bpe); setVillager(villager, bpe);
} }
if (entity instanceof Colorable c) { if (entity instanceof Colorable c) {
if (c.getColor() != null) { if (c.getColor() != null) {
@ -321,11 +321,10 @@ public class BlueprintClipboard {
/** /**
* Set the villager stats * Set the villager stats
* @param entity - villager * @param v - villager
* @param bpe - Blueprint Entity * @param bpe - Blueprint Entity
*/ */
private void setVillager(LivingEntity entity, BlueprintEntity bpe) { private void setVillager(Villager v, BlueprintEntity bpe) {
Villager v = (Villager)entity;
bpe.setExperience(v.getVillagerExperience()); bpe.setExperience(v.getVillagerExperience());
bpe.setLevel(v.getVillagerLevel()); bpe.setLevel(v.getVillagerLevel());
bpe.setProfession(v.getProfession()); bpe.setProfession(v.getProfession());

View File

@ -305,8 +305,8 @@ public class BlueprintPaster {
writeSign(block, bpBlock.getSignLines(), bpBlock.isGlowingText()); writeSign(block, bpBlock.getSignLines(), bpBlock.isGlowingText());
} }
// Chests, in general // Chests, in general
if (bs instanceof InventoryHolder) { if (bs instanceof InventoryHolder holder) {
Inventory ih = ((InventoryHolder)bs).getInventory(); Inventory ih = holder.getInventory();
// Double chests are pasted as two blocks so inventory is filled twice. // Double chests are pasted as two blocks so inventory is filled twice.
// This code stops over-filling for the first block. // This code stops over-filling for the first block.
bpBlock.getInventory().forEach(ih::setItem); bpBlock.getInventory().forEach(ih::setItem);

View File

@ -56,23 +56,23 @@ public class BlueprintEntity {
* @since 1.8.0 * @since 1.8.0
*/ */
public void configureEntity(Entity e) { public void configureEntity(Entity e) {
if (e instanceof Villager) { if (e instanceof Villager villager) {
setVillager(e); setVillager(villager);
} }
if (e instanceof Colorable) { if (e instanceof Colorable c) {
((Colorable) e).setColor(color); c.setColor(color);
} }
if (tamed != null && e instanceof Tameable) { if (tamed != null && e instanceof Tameable tameable) {
((Tameable)e).setTamed(tamed); tameable.setTamed(tamed);
} }
if (chest != null && e instanceof ChestedHorse) { if (chest != null && e instanceof ChestedHorse chestedHorse) {
((ChestedHorse)e).setCarryingChest(chest); chestedHorse.setCarryingChest(chest);
} }
if (adult != null && e instanceof Ageable) { if (adult != null && e instanceof Ageable ageable) {
if (adult) { if (adult) {
((Ageable)e).setAdult(); ageable.setAdult();
} else { } else {
((Ageable)e).setBaby(); ageable.setBaby();
} }
} }
if (e instanceof AbstractHorse horse) { if (e instanceof AbstractHorse horse) {
@ -81,18 +81,17 @@ public class BlueprintEntity {
inventory.forEach(horse.getInventory()::setItem); inventory.forEach(horse.getInventory()::setItem);
} }
} }
if (style != null && e instanceof Horse) { if (style != null && e instanceof Horse horse) {
((Horse)e).setStyle(style); horse.setStyle(style);
} }
} }
/** /**
* @param e - villager * @param v - villager
* @since 1.16.0 * @since 1.16.0
*/ */
private void setVillager(Entity e) { private void setVillager(Villager v) {
Villager v = (Villager)e;
v.setProfession(profession == null ? Profession.NONE : profession); v.setProfession(profession == null ? Profession.NONE : profession);
v.setVillagerExperience(experience == null ? 0 : experience); v.setVillagerExperience(experience == null ? 0 : experience);
v.setVillagerLevel(level == null ? 0 : level); v.setVillagerLevel(level == null ? 0 : level);