use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class ExemptionsCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2)
return false;
String playerName = args[1].trim();
Player player = DataManager.getPlayer(playerName);
UUID id;
if (player != null) {
playerName = player.getName();
id = player.getUniqueId();
} else {
id = DataManager.getUUID(playerName);
}
final List<String> entries = new LinkedList<String>();
if (id == null) {
sender.sendMessage(TAG + "Not online nor a UUID: " + playerName);
return true;
} else {
for (CheckType type : CheckType.values()) {
if (NCPExemptionManager.isExempted(id, type)) {
entries.add(type.toString());
}
}
}
if (entries.isEmpty()) {
sender.sendMessage(TAG + "No exemption entries available for " + playerName + " .");
} else {
// TODO: Compress entries ?
sender.sendMessage(TAG + "Exemptions for " + playerName + ": " + StringUtil.join(entries, ", "));
}
return true;
}
use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class FightData method dataOnRemoveSubCheckData.
@Override
public boolean dataOnRemoveSubCheckData(final Collection<CheckType> checkTypes) {
for (final CheckType checkType : checkTypes) {
switch(checkType) {
// TODO: case FIGHT: ...
case FIGHT_DIRECTION:
directionVL = 0;
break;
case FIGHT_REACH:
reachVL = 0;
reachMod = 1.0;
break;
case FIGHT_ANGLE:
angleVL = 0;
angleHits.clear();
break;
case FIGHT_SPEED:
speedVL = 0;
speedBuckets.clear(System.currentTimeMillis());
speedShortTermCount = 0;
speedShortTermTick = 0;
break;
case FIGHT_FASTHEAL:
fastHealVL = 0;
fastHealRefTime = 0;
fastHealBuffer = 0;
regainHealthTime = 0;
break;
case FIGHT_GODMODE:
godModeVL = 0;
godModeBuffer = 0;
godModeAcc = 0;
godModeLastTime = 0;
godModeLastAge = 0;
// Not sure here, possibly a shared thing.
lastNoDamageTicks = 0;
// godModeHealth / ...
break;
case FIGHT_CRITICAL:
criticalVL = 0;
break;
case FIGHT_NOSWING:
noSwingVL = 0;
// Not reset time, for leniency rather.
break;
case FIGHT_SELFHIT:
selfHitVL.clear(System.currentTimeMillis());
break;
case FIGHT:
return true;
default:
break;
}
}
return false;
}
use of fr.neatmonster.nocheatplus.checks.CheckType 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.checks.CheckType 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();
}
}
use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class RegisterInstance method removeSubCheckData.
/**
* Register for sub check removal.
*
* @param checkType
* @param withDescendantCheckTypes
* @return
*/
public RegisterInstance<T, A> removeSubCheckData(final CheckType checkType, final boolean withDescendantCheckTypes) {
if (!IDataOnRemoveSubCheckData.class.isAssignableFrom(type)) {
throw new UnsupportedOperationException();
}
final Collection<CheckType> checkTypes = withDescendantCheckTypes ? CheckTypeUtil.getWithDescendants(checkType) : Arrays.asList(checkType);
items.add(new IDoRegister() {
@SuppressWarnings("unchecked")
@Override
public void doRegister() {
factoryRegistry.addToGroups(checkTypes, (Class<? extends IDataOnRemoveSubCheckData>) type, IDataOnRemoveSubCheckData.class);
}
});
return this;
}
Aggregations