Add capability to mostly ignore certain vehicle types (default: arrows).

Configuration setting is hidden for now.
This commit is contained in:
asofold 2017-04-07 22:11:21 +02:00
parent 718f991832
commit 464e374c10
3 changed files with 29 additions and 1 deletions

View File

@ -14,8 +14,12 @@
*/
package fr.neatmonster.nocheatplus.checks.moving;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -205,6 +209,8 @@ public class MovingConfig extends ACheckConfig {
public final boolean vehiclePreventDestroyOwn;
public final boolean scheduleVehicleSetBacks;
public final Set<EntityType> ignoredVehicles = new HashSet<EntityType>();
public final boolean vehicleMorePacketsCheck;
public final ActionList vehicleMorePacketsActions;
@ -355,6 +361,21 @@ public class MovingConfig extends ACheckConfig {
vehicleEnvelopeActive = ref == AlmostBoolean.MAYBE ? ServerVersion.compareMinecraftVersion("1.9") >= 0 : ref.decide();
config.readDoubleValuesForEntityTypes(ConfPaths.MOVING_VEHICLE_ENVELOPE_HSPEEDCAP, vehicleEnvelopeHorizontalSpeedCap, 4.0, true);
vehicleEnvelopeActions = config.getOptimizedActionList(ConfPaths.MOVING_VEHICLE_ENVELOPE_ACTIONS, Permissions.MOVING_VEHICLE_ENVELOPE);
// Ignored vehicle types (ignore mostly, no checks run).
List<String> types;
if (config.get(ConfPaths.MOVING_VEHICLE_IGNOREDVEHICLES) == null) { // Hidden setting for now.
// Use defaults.
types = Arrays.asList("arrow", "spectral_arrow", "tipped_arrow");
}
else {
types = config.getStringList(ConfPaths.MOVING_VEHICLE_IGNOREDVEHICLES);
}
for (String stype : types) {
EntityType type = EntityType.valueOf(stype.toUpperCase());
if (type != null) {
ignoredVehicles.add(type);
}
}
// Messages.
msgKickIllegalMove = ColorUtil.replaceColors(config.getString(ConfPaths.MOVING_MESSAGE_ILLEGALPLAYERMOVE));

View File

@ -337,8 +337,14 @@ public class VehicleChecks extends CheckListener {
final Location from, final Location to, final Player player, final boolean fake,
final MovingData data) {
// TODO: Detect teleportation and similar.
final World world = vehicle.getWorld();
final MovingConfig cc = MovingConfig.getConfig(player);
// Exclude certain vehicle types.
if (cc.ignoredVehicles.contains(vehicleType)) {
// 100% legit.
data.clearVehicleData();
return;
}
final World world = vehicle.getWorld();
final VehicleMoveInfo moveInfo = aux.useVehicleMoveInfo();
// vehicleLocation: Track when it could become null! -> checkIllegal -> no setback or null location.
final Location vehicleLocation = vehicle.getLocation(moveInfo.useLoc);

View File

@ -673,6 +673,7 @@ public abstract class ConfPaths {
public static final String MOVING_VEHICLE_ENFORCELOCATION = MOVING_VEHICLE + "enforcelocation";
public static final String MOVING_VEHICLE_PREVENTDESTROYOWN = MOVING_VEHICLE + "preventdestroyown";
public static final String MOVING_VEHICLE_SCHEDULESETBACKS = MOVING_VEHICLE + "schedulesetbacks";
public static final String MOVING_VEHICLE_IGNOREDVEHICLES = MOVING_VEHICLE + "ignoredvehicles";
private static final String MOVING_VEHICLE_MOREPACKETS = MOVING_VEHICLE + "morepackets.";
public static final String MOVING_VEHICLE_MOREPACKETS_CHECK = MOVING_VEHICLE_MOREPACKETS + "active";
public static final String MOVING_VEHICLE_MOREPACKETS_ACTIONS = MOVING_VEHICLE_MOREPACKETS + "actions";