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();
}
}
Aggregations