public V remove( long key ) { synchronized( mutex ) { return m.remove( key ); } } public void putAll( Map<? extends Long, ? extends V> map ) {
/** * * @return removes the component with the specified class from the entity and returns it. * Returns null if no component could be removed. */ public <T extends Component> Component remove(long entityId, Class<T> componentClass) { TLongObjectMap<Component> entityMap = store.get(componentClass); if (entityMap != null) { return entityMap.remove(entityId); } return null; }
public void remove(long entityId) { for (TLongObjectMap<Component> entityMap : store.values()) { entityMap.remove(entityId); } }
public List<Component> removeAndReturnComponentsOf(long entityId) { List<Component> componentList = Lists.newArrayList(); for (TLongObjectMap<Component> entityMap : store.values()) { Component component = entityMap.remove(entityId); if (component != null) { componentList.add(component); } } return componentList; }
/** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return the removed value, or Integer(0) if it was not found in the map */ public V remove( Object key ) { long k; if ( key != null ) { if ( key instanceof Long ) { k = unwrapKey( ( Long ) key ); } else { return null; } } else { k = _map.getNoEntryKey(); } return _map.remove( k ); }
public void onEntityDestroyed(EntityRef entity) { if (entity.isPersistent()) { entityDeltas.remove(entity.getId()); destroyedEntities.add(entity.getId()); } }
void remove(long id) { setupNodes.remove(id); }
public synchronized void clear(Type type, long id) { TLongObjectMap<List<CacheNode>> typeCache = this.eventCache.get(type); if (typeCache == null) return; List<CacheNode> events = typeCache.remove(id); if (events != null) LOG.debug("Clearing cache for type {} with ID {} (Size: {})", type, id, events.size()); }
public ConnectionRequest removeAudioConnection(long guildId) { //This will only be used by GuildDeleteHandler to ensure that // no further voice state updates are sent for this Guild //TODO: users may still queue new requests via the old AudioManager, how could we prevent this? return locked("There was an error cleaning up audio connections for deleted guild", () -> queuedAudioConnections.remove(guildId)); }
public synchronized void playbackCache(Type type, long triggerId) { TLongObjectMap<List<CacheNode>> typeCache = this.eventCache.get(type); if (typeCache == null) return; List<CacheNode> items = typeCache.remove(triggerId); if (items != null && !items.isEmpty()) { EventCache.LOG.debug("Replaying {} events from the EventCache for type {} with id: {}", items.size(), type, triggerId); for (CacheNode item : items) item.execute(); } }
void handleRemoveMember(JSONObject member) { if (members == null || removedMembers == null) return; expectedMemberCount--; long userId = member.getJSONObject("user").getLong("id"); members.remove(userId); removedMembers.add(userId); EventCache eventCache = getController().getJDA().getEventCache(); if (!getController().containsMember(userId, this)) // if no other setup node contains this userId we clear it here eventCache.clear(EventCache.Type.USER, userId); }
private void applyPermissions(AbstractChannelImpl<?> channel, JSONObject content, JSONArray permOverwrites, List<IPermissionHolder> contained, List<IPermissionHolder> changed) { //Determines if a new PermissionOverride was created or updated. //If a PermissionOverride was created or updated it stores it in the proper Map to be reported by the Event. for (int i = 0; i < permOverwrites.length(); i++) { handlePermissionOverride(permOverwrites.getJSONObject(i), channel, content, changed, contained); } //Check if any overrides were deleted because of this event. //Get the current overrides. (we copy them to a new list because the Set returned is backed by the Map, meaning our removes would remove from the Map. Not good. //Loop through all of the json defined overrides. If we find a match, remove the User or Role from our lists. //Any entries remaining in these lists after this for loop is over will be removed from the Channel's overrides. final TLongList toRemove = new TLongLinkedList(); final TLongObjectMap<PermissionOverride> overridesMap = channel.getOverrideMap(); TDecorators.wrap(overridesMap.keySet()).stream() .map(id -> mapPermissionHolder(id, channel.getGuild())) .filter(Objects::nonNull) .filter(permHolder -> !contained.contains(permHolder)) .forEach(permHolder -> { changed.add(permHolder); toRemove.add(getIdLong(permHolder)); }); toRemove.forEach((id) -> { overridesMap.remove(id); return true; }); }
public void ready(long id) { setupNodes.remove(id); WebSocketClient client = getJDA().getClient(); if (!client.isReady() && --incompleteCount < 1) client.ready(); else tryChunking(); }
queuedAudioConnections.remove(guildId); return;
protected void updateAudioManagerReferences() { final TLongObjectMap<AudioManager> managerMap = api.getAudioManagerMap(); if (managerMap.size() > 0) LOG.trace("Updating AudioManager references"); synchronized (managerMap) { for (TLongObjectIterator<AudioManager> it = managerMap.iterator(); it.hasNext(); ) { it.advance(); final long guildId = it.key(); final AudioManagerImpl mng = (AudioManagerImpl) it.value(); GuildImpl guild = (GuildImpl) api.getGuildById(guildId); if (guild == null) { //We no longer have access to the guild that this audio manager was for. Set the value to null. queuedAudioConnections.remove(guildId); mng.closeAudioConnection(ConnectionStatus.DISCONNECTED_REMOVED_DURING_RECONNECT); it.remove(); } } } }
Role removedRole = guild.getRolesMap().remove(roleId); if (removedRole == null)
private void completeSetup() { updateStatus(GuildSetupController.Status.BUILDING); JDAImpl api = getController().getJDA(); for (TLongIterator it = removedMembers.iterator(); it.hasNext(); ) members.remove(it.next()); removedMembers.clear(); GuildImpl guild = api.getEntityBuilder().createGuild(id, partialGuild, members); updateAudioManagerReference(guild); if (join) { api.getEventManager().handle(new GuildJoinEvent(api, api.getResponseTotal(), guild)); if (requestedChunk) getController().ready(id); else getController().remove(id); } else { api.getEventManager().handle(new GuildReadyEvent(api, api.getResponseTotal(), guild)); getController().ready(id); } updateStatus(GuildSetupController.Status.READY); GuildSetupController.log.debug("Finished setup for guild {} firing cached events {}", id, cachedEvents.size()); api.getClient().handle(cachedEvents); api.getEventCache().playbackCache(EventCache.Type.GUILD, id); }