Search in sources :

Example 1 with IHaveCheckType

use of fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType in project NoCheatPlus by NoCheatPlus.

the class PlayerDataManager method clearData.

@Override
public void clearData(final CheckType checkType) {
    final CheckRemovalSpec removalSpec = new CheckRemovalSpec(checkType, true, this);
    final boolean hasComplete = !removalSpec.completeRemoval.isEmpty();
    final boolean hasSub = !removalSpec.subCheckRemoval.isEmpty();
    if (hasComplete || hasSub) {
        for (final Entry<UUID, PlayerData> entry : playerData.iterable()) {
            final IPlayerData pData = entry.getValue();
            if (hasComplete) {
                pData.removeAllGenericInstances(removalSpec.completeRemoval);
            }
            if (hasSub) {
                pData.removeSubCheckData(removalSpec.subCheckRemoval, removalSpec.checkTypes);
            }
        // TODO: Remove the PlayerData instance, if suitable?
        }
    }
    // TODO: IRemoveData - why register here at all ?
    for (final IRemoveData rmd : iRemoveData) {
        if (checkType == CheckType.ALL) {
            // Not sure this is really good, though.
            rmd.removeAllData();
        } else if (rmd instanceof IHaveCheckType) {
            final CheckType refType = ((IHaveCheckType) rmd).getCheckType();
            if (refType == checkType || CheckTypeUtil.isAncestor(checkType, refType)) {
                rmd.removeAllData();
            }
        }
    }
    for (final CheckType type : removalSpec.checkTypes) {
        final Map<String, ExecutionHistory> map = executionHistories.get(type);
        if (map != null) {
            map.clear();
        }
    }
    ViolationHistory.clear(checkType);
    // TODO: PlayerData removal should have other mechanisms (stages).
    if (checkType == CheckType.ALL) {
        bulkPlayerDataRemoval.addAll(playerData.getKeys());
        // Only removes offline player data.
        doBulkPlayerDataRemoval();
    }
}
Also used : IHaveCheckType(fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType) CheckRemovalSpec(fr.neatmonster.nocheatplus.components.registry.factory.RichFactoryRegistry.CheckRemovalSpec) IHaveCheckType(fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType) CheckType(fr.neatmonster.nocheatplus.checks.CheckType) IRemoveData(fr.neatmonster.nocheatplus.components.registry.feature.IRemoveData) UUID(java.util.UUID)

Aggregations

CheckType (fr.neatmonster.nocheatplus.checks.CheckType)1 CheckRemovalSpec (fr.neatmonster.nocheatplus.components.registry.factory.RichFactoryRegistry.CheckRemovalSpec)1 IHaveCheckType (fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType)1 IRemoveData (fr.neatmonster.nocheatplus.components.registry.feature.IRemoveData)1 UUID (java.util.UUID)1