mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 07:59:28 +00:00
Cleaned up code
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.willfp.illusioner.proxy.v1_15_R1;
|
package com.willfp.illusioner.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.illusioner.proxy.proxies.EntityIllusionerProxy;
|
||||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
import net.minecraft.server.v1_15_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_15_R1.EntityIllagerIllusioner;
|
import net.minecraft.server.v1_15_R1.EntityIllagerIllusioner;
|
||||||
@@ -20,18 +22,13 @@ import net.minecraft.server.v1_15_R1.PathfinderGoalRandomStroll;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
||||||
/**
|
/**
|
||||||
* The display name for the illusioner.
|
* The display name for the illusioner.
|
||||||
@@ -47,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
* Instantiate a new illusioner entity.
|
* Instantiate a new illusioner entity.
|
||||||
*
|
*
|
||||||
* @param location The location to spawn it at.
|
* @param location The location to spawn it at.
|
||||||
* @param maxHealth The max health for the illusioner to have.
|
|
||||||
* @param attackDamage The attack damage for the illusioner to have.
|
|
||||||
* @param name The name of the illusioner.
|
|
||||||
*/
|
*/
|
||||||
public EntityIllusioner(@NotNull final Location location,
|
public EntityIllusioner(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
||||||
this.displayName = name;
|
|
||||||
|
this.displayName = IllusionerManager.OPTIONS.getName();
|
||||||
|
|
||||||
this.setPosition(location.getX(), location.getY(), location.getZ());
|
this.setPosition(location.getX(), location.getY(), location.getZ());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
|
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
this.setHealth((float) maxHealth);
|
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(attackDamage);
|
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
|
||||||
|
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
||||||
@@ -71,45 +63,48 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(6, new PathfinderGoalBowShoot(this, 0.5D, 20, 15.0F));
|
this.goalSelector.a(6, new PathfinderGoalBowShoot<>(this, 0.5D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
||||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
||||||
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
||||||
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)).a(300));
|
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityVillagerAbstract.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar createBossbar(@NotNull final Plugin plugin,
|
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
|
||||||
@NotNull final BarColor color,
|
|
||||||
@NotNull final BarStyle style) {
|
|
||||||
if (bossBar != null) {
|
if (bossBar != null) {
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, color, style, (BarFlag) null);
|
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
|
||||||
this.bossBar = bossBar;
|
this.bossBar = bossBar;
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
||||||
|
|
||||||
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
if (entity1 instanceof Player) {
|
if (!entity.isDead()) {
|
||||||
bossBar.addPlayer((Player) entity1);
|
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);
|
||||||
|
|
||||||
new BukkitRunnable() {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
@Override
|
if (!entity.isDead()) {
|
||||||
public void run() {
|
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
if (!entity.isDead()) {
|
} else {
|
||||||
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
||||||
} else {
|
bossBar.setVisible(false);
|
||||||
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
runnable.cancel();
|
||||||
bossBar.setVisible(false);
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 0, 1);
|
}).runTaskTimer(0, 1);
|
||||||
|
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class IllusionerHelper implements IllusionerHelperProxy {
|
public class IllusionerHelper implements IllusionerHelperProxy {
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy spawn(@NotNull final Location location,
|
public EntityIllusionerProxy spawn(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
EntityIllusioner illusioner = new EntityIllusioner(location);
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
|
|
||||||
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
||||||
return illusioner;
|
return illusioner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner,
|
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
|
||||||
@NotNull final Location location,
|
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
if (illusioner instanceof CraftIllusioner) {
|
if (illusioner instanceof CraftIllusioner) {
|
||||||
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
||||||
return null;
|
return null;
|
||||||
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
illusioner.remove();
|
illusioner.remove();
|
||||||
return spawn(location, maxHealth, attackDamage, name);
|
return spawn(illusioner.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.illusioner.proxy.v1_16_R1;
|
package com.willfp.illusioner.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.illusioner.proxy.proxies.EntityIllusionerProxy;
|
||||||
import net.minecraft.server.v1_16_R1.EntityHuman;
|
import net.minecraft.server.v1_16_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_16_R1.EntityIllagerIllusioner;
|
import net.minecraft.server.v1_16_R1.EntityIllagerIllusioner;
|
||||||
@@ -21,18 +22,13 @@ import net.minecraft.server.v1_16_R1.PathfinderGoalRandomStroll;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
||||||
/**
|
/**
|
||||||
* The display name for the illusioner.
|
* The display name for the illusioner.
|
||||||
@@ -48,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
* Instantiate a new illusioner entity.
|
* Instantiate a new illusioner entity.
|
||||||
*
|
*
|
||||||
* @param location The location to spawn it at.
|
* @param location The location to spawn it at.
|
||||||
* @param maxHealth The max health for the illusioner to have.
|
|
||||||
* @param attackDamage The attack damage for the illusioner to have.
|
|
||||||
* @param name The name of the illusioner.
|
|
||||||
*/
|
*/
|
||||||
public EntityIllusioner(@NotNull final Location location,
|
public EntityIllusioner(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
||||||
this.displayName = name;
|
|
||||||
|
this.displayName = IllusionerManager.OPTIONS.getName();
|
||||||
|
|
||||||
this.setPosition(location.getX(), location.getY(), location.getZ());
|
this.setPosition(location.getX(), location.getY(), location.getZ());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
|
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
this.setHealth((float) maxHealth);
|
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(attackDamage);
|
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
|
||||||
|
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
||||||
@@ -72,45 +63,48 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(6, new PathfinderGoalBowShoot(this, 0.5D, 20, 15.0F));
|
this.goalSelector.a(6, new PathfinderGoalBowShoot<>(this, 0.5D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
||||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
||||||
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
||||||
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)).a(300));
|
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityVillagerAbstract.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar createBossbar(@NotNull final Plugin plugin,
|
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
|
||||||
@NotNull final BarColor color,
|
|
||||||
@NotNull final BarStyle style) {
|
|
||||||
if (bossBar != null) {
|
if (bossBar != null) {
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, color, style, (BarFlag) null);
|
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
|
||||||
this.bossBar = bossBar;
|
this.bossBar = bossBar;
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
||||||
|
|
||||||
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
if (entity1 instanceof Player) {
|
if (!entity.isDead()) {
|
||||||
bossBar.addPlayer((Player) entity1);
|
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);
|
||||||
|
|
||||||
new BukkitRunnable() {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
@Override
|
if (!entity.isDead()) {
|
||||||
public void run() {
|
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
if (!entity.isDead()) {
|
} else {
|
||||||
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
||||||
} else {
|
bossBar.setVisible(false);
|
||||||
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
runnable.cancel();
|
||||||
bossBar.setVisible(false);
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 0, 1);
|
}).runTaskTimer(0, 1);
|
||||||
|
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class IllusionerHelper implements IllusionerHelperProxy {
|
public class IllusionerHelper implements IllusionerHelperProxy {
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy spawn(@NotNull final Location location,
|
public EntityIllusionerProxy spawn(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
EntityIllusioner illusioner = new EntityIllusioner(location);
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
|
|
||||||
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
||||||
return illusioner;
|
return illusioner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner,
|
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
|
||||||
@NotNull final Location location,
|
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
if (illusioner instanceof CraftIllusioner) {
|
if (illusioner instanceof CraftIllusioner) {
|
||||||
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
||||||
return null;
|
return null;
|
||||||
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
illusioner.remove();
|
illusioner.remove();
|
||||||
return spawn(location, maxHealth, attackDamage, name);
|
return spawn(illusioner.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.illusioner.proxy.v1_16_R2;
|
package com.willfp.illusioner.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.illusioner.proxy.proxies.EntityIllusionerProxy;
|
||||||
import net.minecraft.server.v1_16_R2.EntityHuman;
|
import net.minecraft.server.v1_16_R2.EntityHuman;
|
||||||
import net.minecraft.server.v1_16_R2.EntityIllagerIllusioner;
|
import net.minecraft.server.v1_16_R2.EntityIllagerIllusioner;
|
||||||
@@ -21,18 +22,13 @@ import net.minecraft.server.v1_16_R2.PathfinderGoalRandomStroll;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
||||||
/**
|
/**
|
||||||
* The display name for the illusioner.
|
* The display name for the illusioner.
|
||||||
@@ -48,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
* Instantiate a new illusioner entity.
|
* Instantiate a new illusioner entity.
|
||||||
*
|
*
|
||||||
* @param location The location to spawn it at.
|
* @param location The location to spawn it at.
|
||||||
* @param maxHealth The max health for the illusioner to have.
|
|
||||||
* @param attackDamage The attack damage for the illusioner to have.
|
|
||||||
* @param name The name of the illusioner.
|
|
||||||
*/
|
*/
|
||||||
public EntityIllusioner(@NotNull final Location location,
|
public EntityIllusioner(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
||||||
this.displayName = name;
|
|
||||||
|
this.displayName = IllusionerManager.OPTIONS.getName();
|
||||||
|
|
||||||
this.setPosition(location.getX(), location.getY(), location.getZ());
|
this.setPosition(location.getX(), location.getY(), location.getZ());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
|
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
this.setHealth((float) maxHealth);
|
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(attackDamage);
|
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
|
||||||
|
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
||||||
@@ -72,45 +63,48 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(6, new PathfinderGoalBowShoot(this, 0.5D, 20, 15.0F));
|
this.goalSelector.a(6, new PathfinderGoalBowShoot<>(this, 0.5D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
||||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
||||||
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
||||||
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)).a(300));
|
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityVillagerAbstract.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar createBossbar(@NotNull final Plugin plugin,
|
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
|
||||||
@NotNull final BarColor color,
|
|
||||||
@NotNull final BarStyle style) {
|
|
||||||
if (bossBar != null) {
|
if (bossBar != null) {
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, color, style, (BarFlag) null);
|
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
|
||||||
this.bossBar = bossBar;
|
this.bossBar = bossBar;
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
||||||
|
|
||||||
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
if (entity1 instanceof Player) {
|
if (!entity.isDead()) {
|
||||||
bossBar.addPlayer((Player) entity1);
|
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);
|
||||||
|
|
||||||
new BukkitRunnable() {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
@Override
|
if (!entity.isDead()) {
|
||||||
public void run() {
|
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
if (!entity.isDead()) {
|
} else {
|
||||||
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
||||||
} else {
|
bossBar.setVisible(false);
|
||||||
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
runnable.cancel();
|
||||||
bossBar.setVisible(false);
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 0, 1);
|
}).runTaskTimer(0, 1);
|
||||||
|
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class IllusionerHelper implements IllusionerHelperProxy {
|
public class IllusionerHelper implements IllusionerHelperProxy {
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy spawn(@NotNull final Location location,
|
public EntityIllusionerProxy spawn(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
EntityIllusioner illusioner = new EntityIllusioner(location);
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
|
|
||||||
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
||||||
return illusioner;
|
return illusioner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner,
|
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
|
||||||
@NotNull final Location location,
|
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
if (illusioner instanceof CraftIllusioner) {
|
if (illusioner instanceof CraftIllusioner) {
|
||||||
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
||||||
return null;
|
return null;
|
||||||
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
illusioner.remove();
|
illusioner.remove();
|
||||||
return spawn(location, maxHealth, attackDamage, name);
|
return spawn(illusioner.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.willfp.illusioner.proxy.v1_16_R3;
|
package com.willfp.illusioner.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.illusioner.proxy.proxies.EntityIllusionerProxy;
|
||||||
import net.minecraft.server.v1_16_R3.EntityHuman;
|
import net.minecraft.server.v1_16_R3.EntityHuman;
|
||||||
import net.minecraft.server.v1_16_R3.EntityIllagerIllusioner;
|
import net.minecraft.server.v1_16_R3.EntityIllagerIllusioner;
|
||||||
@@ -20,18 +22,13 @@ import net.minecraft.server.v1_16_R3.PathfinderGoalRandomStroll;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
|
||||||
/**
|
/**
|
||||||
* The display name for the illusioner.
|
* The display name for the illusioner.
|
||||||
@@ -47,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
* Instantiate a new illusioner entity.
|
* Instantiate a new illusioner entity.
|
||||||
*
|
*
|
||||||
* @param location The location to spawn it at.
|
* @param location The location to spawn it at.
|
||||||
* @param maxHealth The max health for the illusioner to have.
|
|
||||||
* @param attackDamage The attack damage for the illusioner to have.
|
|
||||||
* @param name The name of the illusioner.
|
|
||||||
*/
|
*/
|
||||||
public EntityIllusioner(@NotNull final Location location,
|
public EntityIllusioner(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
|
||||||
this.displayName = name;
|
|
||||||
|
this.displayName = IllusionerManager.OPTIONS.getName();
|
||||||
|
|
||||||
this.setPosition(location.getX(), location.getY(), location.getZ());
|
this.setPosition(location.getX(), location.getY(), location.getZ());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
|
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
this.setHealth((float) maxHealth);
|
this.setHealth((float) IllusionerManager.OPTIONS.getMaxHealth());
|
||||||
|
|
||||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(attackDamage);
|
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(IllusionerManager.OPTIONS.getAttackDamage());
|
||||||
|
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
this.goalSelector.a(1, new EntityIllagerWizard.b());
|
||||||
@@ -71,46 +63,48 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
|
|||||||
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
this.goalSelector.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||||
this.goalSelector.a(6, new PathfinderGoalBowShoot(this, 0.5D, 20, 15.0F));
|
this.goalSelector.a(6, new PathfinderGoalBowShoot<>(this, 0.5D, 20, 15.0F));
|
||||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||||
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
||||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
||||||
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
|
||||||
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true)).a(300));
|
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityVillagerAbstract.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
|
||||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, false)).a(300));
|
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar createBossbar(@NotNull final Plugin plugin,
|
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
|
||||||
@NotNull final BarColor color,
|
|
||||||
@NotNull final BarStyle style) {
|
|
||||||
if (bossBar != null) {
|
if (bossBar != null) {
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, color, style, (BarFlag) null);
|
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
|
||||||
this.bossBar = bossBar;
|
this.bossBar = bossBar;
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
|
||||||
|
|
||||||
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
if (entity1 instanceof Player) {
|
if (!entity.isDead()) {
|
||||||
bossBar.addPlayer((Player) entity1);
|
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);
|
||||||
|
|
||||||
new BukkitRunnable() {
|
plugin.getRunnableFactory().create(runnable -> {
|
||||||
@Override
|
if (!entity.isDead()) {
|
||||||
public void run() {
|
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
if (!entity.isDead()) {
|
} else {
|
||||||
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
||||||
} else {
|
bossBar.setVisible(false);
|
||||||
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
runnable.cancel();
|
||||||
bossBar.setVisible(false);
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 0, 1);
|
}).runTaskTimer(0, 1);
|
||||||
|
|
||||||
return bossBar;
|
return bossBar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class IllusionerHelper implements IllusionerHelperProxy {
|
public class IllusionerHelper implements IllusionerHelperProxy {
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy spawn(@NotNull final Location location,
|
public EntityIllusionerProxy spawn(@NotNull final Location location) {
|
||||||
final double maxHealth,
|
EntityIllusioner illusioner = new EntityIllusioner(location);
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
|
|
||||||
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
|
||||||
return illusioner;
|
return illusioner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner,
|
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
|
||||||
@NotNull final Location location,
|
|
||||||
final double maxHealth,
|
|
||||||
final double attackDamage,
|
|
||||||
@NotNull final String name) {
|
|
||||||
if (illusioner instanceof CraftIllusioner) {
|
if (illusioner instanceof CraftIllusioner) {
|
||||||
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
|
||||||
return null;
|
return null;
|
||||||
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
illusioner.remove();
|
illusioner.remove();
|
||||||
return spawn(location, maxHealth, attackDamage, name);
|
return spawn(illusioner.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package com.willfp.illusioner.config.configs;
|
package com.willfp.illusioner.config.configs;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.BaseConfig;
|
import com.willfp.eco.util.config.StaticBaseConfig;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|
||||||
import com.willfp.illusioner.IllusionerPlugin;
|
import com.willfp.illusioner.IllusionerPlugin;
|
||||||
|
|
||||||
public class Attacks extends BaseConfig {
|
public class Attacks extends StaticBaseConfig {
|
||||||
/**
|
/**
|
||||||
* Instantiate attacks.yml.
|
* Instantiate attacks.yml.
|
||||||
*/
|
*/
|
||||||
public Attacks() {
|
public Attacks() {
|
||||||
super("attacks", false, IllusionerPlugin.getInstance());
|
super("attacks", IllusionerPlugin.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package com.willfp.illusioner.config.configs;
|
package com.willfp.illusioner.config.configs;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.BaseConfig;
|
import com.willfp.eco.util.config.StaticBaseConfig;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|
||||||
import com.willfp.illusioner.IllusionerPlugin;
|
import com.willfp.illusioner.IllusionerPlugin;
|
||||||
|
|
||||||
public class Sounds extends BaseConfig {
|
public class Sounds extends StaticBaseConfig {
|
||||||
/**
|
/**
|
||||||
* Instantiate sounds.yml.
|
* Instantiate sounds.yml.
|
||||||
*/
|
*/
|
||||||
public Sounds() {
|
public Sounds() {
|
||||||
super("sounds", false, IllusionerPlugin.getInstance());
|
super("sounds", IllusionerPlugin.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,5 +116,17 @@ public class AttackListeners implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IllusionerManager.OPTIONS.getGameplayOptions().isIgnoreFire()) {
|
||||||
|
if (event.getCause().equals(EntityDamageEvent.DamageCause.FIRE) || event.getCause().equals(EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IllusionerManager.OPTIONS.getGameplayOptions().isIgnoreSuffocation()) {
|
||||||
|
if (event.getCause().equals(EntityDamageEvent.DamageCause.SUFFOCATION)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,13 +78,8 @@ public class SpawnListeners extends PluginDependent implements Listener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
EntityIllusionerProxy illusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).spawn(
|
EntityIllusionerProxy illusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).spawn(event.getBlock().getLocation());
|
||||||
event.getBlock().getLocation(),
|
illusioner.createBossbar(this.getPlugin());
|
||||||
IllusionerManager.OPTIONS.getMaxHealth(),
|
|
||||||
IllusionerManager.OPTIONS.getAttackDamage(),
|
|
||||||
IllusionerManager.OPTIONS.getName()
|
|
||||||
);
|
|
||||||
illusioner.createBossbar(this.getPlugin(), IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,17 +99,11 @@ public class SpawnListeners extends PluginDependent implements Listener {
|
|||||||
|
|
||||||
Illusioner illusioner = (Illusioner) event.getEntity();
|
Illusioner illusioner = (Illusioner) event.getEntity();
|
||||||
|
|
||||||
EntityIllusionerProxy internalIllusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).adapt(
|
EntityIllusionerProxy internalIllusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).adapt(illusioner);
|
||||||
illusioner,
|
|
||||||
illusioner.getLocation(),
|
|
||||||
IllusionerManager.OPTIONS.getMaxHealth(),
|
|
||||||
IllusionerManager.OPTIONS.getAttackDamage(),
|
|
||||||
IllusionerManager.OPTIONS.getName()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (internalIllusioner == null) {
|
if (internalIllusioner == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
internalIllusioner.createBossbar(this.getPlugin(), IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle());
|
internalIllusioner.createBossbar(this.getPlugin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,18 @@ public class GameplayOptions extends PluginDependent {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean ignoreExplosionDamage;
|
private boolean ignoreExplosionDamage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the illusioner is immune to fire damage.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private boolean ignoreFire;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the illusioner is immune to suffocation damage.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private boolean ignoreSuffocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gameplay options.
|
* Gameplay options.
|
||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
@@ -87,6 +99,8 @@ public class GameplayOptions extends PluginDependent {
|
|||||||
shuffle = IllusionerConfigs.ATTACKS.getBool("shuffle.enabled");
|
shuffle = IllusionerConfigs.ATTACKS.getBool("shuffle.enabled");
|
||||||
shuffleChance = IllusionerConfigs.ATTACKS.getDouble("shuffle.chance");
|
shuffleChance = IllusionerConfigs.ATTACKS.getDouble("shuffle.chance");
|
||||||
ignoreExplosionDamage = this.getPlugin().getConfigYml().getBool("ignore-explosion-damage");
|
ignoreExplosionDamage = this.getPlugin().getConfigYml().getBool("ignore-explosion-damage");
|
||||||
|
ignoreFire = this.getPlugin().getConfigYml().getBool("ignore-fire-damage");
|
||||||
|
ignoreSuffocation = this.getPlugin().getConfigYml().getBool("ignore-suffocation-damage");
|
||||||
|
|
||||||
effectOptions.clear();
|
effectOptions.clear();
|
||||||
IllusionerConfigs.ATTACKS.getConfig().getConfigurationSection("effects").getKeys(false).forEach(key -> {
|
IllusionerConfigs.ATTACKS.getConfig().getConfigurationSection("effects").getKeys(false).forEach(key -> {
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ xp:
|
|||||||
max-health: 600 # Hearts is this number divided by 2, eg 600 is 300 hearts
|
max-health: 600 # Hearts is this number divided by 2, eg 600 is 300 hearts
|
||||||
attack-damage: 50 # This isn't an easy boss. Recommend to keep this high
|
attack-damage: 50 # This isn't an easy boss. Recommend to keep this high
|
||||||
ignore-explosion-damage: true
|
ignore-explosion-damage: true
|
||||||
|
ignore-fire-damage: false
|
||||||
|
ignore-suffocation-damage: true
|
||||||
|
|
||||||
spawn:
|
spawn:
|
||||||
# Configure a 3x1 tall column of blocks to summon an illusioner
|
# Configure a 3x1 tall column of blocks to summon an illusioner
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.willfp.illusioner.proxy.proxies;
|
package com.willfp.illusioner.proxy.proxies;
|
||||||
|
|
||||||
|
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||||
import com.willfp.eco.util.proxy.AbstractProxy;
|
import com.willfp.eco.util.proxy.AbstractProxy;
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface EntityIllusionerProxy extends AbstractProxy {
|
public interface EntityIllusionerProxy extends AbstractProxy {
|
||||||
@@ -12,11 +10,7 @@ public interface EntityIllusionerProxy extends AbstractProxy {
|
|||||||
* Create boss bar for an illusioner.
|
* Create boss bar for an illusioner.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin that owns the boss bar.
|
* @param plugin The plugin that owns the boss bar.
|
||||||
* @param color The color of the boss bar.
|
|
||||||
* @param style The style of the boss bar.
|
|
||||||
* @return The created boss bar.
|
* @return The created boss bar.
|
||||||
*/
|
*/
|
||||||
BossBar createBossbar(@NotNull Plugin plugin,
|
BossBar createBossbar(@NotNull AbstractEcoPlugin plugin);
|
||||||
@NotNull BarColor color,
|
|
||||||
@NotNull BarStyle style);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,29 +10,15 @@ public interface IllusionerHelperProxy extends AbstractProxy {
|
|||||||
* Spawn an illusioner.
|
* Spawn an illusioner.
|
||||||
*
|
*
|
||||||
* @param location The location to spawn it at.
|
* @param location The location to spawn it at.
|
||||||
* @param maxHealth The health for the illusioner to have.
|
|
||||||
* @param attackDamage The attack damage for the illusioner to have.
|
|
||||||
* @param name The name of the illusioner.
|
|
||||||
* @return The created illusioner.
|
* @return The created illusioner.
|
||||||
*/
|
*/
|
||||||
EntityIllusionerProxy spawn(@NotNull Location location,
|
EntityIllusionerProxy spawn(@NotNull Location location);
|
||||||
double maxHealth,
|
|
||||||
double attackDamage,
|
|
||||||
@NotNull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a normal illusioner to a plugin-based one.
|
* Convert a normal illusioner to a plugin-based one.
|
||||||
*
|
*
|
||||||
* @param illusioner The illusioner to convert.
|
* @param illusioner The illusioner to convert.
|
||||||
* @param location The location to spawn it at.
|
|
||||||
* @param maxHealth The health for the illusioner to have.
|
|
||||||
* @param attackDamage The attack damage for the illusioner to have.
|
|
||||||
* @param name The name of the illusioner.
|
|
||||||
* @return The created illusioner.
|
* @return The created illusioner.
|
||||||
*/
|
*/
|
||||||
EntityIllusionerProxy adapt(@NotNull Illusioner illusioner,
|
EntityIllusionerProxy adapt(@NotNull Illusioner illusioner);
|
||||||
@NotNull Location location,
|
|
||||||
double maxHealth,
|
|
||||||
double attackDamage,
|
|
||||||
@NotNull String name);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user