[API CHANGE] Add debug flags to check data [missing: use that one].

For debug output now data.debug is used instead of config.debug, so the
data is initialized with the config.debug value. As an effect of this,
removing the data or reloading will override flags that have been set by
means of API-access only.

Affected:
* Adds getDebug and setDebug to ICheckData.
* Adds appropriate configs to all constructors of check data.
* Some per-check debug flags have been removed.

Extras: 
* spaces
* import cleanup.
This commit is contained in:
asofold 2014-12-04 02:02:37 +01:00
parent a2e4db7c94
commit 04d2896f7e
37 changed files with 837 additions and 776 deletions

View File

@ -1,6 +1,5 @@
package fr.neatmonster.nocheatplus.utilities.ds.corw; package fr.neatmonster.nocheatplus.utilities.ds.corw;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;

View File

@ -11,7 +11,7 @@ import fr.neatmonster.nocheatplus.config.ConfigFile;
public abstract class ACheckConfig implements ICheckConfig { public abstract class ACheckConfig implements ICheckConfig {
/** For on the fly debug setting. */ /** For on the fly debug setting. */
public boolean debug = false; public boolean debug = false; // TODO: Might make private.
/** If to adapt to server side lag. */ /** If to adapt to server side lag. */
public final boolean lag; public final boolean lag;

View File

@ -7,6 +7,22 @@ package fr.neatmonster.nocheatplus.checks.access;
*/ */
public abstract class ACheckData implements ICheckData { public abstract class ACheckData implements ICheckData {
public boolean debug; // TODO: Might make private.
public ACheckData(ICheckConfig config) {
setDebug(config.getDebug());
}
@Override
public void setDebug(boolean debug) {
this.debug = debug;
}
@Override
public boolean getDebug() {
return debug;
}
@Override @Override
public boolean hasCachedPermissionEntry(String permission) { public boolean hasCachedPermissionEntry(String permission) {
return false; return false;

View File

@ -14,6 +14,10 @@ public abstract class AsyncCheckData extends ACheckData {
// TODO: consider using a PermissionEntry class with a timestamp to schedule renewing it. // TODO: consider using a PermissionEntry class with a timestamp to schedule renewing it.
// TODO: consider using a normal HashMap and ensure by contract that the permissions get filled at login, so updates are thread safe. // TODO: consider using a normal HashMap and ensure by contract that the permissions get filled at login, so updates are thread safe.
public AsyncCheckData(ICheckConfig config) {
super(config);
}
/** The permissions that are actually cached. */ /** The permissions that are actually cached. */
protected final Map<String, Boolean> cachedPermissions = Collections.synchronizedMap(new HashMap<String, Boolean>()); protected final Map<String, Boolean> cachedPermissions = Collections.synchronizedMap(new HashMap<String, Boolean>());

View File

@ -12,6 +12,19 @@ import fr.neatmonster.nocheatplus.components.IData;
*/ */
public interface ICheckData extends IData{ public interface ICheckData extends IData{
/**
* Set if to trace/debug this player for the associated checks.
* @param debug
*/
public void setDebug(boolean debug);
/**
* Test if to trace/debug this player for the associated checks.
* @return
*/
public boolean getDebug();
/** /**
* Check if an entry for the given permission exists. * Check if an entry for the given permission exists.
* @param permission * @param permission

View File

@ -58,7 +58,6 @@ public class BlockBreakConfig extends ACheckConfig {
public final boolean fastBreakCheck; public final boolean fastBreakCheck;
public final boolean fastBreakStrict; public final boolean fastBreakStrict;
public final boolean fastBreakDebug;
public final int fastBreakBuckets; public final int fastBreakBuckets;
public final long fastBreakBucketDur; public final long fastBreakBucketDur;
public final float fastBreakBucketFactor; public final float fastBreakBucketFactor;
@ -105,7 +104,6 @@ public class BlockBreakConfig extends ACheckConfig {
// Fastbreak. // Fastbreak.
fastBreakCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK); fastBreakCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK);
fastBreakStrict = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_STRICT); fastBreakStrict = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_STRICT);
fastBreakDebug = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false);
fastBreakDelay = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_DELAY); fastBreakDelay = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_DELAY);
fastBreakGrace = Math.max(data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION, 2000), data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_GRACE)); fastBreakGrace = Math.max(data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION, 2000), data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_GRACE));
fastBreakBucketDur = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_DUR, 4000); fastBreakBucketDur = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_DUR, 4000);

View File

@ -80,7 +80,7 @@ public class BlockBreakData extends ACheckData {
// TODO: use tick here too ? // TODO: use tick here too ?
public long wasInstaBreak; public long wasInstaBreak;
public final Timings stats; public Timings stats;
// Data of the fast break check. // Data of the fast break check.
public final ActionFrequency fastBreakPenalties; public final ActionFrequency fastBreakPenalties;
@ -101,12 +101,29 @@ public class BlockBreakData extends ACheckData {
public BlockBreakData(final BlockBreakConfig cc) { public BlockBreakData(final BlockBreakConfig cc) {
stats = cc.fastBreakDebug?(new Timings("NCP/FASTBREAK")):null; super(cc);
setStats();
fastBreakPenalties = new ActionFrequency(cc.fastBreakBuckets, cc.fastBreakBucketDur); fastBreakPenalties = new ActionFrequency(cc.fastBreakBuckets, cc.fastBreakBucketDur);
frequencyBuckets = new ActionFrequency(cc.frequencyBuckets, cc.frequencyBucketDur); frequencyBuckets = new ActionFrequency(cc.frequencyBuckets, cc.frequencyBucketDur);
wrongBlockVL = new ActionFrequency(6, 20000); wrongBlockVL = new ActionFrequency(6, 20000);
} }
@Override
public void setDebug(boolean debug) {
super.setDebug(debug);
setStats();
}
private void setStats() {
if (getDebug()) {
if (stats == null) {
stats = new Timings("NCP/FASTBREAK");
}
} else {
stats = null;
}
}
/** /**
* Meant to record the first click/damage on a block (not subsequent clicking), forces internals update. * Meant to record the first click/damage on a block (not subsequent clicking), forces internals update.
* @param block * @param block

View File

@ -103,7 +103,7 @@ public class FastBreak extends Check {
data.fastBreakVL *= 0.9D; data.fastBreakVL *= 0.9D;
} }
if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) { if ((data.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
// General stats: // General stats:
if (data.stats != null) { if (data.stats != null) {
data.stats.addStats(data.stats.getId(blockType+ "/u", true), elapsedTime); data.stats.addStats(data.stats.getId(blockType+ "/u", true), elapsedTime);

View File

@ -59,7 +59,7 @@ public class WrongBlock extends Check {
} }
if (wrongBlock) { if (wrongBlock) {
if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) { if ((data.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
player.sendMessage("WrongBlock failure with dist: " + dist); player.sendMessage("WrongBlock failure with dist: " + dist);
} }
data.wrongBlockVL.add(now, (float) (dist + 1) / 2f); data.wrongBlockVL.add(now, (float) (dist + 1) / 2f);

View File

@ -48,7 +48,7 @@ public class BlockInteractData extends ACheckData {
*/ */
public static BlockInteractData getData(final Player player) { public static BlockInteractData getData(final Player player) {
if (!playersMap.containsKey(player.getName())) if (!playersMap.containsKey(player.getName()))
playersMap.put(player.getName(), new BlockInteractData()); playersMap.put(player.getName(), new BlockInteractData(BlockInteractConfig.getConfig(player)));
return playersMap.get(player.getName()); return playersMap.get(player.getName());
} }
@ -83,6 +83,10 @@ public class BlockInteractData extends ACheckData {
/** Number of interactions since last reset-time. */ /** Number of interactions since last reset-time. */
public int speedCount = 0; public int speedCount = 0;
public BlockInteractData(final BlockInteractConfig config) {
super(config);
}
/** /**
* Last interacted block. * Last interacted block.
* @param block * @param block

View File

@ -42,7 +42,7 @@ public class Speed extends Check {
data.speedVL *= 0.99; data.speedVL *= 0.99;
} }
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if (data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
player.sendMessage("Interact speed: " + data.speedCount); player.sendMessage("Interact speed: " + data.speedCount);
} }

View File

@ -91,7 +91,7 @@ public class Visible extends Check {
blockCache.cleanup(); blockCache.cleanup();
} }
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if (data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
// TODO: Tags // TODO: Tags
player.sendMessage("Interact visible: " + (action == Action.RIGHT_CLICK_BLOCK ? "right" : "left") + " collide=" + rayTracing.collides()); player.sendMessage("Interact visible: " + (action == Action.RIGHT_CLICK_BLOCK ? "right" : "left") + " collide=" + rayTracing.collides());
} }

View File

@ -45,7 +45,7 @@ public class BlockPlaceData extends ACheckData {
*/ */
public static BlockPlaceData getData(final Player player) { public static BlockPlaceData getData(final Player player) {
if (!playersMap.containsKey(player.getName())) if (!playersMap.containsKey(player.getName()))
playersMap.put(player.getName(), new BlockPlaceData()); playersMap.put(player.getName(), new BlockPlaceData(BlockPlaceConfig.getConfig(player)));
return playersMap.get(player.getName()); return playersMap.get(player.getName());
} }
@ -85,4 +85,9 @@ public class BlockPlaceData extends ACheckData {
// Data of the speed check; // Data of the speed check;
public boolean speedLastRefused; public boolean speedLastRefused;
public long speedLastTime; public long speedLastTime;
public BlockPlaceData(final BlockPlaceConfig config) {
super (config);
}
} }

View File

@ -45,7 +45,7 @@ public class ChatData extends AsyncCheckData {
*/ */
public static synchronized ChatData getData(final Player player) { public static synchronized ChatData getData(final Player player) {
if (!playersMap.containsKey(player.getName())) if (!playersMap.containsKey(player.getName()))
playersMap.put(player.getName(), new ChatData()); playersMap.put(player.getName(), new ChatData(ChatConfig.getConfig(player)));
return playersMap.get(player.getName()); return playersMap.get(player.getName());
} }
@ -89,6 +89,10 @@ public class ChatData extends AsyncCheckData {
public int relogWarnings; public int relogWarnings;
public long relogWarningTime; public long relogWarningTime;
public ChatData(final ChatConfig config) {
super(config);
}
/** /**
* Clear the data of the no pwnage check. * Clear the data of the no pwnage check.
*/ */

View File

@ -115,7 +115,7 @@ public class Text extends Check implements INotifyReload {
boolean cancel = false; boolean cancel = false;
boolean debug = cc.textDebug || cc.debug; boolean debug = data.debug;
final List<String> debugParts; final List<String> debugParts;
if (debug) { if (debug) {

View File

@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
public class BedLeave extends Check { public class BedLeave extends Check {

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.access.ACheckData; import fr.neatmonster.nocheatplus.checks.access.ACheckData;
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory; import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
import fr.neatmonster.nocheatplus.checks.access.ICheckData; import fr.neatmonster.nocheatplus.checks.access.ICheckData;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.utilities.ActionFrequency; import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
import fr.neatmonster.nocheatplus.utilities.PenaltyTime; import fr.neatmonster.nocheatplus.utilities.PenaltyTime;
@ -38,7 +37,7 @@ public class CombinedData extends ACheckData {
final String playerName = player.getName(); final String playerName = player.getName();
CombinedData data = playersMap.get(playerName); CombinedData data = playersMap.get(playerName);
if (data == null){ if (data == null){
data = new CombinedData(player); data = new CombinedData(CombinedConfig.getConfig(player));
playersMap.put(playerName, data); playersMap.put(playerName, data);
} }
return data; return data;
@ -82,9 +81,8 @@ public class CombinedData extends ACheckData {
public long lastLogoutTime; public long lastLogoutTime;
public long lastMoveTime; public long lastMoveTime;
public CombinedData(final Player player){ public CombinedData(final CombinedConfig config){
// final CombinedConfig cc = CombinedConfig.getConfig(player); super(config);
// TODO: Get some things from the config.
} }
} }

View File

@ -43,7 +43,7 @@ public class Critical extends Check {
final double mcFallDistance = (double) player.getFallDistance(); final double mcFallDistance = (double) player.getFallDistance();
final MovingConfig mCc = MovingConfig.getConfig(player); final MovingConfig mCc = MovingConfig.getConfig(player);
// TODO: All debugging to the trace (later allow hooking your own trace). // TODO: All debugging to the trace (later allow hooking your own trace).
if (mcFallDistance > 0.0 && cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) { if (mcFallDistance > 0.0 && data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
final MovingData mData = MovingData.getData(player); final MovingData mData = MovingData.getData(player);
if (MovingListener.shouldCheckSurvivalFly(player, mData, mCc) && CheckType.MOVING_NOFALL.isEnabled(player)) { if (MovingListener.shouldCheckSurvivalFly(player, mData, mCc) && CheckType.MOVING_NOFALL.isEnabled(player)) {

View File

@ -46,7 +46,7 @@ public class FastHeal extends Check {
} }
} }
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if (data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
player.sendMessage("Regain health(SATIATED): " + (time - data.fastHealRefTime) + " ms "+ "(buffer=" + data.fastHealBuffer + ")" +" , cancel=" + cancel); player.sendMessage("Regain health(SATIATED): " + (time - data.fastHealRefTime) + " ms "+ "(buffer=" + data.fastHealBuffer + ")" +" , cancel=" + cancel);
} }

View File

@ -192,10 +192,11 @@ public class FightData extends ACheckData {
public int lastExplosionEntityId = Integer.MAX_VALUE; public int lastExplosionEntityId = Integer.MAX_VALUE;
public FightData(final FightConfig cc){ public FightData(final FightConfig config){
speedBuckets = new ActionFrequency(cc.speedBuckets, cc.speedBucketDur); super(config);
speedBuckets = new ActionFrequency(config.speedBuckets, config.speedBucketDur);
// Start with full fast-heal buffer. // Start with full fast-heal buffer.
fastHealBuffer = cc.fastHealBuffer; fastHealBuffer = config.fastHealBuffer;
} }
public void onWorldChange() { public void onWorldChange() {

View File

@ -158,7 +158,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// damagedPlayer.getLocation(useLoc2); // damagedPlayer.getLocation(useLoc2);
// } // }
// Log. // Log.
if (cc.debug && damagedPlayer.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if (data.debug && damagedPlayer.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
damagedPlayer.sendMessage("Attacked by " + player.getName() + ": inv=" + mcAccess.getInvulnerableTicks(damagedPlayer) + " ndt=" + damagedPlayer.getNoDamageTicks()); damagedPlayer.sendMessage("Attacked by " + player.getName() + ": inv=" + mcAccess.getInvulnerableTicks(damagedPlayer) + " ndt=" + damagedPlayer.getNoDamageTicks());
} }
// Check for self hit exploits (mind that projectiles are excluded from this.) // Check for self hit exploits (mind that projectiles are excluded from this.)
@ -266,7 +266,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
} }
// Angle check. // Angle check.
if (angle.check(player, worldChanged, data, cc)) { if (angle.check(player, worldChanged, data, cc)) {
if (!cancelled && cc.debug) { if (!cancelled && data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " fight.angle cancel without yawrate cancel."); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " fight.angle cancel without yawrate cancel.");
} }
cancelled = true; cancelled = true;
@ -298,7 +298,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// Judge as "lost sprint" problem. // Judge as "lost sprint" problem.
// TODO: What would mData.lostSprintCount > 0 mean here? // TODO: What would mData.lostSprintCount > 0 mean here?
mData.lostSprintCount = 7; mData.lostSprintCount = 7;
if ((cc.debug || mc.debug) && BuildParameters.debugLevel > 0){ if ((data.debug || mc.debug) && BuildParameters.debugLevel > 0){
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " (lostsprint) hDist to last from: " + hDist + " | targetdist=" + TrigUtil.distance(loc.getX(), loc.getZ(), damagedLoc.getX(), damagedLoc.getZ()) + " | sprinting=" + player.isSprinting() + " | food=" + player.getFoodLevel() +" | hbuf=" + mData.sfHorizontalBuffer); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " (lostsprint) hDist to last from: " + hDist + " | targetdist=" + TrigUtil.distance(loc.getX(), loc.getZ(), damagedLoc.getX(), damagedLoc.getZ()) + " | sprinting=" + player.isSprinting() + " | food=" + player.getFoodLevel() +" | hbuf=" + mData.sfHorizontalBuffer);
} }
} }
@ -310,7 +310,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// (Cancel after sprinting hacks, because of potential fp). // (Cancel after sprinting hacks, because of potential fp).
if (!cancelled && data.attackPenalty.isPenalty(now)) { if (!cancelled && data.attackPenalty.isPenalty(now)) {
cancelled = true; cancelled = true;
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " ~ attack penalty."); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " ~ attack penalty.");
} }
} }

View File

@ -128,7 +128,7 @@ public class Reach extends Check {
data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP); data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
} }
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if (data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
player.sendMessage("NC+: Attack/reach " + damaged.getType()+ " height="+ StringUtil.fdec3.format(height) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(reachMod)); player.sendMessage("NC+: Attack/reach " + damaged.getType()+ " height="+ StringUtil.fdec3.format(height) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(reachMod));
} }
@ -263,7 +263,7 @@ public class Reach extends Check {
data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP); data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
} }
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if (data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
player.sendMessage("NC+: Attack/reach " + damaged.getType()+ " height="+ StringUtil.fdec3.format(context.damagedHeight) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(data.reachMod)); player.sendMessage("NC+: Attack/reach " + damaged.getType()+ " height="+ StringUtil.fdec3.format(context.damagedHeight) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(data.reachMod));
} }

View File

@ -131,7 +131,7 @@ public class FastClick extends Check {
cancel = executeActions(vd); cancel = executeActions(vd);
} }
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if (data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
player.sendMessage("FastClick: " + data.fastClickFreq.bucketScore(0) + " | " + data.fastClickFreq.score(1f) + " | cursor=" + cursor + " | clicked=" + clicked); player.sendMessage("FastClick: " + data.fastClickFreq.bucketScore(0) + " | " + data.fastClickFreq.score(1f) + " | cursor=" + cursor + " | clicked=" + clicked);
} }

View File

@ -78,7 +78,7 @@ public class InstantBow extends Check {
} }
} }
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) { if (data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
player.sendMessage(ChatColor.YELLOW + "NCP: " + ChatColor.GRAY + "Bow shot - force: " + force +", " + (cc.instantBowStrict || pullDuration < 2 * expectedPullDuration ? ("pull time: " + pullDuration) : "") + "(" + expectedPullDuration +")"); player.sendMessage(ChatColor.YELLOW + "NCP: " + ChatColor.GRAY + "Bow shot - force: " + force +", " + (cc.instantBowStrict || pullDuration < 2 * expectedPullDuration ? ("pull time: " + pullDuration) : "") + "(" + expectedPullDuration +")");
} }

