Search in sources :

Example 16 with CheckType

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

Example 17 with CheckType

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

Example 18 with CheckType

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);
    }
}
Also used : IHaveCheckType(fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType) CheckType(fr.neatmonster.nocheatplus.checks.CheckType) IData(fr.neatmonster.nocheatplus.components.data.IData) IRemoveData(fr.neatmonster.nocheatplus.components.registry.feature.IRemoveData) ICanHandleTimeRunningBackwards(fr.neatmonster.nocheatplus.components.data.ICanHandleTimeRunningBackwards) UUID(java.util.UUID)

Example 19 with CheckType

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();
    }
}
Also used : IHaveCheckType(fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType) CheckRemovalSpec(fr.neatmonster.nocheatplus.components.registry.factory.RichFactoryRegistry.CheckRemovalSpec) IHaveCheckType(fr.neatmonster.nocheatplus.components.registry.feature.IHaveCheckType) CheckType(fr.neatmonster.nocheatplus.checks.CheckType) IRemoveData(fr.neatmonster.nocheatplus.components.registry.feature.IRemoveData) UUID(java.util.UUID)

Example 20 with CheckType

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;
}
Also used : CheckType(fr.neatmonster.nocheatplus.checks.CheckType) IDataOnRemoveSubCheckData(fr.neatmonster.nocheatplus.components.data.IDataOnRemoveSubCheckData) IDoRegister(fr.neatmonster.nocheatplus.components.registry.setup.IDoRegister)

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