use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class CombinedData method dataOnRemoveSubCheckData.
@Override
public boolean dataOnRemoveSubCheckData(Collection<CheckType> checkTypes) {
for (final CheckType checkType : checkTypes) {
switch(checkType) {
// TODO: case COMBINED:
case COMBINED_IMPROBABLE:
improbableVL = 0;
// TODO: Document there, which to use.
improbableCount.clear(System.currentTimeMillis());
break;
case COMBINED_YAWRATE:
// TODO: Document there, which to use.
yawFreq.clear(System.currentTimeMillis());
break;
case COMBINED_BEDLEAVE:
bedLeaveVL = 0;
// wasInBed is probably better kept?
wasInBed = false;
break;
case COMBINED_MUNCHHAUSEN:
munchHausenVL = 0;
break;
case COMBINED:
return true;
default:
break;
}
}
return false;
}
use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class RemovePlayerCommand method onCommand.
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 2 || args.length > 3)
return false;
String playerName = args[1];
final CheckType checkType;
if (args.length == 3) {
try {
checkType = CheckType.valueOf(args[2].toUpperCase().replace('-', '_').replace('.', '_'));
} catch (Exception e) {
sender.sendMessage(TAG + "Could not interpret: " + args[2]);
sender.sendMessage(TAG + "Check type should be one of: " + StringUtil.join(Arrays.asList(CheckType.values()), " | "));
return true;
}
} else
checkType = CheckType.ALL;
if (playerName.equals("*")) {
DataManager.clearData(checkType);
sender.sendMessage(TAG + "Removed all data and history: " + checkType);
return true;
}
final Player player = DataManager.getPlayer(playerName);
if (player != null)
playerName = player.getName();
ViolationHistory hist = ViolationHistory.getHistory(playerName, false);
boolean somethingFound = false;
if (hist != null) {
somethingFound = hist.remove(checkType);
if (checkType == CheckType.ALL) {
somethingFound = true;
ViolationHistory.removeHistory(playerName);
}
}
if (DataManager.removeExecutionHistory(checkType, playerName)) {
somethingFound = true;
}
if (DataManager.removeData(playerName, checkType)) {
somethingFound = true;
}
if (somethingFound) {
sender.sendMessage(TAG + "Issued history and data removal (" + checkType + "): " + playerName);
} else
sender.sendMessage(TAG + "Nothing found (" + checkType + "): " + playerName + " (spelled correctly?)");
return true;
}
use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class UnexemptCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
// TODO: Reduce copy and paste by introducing some super class.
if (args.length < 2 || args.length > 3)
return false;
String playerName = args[1];
final CheckType checkType;
if (args.length == 3) {
try {
checkType = CheckType.valueOf(args[2].toUpperCase().replace('-', '_').replace('.', '_'));
} catch (Exception e) {
sender.sendMessage(TAG + "Could not interpret: " + args[2]);
sender.sendMessage(TAG + "Check type should be one of: " + StringUtil.join(Arrays.asList(CheckType.values()), " | "));
return true;
}
} else
checkType = CheckType.ALL;
if (playerName.equals("*")) {
// Unexempt all.
// TODO: might care to find players only ?
NCPExemptionManager.clear();
sender.sendMessage(TAG + "Removed exemptions for all players for checks: " + checkType);
return true;
}
// Find player.
final Player player = DataManager.getPlayer(playerName);
final UUID id;
if (player != null) {
playerName = player.getName();
id = player.getUniqueId();
} else {
id = DataManager.getUUID(playerName);
}
if (id == null) {
sender.sendMessage(TAG + "Not an online player nor a UUID: " + playerName);
} else {
NCPExemptionManager.unexempt(id, checkType);
sender.sendMessage(TAG + "Remove exemptions for " + playerName + " for checks: " + checkType);
}
return true;
}
use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class CommandUtil method getCheckTypeTabMatches.
/**
* Match for CheckType, some smart method, to also match after first "_" for convenience of input.
* @param input
* @return
*/
public static List<String> getCheckTypeTabMatches(final String input) {
final String ref = input.toUpperCase().replace('-', '_').replace('.', '_');
final List<String> res = new ArrayList<String>();
for (final CheckType checkType : CheckType.values()) {
final String name = checkType.name();
if (name.startsWith(ref)) {
res.add(name);
}
}
if (ref.indexOf('_') == -1) {
for (final CheckType checkType : CheckType.values()) {
final String name = checkType.name();
final String[] split = name.split("_", 2);
if (split.length > 1 && split[1].startsWith(ref)) {
res.add(name);
}
}
}
if (!res.isEmpty()) {
Collections.sort(res);
return res;
}
return null;
}
use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.
the class NCPHookManager method shouldCancelVLProcessing.
/**
* This is called by checks when players fail them.
*
* @param checkType
* the check type
* @param player
* the player that fails the check
* @return if we should cancel the VL processing
*/
public static final boolean shouldCancelVLProcessing(final ViolationData violationData) {
// Checks for hooks registered for this event, parent groups or ALL will be inserted into the list.
// Return true as soon as one hook returns true. Test hooks, if present.
final CheckType type = violationData.check.getType();
final List<NCPHook> hooksCheck = hooksByChecks.get(type);
if (!hooksCheck.isEmpty()) {
if (CheckTypeUtil.needsSynchronization(type)) {
synchronized (hooksCheck) {
return applyHooks(type, violationData.player, violationData, hooksCheck);
}
} else {
return applyHooks(type, violationData.player, violationData, hooksCheck);
}
}
return false;
}
Aggregations