View File

@ -46,7 +46,7 @@ public class InventoryData extends ACheckData {
*/ */
public static InventoryData getData(final Player player) { public static InventoryData getData(final Player player) {
if (!playersMap.containsKey(player.getName())) if (!playersMap.containsKey(player.getName()))
playersMap.put(player.getName(), new InventoryData()); playersMap.put(player.getName(), new InventoryData(InventoryConfig.getConfig(player)));
return playersMap.get(player.getName()); return playersMap.get(player.getName());
} }
@ -87,4 +87,8 @@ public class InventoryData extends ACheckData {
public Material instantEatFood; public Material instantEatFood;
public long instantEatInteract; public long instantEatInteract;
public InventoryData(final InventoryConfig config) {
super(config);
}
} }

View File

@ -77,7 +77,7 @@ public class MorePackets extends Check {
// Violation handling. // Violation handling.
final ViolationData vd = new ViolationData(this, player, data.morePacketsVL, violation, cc.morePacketsActions); final ViolationData vd = new ViolationData(this, player, data.morePacketsVL, violation, cc.morePacketsActions);
if (cc.debug || vd.needsParameters()) { if (data.debug || vd.needsParameters()) {
vd.setParameter(ParameterName.PACKETS, Integer.toString(new Double(violation).intValue())); vd.setParameter(ParameterName.PACKETS, Integer.toString(new Double(violation).intValue()));
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+")); vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
} }

View File

@ -75,7 +75,7 @@ public class MorePacketsVehicle extends Check {
// Execute whatever actions are associated with this check and the violation level and find out if we should // Execute whatever actions are associated with this check and the violation level and find out if we should
// cancel the event. // cancel the event.
final ViolationData vd = new ViolationData(this, 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()) { if (data.debug || vd.needsParameters()) {
vd.setParameter(ParameterName.PACKETS, Integer.toString(-data.morePacketsVehicleBuffer)); vd.setParameter(ParameterName.PACKETS, Integer.toString(-data.morePacketsVehicleBuffer));
} }
if (executeActions(vd)){ if (executeActions(vd)){

View File

@ -80,6 +80,7 @@ public class MovingConfig extends ACheckConfig {
public final float morePacketsEPSIdeal; public final float morePacketsEPSIdeal;
/** The maximum number of packets per second that we accept. */ /** The maximum number of packets per second that we accept. */
public final float morePacketsEPSMax; public final float morePacketsEPSMax;
public final int morePacketsEPSBuckets;
public final float morePacketsBurstPackets; public final float morePacketsBurstPackets;
public final double morePacketsBurstDirect; public final double morePacketsBurstDirect;
public final double morePacketsBurstEPM; public final double morePacketsBurstEPM;
@ -175,6 +176,7 @@ public class MovingConfig extends ACheckConfig {
morePacketsCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK); morePacketsCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);
morePacketsEPSIdeal = config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL); morePacketsEPSIdeal = config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL);
morePacketsEPSMax = Math.max(morePacketsEPSIdeal, config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSMAX)); morePacketsEPSMax = Math.max(morePacketsEPSIdeal, config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSMAX));
morePacketsEPSBuckets = 2 * Math.max(1, Math.min(60, config.getInt(ConfPaths.MOVING_MOREPACKETS_SECONDS)));
morePacketsBurstPackets = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM); morePacketsBurstPackets = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM);
morePacketsBurstDirect = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT); morePacketsBurstDirect = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT);
morePacketsBurstEPM = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM); morePacketsBurstEPM = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM);

