Make illegal move kick messages configurable.

This commit is contained in:
asofold 2016-06-18 17:39:45 +02:00
parent 307374254b
commit 9c9210e411
6 changed files with 24 additions and 6 deletions

View File

@ -38,6 +38,7 @@ import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
import fr.neatmonster.nocheatplus.utilities.ds.prefixtree.SimpleCharPrefixTree;
@ -213,6 +214,10 @@ public class MovingConfig extends ACheckConfig {
public final int traceMaxAge;
public final int traceMaxSize;
// Messages.
public final String msgKickIllegalMove;
public final String msgKickIllegalVehicleMove;
/**
* Instantiates a new moving configuration.
*
@ -342,6 +347,9 @@ public class MovingConfig extends ACheckConfig {
config.readDoubleValuesForEntityTypes(ConfPaths.MOVING_VEHICLE_ENVELOPE_HSPEEDCAP, vehicleEnvelopeHorizontalSpeedCap, 4.0, true);
vehicleEnvelopeActions = config.getOptimizedActionList(ConfPaths.MOVING_VEHICLE_ENVELOPE_ACTIONS, Permissions.MOVING_VEHICLE_ENVELOPE);
// Messages.
msgKickIllegalMove = ColorUtil.replaceColors(config.getString(ConfPaths.MOVING_MESSAGE_ILLEGALPLAYERMOVE));
msgKickIllegalVehicleMove = ColorUtil.replaceColors(config.getString(ConfPaths.MOVING_MESSAGE_ILLEGALVEHICLEMOVE));
}
/* (non-Javadoc)

View File

@ -120,7 +120,7 @@ public class MovingUtil {
} else {
StaticLog.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them.");
}
CheckUtils.kickIllegalMove(player);
CheckUtils.kickIllegalMove(player, cc);
}
}

View File

@ -376,7 +376,7 @@ public class VehicleChecks extends CheckListener {
// TODO: Obviously applies under unknown conditions.
SetBackEntry newTo = data.vehicleSetBacks.getValidSafeMediumEntry();
if (newTo == null) {
recoverVehicleSetBack(player, vehicle, vehicleLocation, moveInfo, data);
recoverVehicleSetBack(player, vehicle, vehicleLocation, moveInfo, data, cc);
}
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().warning(Streams.STATUS, CheckUtils.getLogMessagePrefix(player, CheckType.MOVING_VEHICLE) + "Illegal coordinates on checkVehicleMove: from: " + from + " , to: " + to);
setBack(player, vehicle, newTo, data, cc);
@ -405,7 +405,8 @@ public class VehicleChecks extends CheckListener {
* @param data
*/
private void recoverVehicleSetBack(final Player player, final Entity vehicle,
final Location vehicleLocation, final VehicleMoveInfo moveInfo, final MovingData data) {
final Location vehicleLocation, final VehicleMoveInfo moveInfo,
final MovingData data, final MovingConfig cc) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().warning(Streams.STATUS, CheckUtils.getLogMessagePrefix(player, checkType) + "Illegal coordinates on vehicle moving: world: " + moveInfo.from.getWorldName() + " , from: " + LocUtil.simpleFormat(moveInfo.from) + " , to: " + LocUtil.simpleFormat(moveInfo.to));
// TODO: Kick for illegal moves?
if (moveInfo.from.hasIllegalCoords()) {
@ -415,7 +416,7 @@ public class VehicleChecks extends CheckListener {
// Can't recover vehicle coordinates.
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().warning(Streams.STATUS, CheckUtils.getLogMessagePrefix(player, checkType) + "Could not recover vehicle coordinates. Player will be kicked.");
// Just kick.
player.kickPlayer("Vehicle error.");
player.kickPlayer(cc.msgKickIllegalVehicleMove);
}
else {
// Better than nothing.

View File

@ -675,6 +675,10 @@ public abstract class ConfPaths {
public static final String MOVING_VEHICLE_ENVELOPE_HSPEEDCAP = MOVING_VEHICLE_ENVELOPE + "hdistcap"; // Section.
public static final String MOVING_VEHICLE_ENVELOPE_ACTIONS = MOVING_VEHICLE_ENVELOPE + "actions";
private static final String MOVING_MESSAGE = MOVING + "message.";
public static final String MOVING_MESSAGE_ILLEGALPLAYERMOVE = MOVING_MESSAGE + "illegalplayermove";
public static final String MOVING_MESSAGE_ILLEGALVEHICLEMOVE = MOVING_MESSAGE + "illegalvehiclemove";
public static final String NET = CHECKS + "net.";
private static final String NET_ATTACKFREQUENCY = NET + "attackfrequency.";

View File

@ -477,6 +477,10 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.MOVING_VEHICLE_ENVELOPE_ACTIVE, "default");
set(ConfPaths.MOVING_VEHICLE_ENVELOPE_ACTIONS, "cancel vl>100 cancel log:vehicleenvelope:0:15:icf");
// Messages
set(ConfPaths.MOVING_MESSAGE_ILLEGALPLAYERMOVE, "Illegal move.");
set(ConfPaths.MOVING_MESSAGE_ILLEGALVEHICLEMOVE, "Illegal vehicle move.");
// NET
// AttackFrequency

View File

@ -34,6 +34,7 @@ import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakData;
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
import fr.neatmonster.nocheatplus.checks.fight.FightData;
import fr.neatmonster.nocheatplus.checks.inventory.InventoryData;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
import fr.neatmonster.nocheatplus.hooks.APIUtils;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
@ -52,8 +53,8 @@ public class CheckUtils {
* Kick and log.
* @param player
*/
public static void kickIllegalMove(final Player player){
player.kickPlayer("Illegal move.");
public static void kickIllegalMove(final Player player, final MovingConfig cc){
player.kickPlayer(cc.msgKickIllegalMove);
StaticLog.logWarning("[NCP] Disconnect " + player.getName() + " due to illegal move!");
}