Search in sources :

Example 1 with CheckType

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;
}
Also used : CheckType(fr.neatmonster.nocheatplus.checks.CheckType)

Example 2 with CheckType

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;
}
Also used : Player(org.bukkit.entity.Player) CheckType(fr.neatmonster.nocheatplus.checks.CheckType) ViolationHistory(fr.neatmonster.nocheatplus.checks.ViolationHistory)

Example 3 with CheckType

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;
}
Also used : Player(org.bukkit.entity.Player) CheckType(fr.neatmonster.nocheatplus.checks.CheckType) UUID(java.util.UUID)

Example 4 with CheckType

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;
}
Also used : CheckType(fr.neatmonster.nocheatplus.checks.CheckType) ArrayList(java.util.ArrayList)

Example 5 with CheckType

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;
}
Also used : CheckType(fr.neatmonster.nocheatplus.checks.CheckType)

Aggregations

CheckType (fr.neatmonster.nocheatplus.checks.CheckType)20 Player (org.bukkit.entity.Player)6 UUID (java.util.UUID)5 IHaveCheckType (fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType)2 IRemoveData (fr.neatmonster.nocheatplus.components.registry.feature.IRemoveData)2 Test (org.junit.Test)2 ViolationHistory (fr.neatmonster.nocheatplus.checks.ViolationHistory)1 VLView (fr.neatmonster.nocheatplus.checks.ViolationHistory.VLView)1 ICanHandleTimeRunningBackwards (fr.neatmonster.nocheatplus.components.data.ICanHandleTimeRunningBackwards)1 IData (fr.neatmonster.nocheatplus.components.data.IData)1 IDataOnRemoveSubCheckData (fr.neatmonster.nocheatplus.components.data.IDataOnRemoveSubCheckData)1 CheckTypeTree (fr.neatmonster.nocheatplus.components.data.checktype.CheckTypeTree)1 CheckTypeTreeNodeFactory (fr.neatmonster.nocheatplus.components.data.checktype.CheckTypeTree.CheckTypeTreeNodeFactory)1 CheckRemovalSpec (fr.neatmonster.nocheatplus.components.registry.factory.RichFactoryRegistry.CheckRemovalSpec)1 IDoRegister (fr.neatmonster.nocheatplus.components.registry.setup.IDoRegister)1 RegisteredPermission (fr.neatmonster.nocheatplus.permissions.RegisteredPermission)1 IPlayerData (fr.neatmonster.nocheatplus.players.IPlayerData)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1