View File

@ -10,9 +10,6 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.access.ACheckData; import fr.neatmonster.nocheatplus.checks.access.ACheckData;
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory; import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
import fr.neatmonster.nocheatplus.checks.access.ICheckData; import fr.neatmonster.nocheatplus.checks.access.ICheckData;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.utilities.ActionAccumulator; import fr.neatmonster.nocheatplus.utilities.ActionAccumulator;
import fr.neatmonster.nocheatplus.utilities.ActionFrequency; import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation; import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
@ -61,7 +58,7 @@ public class MovingData extends ACheckData {
// Note that the trace might be null after just calling this. // Note that the trace might be null after just calling this.
MovingData data = playersMap.get(player.getName()); MovingData data = playersMap.get(player.getName());
if (data == null) { if (data == null) {
data = new MovingData(ConfigManager.getConfigFile(player.getWorld().getName())); data = new MovingData(MovingConfig.getConfig(player));
playersMap.put(player.getName(), data); playersMap.put(player.getName(), data);
} }
return data; return data;
@ -209,10 +206,9 @@ public class MovingData extends ACheckData {
public boolean wasInVehicle = false; public boolean wasInVehicle = false;
public MoveConsistency vehicleConsistency = MoveConsistency.INCONSISTENT; public MoveConsistency vehicleConsistency = MoveConsistency.INCONSISTENT;
public MovingData(final ConfigFile config) { public MovingData(final MovingConfig config) {
// TODO: Parameters from cc. super(config);
final int nob = 2 * Math.max(1, Math.min(60, config.getInt(ConfPaths.MOVING_MOREPACKETS_SECONDS))); morePacketsFreq = new ActionFrequency(config.morePacketsEPSBuckets, 500);
morePacketsFreq = new ActionFrequency(nob, 500);
morePacketsBurstFreq = new ActionFrequency(12, 5000); morePacketsBurstFreq = new ActionFrequency(12, 5000);
} }

View File

@ -447,7 +447,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
data.noFallAssumeGround = false; data.noFallAssumeGround = false;
data.resetTeleported(); data.resetTeleported();
// Debug. // Debug.
if (cc.debug) { if (data.debug) {
DebugUtil.outputMoveDebug(player, moveInfo.from, moveInfo.to, Math.max(cc.noFallyOnGround, cc.yOnGround), mcAccess); DebugUtil.outputMoveDebug(player, moveInfo.from, moveInfo.to, Math.max(cc.noFallyOnGround, cc.yOnGround), mcAccess);
} }
// Check for illegal move and bounding box etc. // Check for illegal move and bounding box etc.
@ -694,7 +694,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
event.setTo(newTo); event.setTo(newTo);
// Debug. // Debug.
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " set back to: " + newTo.getWorld() + StringUtil.fdec3.format(newTo.getX()) + ", " + StringUtil.fdec3.format(newTo.getY()) + ", " + StringUtil.fdec3.format(newTo.getZ())); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " set back to: " + newTo.getWorld() + StringUtil.fdec3.format(newTo.getX()) + ", " + StringUtil.fdec3.format(newTo.getY()) + ", " + StringUtil.fdec3.format(newTo.getZ()));
} }
} }
@ -747,7 +747,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
* @param cc * @param cc
*/ */
private void onVehicleLeaveMiss(final Player player, final MovingData data, final MovingConfig cc) { private void onVehicleLeaveMiss(final Player player, final MovingData data, final MovingConfig cc) {
if (cc.debug) { if (data.debug) {
StaticLog.logWarning("[NoCheatPlus] VehicleExitEvent missing for: " + player.getName()); StaticLog.logWarning("[NoCheatPlus] VehicleExitEvent missing for: " + player.getName());
} }
onPlayerVehicleLeave(player, null); onPlayerVehicleLeave(player, null);
@ -981,7 +981,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
data.sfHoverTicks = -1; // Important against concurrent modification exception. data.sfHoverTicks = -1; // Important against concurrent modification exception.
} }
if (cc.debug && BuildParameters.debugLevel > 0) { if (data.debug && BuildParameters.debugLevel > 0) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " TP" + (smallRange ? " (small-range)" : "") + (cancel ? " (cancelled)" : "") + ": " + to); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " TP" + (smallRange ? " (small-range)" : "") + (cancel ? " (cancelled)" : "") + ": " + to);
} }
} }
@ -989,7 +989,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Cancelled, not a set back, ignore it, basically. // Cancelled, not a set back, ignore it, basically.
// Better reset teleported (compatibility). Might have drawbacks. // Better reset teleported (compatibility). Might have drawbacks.
data.resetTeleported(); data.resetTeleported();
if (cc.debug && BuildParameters.debugLevel > 0) { if (data.debug && BuildParameters.debugLevel > 0) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " TP (cancelled): " + to); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " TP (cancelled): " + to);
} }
return; return;
@ -1028,7 +1028,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final Vector velocity = event.getVelocity(); final Vector velocity = event.getVelocity();
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, event.getPlayer().getName() + " new velocity: " + velocity); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, event.getPlayer().getName() + " new velocity: " + velocity);
} }
@ -1128,7 +1128,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
data.clearNoFallData(); data.clearNoFallData();
} }
if (cc.debug) { if (data.debug) {
// Log move. // Log move.
DebugUtil.outputDebugVehicleMove(player, vehicle, from, to, fake); DebugUtil.outputDebugVehicleMove(player, vehicle, from, to, fake);
} }
@ -1149,7 +1149,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// TODO: Might log debug if skipping. // TODO: Might log debug if skipping.
// TODO: Problem: scheduling allows a lot of things to happen until the task is run. Thus control about some things might be necessary. // TODO: Problem: scheduling allows a lot of things to happen until the task is run. Thus control about some things might be necessary.
// TODO: Reset on world changes or not? // TODO: Reset on world changes or not?
data.morePacketsVehicleTaskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new VehicleSetBack(vehicle, player, newTo, cc.debug)); data.morePacketsVehicleTaskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new VehicleSetBack(vehicle, player, newTo, data.debug));
} }
useLoc.setWorld(null); useLoc.setWorld(null);
} }
@ -1213,7 +1213,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final float fallDistance = player.getFallDistance(); final float fallDistance = player.getFallDistance();
final double damage = BridgeHealth.getDamage(event); final double damage = BridgeHealth.getDamage(event);
final float yDiff = (float) (data.noFallMaxY - loc.getY()); final float yDiff = (float) (data.noFallMaxY - loc.getY());
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " damage(FALL): " + damage + " / dist=" + player.getFallDistance() + " nf=" + data.noFallFallDistance + " yDiff=" + yDiff); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " damage(FALL): " + damage + " / dist=" + player.getFallDistance() + " nf=" + data.noFallFallDistance + " yDiff=" + yDiff);
} }
// Fall-back check. // Fall-back check.
@ -1221,7 +1221,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
if (maxD > damage) { if (maxD > damage) {
// TODO: respect dealDamage ? // TODO: respect dealDamage ?
BridgeHealth.setDamage(event, maxD); BridgeHealth.setDamage(event, maxD);
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Adjust fall damage to: " + maxD); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Adjust fall damage to: " + maxD);
} }
} }
@ -1286,7 +1286,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Check loaded chunks. // Check loaded chunks.
if (cc.loadChunksOnJoin) { if (cc.loadChunksOnJoin) {
final int loaded = BlockCache.ensureChunksLoaded(loc.getWorld(), loc.getX(), loc.getZ(), 3.0); final int loaded = BlockCache.ensureChunksLoaded(loc.getWorld(), loc.getX(), loc.getZ(), 3.0);
if (loaded > 0 && cc.debug && BuildParameters.debugLevel > 0) { if (loaded > 0 && data.debug && BuildParameters.debugLevel > 0) {
// DEBUG // DEBUG
StaticLog.logInfo("[NoCheatPlus] Player join: Loaded " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " for player: " + player.getName()); StaticLog.logInfo("[NoCheatPlus] Player join: Loaded " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " for player: " + player.getName());
} }
@ -1354,11 +1354,10 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
@Override @Override
public void playerLeaves(final Player player) { public void playerLeaves(final Player player) {
final MovingConfig cc = MovingConfig.getConfig(player);
final MovingData data = MovingData.getData(player); final MovingData data = MovingData.getData(player);
final Location loc = player.getLocation(useLoc); final Location loc = player.getLocation(useLoc);
// Debug logout. // Debug logout.
if (cc.debug) { if (data.debug) {
StaticLog.logInfo("[NoCheatPlus] Player " + player.getName() + " leaves at location: " + loc.toString()); StaticLog.logInfo("[NoCheatPlus] Player " + player.getName() + " leaves at location: " + loc.toString());
} }
if (!player.isSleeping() && !player.isDead()) { if (!player.isSleeping() && !player.isDead()) {
@ -1487,7 +1486,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
} }
} }
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " vehicle leave: " + vehicle.getType() + "@" + pLoc.distance(vLoc)); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " vehicle leave: " + vehicle.getType() + "@" + pLoc.distance(vLoc));
} }
} }
@ -1497,7 +1496,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
loc.setY(Location.locToBlock(loc.getY()) + 1.25); loc.setY(Location.locToBlock(loc.getY()) + 1.25);
} }
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " vehicle leave: " + pLoc.toString() + (pLoc.equals(loc) ? "" : " / player at: " + pLoc.toString())); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " vehicle leave: " + pLoc.toString() + (pLoc.equals(loc) ? "" : " / player at: " + pLoc.toString()));
} }
data.resetPositions(loc); data.resetPositions(loc);
@ -1642,7 +1641,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final boolean res; final boolean res;
// TODO: Collect flags, more margin ? // TODO: Collect flags, more margin ?
final int loaded = info.from.ensureChunksLoaded(); final int loaded = info.from.ensureChunksLoaded();
if (loaded > 0 && cc.debug && BuildParameters.debugLevel > 0) { if (loaded > 0 && data.debug && BuildParameters.debugLevel > 0) {
// DEBUG // DEBUG
StaticLog.logInfo("[NoCheatPlus] Hover check: Needed to load " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " around " + loc.getBlockX() + "," + loc.getBlockZ() + " in order to check player: " + player.getName()); StaticLog.logInfo("[NoCheatPlus] Hover check: Needed to load " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " around " + loc.getBlockX() + "," + loc.getBlockZ() + " in order to check player: " + player.getName());
} }

