mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 02:48:04 +01:00
Add fall-back configurability for latest addition.
This commit is contained in:
parent
f597f8bded
commit
ee5c86bb4f
@ -146,6 +146,8 @@ public class MovingConfig extends ACheckConfig {
|
||||
public final boolean loadChunksOnJoin;
|
||||
public final long sprintingGrace;
|
||||
public final int speedGrace;
|
||||
public final boolean vehicleEnforceLocation;
|
||||
public final boolean vehiclePreventDestroyOwn;
|
||||
|
||||
/**
|
||||
* Instantiates a new moving configuration.
|
||||
@ -220,6 +222,9 @@ public class MovingConfig extends ACheckConfig {
|
||||
loadChunksOnJoin = config.getBoolean(ConfPaths.MOVING_LOADCHUNKS_JOIN);
|
||||
sprintingGrace = Math.max(0L, (long) (config.getDouble(ConfPaths.MOVING_SPRINTINGGRACE) * 1000.0)); // Config: seconds.
|
||||
speedGrace = Math.max(0, (int) Math.round(config.getDouble(ConfPaths.MOVING_SPEEDGRACE) * 20.0)); // Config: seconds
|
||||
|
||||
vehicleEnforceLocation = config.getBoolean(ConfPaths.MOVING_VEHICLES_ENFORCELOCATION);
|
||||
vehiclePreventDestroyOwn = config.getBoolean(ConfPaths.MOVING_VEHICLES_PREVENTDESTROYOWN);
|
||||
}
|
||||
|
||||
|
||||
|
@ -694,7 +694,11 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
data.vehicleConsistency = MoveConsistency.getConsistency(from, to, vLoc);
|
||||
// TODO: Consider TeleportUtil.forceMount or similar.
|
||||
if (data.vehicleConsistency == MoveConsistency.INCONSISTENT) {
|
||||
if (MovingConfig.getConfig(player).vehicleEnforceLocation) {
|
||||
return vLoc;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
data.resetPositions(vLoc);
|
||||
return null;
|
||||
@ -1325,20 +1329,16 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
public void onVehicleDestroyLowest(final VehicleDestroyEvent event) {
|
||||
// Prevent destroying ones own vehicle.
|
||||
final Entity attacker = event.getAttacker();
|
||||
if (!(attacker instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
final Vehicle vehicle = event.getVehicle();
|
||||
if (!attacker.equals(vehicle.getPassenger())) {
|
||||
return;
|
||||
}
|
||||
if (attacker instanceof Player && attacker.equals(event.getVehicle().getPassenger())) {
|
||||
final Player player = (Player) attacker;
|
||||
if (!creativeFly.isEnabled(player) && !survivalFly.isEnabled(player)) {
|
||||
return;
|
||||
}
|
||||
if (survivalFly.isEnabled(player) || creativeFly.isEnabled(player)) {
|
||||
if (MovingConfig.getConfig(player).vehiclePreventDestroyOwn) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.DARK_RED + "Destroying your own vehicle is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onVehicleDestroy(final VehicleDestroyEvent event) {
|
||||
|
@ -641,6 +641,10 @@ public abstract class ConfPaths {
|
||||
public static final String MOVING_SPRINTINGGRACE = MOVING + "sprintinggrace";
|
||||
public static final String MOVING_SPEEDGRACE = MOVING + "speedgrace";
|
||||
|
||||
private static final String MOVING_VEHICLES = MOVING + "vehicles.";
|
||||
public static final String MOVING_VEHICLES_ENFORCELOCATION = MOVING_VEHICLES + "enforcelocation";
|
||||
public static final String MOVING_VEHICLES_PREVENTDESTROYOWN = MOVING_VEHICLES + "preventdestroyown";
|
||||
|
||||
/*
|
||||
* dP"8 d8 ,e,
|
||||
* C8b Y d88 888,8, " 888 8e e88 888 dP"Y
|
||||
|
@ -469,7 +469,11 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.MOVING_SURVIVALFLY_HOVER_FALLDAMAGE, true);
|
||||
set(ConfPaths.MOVING_SURVIVALFLY_HOVER_SFVIOLATION, 500);
|
||||
|
||||
// Special.
|
||||
// Vehicles.
|
||||
set(ConfPaths.MOVING_VEHICLES_PREVENTDESTROYOWN, true);
|
||||
set(ConfPaths.MOVING_VEHICLES_ENFORCELOCATION, true);
|
||||
|
||||
// Velocity.
|
||||
set(ConfPaths.MOVING_VELOCITY_GRACETICKS, 20);
|
||||
set(ConfPaths.MOVING_VELOCITY_ACTIVATIONCOUNTER, 80);
|
||||
set(ConfPaths.MOVING_VELOCITY_ACTIVATIONTICKS, 140);
|
||||
|
Loading…
Reference in New Issue
Block a user