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");
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations