(Possibly) fix invisible bosses.
Unsurprisingly, MobArena's monster handling is sub-optimal, possibly due to premature optimization. Before, when e.g. a Creeper boss would explode, it would not be removed from the bosses collection, and thus the ability thread would continue on running. This patch adds a tiny bit of overhead w.r.t. removing dead monsters, but it fixes the issue with Creeper bosses, and with a bit of luck, mcMMO will not cause issues anymore (yet to be tested).
This commit is contained in:
@@ -314,7 +314,8 @@ public class ArenaListener
|
|||||||
if (!monsters.getMonsters().contains(event.getEntity()) && !arena.getRegion().contains(event.getLocation(), 10))
|
if (!monsters.getMonsters().contains(event.getEntity()) && !arena.getRegion().contains(event.getLocation(), 10))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
monsters.removeMonster(event.getEntity());
|
// The generic remove method removes bosses as well
|
||||||
|
monsters.remove(event.getEntity());
|
||||||
|
|
||||||
// Cancel if the arena isn't running
|
// Cancel if the arena isn't running
|
||||||
if (!arena.isRunning()) {
|
if (!arena.isRunning()) {
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ public class MASpawnThread implements Runnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.isDead() || !region.contains(e.getLocation())) {
|
if (e.isDead() || !region.contains(e.getLocation())) {
|
||||||
monsterManager.removeMonster(e);
|
monsterManager.remove(e);
|
||||||
e.remove();
|
e.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,10 +248,6 @@ public class MASpawnThread implements Runnable
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove debug message
|
|
||||||
Location l = p.getLocation();
|
|
||||||
System.out.println("Player: " + p.getName() + " found at location:" + l.getX() + ", " + l.getY() + ", " + l.getZ());
|
|
||||||
|
|
||||||
Messenger.tellPlayer(p, "Leaving so soon?");
|
Messenger.tellPlayer(p, "Leaving so soon?");
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
arena.playerLeave(p);
|
arena.playerLeave(p);
|
||||||
|
|||||||
@@ -59,6 +59,19 @@ public class MonsterManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void remove(Entity e) {
|
||||||
|
if (monsters.remove(e)) {
|
||||||
|
sheep.remove(e);
|
||||||
|
golems.remove(e);
|
||||||
|
pets.remove(e);
|
||||||
|
suppliers.remove(e);
|
||||||
|
MABoss boss = bosses.remove(e);
|
||||||
|
if (boss != null) {
|
||||||
|
boss.setDead(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Set<LivingEntity> getMonsters() {
|
public Set<LivingEntity> getMonsters() {
|
||||||
return monsters;
|
return monsters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ public class BossAbilityThread implements Runnable
|
|||||||
if (bosses.isEmpty()) {
|
if (bosses.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
for (MABoss boss : bosses) {
|
||||||
|
if (boss.isDead()) return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the next ability in the list.
|
// Get the next ability in the list.
|
||||||
Ability ability = abilities.get(counter++ % abilities.size());
|
Ability ability = abilities.get(counter++ % abilities.size());
|
||||||
|
|||||||
Reference in New Issue
Block a user