View File

@ -53,7 +53,7 @@ public class NoFall extends Check {
if (maxD >= 1.0){ if (maxD >= 1.0){
// Damage to be dealt. // Damage to be dealt.
// TODO: more effects like sounds, maybe use custom event with violation added. // TODO: more effects like sounds, maybe use custom event with violation added.
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " NoFall deal damage" + (reallyOnGround ? "" : "violation") + ": " + maxD); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " NoFall deal damage" + (reallyOnGround ? "" : "violation") + ": " + maxD);
} }
// TODO: might not be necessary: if (mcPlayer.invulnerableTicks <= 0) [no damage event for resetting] // TODO: might not be necessary: if (mcPlayer.invulnerableTicks <= 0) [no damage event for resetting]
@ -173,7 +173,7 @@ public class NoFall extends Check {
else if (cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){ else if (cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){
final double max = Math.max(data.noFallFallDistance, mcFallDistance); final double max = Math.max(data.noFallFallDistance, mcFallDistance);
if (max > 0.0 && max < 0.75){ // (Ensure this does not conflict with deal-damage set to false.) if (max > 0.0 && max < 0.75){ // (Ensure this does not conflict with deal-damage set to false.)
if (cc.debug){ if (data.debug){
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " NoFall: Reset fall distance (anticriticals): mc=" + mcFallDistance +" / nf=" + data.noFallFallDistance); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " NoFall: Reset fall distance (anticriticals): mc=" + mcFallDistance +" / nf=" + data.noFallFallDistance);
} }
if (data.noFallFallDistance > 0){ if (data.noFallFallDistance > 0){
@ -185,7 +185,7 @@ public class NoFall extends Check {
} }
} }
if (cc.debug){ if (data.debug){
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " NoFall: mc=" + mcFallDistance +" / nf=" + data.noFallFallDistance + (oldNFDist < data.noFallFallDistance ? " (+" + (data.noFallFallDistance - oldNFDist) + ")" : "") + " | ymax=" + data.noFallMaxY); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " NoFall: mc=" + mcFallDistance +" / nf=" + data.noFallFallDistance + (oldNFDist < data.noFallFallDistance ? " (+" + (data.noFallFallDistance - oldNFDist) + ")" : "") + " | ymax=" + data.noFallMaxY);
} }

