9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-21 16:09:24 +00:00

Began conversion into ecobosses

This commit is contained in:
Auxilor
2021-03-11 13:44:14 +00:00
parent bbd78d8e03
commit 6d8b7405f7
43 changed files with 613 additions and 1054 deletions

View File

@@ -1,8 +1,6 @@
package com.willfp.illusioner.proxy.v1_15_R1;
package com.willfp.ecobosses.proxy.v1_15_R1;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
import net.minecraft.server.v1_15_R1.EntityHuman;
import net.minecraft.server.v1_15_R1.EntityIllagerIllusioner;
import net.minecraft.server.v1_15_R1.EntityIllagerWizard;
@@ -11,7 +9,6 @@ import net.minecraft.server.v1_15_R1.EntityIronGolem;
import net.minecraft.server.v1_15_R1.EntityRaider;
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.EntityVillagerAbstract;
import net.minecraft.server.v1_15_R1.GenericAttributes;
import net.minecraft.server.v1_15_R1.PathfinderGoalBowShoot;
import net.minecraft.server.v1_15_R1.PathfinderGoalFloat;
import net.minecraft.server.v1_15_R1.PathfinderGoalHurtByTarget;
@@ -19,48 +16,25 @@ import net.minecraft.server.v1_15_R1.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_15_R1.PathfinderGoalMeleeAttack;
import net.minecraft.server.v1_15_R1.PathfinderGoalNearestAttackableTarget;
import net.minecraft.server.v1_15_R1.PathfinderGoalRandomStroll;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.util.CraftNamespacedKey;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
public class CustomIllusioner extends EntityIllagerIllusioner implements CustomIllusionerProxy {
/**
* The display name for the illusioner.
*/
private final String displayName;
/**
* The boss bar linked to the illusioner.
*/
private BossBar bossBar = null;
/**
* Instantiate a new illusioner entity.
* Instantiate a new custom illusioner entity.
*
* @param location The location to spawn it at.
*/
public EntityIllusioner(@NotNull final Location location) {
public CustomIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("illusioner:illusioner"), PersistentDataType.INTEGER, 1);
this.displayName = IllusionerManager.OPTIONS.getName();
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("ecobosses:type"), PersistentDataType.STRING, "custom_illusioner");
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
this.goalSelector.a(0, new PathfinderGoalFloat(this));
this.goalSelector.a(1, new EntityIllagerWizard.b());
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
@@ -78,38 +52,9 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
}
@Override
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
return bossBar;
}
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
this.bossBar = bossBar;
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.getPlayers().forEach(bossBar::removePlayer);
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
if (entity1 instanceof Player) {
bossBar.addPlayer((Player) entity1);
}
});
} else {
runnable.cancel();
}
}).runTaskTimer(0, 40);
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
} else {
bossBar.getPlayers().forEach(bossBar::removePlayer);
bossBar.setVisible(false);
runnable.cancel();
}
}).runTaskTimer(0, 1);
return bossBar;
public CustomIllusionerProxy spawn(@NotNull final Location location) {
CustomIllusioner illusioner = new CustomIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
}

View File

@@ -1,31 +0,0 @@
package com.willfp.illusioner.proxy.v1_15_R1;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.illusioner.proxy.proxies.IllusionerHelperProxy;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftIllusioner;
import org.bukkit.entity.Illusioner;
import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location) {
EntityIllusioner illusioner = new EntityIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
@Override
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
}
} else {
return null;
}
illusioner.remove();
return spawn(illusioner.getLocation());
}
}

View File

