diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java index 2b76ac1a..d8cf35f8 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java @@ -1,7 +1,5 @@ package fr.neatmonster.nocheatplus.checks.moving; -import java.util.Map; - import org.bukkit.Location; import org.bukkit.entity.Player; @@ -73,17 +71,20 @@ public class MorePackets extends Check { // Player used up buffer, they fail the check. if (data.morePacketsBuffer < 0) { - data.morePacketsPackets = -data.morePacketsBuffer; - + // Increment violation level. data.morePacketsVL = -data.morePacketsBuffer; - + // Execute whatever actions are associated with this check and the violation level and find out if we should // cancel the event. - if (executeActions(player, data.morePacketsVL, -data.morePacketsBuffer, MovingConfig.getConfig(player).morePacketsActions)){ + final ViolationData vd = new ViolationData(this, player, data.morePacketsVL, -data.morePacketsBuffer, cc.morePacketsActions); + if (cc.debug || vd.needsParameters()) { + vd.setParameter(ParameterName.PACKETS, Integer.toString(-data.morePacketsBuffer)); + } + if (executeActions(vd)){ newTo = data.getMorePacketsSetBack(); } - + } if (data.morePacketsLastTime + 1000 < time) { @@ -111,7 +112,7 @@ public class MorePackets extends Check { } } else if (data.morePacketsLastTime > time) { // Security check, maybe system time changed. - data.morePacketsLastTime = time; + data.morePacketsLastTime = time; } if (newTo == null) { @@ -123,10 +124,4 @@ public class MorePackets extends Check { return new Location(player.getWorld(), newTo.getX(), newTo.getY(), newTo.getZ(), to.getYaw(), to.getPitch()); } - @Override - protected Map getParameterMap(final ViolationData violationData) { - final Map parameters = super.getParameterMap(violationData); - parameters.put(ParameterName.PACKETS, String.valueOf(MovingData.getData(violationData.player).morePacketsPackets)); - return parameters; - } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java index 2128a95f..b80178b1 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java @@ -1,7 +1,5 @@ package fr.neatmonster.nocheatplus.checks.moving; -import java.util.Map; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -70,14 +68,17 @@ public class MorePacketsVehicle extends Check { // Player used up buffer, they fail the check. if (data.morePacketsVehicleBuffer < 0) { - data.morePacketsVehiclePackets = -data.morePacketsVehicleBuffer; // Increment violation level. data.morePacketsVehicleVL = -data.morePacketsVehicleBuffer; // Execute whatever actions are associated with this check and the violation level and find out if we should // cancel the event. - if (executeActions(player, data.morePacketsVehicleVL, -data.morePacketsVehicleBuffer, cc.morePacketsVehicleActions)){ + final ViolationData vd = new ViolationData(this, player, data.morePacketsVehicleVL, -data.morePacketsVehicleBuffer, cc.morePacketsVehicleActions); + if (cc.debug || vd.needsParameters()) { + vd.setParameter(ParameterName.PACKETS, Integer.toString(-data.morePacketsVehicleBuffer)); + } + if (executeActions(vd)){ newTo = data.getMorePacketsVehicleSetBack(); } } @@ -91,34 +92,33 @@ public class MorePacketsVehicle extends Check { // If there was a long pause (maybe server lag?), allow buffer to grow up to 100. if (seconds > 2) { - if (data.morePacketsVehicleBuffer > 100) - data.morePacketsVehicleBuffer = 100; - } else if (data.morePacketsVehicleBuffer > 50) - // Only allow growth up to 50. + if (data.morePacketsVehicleBuffer > 100) { + data.morePacketsVehicleBuffer = 100; + } + } else if (data.morePacketsVehicleBuffer > 50) { + // Only allow growth up to 50. data.morePacketsVehicleBuffer = 50; - + } + // Set the new "last" time. data.morePacketsVehicleLastTime = time; // Set the new "setback" location. - if (newTo == null) - data.setMorePacketsVehicleSetBack(from); - } else if (data.morePacketsVehicleLastTime > time) - // Security check, maybe system time changed. + if (newTo == null) { + data.setMorePacketsVehicleSetBack(from); + } + } else if (data.morePacketsVehicleLastTime > time) { + // Security check, maybe system time changed. data.morePacketsVehicleLastTime = time; + } - if (newTo == null) - return null; + if (newTo == null) { + return null; + } // Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()" to allow the // player to look somewhere else despite getting pulled back by NoCheatPlus. return new Location(player.getWorld(), newTo.getX(), newTo.getY(), newTo.getZ(), to.getYaw(), to.getPitch()); } - @Override - protected Map getParameterMap(final ViolationData violationData) { - final Map parameters = super.getParameterMap(violationData); - parameters.put(ParameterName.PACKETS, String.valueOf(MovingData.getData(violationData.player).morePacketsVehiclePackets)); - return parameters; - } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index 8b51844e..3ed0e7e1 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -149,13 +149,11 @@ public class MovingData extends ACheckData { // Data of the more packets check. public int morePacketsBuffer = 50; public long morePacketsLastTime; - public int morePacketsPackets; private Location morePacketsSetback = null; // Data of the more packets vehicle check. public int morePacketsVehicleBuffer = 50; public long morePacketsVehicleLastTime; - public int morePacketsVehiclePackets; private Location morePacketsVehicleSetback = null; /** Task id of the morepackets set-back task. */ public int morePacketsVehicleTaskId = -1;