diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java index 1bb3c62..aa5e87f 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java @@ -6,10 +6,7 @@ import com.willfp.eco.core.command.AbstractCommand; import com.willfp.eco.core.integrations.IntegrationLoader; import com.willfp.ecobosses.bosses.EcoBoss; import com.willfp.ecobosses.bosses.EcoBosses; -import com.willfp.ecobosses.bosses.listeners.AttackListeners; -import com.willfp.ecobosses.bosses.listeners.DeathListeners; -import com.willfp.ecobosses.bosses.listeners.PassiveListeners; -import com.willfp.ecobosses.bosses.listeners.SpawnListeners; +import com.willfp.ecobosses.bosses.listeners.*; import com.willfp.ecobosses.commands.CommandEbdrop; import com.willfp.ecobosses.commands.CommandEbkillall; import com.willfp.ecobosses.commands.CommandEbreload; @@ -46,7 +43,7 @@ public class EcoBossesPlugin extends EcoPlugin { */ @Override public void enable() { - + this.getScheduler().runTimer(new AutoSpawnTimer(), 5, 1); } /** 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 8afb876..8f0ea2c 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 @@ -10,18 +10,10 @@ import com.willfp.ecobosses.bosses.effects.Effect; import com.willfp.ecobosses.bosses.effects.Effects; import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils; 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.TargetMode; +import com.willfp.ecobosses.bosses.util.obj.*; import lombok.AccessLevel; import lombok.Getter; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; import org.bukkit.configuration.InvalidConfigurationException; @@ -31,16 +23,7 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; public class EcoBoss extends PluginDependent { @@ -234,6 +217,18 @@ public class EcoBoss extends PluginDependent { @Getter private final boolean disableBoats; + /** + * The time between auto spawns. + */ + @Getter + private final int autoSpawnInterval; + + /** + * Locations that the boss can auto spawn at. + */ + @Getter + private final List autoSpawnLocations; + /** * Create a new Boss. * @@ -425,6 +420,18 @@ public class EcoBoss extends PluginDependent { // Boat + Minecarts this.disableBoats = this.getConfig().getBool("defence.no-boats"); + // Auto Spawn + this.autoSpawnInterval = this.getConfig().getInt("auto-spawn-interval"); + this.autoSpawnLocations = new ArrayList<>(); + for (String string : this.getConfig().getStrings("auto-spawn-locations")) { + String[] split = string.split(":"); + World world = Bukkit.getWorld(split[0]); + double x = Double.parseDouble(split[1]); + double y = Double.parseDouble(split[2]); + double z = Double.parseDouble(split[3]); + autoSpawnLocations.add(new Location(world, x, y, z)); + } + if (this.getConfig().getBool("enabled")) { EcoBosses.addBoss(this); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/listeners/AutoSpawnTimer.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/listeners/AutoSpawnTimer.java new file mode 100644 index 0000000..4aed05d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/listeners/AutoSpawnTimer.java @@ -0,0 +1,30 @@ +package com.willfp.ecobosses.bosses.listeners; + +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecobosses.bosses.EcoBoss; +import com.willfp.ecobosses.bosses.EcoBosses; +import org.bukkit.Location; + +public class AutoSpawnTimer implements Runnable { + private int tick = 0; + + @Override + public void run() { + tick++; + + for (EcoBoss boss : EcoBosses.values()) { + if (boss.getAutoSpawnInterval() < 0) { + continue; + } + + if (boss.getAutoSpawnLocations().isEmpty()) { + continue; + } + + if (tick % boss.getAutoSpawnInterval() == 0) { + Location location = boss.getAutoSpawnLocations().get(NumberUtils.randInt(0, boss.getAutoSpawnLocations().size() - 1)); + boss.spawn(location); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml index b67b7c9..b1207c7 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml @@ -13,6 +13,9 @@ attack-damage: 50 movement-speed: 2 follow-range: 15 +auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable. +auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100 + spawn-totem: enabled: true top: beacon 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 2f14d94..29f67d9 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml @@ -13,6 +13,9 @@ attack-damage: 30 movement-speed: 1.2 follow-range: 20 +auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable. +auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100 + spawn-totem: enabled: true top: carved_pumpkin diff --git a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml index 60c72dc..33c5c33 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml @@ -13,6 +13,9 @@ attack-damage: 90 movement-speed: 1.5 follow-range: 16 +auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable. +auto-spawn-locations: [] # Formatted as world:x:y:z - for example world_nether:100:10:100 + spawn-totem: enabled: true top: netherite_block diff --git a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml index ab63f2e..e6f9e7b 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml @@ -13,6 +13,9 @@ attack-damage: 70 movement-speed: 1.3 follow-range: 15 +auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable. +auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100 + spawn-totem: enabled: true top: netherite_block