mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 16:09:24 +00:00
Removed UUID tracking
This commit is contained in:
@@ -31,6 +31,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -39,7 +40,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||
@@ -208,7 +208,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||
/**
|
||||
* The currently living bosses of this type.
|
||||
*/
|
||||
private final Map<UUID, LivingEcoBoss> livingBosses;
|
||||
private final Map<LivingEntity, LivingEcoBoss> livingBosses;
|
||||
|
||||
/**
|
||||
* The effect names and arguments.
|
||||
@@ -476,7 +476,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||
location.getChunk().load();
|
||||
|
||||
LivingEntity entity = bossType.spawnBossEntity(location);
|
||||
this.livingBosses.put(entity.getUniqueId(), new LivingEcoBoss(
|
||||
this.livingBosses.put(entity, new LivingEcoBoss(
|
||||
this.getPlugin(),
|
||||
entity,
|
||||
this
|
||||
@@ -491,16 +491,16 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||
* @return The living boss, or null if not a boss.
|
||||
*/
|
||||
public LivingEcoBoss getLivingBoss(@NotNull final LivingEntity entity) {
|
||||
return this.livingBosses.get(entity.getUniqueId());
|
||||
return this.livingBosses.get(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove living boss.
|
||||
*
|
||||
* @param uuid The entity UUID.
|
||||
* @param entity The entity.
|
||||
*/
|
||||
public void removeLivingBoss(@NotNull final UUID uuid) {
|
||||
this.livingBosses.remove(uuid);
|
||||
public void removeLivingBoss(@Nullable final LivingEntity entity) {
|
||||
this.livingBosses.remove(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -508,7 +508,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||
*
|
||||
* @return The living bosses.
|
||||
*/
|
||||
public Map<UUID, LivingEcoBoss> getLivingBosses() {
|
||||
public Map<LivingEntity, LivingEcoBoss> getLivingBosses() {
|
||||
return ImmutableMap.copyOf(this.livingBosses);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.willfp.eco.util.StringUtils;
|
||||
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
||||
import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker;
|
||||
import com.willfp.ecobosses.bosses.tick.tickers.ChunkLoadTicker;
|
||||
import com.willfp.ecobosses.bosses.tick.tickers.HealthPlaceholderTicker;
|
||||
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
|
||||
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||
@@ -25,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
|
||||
@@ -35,11 +33,6 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
|
||||
@Getter
|
||||
private LivingEntity entity;
|
||||
|
||||
/**
|
||||
* The entity UUID.
|
||||
*/
|
||||
private final UUID uuid;
|
||||
|
||||
/**
|
||||
* The boss.
|
||||
*/
|
||||
@@ -67,7 +60,6 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
|
||||
@NotNull final EcoBoss boss) {
|
||||
super(plugin);
|
||||
this.entity = entity;
|
||||
this.uuid = entity.getUniqueId();
|
||||
this.boss = boss;
|
||||
|
||||
this.onSpawn();
|
||||
@@ -76,7 +68,6 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
|
||||
this.tickers = new ArrayList<>();
|
||||
this.tickers.add(new HealthPlaceholderTicker());
|
||||
this.tickers.add(new TargetTicker(boss.getTargetMode(), boss.getTargetDistance()));
|
||||
this.tickers.add(new ChunkLoadTicker());
|
||||
if (boss.isBossbarEnabled()) {
|
||||
this.tickers.add(
|
||||
new BossBarTicker(
|
||||
@@ -141,16 +132,14 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
|
||||
|
||||
private void tick(final long tick,
|
||||
@NotNull final RunnableTask runnable) {
|
||||
this.entity = (LivingEntity) Bukkit.getEntity(uuid);
|
||||
|
||||
if (entity == null || entity.isDead() || boss.getLivingBoss(entity) == null) {
|
||||
if (entity == null || entity.isDead()) {
|
||||
for (BossTicker ticker : tickers) {
|
||||
ticker.onDeath(boss, entity, tick);
|
||||
}
|
||||
for (Effect effect : effects) {
|
||||
effect.onDeath(boss, entity, tick);
|
||||
}
|
||||
boss.removeLivingBoss(uuid);
|
||||
boss.removeLivingBoss(entity);
|
||||
runnable.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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 com.willfp.ecobosses.bosses.LivingEcoBoss;
|
||||
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -13,7 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AutoSpawnTimer implements Runnable {
|
||||
private int tick = 0;
|
||||
@@ -33,9 +34,9 @@ public class AutoSpawnTimer implements Runnable {
|
||||
|
||||
Set<World> worlds = new HashSet<>();
|
||||
|
||||
for (UUID uuid : boss.getLivingBosses().keySet()) {
|
||||
Entity entity = Bukkit.getEntity(uuid);
|
||||
Bukkit.getLogger().info(boss.getLivingBosses().toString());
|
||||
|
||||
for (Entity entity : boss.getLivingBosses().values().stream().map(LivingEcoBoss::getEntity).collect(Collectors.toList())) {
|
||||
BossUtils.warnIfNull(entity);
|
||||
assert entity != null;
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.willfp.ecobosses.bosses.tick.tickers;
|
||||
|
||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChunkLoadTicker implements BossTicker {
|
||||
/**
|
||||
* Create new chunk load ticker.
|
||||
*/
|
||||
public ChunkLoadTicker() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(@NotNull final EcoBoss boss,
|
||||
@NotNull final LivingEntity entity,
|
||||
final long tick) {
|
||||
Chunk chunk = entity.getLocation().getChunk();
|
||||
if (!chunk.isLoaded()) {
|
||||
chunk.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@UtilityClass
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -96,8 +95,7 @@ public class BossUtils {
|
||||
public int killAllBosses(final boolean force) {
|
||||
int amount = 0;
|
||||
for (EcoBoss boss : EcoBosses.values()) {
|
||||
for (UUID uuid : boss.getLivingBosses().keySet()) {
|
||||
LivingEntity entity = (LivingEntity) Bukkit.getEntity(uuid);
|
||||
for (LivingEntity entity : boss.getLivingBosses().keySet()) {
|
||||
assert entity != null;
|
||||
entity.damage(10000000);
|
||||
amount++;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.willfp.ecobosses.bosses.util.obj;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record DamagerProperty(UUID playerUUID, double damage) {
|
||||
|
||||
Reference in New Issue
Block a user