Search in sources :

Example 11 with MapDisplayInfo

use of com.bergerkiller.bukkit.common.map.binding.MapDisplayInfo in project BKCommonLib by bergerhealer.

the class CommonMapController method cleanupUnusedUUIDs.

protected synchronized void cleanupUnusedUUIDs(Set<MapUUID> existingMapUUIDs) {
    HashSet<MapUUID> idsToRemove = new HashSet<MapUUID>(mapIdByUUID.keySet());
    idsToRemove.removeAll(existingMapUUIDs);
    for (MapUUID toRemove : idsToRemove) {
        // Clean up the map display information first
        MapDisplayInfo displayInfo = maps.get(toRemove.getUUID());
        if (displayInfo != null) {
            if (displayInfo.getSessions().isEmpty()) {
                MapDisplayInfo removed = maps.remove(toRemove.getUUID());
                if (removed != null) {
                    mapsValues.remove(removed);
                    removed.onRemoved();
                }
            } else {
                // still has an active session; cannot remove
                continue;
            }
        }
        // Clean up from bi-directional mapping
        Integer mapId = mapIdByUUID.remove(toRemove);
        if (mapId != null) {
            mapUUIDById.remove(mapId.intValue());
        }
        // Clean up from 'dirty' set (probably never needed)
        dirtyMapUUIDSet.removeAll(toRemove.getUUID());
    }
}
Also used : MapDisplayInfo(com.bergerkiller.bukkit.common.map.binding.MapDisplayInfo) MapUUID(com.bergerkiller.bukkit.common.map.util.MapUUID) HashSet(java.util.HashSet)

Aggregations

MapDisplayInfo (com.bergerkiller.bukkit.common.map.binding.MapDisplayInfo)11 ItemFrameInfo (com.bergerkiller.bukkit.common.map.binding.ItemFrameInfo)4 MapSession (com.bergerkiller.bukkit.common.map.MapSession)3 MapUUID (com.bergerkiller.bukkit.common.map.util.MapUUID)3 MapDisplay (com.bergerkiller.bukkit.common.map.MapDisplay)2 CommonPlugin (com.bergerkiller.bukkit.common.internal.CommonPlugin)1 MapDisplayProperties (com.bergerkiller.bukkit.common.map.MapDisplayProperties)1 MapLookPosition (com.bergerkiller.bukkit.common.map.util.MapLookPosition)1 DataWatcher (com.bergerkiller.bukkit.common.wrappers.DataWatcher)1 IntHashMap (com.bergerkiller.bukkit.common.wrappers.IntHashMap)1 OutputTypeMap (com.bergerkiller.mountiplex.reflection.util.OutputTypeMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Player (org.bukkit.entity.Player)1 ItemStack (org.bukkit.inventory.ItemStack)1 PlayerInventory (org.bukkit.inventory.PlayerInventory)1