From 8322b3d8f80de59a00ee7c90efe12cb58b8df7f6 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 12 Mar 2021 12:40:33 +0000 Subject: [PATCH] Began coding ecoboss config loading --- .../com/willfp/ecobosses/bosses/EcoBoss.java | 114 +++++++++++++++++- .../bosses/options/GameplayOptions.java | 2 +- .../util/obj/{ => attacks}/EffectOption.java | 2 +- .../util/obj/{ => attacks}/SummonsOption.java | 2 +- .../src/main/resources/bosses/illusioner.yml | 2 + 5 files changed, 118 insertions(+), 4 deletions(-) rename eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/{ => attacks}/EffectOption.java (95%) rename eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/{ => attacks}/SummonsOption.java (92%) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java index bc61817..35f7606 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java @@ -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 drops; + /** + * The exp to drop. + */ + @Getter + private final ExperienceOptions experienceOptions; + + /** + * The effects. + */ + @Getter + private final Set effects; + + /** + * The summons. + */ + @Getter + private final Set 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 injureSounds; + + /** + * Spawn sounds. + */ + @Getter + private final List spawnSounds; + + /** + * Death sounds. + */ + @Getter + private final List deathSounds; + + /** + * Summon sounds. + */ + @Getter + private final List 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,7 +237,9 @@ public class EcoBoss extends PluginDependent { assert attackDamage != null; attackDamage.setBaseValue(this.getAttackDamage()); - createBossBar(entity); + if (this.isBossbarEnabled()) { + createBossBar(entity); + } } private void createBossBar(@NotNull final LivingEntity entity) { diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/options/GameplayOptions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/options/GameplayOptions.java index 2183b82..a3a7dba 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/options/GameplayOptions.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/options/GameplayOptions.java @@ -2,7 +2,7 @@ package com.willfp.ecobosses.bosses.options; import com.willfp.eco.util.internal.PluginDependent; import com.willfp.eco.util.plugin.AbstractEcoPlugin; -import com.willfp.ecobosses.bosses.util.obj.EffectOption; +import com.willfp.ecobosses.bosses.util.obj.attacks.EffectOption; import com.willfp.ecobosses.bosses.util.obj.OptionedSound; import com.willfp.ecobosses.config.EcoBossesConfigs; import lombok.Getter; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EffectOption.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/attacks/EffectOption.java similarity index 95% rename from eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EffectOption.java rename to eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/attacks/EffectOption.java index d5132e7..f387705 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EffectOption.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/attacks/EffectOption.java @@ -1,4 +1,4 @@ -package com.willfp.ecobosses.bosses.util.obj; +package com.willfp.ecobosses.bosses.util.obj.attacks; import lombok.Getter; import org.bukkit.potion.PotionEffectType; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/SummonsOption.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/attacks/SummonsOption.java similarity index 92% rename from eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/SummonsOption.java rename to eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/attacks/SummonsOption.java index 2f099ee..36bb5a0 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/SummonsOption.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/attacks/SummonsOption.java @@ -1,4 +1,4 @@ -package com.willfp.ecobosses.bosses.util.obj; +package com.willfp.ecobosses.bosses.util.obj.attacks; import lombok.Getter; import org.bukkit.entity.EntityType; diff --git a/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml b/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml index 5d59e32..eb14e4f 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml @@ -72,6 +72,8 @@ sounds: # Volume is the distance that it can be heard from # Pitch is 0.5-2 + # All the sounds for a given category are played at the same time (layered) + spawn: # On spawn - "entity_illusioner_mirror_move:1000:0.5" - "entity_wither_spawn:1000L:2"