9
0
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:
Auxilor
2021-01-30 11:38:59 +00:00
parent 7881c5e94a
commit efbbd7d623
16 changed files with 193 additions and 249 deletions

View File

@@ -1,5 +1,7 @@
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 net.minecraft.server.v1_15_R1.EntityHuman;
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.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_15_R1.CraftWorld;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("unchecked")
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
/**
* The display name for the illusioner.
@@ -47,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
* Instantiate a new illusioner entity.
*
* @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,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.displayName = name;
this.displayName = IllusionerManager.OPTIONS.getName();
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
this.setHealth((float) maxHealth);
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
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(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(8, new PathfinderGoalRandomStroll(this, 0.6D));
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(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.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(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, EntityIronGolem.class, false)).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, EntityIronGolem.class, false)).a(300));
}
@Override
public BossBar createBossbar(@NotNull final Plugin plugin,
@NotNull final BarColor color,
@NotNull final BarStyle style) {
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
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;
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);
new BukkitRunnable() {
@Override
public void run() {
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);
this.cancel();
runnable.cancel();
}
}
}.runTaskTimer(plugin, 0, 1);
}).runTaskTimer(0, 1);
return bossBar;
}

View File

@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
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,
@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
return null;
}
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
return spawn(illusioner.getLocation());
}
}

View File

@@ -1,6 +1,7 @@
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 net.minecraft.server.v1_16_R1.EntityHuman;
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.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_R1.CraftWorld;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("unchecked")
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
/**
* The display name for the illusioner.
@@ -48,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
* Instantiate a new illusioner entity.
*
* @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,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.displayName = name;
this.displayName = IllusionerManager.OPTIONS.getName();
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
this.setHealth((float) maxHealth);
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
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(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(8, new PathfinderGoalRandomStroll(this, 0.6D));
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(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.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(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, EntityIronGolem.class, false)).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, EntityIronGolem.class, false)).a(300));
}
@Override
public BossBar createBossbar(@NotNull final Plugin plugin,
@NotNull final BarColor color,
@NotNull final BarStyle style) {
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
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;
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);
new BukkitRunnable() {
@Override
public void run() {
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);
this.cancel();
runnable.cancel();
}
}
}.runTaskTimer(plugin, 0, 1);
}).runTaskTimer(0, 1);
return bossBar;
}

View File

@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
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,
@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
return null;
}
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
return spawn(illusioner.getLocation());
}
}

View File

@@ -1,6 +1,7 @@
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 net.minecraft.server.v1_16_R2.EntityHuman;
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.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_R2.CraftWorld;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("unchecked")
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
/**
* The display name for the illusioner.
@@ -48,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
* Instantiate a new illusioner entity.
*
* @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,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.displayName = name;
this.displayName = IllusionerManager.OPTIONS.getName();
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
this.setHealth((float) maxHealth);
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
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(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(8, new PathfinderGoalRandomStroll(this, 0.6D));
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(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.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(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, EntityIronGolem.class, false)).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, EntityIronGolem.class, false)).a(300));
}
@Override
public BossBar createBossbar(@NotNull final Plugin plugin,
@NotNull final BarColor color,
@NotNull final BarStyle style) {
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
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;
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);
new BukkitRunnable() {
@Override
public void run() {
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);
this.cancel();
runnable.cancel();
}
}
}.runTaskTimer(plugin, 0, 1);
}).runTaskTimer(0, 1);
return bossBar;
}

View File

@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
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,
@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
return null;
}
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
return spawn(illusioner.getLocation());
}
}

View File

@@ -1,5 +1,7 @@
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 net.minecraft.server.v1_16_R3.EntityHuman;
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.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;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("unchecked")
public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerProxy {
/**
* The display name for the illusioner.
@@ -47,23 +44,18 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI
* Instantiate a new illusioner entity.
*
* @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,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusioner(@NotNull final Location location) {
super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle());
this.displayName = name;
this.displayName = IllusionerManager.OPTIONS.getName();
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(maxHealth);
this.setHealth((float) maxHealth);
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(IllusionerManager.OPTIONS.getMaxHealth());
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(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(8, new PathfinderGoalRandomStroll(this, 0.6D));
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(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.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(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, EntityIronGolem.class, false)).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, EntityIronGolem.class, false)).a(300));
}
@Override
public BossBar createBossbar(@NotNull final Plugin plugin,
@NotNull final BarColor color,
@NotNull final BarStyle style) {
public BossBar createBossbar(@NotNull final AbstractEcoPlugin plugin) {
if (bossBar != null) {
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;
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);
new BukkitRunnable() {
@Override
public void run() {
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);
this.cancel();
runnable.cancel();
}
}
}.runTaskTimer(plugin, 0, 1);
}).runTaskTimer(0, 1);
return bossBar;
}

View File

@@ -10,21 +10,14 @@ import org.jetbrains.annotations.NotNull;
public class IllusionerHelper implements IllusionerHelperProxy {
@Override
public EntityIllusionerProxy spawn(@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name);
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,
@NotNull final Location location,
final double maxHealth,
final double attackDamage,
@NotNull final String name) {
public EntityIllusionerProxy adapt(@NotNull final Illusioner illusioner) {
if (illusioner instanceof CraftIllusioner) {
if (((CraftIllusioner) illusioner).getHandle() instanceof EntityIllusionerProxy) {
return null;
@@ -33,6 +26,6 @@ public class IllusionerHelper implements IllusionerHelperProxy {
return null;
}
illusioner.remove();
return spawn(location, maxHealth, attackDamage, name);
return spawn(illusioner.getLocation());
}
}

View File

@@ -1,14 +1,13 @@
package com.willfp.illusioner.config.configs;
import com.willfp.eco.util.config.BaseConfig;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.config.StaticBaseConfig;
import com.willfp.illusioner.IllusionerPlugin;
public class Attacks extends BaseConfig {
public class Attacks extends StaticBaseConfig {
/**
* Instantiate attacks.yml.
*/
public Attacks() {
super("attacks", false, IllusionerPlugin.getInstance());
super("attacks", IllusionerPlugin.getInstance());
}
}

