mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-20 15:39:31 +00:00
Fixed several bugs
This commit is contained in:
@@ -94,6 +94,7 @@ public class LivingEcoBoss extends PluginDependent {
|
||||
private void onSpawn() {
|
||||
entity.getPersistentDataContainer().set(this.getPlugin().getNamespacedKeyFactory().create("boss"), PersistentDataType.STRING, boss.getName());
|
||||
entity.setPersistent(true);
|
||||
entity.setRemoveWhenFarAway(false);
|
||||
|
||||
entity.setCustomName(boss.getDisplayName());
|
||||
entity.setCustomNameVisible(true);
|
||||
|
||||
@@ -31,10 +31,6 @@ public class AutoSpawnTimer implements Runnable {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!boss.getLivingBosses().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<World> worlds = new HashSet<>();
|
||||
|
||||
for (UUID uuid : boss.getLivingBosses().keySet()) {
|
||||
|
||||
@@ -6,8 +6,10 @@ import com.willfp.ecobosses.bosses.EcoBosses;
|
||||
import com.willfp.ecobosses.bosses.util.obj.DamagerProperty;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -79,6 +81,16 @@ public class BossUtils {
|
||||
* @return The amount of bosses killed.
|
||||
*/
|
||||
public int killAllBosses() {
|
||||
return killAllBosses(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill all bosses.
|
||||
*
|
||||
* @param force If all entities should be checked for being bosses.
|
||||
* @return The amount of bosses killed.
|
||||
*/
|
||||
public int killAllBosses(final boolean force) {
|
||||
int amount = 0;
|
||||
for (EcoBoss boss : EcoBosses.values()) {
|
||||
for (UUID uuid : boss.getLivingBosses().keySet()) {
|
||||
@@ -89,6 +101,22 @@ public class BossUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (force) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (BossUtils.getBoss((LivingEntity) entity) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<KeyedBossBar> bars = new ArrayList<>();
|
||||
Bukkit.getBossBars().forEachRemaining(bars::add);
|
||||
for (KeyedBossBar bar : bars) {
|
||||
|
||||
@@ -21,6 +21,11 @@ public class CommandEbkillall extends AbstractCommand {
|
||||
@Override
|
||||
public void onExecute(@NotNull final CommandSender sender,
|
||||
@NotNull final List<String> args) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(BossUtils.killAllBosses())));
|
||||
boolean force = false;
|
||||
if (args.size() == 1) {
|
||||
force = args.get(0).equalsIgnoreCase("force");
|
||||
}
|
||||
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(BossUtils.killAllBosses(force))));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user