9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-21 07:59:28 +00:00

Cleaned up bosstype

This commit is contained in:
Auxilor
2021-03-12 11:59:22 +00:00
parent 8828e80dca
commit 32100fe08f
3 changed files with 16 additions and 17 deletions

View File

@@ -19,7 +19,6 @@ import net.minecraft.server.v1_16_R3.PathfinderGoalRandomStroll;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey;
import org.bukkit.entity.Illusioner;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
@@ -51,11 +50,4 @@ public class CustomIllusioner extends EntityIllagerIllusioner implements CustomI
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
}
@Override
public Illusioner spawn(@NotNull final Location location) {
CustomIllusioner illusioner = new CustomIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return (Illusioner) illusioner.getBukkitEntity();
}
}

View File

@@ -1,13 +1,15 @@
package com.willfp.ecobosses.bosses.util.bosstype;
import com.willfp.ecobosses.proxy.util.CustomEntities;
import com.willfp.ecobosses.proxy.util.CustomEntity;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import org.jetbrains.annotations.Nullable;
@UtilityClass
@SuppressWarnings("unchecked")
public class BossEntityUtils {
/**
* Get boss type.
@@ -15,11 +17,17 @@ public class BossEntityUtils {
* @param id The name.
* @return The boss type.
*/
@Nullable
public static BossType getBossType(@NotNull final String id) {
if (CustomEntities.getEntityClass(id) != null) {
return new CustomBossType(Objects.requireNonNull(CustomEntities.getEntityClass(id)));
} else {
return new VanillaBossType(Objects.requireNonNull(EntityType.valueOf(id.toUpperCase()).getEntityClass()));
Class<? extends CustomEntity<? extends LivingEntity>> proxy = CustomEntities.getEntityClass(id.toLowerCase());
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
if (proxy != null) {
return new CustomBossType(proxy);
}
if (type != null) {
return new VanillaBossType(type);
}
return null;
}
}

View File

@@ -1,7 +1,6 @@
package com.willfp.ecobosses.bosses.util.bosstype;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
@@ -11,14 +10,14 @@ class VanillaBossType extends BossType {
/**
* The entity type.
*/
private final Class<? extends Entity> entityClass;
private final Class<? extends LivingEntity> entityClass;
/**
* Create new vanilla boss type.
*
* @param entityClass The entity class.
*/
VanillaBossType(@NotNull final Class<? extends Entity> entityClass) {
VanillaBossType(@NotNull final Class<? extends LivingEntity> entityClass) {
this.entityClass = entityClass;
}