mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 07:59:28 +00:00
Added auto spawn system
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<Location> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user