From b75b83aebf02ceb8694c9ca5547dfeb28645a21a Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Sep 2021 08:44:37 +0100 Subject: [PATCH] Updated PR to use ChargedCreeperBossType --- .../bosses/util/bosstype/BossEntityUtils.java | 2 +- .../util/bosstype/ChargedCreeperBossType.java | 30 +++++++++++++++++++ .../bosses/util/bosstype/VanillaBossType.java | 18 ----------- 3 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java index b8813b7..cc50e7c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java @@ -42,7 +42,7 @@ public class BossEntityUtils { } if (id.equalsIgnoreCase("charged_creeper")) { - return new VanillaBossType(Creeper.class, true); + return new ChargedCreeperBossType(); } try { diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java new file mode 100644 index 0000000..c867868 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java @@ -0,0 +1,30 @@ +package com.willfp.ecobosses.bosses.util.bosstype; + +import org.bukkit.Location; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +class ChargedCreeperBossType extends VanillaBossType { + /** + * Create new Charged Creeper boss type. + */ + ChargedCreeperBossType() { + super(Creeper.class); + } + + /** + * Spawn a charged creeper. + * + * @param location The location. + * @return The entity. + */ + @Override + public LivingEntity spawnBossEntity(@NotNull final Location location) { + Creeper creeper = Objects.requireNonNull(location.getWorld()).spawn(location, Creeper.class); + creeper.setPowered(true); + return creeper; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java index 708b6ea..f1f3195 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java @@ -13,11 +13,6 @@ class VanillaBossType extends BossType { */ private final Class entityClass; - /** - * If the entity is Creeper and should or should not be charged. - */ - private final boolean creeperCharged; - /** * Create new vanilla boss type. * @@ -25,24 +20,11 @@ class VanillaBossType extends BossType { */ VanillaBossType(@NotNull final Class entityClass) { this.entityClass = entityClass; - this.creeperCharged = false; - } - - /** - * Create new vanilla boss type. - * - * @param entityClass The entity class. - * @param creeperCharged The creeper power state. - */ - VanillaBossType(@NotNull final Class entityClass, boolean creeperCharged) { - this.entityClass = entityClass; - this.creeperCharged = creeperCharged; } @Override public LivingEntity spawnBossEntity(@NotNull final Location location) { LivingEntity result = Objects.requireNonNull(location.getWorld()).spawn(location, entityClass); - if (result instanceof Creeper creeper && creeperCharged) creeper.setPowered(true); return result; } }