Search in sources :

Example 6 with PermissionPolicy

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

the class PlayerDataManager method adjustSettings.

/**
 * Fetch settings from the current default config.
 */
private void adjustSettings() {
    final ConfigFile config = ConfigManager.getConfigFile();
    doExpireData = config.getBoolean(ConfPaths.DATA_EXPIRATION_ACTIVE);
    // in minutes
    durExpireData = config.getLong(ConfPaths.DATA_EXPIRATION_DURATION, 1, 1000000, 60) * 60000L;
    // hidden.
    deleteData = config.getBoolean(ConfPaths.DATA_EXPIRATION_DATA, true);
    deleteHistory = config.getBoolean(ConfPaths.DATA_EXPIRATION_HISTORY);
    // TODO: Per world permission registries: need world configs (...).
    Set<RegisteredPermission> changedPermissions = null;
    try {
        // TODO: Only update if changes are there - should have a config-path hash+size thing (+ setting).
        changedPermissions = permissionRegistry.updateSettings(PermissionSettings.fromConfig(config, ConfPaths.PERMISSIONS_POLICY_DEFAULT, ConfPaths.PERMISSIONS_POLICY_RULES));
    } catch (Exception e) {
        StaticLog.logSevere("Failed to read the permissions setup. Relay to ALWAYS policy.");
        StaticLog.logSevere(e);
        permissionRegistry.updateSettings(new PermissionSettings(null, null, new PermissionPolicy()));
    }
    // Invalidate all already fetched permissions.
    for (final Entry<UUID, PlayerData> entry : playerData.iterable()) {
        entry.getValue().adjustSettings(changedPermissions);
    }
}
Also used : ConfigFile(fr.neatmonster.nocheatplus.config.ConfigFile) PermissionSettings(fr.neatmonster.nocheatplus.permissions.PermissionSettings) RegisteredPermission(fr.neatmonster.nocheatplus.permissions.RegisteredPermission) UUID(java.util.UUID) PermissionPolicy(fr.neatmonster.nocheatplus.permissions.PermissionPolicy)

Aggregations

PermissionPolicy (fr.neatmonster.nocheatplus.permissions.PermissionPolicy)6 Test (org.junit.Test)3 ConfigFile (fr.neatmonster.nocheatplus.config.ConfigFile)1 PermissionSettings (fr.neatmonster.nocheatplus.permissions.PermissionSettings)1 PermissionRule (fr.neatmonster.nocheatplus.permissions.PermissionSettings.PermissionRule)1 RegisteredPermission (fr.neatmonster.nocheatplus.permissions.RegisteredPermission)1 UUID (java.util.UUID)1