View File

@ -57,7 +57,7 @@ public class Passable extends Check {
toPassable = false; toPassable = false;
tags = "raytracing_2x_"; tags = "raytracing_2x_";
} }
else if (cc.debug) { else if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " passable: allow moving out of a block."); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " passable: allow moving out of a block.");
} }
} }
@ -148,10 +148,10 @@ public class Passable extends Check {
if (BlockProperties.isPassable(from.getBlockCache(), ref) || loc == null || TrigUtil.distance(from, loc) > 0.13) { if (BlockProperties.isPassable(from.getBlockCache(), ref) || loc == null || TrigUtil.distance(from, loc) > 0.13) {
// if (BlockProperties.isPassableExact(from.getBlockCache(), ref)) { // if (BlockProperties.isPassableExact(from.getBlockCache(), ref)) {
loc = ref; loc = ref;
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Using set-back location for passable."); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Using set-back location for passable.");
} }
} else if (cc.debug) { } else if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Ignoring set-back for passable."); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Ignoring set-back for passable.");
} }
} }
@ -161,7 +161,7 @@ public class Passable extends Check {
// Return the reset position. // Return the reset position.
data.passableVL += 1d; data.passableVL += 1d;
final ViolationData vd = new ViolationData(this, player, data.passableVL, 1, cc.passableActions); final ViolationData vd = new ViolationData(this, player, data.passableVL, 1, cc.passableActions);
if (cc.debug || vd.needsParameters()) { if (data.debug || vd.needsParameters()) {
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ())); vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ())); vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", TrigUtil.distance(from, to))); vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", TrigUtil.distance(from, to)));
@ -179,7 +179,7 @@ public class Passable extends Check {
newTo = LocUtil.clone(loc); newTo = LocUtil.clone(loc);
} else { } else {
newTo = from.getLocation(); newTo = from.getLocation();
if (cc.debug) { if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Using from location for passable."); NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Using from location for passable.");
} }
} }

