|
|
|
|
@@ -5,15 +5,22 @@ import com.willfp.eco.util.internal.PluginDependent;
|
|
|
|
|
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.obj.SpawnTotem;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.obj.attacks.EffectOption;
|
|
|
|
|
import com.willfp.ecobosses.bosses.util.obj.attacks.SummonsOption;
|
|
|
|
|
import lombok.AccessLevel;
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
|
import org.bukkit.attribute.Attribute;
|
|
|
|
|
import org.bukkit.attribute.AttributeInstance;
|
|
|
|
|
import org.bukkit.boss.BarColor;
|
|
|
|
|
import org.bukkit.boss.BarFlag;
|
|
|
|
|
import org.bukkit.boss.BarStyle;
|
|
|
|
|
import org.bukkit.boss.BossBar;
|
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
@@ -21,8 +28,10 @@ import org.bukkit.inventory.ItemStack;
|
|
|
|
|
import org.bukkit.persistence.PersistentDataType;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
public class EcoBoss extends PluginDependent {
|
|
|
|
|
/**
|
|
|
|
|
@@ -37,6 +46,12 @@ public class EcoBoss extends PluginDependent {
|
|
|
|
|
@Getter(AccessLevel.PRIVATE)
|
|
|
|
|
private final AbstractUndefinedConfig config;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The display name of the boss.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final String displayName;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The base entity spawner.
|
|
|
|
|
*/
|
|
|
|
|
@@ -90,6 +105,66 @@ public class EcoBoss extends PluginDependent {
|
|
|
|
|
@Getter
|
|
|
|
|
private final List<ItemStack> drops;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The exp to drop.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final ExperienceOptions experienceOptions;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The effects.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final Set<EffectOption> effects;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The summons.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final Set<SummonsOption> summons;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The shuffle chance.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final double shuffleChance;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If attacks should be called on injury.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final boolean attackOnInjure;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The ItemStack for the spawn egg.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final ItemStack spawnEgg;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sounds played on injure.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final List<OptionedSound> injureSounds;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Spawn sounds.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final List<OptionedSound> spawnSounds;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Death sounds.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final List<OptionedSound> deathSounds;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Summon sounds.
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
private final List<OptionedSound> summonSounds;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new Boss.
|
|
|
|
|
*
|
|
|
|
|
@@ -104,6 +179,41 @@ public class EcoBoss extends PluginDependent {
|
|
|
|
|
this.config = config;
|
|
|
|
|
this.name = name;
|
|
|
|
|
|
|
|
|
|
this.displayName = this.getConfig().getString("name");
|
|
|
|
|
|
|
|
|
|
// Boss Bar
|
|
|
|
|
this.bossbarEnabled = this.getConfig().getBool("bossbar.enabled");
|
|
|
|
|
this.bossbarProperties = new BossbarProperties(
|
|
|
|
|
BarColor.valueOf(this.getConfig().getString("bossbar.color").toUpperCase()),
|
|
|
|
|
BarStyle.valueOf(this.getConfig().getString("bossbar.style").toUpperCase())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Attributes
|
|
|
|
|
this.attackDamage = this.getConfig().getInt("attack-damage");
|
|
|
|
|
this.maxHealth = this.getConfig().getInt("max-health");
|
|
|
|
|
|
|
|
|
|
// Spawn Totem
|
|
|
|
|
this.spawnTotemEnabled = this.getConfig().getBool("spawn-totem.enabled");
|
|
|
|
|
this.spawnTotem = new SpawnTotem(
|
|
|
|
|
Material.getMaterial(this.getConfig().getString("spawn-totem.bottom").toUpperCase()),
|
|
|
|
|
Material.getMaterial(this.getConfig().getString("spawn-totem.middle").toUpperCase()),
|
|
|
|
|
Material.getMaterial(this.getConfig().getString("spawn-totem.top").toUpperCase())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Rewards
|
|
|
|
|
this.drops = new ArrayList<>();
|
|
|
|
|
this.getConfig().getSection("rewards.drops").getKeys(false).forEach(s -> {
|
|
|
|
|
this.drops.add(this.getConfig().getConfig().getItemStack("rewards.drops." + s));
|
|
|
|
|
});
|
|
|
|
|
this.experienceOptions = new ExperienceOptions(
|
|
|
|
|
this.getConfig().getInt("rewards.xp.minimum"),
|
|
|
|
|
this.getConfig().getInt("rewards.xp.maximum")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Immunities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.getConfig().getBool("enabled")) {
|
|
|
|
|
EcoBosses.addBoss(this);
|
|
|
|
|
}
|
|
|
|
|
@@ -127,8 +237,10 @@ public class EcoBoss extends PluginDependent {
|
|
|
|
|
assert attackDamage != null;
|
|
|
|
|
attackDamage.setBaseValue(this.getAttackDamage());
|
|
|
|
|
|
|
|
|
|
if (this.isBossbarEnabled()) {
|
|
|
|
|
createBossBar(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createBossBar(@NotNull final LivingEntity entity) {
|
|
|
|
|
BossBar bossBar = Bukkit.getServer().createBossBar(
|
|
|
|
|
|