Search in sources :

Example 1 with PermissionInfo

use of fr.neatmonster.nocheatplus.permissions.PermissionInfo in project NoCheatPlus by NoCheatPlus.

the class PlayerData method invalidateOffline.

private void invalidateOffline() {
    final Iterator<Entry<Integer, PermissionNode>> it = permissions.iterator();
    // TODO: More efficient: get unmodifiable collection from registry?
    while (it.hasNext()) {
        final PermissionNode node = it.next().getValue();
        final PermissionInfo info = node.getPermissionInfo();
        if (info.invalidationOffline() || /*
                     * TODO: world based should only be invalidated with world
                     * changing. Therefore store the last world info
                     * (UUID/name?) in PlayerData and use on login for
                     * comparison.
                     */
        info.invalidationWorld()) {
            // TODO: Really count leave as world change?
            node.invalidate();
        }
    }
}
Also used : Entry(java.util.Map.Entry) PermissionInfo(fr.neatmonster.nocheatplus.permissions.PermissionInfo) PermissionNode(fr.neatmonster.nocheatplus.permissions.PermissionNode)

Example 2 with PermissionInfo

use of fr.neatmonster.nocheatplus.permissions.PermissionInfo in project NoCheatPlus by NoCheatPlus.

the class PlayerData method onPlayerChangedWorld.

/**
 * Early adaption on world change.
 *
 * @param oldWorld
 * @param newWorld
 * @param types
 */
void onPlayerChangedWorld(final Player player, final World oldWorld, final World newWorld, final WorldDataManager worldDataManager, final Collection<Class<? extends IDataOnWorldChange>> types) {
    updateCurrentWorld(newWorld, worldDataManager);
    // TODO: Double-invalidation (previous policy and target world policy)
    final Iterator<Entry<Integer, PermissionNode>> it = permissions.iterator();
    // TODO: More efficient: get unmodifiable collection from registry?
    while (it.hasNext()) {
        final PermissionNode node = it.next().getValue();
        final PermissionInfo info = node.getPermissionInfo();
        if (info.invalidationWorld()) {
            node.invalidate();
        }
    }
    requestLazyPermissionUpdate(permissionRegistry.getPreferKeepUpdatedWorld());
    for (final Class<? extends IDataOnWorldChange> type : types) {
        final IDataOnWorldChange instance = dataCache.get(type);
        if (instance != null && instance.dataOnWorldChange(player, this, oldWorld, newWorld)) {
            dataCache.remove(type);
        }
    }
}
Also used : Entry(java.util.Map.Entry) PermissionInfo(fr.neatmonster.nocheatplus.permissions.PermissionInfo) IDataOnWorldChange(fr.neatmonster.nocheatplus.components.data.IDataOnWorldChange) PermissionNode(fr.neatmonster.nocheatplus.permissions.PermissionNode)

Aggregations

PermissionInfo (fr.neatmonster.nocheatplus.permissions.PermissionInfo)2 PermissionNode (fr.neatmonster.nocheatplus.permissions.PermissionNode)2 Entry (java.util.Map.Entry)2 IDataOnWorldChange (fr.neatmonster.nocheatplus.components.data.IDataOnWorldChange)1