use of fr.neatmonster.nocheatplus.components.registry.feature.IRemoveData in project NoCheatPlus by NoCheatPlus.
the class PlayerDataManager method handleSystemTimeRanBackwards.
/**
* Adjust to the system time having run backwards. This is much like
* clearData(CheckType.ALL), with the exception of calling
* ICanHandleTimeRunningBackwards.handleTimeRanBackwards for data instances
* which implement this.
*/
public void handleSystemTimeRanBackwards() {
// Collect data factories and clear execution history.
for (final CheckType type : CheckTypeUtil.getWithDescendants(CheckType.ALL)) {
final Map<String, ExecutionHistory> map = executionHistories.get(type);
if (map != null) {
map.clear();
}
}
for (final IRemoveData rmd : iRemoveData) {
if (rmd instanceof ICanHandleTimeRunningBackwards) {
((ICanHandleTimeRunningBackwards) rmd).handleTimeRanBackwards();
} else {
rmd.removeAllData();
}
}
ViolationHistory.clear(CheckType.ALL);
// PlayerData
// TODO: Register explicitly (adding IDataOnTimeRanBackwards)?
Collection<Class<? extends IData>> dataTypes = factoryRegistry.getGroupedTypes(IData.class);
for (final Entry<UUID, PlayerData> entry : playerData.iterable()) {
entry.getValue().handleTimeRanBackwards(dataTypes);
}
}
use of fr.neatmonster.nocheatplus.components.registry.feature.IRemoveData 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