Clear static object REMOVE messages when re-adding

This commit is contained in:
Gary Tierney
2017-09-17 20:27:50 +01:00
parent 8a3decfc54
commit 169d89ffc0
2 changed files with 6 additions and 16 deletions
@@ -46,7 +46,7 @@ class ExpireObjectTask(
respawning = true
setDelay(respawnDelay)
} else {
region.removeEntity(replacement, false)
region.removeEntity(replacement)
world.spawn(obj)
stop()
}
@@ -334,23 +334,13 @@ public final class Region {
listeners.forEach(listener -> listener.execute(this, entity, type));
}
/**
* Removes an {@link Entity} from this Region and notifies listeners.
*
* @param entity The Entity.
* @throws IllegalArgumentException If the Entity does not belong in this Region, or if it was never added.
*/
public void removeEntity(Entity entity) {
removeEntity(entity, true);
}
/**
* Removes an {@link Entity} from this Region.
*
* @param entity The Entity.
* @throws IllegalArgumentException If the Entity does not belong in this Region, or if it was never added.
*/
public void removeEntity(Entity entity, boolean notifyListeners) {
public void removeEntity(Entity entity) {
EntityType type = entity.getEntityType();
if (type.isTransient()) {
throw new IllegalArgumentException("Tried to remove a transient Entity (" + entity + ") from " +
@@ -366,9 +356,7 @@ public final class Region {
throw new IllegalArgumentException("Entity (" + entity + ") belongs in (" + this + ") but does not exist.");
}
if (notifyListeners) {
notifyListeners(entity, EntityUpdateType.REMOVE);
}
notifyListeners(entity, EntityUpdateType.REMOVE);
}
@Override
@@ -425,7 +413,9 @@ public final class Region {
} else { // TODO should this really be possible?
removedObjects.get(height).remove(inverse);
}
} else if (update == EntityUpdateType.REMOVE && !type.isTransient()) {
}
if (update == EntityUpdateType.REMOVE && !type.isTransient()) {
updates.remove(inverse);
}