mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-06-26 06:35:03 +02:00
3.0.0-SNAPSHOT-U17
Fixed up EntityTypeMechanic to now use EntityFinder, added a new Debug message.
This commit is contained in:
parent
25b058deb3
commit
7d08f613d0
|
@ -2,9 +2,8 @@ package net.aminecraftdev.custombosses.mechanics;
|
|||
|
||||
import net.aminecraftdev.custombosses.entity.BossEntity;
|
||||
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
||||
import net.aminecraftdev.custombosses.utils.EntityTypeUtil;
|
||||
import net.aminecraftdev.custombosses.utils.EntityFinder;
|
||||
import net.aminecraftdev.custombosses.utils.IMechanic;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
/**
|
||||
|
@ -17,23 +16,14 @@ public class EntityTypeMechanic implements IMechanic {
|
|||
@Override
|
||||
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
|
||||
String bossEntityType = bossEntity.getMainStats().getEntityType();
|
||||
LivingEntity livingEntity;
|
||||
String input = bossEntityType.split(":")[0];
|
||||
EntityFinder entityFinder = EntityFinder.get(input);
|
||||
|
||||
try {
|
||||
livingEntity = EntityTypeUtil.get(bossEntityType, activeBossHolder.getLocation());
|
||||
} catch (NullPointerException ex) {
|
||||
return false;
|
||||
}
|
||||
if(entityFinder == null) return false;
|
||||
|
||||
if(livingEntity == null) {
|
||||
EntityType entityType = EntityType.valueOf(bossEntityType.toUpperCase());
|
||||
LivingEntity livingEntity = entityFinder.spawnNewLivingEntity(bossEntityType, activeBossHolder.getLocation());
|
||||
|
||||
try {
|
||||
livingEntity = (LivingEntity) activeBossHolder.getLocation().getWorld().spawnEntity(activeBossHolder.getLocation(), entityType);
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(livingEntity == null) return false;
|
||||
|
||||
activeBossHolder.setLivingEntity(livingEntity);
|
||||
return true;
|
||||
|
|
|
@ -13,7 +13,8 @@ public enum Debug {
|
|||
MAX_HEALTH("You cannot set the max health higher than {0}. You can adjust your max health in the spigot.yml file and restart your server to increase this."),
|
||||
MECHANIC_APPLICATION_FAILED("Some mechanics have failed to be applied. It got stuck at {0} mechanic."),
|
||||
|
||||
ATTEMPTED_TO_SPAWN_WHILE_DISABLED("The {0} boss/minion attempted to spawn while editing is enabled.");
|
||||
ATTEMPTED_TO_SPAWN_WHILE_DISABLED("The {0} boss/minion attempted to spawn while editing is enabled."),
|
||||
FAILED_ATTEMPT_TO_SPAWN_BOSS("A boss has attempted to spawn but cannot spawn for the following reason: \n{0}");
|
||||
|
||||
private String message;
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ package net.aminecraftdev.custombosses.utils;
|
|||
import lombok.Getter;
|
||||
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
|
||||
import net.aminecraftdev.custombosses.utils.entity.handlers.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -93,6 +95,23 @@ public enum EntityFinder {
|
|||
this.customEntityHandler = null;
|
||||
}
|
||||
|
||||
public LivingEntity spawnNewLivingEntity(String input, Location location) {
|
||||
if(this.customEntityHandler != null) {
|
||||
LivingEntity livingEntity;
|
||||
|
||||
try {
|
||||
livingEntity = this.customEntityHandler.getBaseEntity(input, location);
|
||||
} catch (NullPointerException ex) {
|
||||
Debug.FAILED_ATTEMPT_TO_SPAWN_BOSS.debug(ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return livingEntity;
|
||||
} else {
|
||||
return (LivingEntity) location.getWorld().spawnEntity(location, getEntityType());
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityFinder get(String name) {
|
||||
for(EntityFinder entityFinder : values()) {
|
||||
for (String s : entityFinder.getNames()) {
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -19,7 +19,7 @@
|
|||
</modules>
|
||||
|
||||
<properties>
|
||||
<plugin.version>3.0.0-SNAPSHOT-U16</plugin.version>
|
||||
<plugin.version>3.0.0-SNAPSHOT-U17</plugin.version>
|
||||
<plugin.name>CustomBosses</plugin.name>
|
||||
<plugin.main>net.aminecraftdev.custombosses.CustomBosses</plugin.main>
|
||||
<plugin.author>AMinecraftDev</plugin.author>
|
||||
|
|
Loading…
Reference in New Issue
Block a user