@@ -1,8 +1,6 @@
package com.willfp.illusioner.proxy.v1_16_R1;
package com.willfp.ecobosses.proxy.v1_16_R1;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
import net.minecraft.server.v1_16_R1.EntityHuman;
import net.minecraft.server.v1_16_R1.EntityIllagerIllusioner;
import net.minecraft.server.v1_16_R1.EntityIllagerWizard;
@@ -11,7 +9,6 @@ import net.minecraft.server.v1_16_R1.EntityIronGolem;
import net.minecraft.server.v1_16_R1.EntityRaider;
import net.minecraft.server.v1_16_R1.EntityTypes;
import net.minecraft.server.v1_16_R1.EntityVillagerAbstract;
import net.minecraft.server.v1_16_R1.GenericAttributes;
import net.minecraft.server.v1_16_R1.PathfinderGoalBowShoot;
import net.minecraft.server.v1_16_R1.PathfinderGoalFloat;
import net.minecraft.server.v1_16_R1.PathfinderGoalHurtByTarget;
@@ -19,48 +16,25 @@ import net.minecraft.server.v1_16_R1.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_16_R1.PathfinderGoalMeleeAttack;
import net.minecraft.server.v1_16_R1.PathfinderGoalNearestAttackableTarget;
import net.minecraft.server.v1_16_R1.PathfinderGoalRandomStroll;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R1.util.CraftNamespacedKey;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
public class CustomIllusioner extends EntityIllagerIllusioner implements CustomIllusionerProxy {
/**
* The display name for the illusioner.
*/
private final String displayName;
/**
* The boss bar linked to the illusioner.
*/
private BossBar bossBar = null;
/**
* Instantiate a new illusioner entity.
* Instantiate a new custom illusioner entity.
*
* @param location The location to spawn it at.
*/
public EntityIllusioner(@NotNull final Location location) {
public CustomIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("illusioner:illusioner"), PersistentDataType.INTEGER, 1);
this.displayName = IllusionerManager.OPTIONS.getName();
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("ecobosses:type"), PersistentDataType.STRING, "custom_illusioner");
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
this.goalSelector.a(0, new PathfinderGoalFloat(this));
this.goalSelector.a(1, new EntityIllagerWizard.b());
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
@@ -78,38 +52,9 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
}
@Override
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
return bossBar;
}
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
this.bossBar = bossBar;
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.getPlayers().forEach(bossBar::removePlayer);
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
if (entity1 instanceof Player) {
bossBar.addPlayer((Player) entity1);
}
});
} else {
runnable.cancel();
}
}).runTaskTimer(0, 40);
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
} else {
bossBar.getPlayers().forEach(bossBar::removePlayer);
bossBar.setVisible(false);
runnable.cancel();
}
}).runTaskTimer(0, 1);
return bossBar;
public CustomIllusionerProxy spawn(@NotNull final Location location) {
CustomIllusioner illusioner = new CustomIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
}

View File

@@ -1,31 +0,0 @@
package com.willfp.illusioner.proxy.v1_16_R1;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.illusioner.proxy.proxies.IllusionerHelperProxy;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftIllusioner;
import org.bukkit.entity.Illusioner;
import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location) {
EntityIllusioner illusioner = new EntityIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
@Override
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
}
} else {
return null;
}
illusioner.remove();
return spawn(illusioner.getLocation());
}
}

View File

@@ -1,8 +1,6 @@
package com.willfp.illusioner.proxy.v1_16_R2;
package com.willfp.ecobosses.proxy.v1_16_R2;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
import net.minecraft.server.v1_16_R2.EntityHuman;
import net.minecraft.server.v1_16_R2.EntityIllagerIllusioner;
import net.minecraft.server.v1_16_R2.EntityIllagerWizard;
@@ -11,7 +9,6 @@ import net.minecraft.server.v1_16_R2.EntityIronGolem;
import net.minecraft.server.v1_16_R2.EntityRaider;
import net.minecraft.server.v1_16_R2.EntityTypes;
import net.minecraft.server.v1_16_R2.EntityVillagerAbstract;
import net.minecraft.server.v1_16_R2.GenericAttributes;
import net.minecraft.server.v1_16_R2.PathfinderGoalBowShoot;
import net.minecraft.server.v1_16_R2.PathfinderGoalFloat;
import net.minecraft.server.v1_16_R2.PathfinderGoalHurtByTarget;
@@ -19,48 +16,25 @@ import net.minecraft.server.v1_16_R2.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_16_R2.PathfinderGoalMeleeAttack;
import net.minecraft.server.v1_16_R2.PathfinderGoalNearestAttackableTarget;
import net.minecraft.server.v1_16_R2.PathfinderGoalRandomStroll;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R2.util.CraftNamespacedKey;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
public class CustomIllusioner extends EntityIllagerIllusioner implements CustomIllusionerProxy {
/**
* The display name for the illusioner.
*/
private final String displayName;
/**
* The boss bar linked to the illusioner.
*/
private BossBar bossBar = null;
/**
* Instantiate a new illusioner entity.
* Instantiate a new custom illusioner entity.
*
* @param location The location to spawn it at.
*/
public EntityIllusioner(@NotNull final Location location) {
public CustomIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("illusioner:illusioner"), PersistentDataType.INTEGER, 1);
this.displayName = IllusionerManager.OPTIONS.getName();
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("ecobosses:type"), PersistentDataType.STRING, "custom_illusioner");
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
this.goalSelector.a(0, new PathfinderGoalFloat(this));
this.goalSelector.a(1, new EntityIllagerWizard.b());
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
@@ -78,38 +52,9 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
}
@Override
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
return bossBar;
}
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
this.bossBar = bossBar;
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.getPlayers().forEach(bossBar::removePlayer);
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
if (entity1 instanceof Player) {
bossBar.addPlayer((Player) entity1);
}
});
} else {
runnable.cancel();
}
}).runTaskTimer(0, 40);
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
} else {
bossBar.getPlayers().forEach(bossBar::removePlayer);
bossBar.setVisible(false);
runnable.cancel();
}
}).runTaskTimer(0, 1);
return bossBar;
public CustomIllusionerProxy spawn(@NotNull final Location location) {
CustomIllusioner illusioner = new CustomIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
}

