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

Began coding ecoboss config loading

This commit is contained in:
Auxilor
2021-03-12 12:40:33 +00:00
parent 39d1170f77
commit 8322b3d8f8
5 changed files with 118 additions and 4 deletions

View File

@@ -5,15 +5,22 @@ import com.willfp.eco.util.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin; import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecobosses.bosses.util.bosstype.BossType; import com.willfp.ecobosses.bosses.util.bosstype.BossType;
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties; 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.ImmunityOptions;
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
import com.willfp.ecobosses.bosses.util.obj.SpawnTotem; 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.AccessLevel;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance; import org.bukkit.attribute.AttributeInstance;
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.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -21,8 +28,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
public class EcoBoss extends PluginDependent { public class EcoBoss extends PluginDependent {
/** /**
@@ -37,6 +46,12 @@ public class EcoBoss extends PluginDependent {
@Getter(AccessLevel.PRIVATE) @Getter(AccessLevel.PRIVATE)
private final AbstractUndefinedConfig config; private final AbstractUndefinedConfig config;
/**
* The display name of the boss.
*/
@Getter
private final String displayName;
/** /**
* The base entity spawner. * The base entity spawner.
*/ */
@@ -90,6 +105,66 @@ public class EcoBoss extends PluginDependent {
@Getter @Getter
private final List<ItemStack> drops; 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. * Create a new Boss.
* *
@@ -104,6 +179,41 @@ public class EcoBoss extends PluginDependent {
this.config = config; this.config = config;
this.name = name; 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")) { if (this.getConfig().getBool("enabled")) {
EcoBosses.addBoss(this); EcoBosses.addBoss(this);
} }
@@ -127,8 +237,10 @@ public class EcoBoss extends PluginDependent {
assert attackDamage != null; assert attackDamage != null;
attackDamage.setBaseValue(this.getAttackDamage()); attackDamage.setBaseValue(this.getAttackDamage());
if (this.isBossbarEnabled()) {
createBossBar(entity); createBossBar(entity);
} }
}
private void createBossBar(@NotNull final LivingEntity entity) { private void createBossBar(@NotNull final LivingEntity entity) {
BossBar bossBar = Bukkit.getServer().createBossBar( BossBar bossBar = Bukkit.getServer().createBossBar(

View File

@@ -2,7 +2,7 @@ package com.willfp.ecobosses.bosses.options;
import com.willfp.eco.util.internal.PluginDependent; import com.willfp.eco.util.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin; 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.bosses.util.obj.OptionedSound;
import com.willfp.ecobosses.config.EcoBossesConfigs; import com.willfp.ecobosses.config.EcoBossesConfigs;
import lombok.Getter; import lombok.Getter;

View File

@@ -1,4 +1,4 @@
package com.willfp.ecobosses.bosses.util.obj; package com.willfp.ecobosses.bosses.util.obj.attacks;
import lombok.Getter; import lombok.Getter;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;

View File

@@ -1,4 +1,4 @@
package com.willfp.ecobosses.bosses.util.obj; package com.willfp.ecobosses.bosses.util.obj.attacks;
import lombok.Getter; import lombok.Getter;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;

View File

@@ -72,6 +72,8 @@ sounds:
# Volume is the distance that it can be heard from # Volume is the distance that it can be heard from
# Pitch is 0.5-2 # Pitch is 0.5-2
# All the sounds for a given category are played at the same time (layered)
spawn: # On spawn spawn: # On spawn
- "entity_illusioner_mirror_move:1000:0.5" - "entity_illusioner_mirror_move:1000:0.5"
- "entity_wither_spawn:1000L:2" - "entity_wither_spawn:1000L:2"