use of fr.neatmonster.nocheatplus.components.data.ICanHandleTimeRunningBackwards in project NoCheatPlus by NoCheatPlus.
the class PlayerData method handleTimeRanBackwards.
public void handleTimeRanBackwards(final Collection<Class<? extends IData>> dataTypes) {
// Permissions.
final Iterator<Entry<Integer, PermissionNode>> it = permissions.iterator();
final long timeNow = System.currentTimeMillis();
while (it.hasNext()) {
final PermissionNode node = it.next().getValue();
switch(node.getFetchingPolicy()) {
case INTERVAL:
node.invalidate();
break;
default:
if (node.getLastFetch() > timeNow) {
node.setState(node.getLastState(), timeNow);
}
break;
}
}
// TODO: Register explicitly or not? (+ auto register?)...
for (final Class<? extends IData> type : dataTypes) {
final IData obj = dataCache.get(type);
if (obj != null && obj instanceof ICanHandleTimeRunningBackwards) {
((ICanHandleTimeRunningBackwards) obj).handleTimeRanBackwards();
}
}
}
use of fr.neatmonster.nocheatplus.components.data.ICanHandleTimeRunningBackwards 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);
}
}
Aggregations