use of fr.neatmonster.nocheatplus.components.registry.factory.RichFactoryRegistry.CheckRemovalSpec in project NoCheatPlus by NoCheatPlus.
the class WorldDataManager method clearData.
@Override
public void clearData(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<String, WorldData> entry : worldDataMap.iterable()) {
final WorldData worldData = entry.getValue();
if (hasComplete) {
worldData.removeAllGenericInstances(removalSpec.completeRemoval);
}
if (hasSub) {
worldData.removeSubCheckData(removalSpec.subCheckRemoval, removalSpec.checkTypes);
}
}
}
}
use of fr.neatmonster.nocheatplus.components.registry.factory.RichFactoryRegistry.CheckRemovalSpec in project NoCheatPlus by NoCheatPlus.
the class PlayerDataManager method removeData.
/**
* Remove data instances from the cache for a given player and a given check
* type. CheckType.ALL and null will be interpreted as removing all data.
* <hr/>
* Does not touch the execution history.
* <hr/>
*
* @param playerName
* Exact player name.
* @param checkType
* Check type to remove data for, null is regarded as ALL.
* @return If any data was present (not strict).
*/
public boolean removeData(final String playerName, CheckType checkType) {
PlayerData pData = getPlayerData(playerName);
// TODO: Once working, use the most correct name from PlayerData.
final UUID playerId = pData == null ? getUUID(playerName) : pData.getPlayerId();
if (pData == null && playerId != null) {
pData = playerData.get(playerId);
}
boolean somethingFound = pData != null || playerId != null;
if (checkType == null) {
checkType = CheckType.ALL;
}
// Check extended registered components.
/*
* TODO: "System data" might not be wise to erase for online players.
* ICheckData vs IData (...), except if registered for per check
* type removal.
*/
somethingFound |= clearComponentData(checkType, playerName);
if (pData != null) {
final CheckRemovalSpec removalSpec = new CheckRemovalSpec(checkType, true, this);
final boolean hasComplete = !removalSpec.completeRemoval.isEmpty();
final boolean hasSub = !removalSpec.subCheckRemoval.isEmpty();
if (hasComplete || hasSub) {
if (hasComplete) {
pData.removeAllGenericInstances(removalSpec.completeRemoval);
}
if (hasSub) {
pData.removeSubCheckData(removalSpec.subCheckRemoval, removalSpec.checkTypes);
}
// TODO: Remove the PlayerData instance, if necessary?
}
// TODO: Maintain a shouldBeOnline flag for fast skipping?
if (checkType == CheckType.ALL) {
// TODO: Fetch/use UUID early, and check validity of name.
if (playerId != null) {
bulkPlayerDataRemoval.add(playerId);
}
}
if (pData.isDebugActive(checkType)) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, CheckUtils.getLogMessagePrefix(playerName, checkType) + "Removed data.");
}
}
return somethingFound;
}
use of fr.neatmonster.nocheatplus.components.registry.factory.RichFactoryRegistry.CheckRemovalSpec 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