Search in sources :

Example 11 with CheckType

use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.

the class TestDump method dumpCheckSilentPermissionForPluginYML.

@Test
public void dumpCheckSilentPermissionForPluginYML() {
    PluginTests.setUnitTestNoCheatPlusAPI(false);
    for (CheckType checkType : CheckType.values()) {
        final RegisteredPermission permission = checkType.getPermission();
        // Only add for actual checks at present.
        if (permission == null || checkType.getType() != CheckTypeType.CHECK) {
            continue;
        }
        // Print:
        System.out.print("    " + permission.getStringRepresentation() + ".silent:\n        default: false\n");
    }
}
Also used : CheckType(fr.neatmonster.nocheatplus.checks.CheckType) RegisteredPermission(fr.neatmonster.nocheatplus.permissions.RegisteredPermission) Test(org.junit.Test)

Example 12 with CheckType

use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.

the class MovingData method dataOnRemoveSubCheckData.

@Override
public boolean dataOnRemoveSubCheckData(Collection<CheckType> checkTypes) {
    // TODO: Likely more fields left to change.
    for (final CheckType checkType : checkTypes) {
        switch(checkType) {
            /*
                 * TODO: case MOVING: // Remove all in-place (future: data might
                 * stay as long as the player is online).
                 */
            case MOVING_SURVIVALFLY:
                survivalFlyVL = 0;
                // TODO: ...
                clearFlyData();
                // TODO: Not sure this is really best for compatibility.
                resetSetBack();
                // TODO: other?
                break;
            case MOVING_CREATIVEFLY:
                creativeFlyVL = 0;
                // TODO: ...
                clearFlyData();
                // TODO: Not sure this is really best for compatibility.
                resetSetBack();
                // TODO: other?
                break;
            case MOVING_NOFALL:
                noFallVL = 0;
                clearNoFallData();
                break;
            case MOVING_MOREPACKETS:
                morePacketsVL = 0;
                clearPlayerMorePacketsData();
                morePacketsSetback = null;
                morePacketsSetBackResetTime = 0;
                break;
            case MOVING_PASSABLE:
                passableVL = 0;
                break;
            case MOVING_VEHICLE:
                vehicleEnvelopeVL = 0;
                vehicleMorePacketsVL = 0;
                clearVehicleData();
                break;
            case MOVING_VEHICLE_ENVELOPE:
                vehicleEnvelopeVL = 0;
                vehicleMoves.invalidate();
                // Also invalidates morepackets set back.
                vehicleSetBacks.invalidateAll();
                break;
            case MOVING_VEHICLE_MOREPACKETS:
                vehicleMorePacketsVL = 0;
                clearVehicleMorePacketsData();
                break;
            case MOVING:
                // Just in case.
                clearMostMovingCheckData();
                return true;
            default:
                break;
        }
    }
    return false;
}
Also used : CheckType(fr.neatmonster.nocheatplus.checks.CheckType)

Example 13 with CheckType

use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.

the class DebugPlayerCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
    // TODO: Wild cards (all players)?
    // TODO: (Allow to specify OverrideType ?)
    // Note that MAYBE means to reset here, it's not the same as direct PlayerData API access.
    DebugEntry entry = new DebugEntry();
    for (int i = 2; i < args.length; i++) {
        String input = args[i];
        if (input.startsWith("?")) {
            entry = DebugEntry.parseEntry(input.substring(1));
            if (entry == null) {
                sender.sendMessage("Bad setup: " + input);
                // Can't continue.
                return true;
            } else {
                // Only update the entry.
                continue;
            }
        }
        final String name = input;
        final Player player;
        if (IdUtil.isValidMinecraftUserName(name)) {
            player = DataManager.getPlayer(name);
        } else {
            UUID id = IdUtil.UUIDFromStringSafe(input);
            if (id == null) {
                sender.sendMessage("Bad name or UUID: " + input);
                continue;
            } else {
                player = DataManager.getPlayer(id);
            }
        }
        if (player == null) {
            sender.sendMessage("Not online: " + name);
            continue;
        }
        // Execute for online player.
        final Collection<CheckType> checkTypes;
        if (entry.checkTypes.isEmpty()) {
            // CheckType.ALL
            checkTypes = Arrays.asList(CheckType.ALL);
        } else {
            checkTypes = entry.checkTypes;
        }
        final IPlayerData data = DataManager.getPlayerData(player);
        for (final CheckType checkType : checkTypes) {
            if (entry.active == AlmostBoolean.MAYBE) {
                data.resetDebug(checkType);
            } else {
                data.overrideDebug(checkType, entry.active, OverrideType.CUSTOM, true);
            }
        }
        sender.sendMessage("Set debug = " + entry.active + " for player " + player.getName() + " for checks: " + StringUtil.join(checkTypes, ","));
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) CheckType(fr.neatmonster.nocheatplus.checks.CheckType) IPlayerData(fr.neatmonster.nocheatplus.players.IPlayerData) UUID(java.util.UUID)

Example 14 with CheckType

use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.

the class TopCommand method onCommand.

@SuppressWarnings("unchecked")
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
    if (args.length < 2) {
        return false;
    }
    int startIndex = 1;
    int n = 10;
    try {
        n = Integer.parseInt(args[1].trim());
        startIndex = 2;
    } catch (NumberFormatException e) {
    }
    if (n <= 0) {
        sender.sendMessage("Setting number of entries to 10");
        n = 1;
    } else if ((sender instanceof Player) && n > 300) {
        sender.sendMessage("Capping number of entries at 300.");
        n = 300;
    } else if (n > 10000) {
        sender.sendMessage("Capping number of entries at 10000.");
        n = 10000;
    }
    Set<CheckType> checkTypes = new LinkedHashSet<CheckType>();
    for (int i = startIndex; i < args.length; i++) {
        CheckType type = null;
        try {
            type = CheckType.valueOf(args[i].trim().toUpperCase().replace('-', '_').replace('.', '_'));
        }// ...
         catch (Throwable t) {
        }
        if (type != null) {
            // Includes type.
            checkTypes.addAll(CheckTypeUtil.getWithDescendants(type));
        }
    }
    if (checkTypes.isEmpty()) {
        sender.sendMessage("No check types specified!");
        return false;
    }
    Comparator<VLView> comparator = VLView.parseMixedComparator(args, startIndex);
    if (comparator == null) {
        // TODO: Default comparator ?
        comparator = new FCFSComparator<VLView>(Arrays.asList(VLView.CmpnVL, VLView.CmpSumVL), true);
    }
    // Run a worker task.
    Bukkit.getScheduler().scheduleSyncDelayedTask(access, new PrimaryThreadWorker(sender, checkTypes, comparator, n, access));
    return true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(org.bukkit.entity.Player) VLView(fr.neatmonster.nocheatplus.checks.ViolationHistory.VLView) CheckType(fr.neatmonster.nocheatplus.checks.CheckType)

Example 15 with CheckType

use of fr.neatmonster.nocheatplus.checks.CheckType in project NoCheatPlus by NoCheatPlus.

the class ExemptCommand 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;
    }
    final Player player = DataManager.getPlayer(playerName);
    if (player == null) {
        sender.sendMessage(TAG + "Player not online: " + playerName);
        return true;
    } else {
        playerName = player.getName();
    }
    NCPExemptionManager.exemptPermanently(player, checkType);
    sender.sendMessage(TAG + "Player " + playerName + " is now exempted from: " + checkType);
    return true;
}
Also used : Player(org.bukkit.entity.Player) 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