*/
public void addEntity(final IEntity entity) {
MapObject object = null;
if (entity instanceof User) {
entity.addChangeListener(new EntityChangeListener() {
public void entityChanged(final IEntity entity, final Object property) {
if (property == IEntity.PROP_POSITION) {
positionChanged(entity.getX(), entity.getY());
}
}
});
positionChanged(entity.getX(), entity.getY());
object = new PlayerMapObject(entity);
} else if (entity instanceof Player) {
object = new PlayerMapObject(entity);
} else if (entity instanceof Portal) {
final Portal portal = (Portal) entity;
if (!portal.isHidden()) {
mapObjects.put(entity, new PortalMapObject(entity));
}
} else if (entity instanceof HousePortal) {
object = new PortalMapObject(entity);
} else if (entity instanceof WalkBlocker) {
object = new WalkBlockerMapObject(entity);
} else if (entity instanceof DomesticAnimal) {
// Only own pets and sheep are drawn but this is checked in the map object so the user status is always up to date
object = new DomesticAnimalMapObject((DomesticAnimal)entity);
} else if (supermanMode && User.isAdmin()) {
if (entity instanceof RPEntity) {
object = new RPEntityMapObject(entity);
} else {
object = new MovingMapObject(entity);
}
}
if (object != null) {
mapObjects.put(entity, object);
// changes to objects that should trigger a refresh
if (object instanceof MovingMapObject) {
entity.addChangeListener(new EntityChangeListener() {
public void entityChanged(final IEntity entity, final Object property) {
if ((property == IEntity.PROP_POSITION)
|| (property == RPEntity.PROP_GHOSTMODE)
|| (property == RPEntity.PROP_GROUP_MEMBERSHIP)) {
needsRefresh = true;