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

Fixed external spawning

This commit is contained in:
Auxilor
2020-12-21 12:52:26 +00:00
parent 47550f9225
commit d6b9756347
5 changed files with 25 additions and 17 deletions

View File

@@ -16,9 +16,10 @@ public class Illusioner implements IllusionerWrapper {
@Override
public EntityIllusionerWrapper adapt(org.bukkit.entity.Illusioner illusioner, Location location, double maxHealth, double attackDamage, String name) {
EntityIllusioner internalIllusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
if(!(illusioner instanceof CraftIllusioner)) return null;
((CraftIllusioner) illusioner).setHandle(internalIllusioner);
return internalIllusioner;
if(illusioner instanceof CraftIllusioner) {
if(((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerWrapper) return null;
} else return null;
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
}
}

View File

@@ -16,9 +16,10 @@ public class Illusioner implements IllusionerWrapper {
@Override
public EntityIllusionerWrapper adapt(org.bukkit.entity.Illusioner illusioner, Location location, double maxHealth, double attackDamage, String name) {
EntityIllusioner internalIllusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
if(!(illusioner instanceof CraftIllusioner)) return null;
((CraftIllusioner) illusioner).setHandle(internalIllusioner);
return internalIllusioner;
if(illusioner instanceof CraftIllusioner) {
if(((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerWrapper) return null;
} else return null;
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
}
}

View File

@@ -16,9 +16,10 @@ public class Illusioner implements IllusionerWrapper {
@Override
public EntityIllusionerWrapper adapt(org.bukkit.entity.Illusioner illusioner, Location location, double maxHealth, double attackDamage, String name) {
EntityIllusioner internalIllusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
if(!(illusioner instanceof CraftIllusioner)) return null;
((CraftIllusioner) illusioner).setHandle(internalIllusioner);
return internalIllusioner;
if(illusioner instanceof CraftIllusioner) {
if(((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerWrapper) return null;
} else return null;
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
}
}

View File

@@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
@@ -16,6 +17,7 @@ import org.bukkit.scheduler.BukkitRunnable;
@SuppressWarnings("unchecked")
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerWrapper {
private final String displayName;
private BossBar bossBar = null;
public EntityIllusioner(Location location, double maxHealth, double attackDamage, String name) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
@@ -46,7 +48,9 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
@Override
public BossBar createBossbar(Plugin plugin, BarColor color, BarStyle style) {
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, color, style);
if(bossBar != null) return bossBar;
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, color, style, (BarFlag) null);
this.bossBar = bossBar;
Bukkit.getServer().getOnlinePlayers().forEach(bossBar::addPlayer);
LivingEntity entity = (LivingEntity) this.getBukkitEntity();

View File

@@ -16,9 +16,10 @@ public class Illusioner implements IllusionerWrapper {
@Override
public EntityIllusionerWrapper adapt(org.bukkit.entity.Illusioner illusioner, Location location, double maxHealth, double attackDamage, String name) {
EntityIllusioner internalIllusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
if(!(illusioner instanceof CraftIllusioner)) return null;
((CraftIllusioner) illusioner).setHandle(internalIllusioner);
return internalIllusioner;
if(illusioner instanceof CraftIllusioner) {
if(((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerWrapper) return null;
} else return null;
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
}
}