View File

@@ -1,31 +0,0 @@
package com.willfp.illusioner.proxy.v1_16_R2;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.illusioner.proxy.proxies.IllusionerHelperProxy;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftIllusioner;
import org.bukkit.entity.Illusioner;
import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location) {
EntityIllusioner illusioner = new EntityIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
@Override
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
}
} else {
return null;
}
illusioner.remove();
return spawn(illusioner.getLocation());
}
}

View File

@@ -1,8 +1,6 @@
package com.willfp.illusioner.proxy.v1_16_R3;
package com.willfp.ecobosses.proxy.v1_16_R3;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
import net.minecraft.server.v1_16_R3.EntityHuman;
import net.minecraft.server.v1_16_R3.EntityIllagerIllusioner;
import net.minecraft.server.v1_16_R3.EntityIllagerWizard;
@@ -11,7 +9,6 @@ import net.minecraft.server.v1_16_R3.EntityIronGolem;
import net.minecraft.server.v1_16_R3.EntityRaider;
import net.minecraft.server.v1_16_R3.EntityTypes;
import net.minecraft.server.v1_16_R3.EntityVillagerAbstract;
import net.minecraft.server.v1_16_R3.GenericAttributes;
import net.minecraft.server.v1_16_R3.PathfinderGoalBowShoot;
import net.minecraft.server.v1_16_R3.PathfinderGoalFloat;
import net.minecraft.server.v1_16_R3.PathfinderGoalHurtByTarget;
@@ -19,48 +16,25 @@ import net.minecraft.server.v1_16_R3.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_16_R3.PathfinderGoalMeleeAttack;
import net.minecraft.server.v1_16_R3.PathfinderGoalNearestAttackableTarget;
import net.minecraft.server.v1_16_R3.PathfinderGoalRandomStroll;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
public class CustomIllusioner extends EntityIllagerIllusioner implements CustomIllusionerProxy {
/**
* The display name for the illusioner.
*/
private final String displayName;
/**
* The boss bar linked to the illusioner.
*/
private BossBar bossBar = null;
/**
* Instantiate a new illusioner entity.
* Instantiate a new custom illusioner entity.
*
* @param location The location to spawn it at.
*/
public EntityIllusioner(@NotNull final Location location) {
public CustomIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("illusioner:illusioner"), PersistentDataType.INTEGER, 1);
this.displayName = IllusionerManager.OPTIONS.getName();
this.getBukkitEntity().getPersistentDataContainer().set(CraftNamespacedKey.fromString("ecobosses:type"), PersistentDataType.STRING, "custom_illusioner");
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
this.goalSelector.a(0, new PathfinderGoalFloat(this));
this.goalSelector.a(1, new EntityIllagerWizard.b());
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
@@ -78,38 +52,9 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
}
@Override
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
return bossBar;
}
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
this.bossBar = bossBar;
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.getPlayers().forEach(bossBar::removePlayer);
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
if (entity1 instanceof Player) {
bossBar.addPlayer((Player) entity1);
}
});
} else {
runnable.cancel();
}
}).runTaskTimer(0, 40);
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
} else {
bossBar.getPlayers().forEach(bossBar::removePlayer);
bossBar.setVisible(false);
runnable.cancel();
}
}).runTaskTimer(0, 1);
return bossBar;
public CustomIllusionerProxy spawn(@NotNull final Location location) {
CustomIllusioner illusioner = new CustomIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
}

View File

@@ -1,31 +0,0 @@
package com.willfp.illusioner.proxy.v1_16_R3;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.illusioner.proxy.proxies.IllusionerHelperProxy;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftIllusioner;
import org.bukkit.entity.Illusioner;
import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location) {
EntityIllusioner illusioner = new EntityIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return illusioner;
}
@Override
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
}
} else {
return null;
}
illusioner.remove();
return spawn(illusioner.getLocation());
}
}