View File

@@ -1,14 +1,13 @@
package com.willfp.illusioner.config.configs;
import com.willfp.eco.util.config.BaseConfig;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.config.StaticBaseConfig;
import com.willfp.illusioner.IllusionerPlugin;
public class Sounds extends BaseConfig {
public class Sounds extends StaticBaseConfig {
/**
* Instantiate sounds.yml.
*/
public Sounds() {
super("sounds", false, IllusionerPlugin.getInstance());
super("sounds", IllusionerPlugin.getInstance());
}
}

View File

@@ -116,5 +116,17 @@ public class AttackListeners implements Listener {
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);
}
}
}
}

View File

@@ -78,13 +78,8 @@ public class SpawnListeners extends PluginDependent implements Listener {
}
});
EntityIllusionerProxy illusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).spawn(
event.getBlock().getLocation(),
IllusionerManager.OPTIONS.getMaxHealth(),
IllusionerManager.OPTIONS.getAttackDamage(),
IllusionerManager.OPTIONS.getName()
);
illusioner.createBossbar(this.getPlugin(), IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle());
EntityIllusionerProxy illusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).spawn(event.getBlock().getLocation());
illusioner.createBossbar(this.getPlugin());
}
/**
@@ -104,17 +99,11 @@ public class SpawnListeners extends PluginDependent implements Listener {
Illusioner illusioner = (Illusioner) event.getEntity();
EntityIllusionerProxy internalIllusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).adapt(
illusioner,
illusioner.getLocation(),
IllusionerManager.OPTIONS.getMaxHealth(),
IllusionerManager.OPTIONS.getAttackDamage(),
IllusionerManager.OPTIONS.getName()
);
EntityIllusionerProxy internalIllusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).adapt(illusioner);
if (internalIllusioner == null) {
return;
}
internalIllusioner.createBossbar(this.getPlugin(), IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle());
internalIllusioner.createBossbar(this.getPlugin());
}
}

View File

@@ -58,6 +58,18 @@ public class GameplayOptions extends PluginDependent {
@Getter
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.
* @param plugin The plugin.
@@ -87,6 +99,8 @@ public class GameplayOptions extends PluginDependent {
shuffle = IllusionerConfigs.ATTACKS.getBool("shuffle.enabled");
shuffleChance = IllusionerConfigs.ATTACKS.getDouble("shuffle.chance");
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();
IllusionerConfigs.ATTACKS.getConfig().getConfigurationSection("effects").getKeys(false).forEach(key -> {

View File

@@ -19,6 +19,8 @@ xp:
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
ignore-explosion-damage: true
ignore-fire-damage: false
ignore-suffocation-damage: true
spawn:
# Configure a 3x1 tall column of blocks to summon an illusioner

View File

@@ -1,10 +1,8 @@
package com.willfp.illusioner.proxy.proxies;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
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.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public interface EntityIllusionerProxy extends AbstractProxy {
@@ -12,11 +10,7 @@ public interface EntityIllusionerProxy extends AbstractProxy {
* Create boss bar for an illusioner.
*
* @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.
*/
BossBar createBossbar(@NotNull Plugin plugin,
@NotNull BarColor color,
@NotNull BarStyle style);
BossBar createBossbar(@NotNull AbstractEcoPlugin plugin);
}

View File

@@ -10,29 +10,15 @@ public interface IllusionerHelperProxy extends AbstractProxy {
* Spawn an illusioner.
*
* @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.
*/
EntityIllusionerProxy spawn(@NotNull Location location,
double maxHealth,
double attackDamage,
@NotNull String name);
EntityIllusionerProxy spawn(@NotNull Location location);
/**
* Convert a normal illusioner to a plugin-based one.
*
* @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.
*/
EntityIllusionerProxy adapt(@NotNull Illusioner illusioner,
@NotNull Location location,
double maxHealth,
double attackDamage,
@NotNull String name);
EntityIllusionerProxy adapt(@NotNull Illusioner illusioner);
}