View File

@ -261,7 +261,7 @@ public class SurvivalFly extends Check {
vDistanceAboveLimit = res[1]; vDistanceAboveLimit = res[1];
if (res[0] == Double.MIN_VALUE && res[1] == Double.MIN_VALUE) { if (res[0] == Double.MIN_VALUE && res[1] == Double.MIN_VALUE) {
// Silent set-back. // Silent set-back.
if (cc.debug) { if (data.debug) {
tags.add("silentsbcobweb"); tags.add("silentsbcobweb");
outputDebug(player, to, data, cc, hDistance, hAllowedDistance, hFreedom, yDistance, vAllowedDistance, fromOnGround, resetFrom, toOnGround, resetTo); outputDebug(player, to, data, cc, hDistance, hAllowedDistance, hFreedom, yDistance, vAllowedDistance, fromOnGround, resetFrom, toOnGround, resetTo);
} }
@ -357,7 +357,7 @@ public class SurvivalFly extends Check {
// TODO: on ground -> on ground improvements // TODO: on ground -> on ground improvements
// Debug output. // Debug output.
if (cc.debug) { if (data.debug) {
outputDebug(player, to, data, cc, hDistance, hAllowedDistance, hFreedom, yDistance, vAllowedDistance, fromOnGround, resetFrom, toOnGround, resetTo); outputDebug(player, to, data, cc, hDistance, hAllowedDistance, hFreedom, yDistance, vAllowedDistance, fromOnGround, resetFrom, toOnGround, resetTo);
} }
@ -522,6 +522,7 @@ public class SurvivalFly extends Check {
// TODO: too many false positives with just checking from ? // TODO: too many false positives with just checking from ?
// TODO: Sneaking and blocking applies to when in water ! // TODO: Sneaking and blocking applies to when in water !
hAllowedDistance = modSwim * walkSpeed * cc.survivalFlySwimmingSpeed / 100D; hAllowedDistance = modSwim * walkSpeed * cc.survivalFlySwimmingSpeed / 100D;
// TODO: Depth strider.
} else if (!sfDirty && player.isSneaking() && reallySneaking.contains(player.getName()) && (!checkPermissions || !player.hasPermission(Permissions.MOVING_SURVIVALFLY_SNEAKING))) { } else if (!sfDirty && player.isSneaking() && reallySneaking.contains(player.getName()) && (!checkPermissions || !player.hasPermission(Permissions.MOVING_SURVIVALFLY_SNEAKING))) {
hAllowedDistance = modSneak * walkSpeed * cc.survivalFlySneakingSpeed / 100D; hAllowedDistance = modSneak * walkSpeed * cc.survivalFlySneakingSpeed / 100D;
} }
@ -545,8 +546,10 @@ public class SurvivalFly extends Check {
} }
// Short cut. // Short cut.
// TODO: Check if a) early return makes sense and b) do it ofr all following parts. // TODO: Check if a) early return makes sense and b) do it for each of the following parts.
if (hDistance <= hAllowedDistance && !cc.debug) { // TODO: Should debug really make a difference? Do early return before permission check only?
// TODO: Consider logging early vs. full.
if (hDistance <= hAllowedDistance && !data.debug) {
// Shortcut for debug disabled. // Shortcut for debug disabled.
return hAllowedDistance; return hAllowedDistance;
} }
@ -556,6 +559,8 @@ public class SurvivalFly extends Check {
hAllowedDistance *= modIce; hAllowedDistance *= modIce;
} }
// TODO: Attributes
// Speed amplifier. // Speed amplifier.
final double speedAmplifier = mcAccess.getFasterMovementAmplifier(player); final double speedAmplifier = mcAccess.getFasterMovementAmplifier(player);
if (speedAmplifier != Double.NEGATIVE_INFINITY) { if (speedAmplifier != Double.NEGATIVE_INFINITY) {

View File

@ -4,7 +4,6 @@ import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.command.AbstractCommand; import fr.neatmonster.nocheatplus.command.AbstractCommand;

View File

@ -6,7 +6,6 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.NCPAPIProvider; import fr.neatmonster.nocheatplus.NCPAPIProvider;
@ -15,8 +14,6 @@ import fr.neatmonster.nocheatplus.command.BaseCommand;
import fr.neatmonster.nocheatplus.command.NoCheatPlusCommand.NCPReloadEvent; import fr.neatmonster.nocheatplus.command.NoCheatPlusCommand.NCPReloadEvent;
import fr.neatmonster.nocheatplus.components.INotifyReload; import fr.neatmonster.nocheatplus.components.INotifyReload;
import fr.neatmonster.nocheatplus.components.order.Order; import fr.neatmonster.nocheatplus.components.order.Order;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager; import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.LogManager; import fr.neatmonster.nocheatplus.logging.LogManager;
import fr.neatmonster.nocheatplus.logging.Streams; import fr.neatmonster.nocheatplus.logging.Streams;

View File

@ -116,7 +116,6 @@ public abstract class ConfPaths {
private static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + "fastbreak."; private static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + "fastbreak.";
public static final String BLOCKBREAK_FASTBREAK_CHECK = BLOCKBREAK_FASTBREAK + "active"; public static final String BLOCKBREAK_FASTBREAK_CHECK = BLOCKBREAK_FASTBREAK + "active";
public static final String BLOCKBREAK_FASTBREAK_STRICT = BLOCKBREAK_FASTBREAK + "strict"; public static final String BLOCKBREAK_FASTBREAK_STRICT = BLOCKBREAK_FASTBREAK + "strict";
public static final String BLOCKBREAK_FASTBREAK_DEBUG = BLOCKBREAK_FASTBREAK + "debug";
private static final String BLOCKBREAK_FASTBREAK_BUCKETS = BLOCKBREAK + "buckets."; private static final String BLOCKBREAK_FASTBREAK_BUCKETS = BLOCKBREAK + "buckets.";
public static final String BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION = BLOCKBREAK_FASTBREAK_BUCKETS + "contention"; public static final String BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION = BLOCKBREAK_FASTBREAK_BUCKETS + "contention";
@GlobalConfig @GlobalConfig
@ -643,6 +642,8 @@ public abstract class ConfPaths {
public static final String MOVING_PASSABLE_RAYTRACING_VCLIPONLY = "checks.moving.passable.raytracing.vcliponly"; public static final String MOVING_PASSABLE_RAYTRACING_VCLIPONLY = "checks.moving.passable.raytracing.vcliponly";
@Deprecated @Deprecated
public static final String FIGHT_CRITICAL_VELOCITY = "checks.fight.critical.velocity"; public static final String FIGHT_CRITICAL_VELOCITY = "checks.fight.critical.velocity";
@Deprecated
public static final String BLOCKBREAK_FASTBREAK_DEBUG = "checks.blockbreak.fastbreak.debug";
} }

View File

@ -1034,7 +1034,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// Debug information about unknown blocks. // Debug information about unknown blocks.
// (Probably removed later.) // (Probably removed later.)
ConfigFile config = ConfigManager.getConfigFile(); ConfigFile config = ConfigManager.getConfigFile();
BlockProperties.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, config.getBoolean(ConfPaths.BLOCKBREAK_DEBUG, config.getBoolean(ConfPaths.CHECKS_DEBUG, false)))); BlockProperties.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_DEBUG, config.getBoolean(ConfPaths.CHECKS_DEBUG, false)));
} }
}); });
} }