[BREAKING] Group several classes into sub packages for moving. Renames.

* Group selected classes into sub-packages of moving.
* Rename classes.
* Must use LinkedList for velocity entries.
* Prepare SimpleAxisVelocity + entry for use-once accounting.

(Might not be the final naming.)
This commit is contained in:
asofold 2015-09-13 13:05:10 +02:00
parent 122e0727b8
commit b2caae38d2
25 changed files with 259 additions and 102 deletions

View File

@ -19,7 +19,7 @@ import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.CheckListener;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingUtil;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.command.CommandUtil;
import fr.neatmonster.nocheatplus.components.INotifyReload;
import fr.neatmonster.nocheatplus.components.JoinLeaveListener;

View File

@ -11,10 +11,10 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.moving.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.MovingUtil;
import fr.neatmonster.nocheatplus.checks.moving.model.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.StringUtil;

View File

@ -7,7 +7,7 @@ import org.bukkit.util.Vector;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.utilities.TrigUtil;
/**

View File

@ -27,12 +27,12 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.combined.Combined;
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
import fr.neatmonster.nocheatplus.checks.inventory.Items;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.model.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.MovingUtil;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
import fr.neatmonster.nocheatplus.components.JoinLeaveListener;
import fr.neatmonster.nocheatplus.logging.Streams;

View File

@ -12,7 +12,7 @@ import org.bukkit.util.Vector;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
import fr.neatmonster.nocheatplus.utilities.TickTask;

View File

@ -11,6 +11,7 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.moving.model.ModelFlying;
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;

View File

@ -12,6 +12,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.access.ACheckConfig;
import fr.neatmonster.nocheatplus.checks.access.CheckConfigFactory;
import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
import fr.neatmonster.nocheatplus.checks.moving.model.ModelFlying;
import fr.neatmonster.nocheatplus.command.CommandUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.versions.Bugs;

View File

@ -11,6 +11,12 @@ import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.access.ACheckData;
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocUtil;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace;
import fr.neatmonster.nocheatplus.checks.moving.model.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.model.MoveConsistency;
import fr.neatmonster.nocheatplus.checks.moving.velocity.FrictionAxisVelocity;
import fr.neatmonster.nocheatplus.checks.moving.velocity.AccountEntry;
import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.utilities.ActionAccumulator;
import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
@ -119,14 +125,14 @@ public class MovingData extends ACheckData {
// Velocity handling.
// TODO: consider resetting these with clearFlyData and onSetBack.
/** Vertical velocity modeled as an axis (positive and negative possible) */
//private final AxisVelocity verVel = new AxisVelocity();
//private final FrictionAxisVelocity verVel = new FrictionAxisVelocity();
private int verticalVelocityCounter;
private double verticalFreedom;
private double verticalVelocity;
private int verticalVelocityUsed = 0;
/** Horizontal velocity modeled as an axis (always positive) */
private final AxisVelocity horVel = new AxisVelocity();
private final FrictionAxisVelocity horVel = new FrictionAxisVelocity();
// Coordinates.
/** Last from coordinates. X is at Double.MAX_VALUE, if not set. */
@ -567,7 +573,7 @@ public class MovingData extends ACheckData {
* Add horizontal velocity (distance). <br>
* @param vel Assumes positive values always.
*/
public void addHorizontalVelocity(final Velocity vel) {
public void addHorizontalVelocity(final AccountEntry vel) {
horVel.add(vel);
}
@ -880,7 +886,7 @@ public class MovingData extends ACheckData {
if (vx != 0.0 || vz != 0.0) {
final double newVal = Math.sqrt(vx * vx + vz * vz);
used = true;
final Velocity vel = new Velocity(tick, newVal, cc.velocityActivationCounter, Math.max(20, 1 + (int) Math.round(newVal * 10.0)));
final AccountEntry vel = new AccountEntry(tick, newVal, cc.velocityActivationCounter, Math.max(20, 1 + (int) Math.round(newVal * 10.0)));
addHorizontalVelocity(vel);
}

View File

@ -51,6 +51,13 @@ import fr.neatmonster.nocheatplus.checks.combined.BedLeave;
import fr.neatmonster.nocheatplus.checks.combined.Combined;
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocUtil;
import fr.neatmonster.nocheatplus.checks.moving.locations.MoveInfo;
import fr.neatmonster.nocheatplus.checks.moving.locations.VehicleSetBack;
import fr.neatmonster.nocheatplus.checks.moving.model.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.model.MoveConsistency;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.checks.moving.velocity.AccountEntry;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
import fr.neatmonster.nocheatplus.components.IData;
@ -1525,7 +1532,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
data.setSetBack(loc);
// Give some freedom to allow the "exiting move".
data.removeAllVelocity();
data.addHorizontalVelocity(new Velocity(0.9, 1, 1));
data.addHorizontalVelocity(new AccountEntry(0.9, 1, 1));
data.fakeVerticalFreedom(0.15, 1.2, 1);
useLoc.setWorld(null);
}

View File

@ -10,6 +10,7 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocUtil;
import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.PassableRayTracing;

View File

@ -15,6 +15,8 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.moving.model.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.compat.BridgeEnchant;
import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.permissions.Permissions;
@ -837,43 +839,30 @@ public class SurvivalFly extends Check {
* @return A violation value > 0.001, to be interpreted like a moving violation.
*/
private static final double verticalAccounting(final double yDistance, final ActionAccumulator acc, final ArrayList<String> tags, final String tag) {
// TODO: distinguish near-ground moves somehow ?
// Determine which buckets to check:
// TODO: One state is checked 3 times vs. different yDiff !?
final int i1, i2;
// TODO: use 1st vs. 2nd whenever possible (!) (logics might need to distinguish falling from other ?...).
// if (acc.bucketCount(0) == acc.bucketCapacity() &&) {
// i1 = 0;
// i2 = 1;
// }
// else {
i1 = 1;
i2 = 2;
// }
// TODO: One move earlier: count first vs. second once first is full.
// TODO: Can all three be related if first one is full ?
if (acc.bucketCount(i1) > 0 && acc.bucketCount(i2) > 0) {
final float sc1 = acc.bucketScore(i1);
final float sc2 = acc.bucketScore(i2);
final double diff = sc1 - sc2;
final double aDiff = Math.abs(diff);
// TODO: Relate this to the fall distance !
// TODO: sharpen later.
if (diff >= 0.0 || yDistance > -1.05 && aDiff < 0.0625) {
// TODO: check vs. sc1 !
if (yDistance <= -1.05 && sc2 < -10.0 && sc1 < -10.0) { // (aDiff < Math.abs(yDistance) || sc2 < - 10.0f)) {
// High falling speeds may pass.
// TODO: high falling speeds may pass within some bounds (!).
tags.add(tag + "grace");
return 0.0;
// TODO: Add air friction and do it per move anyway !?
final int count0 = acc.bucketCount(0);
if (count0 > 0) {
final int count1 = acc.bucketCount(1);
if (count1 > 0) {
final int cap = acc.bucketCapacity();
final float minAmount = 0.0625f;
final float sc0;
if (count0 == cap) {
sc0 = acc.bucketScore(0);
} else {
// Catch extreme changes quick.
sc0 = acc.bucketScore(0) * (float) cap / (float) count0 - minAmount * (float) (cap - count0);
}
tags.add(tag); // Specific tags?
if (diff < 0.0 ) {
// Note: aDiff should be < 0.0625 here.
return Math.max(Math.abs(-0.0625 - diff), 0.001);
}
else {
return 0.0625 + diff;
final float sc1 = acc.bucketScore(1);
if (sc0 > sc1 - 3.0 * minAmount) {
// TODO: Velocity downwards fails here !!!
if (yDistance <= -1.05 && sc1 < -8.0 && sc0 < -8.0) { // (aDiff < Math.abs(yDistance) || sc2 < - 10.0f)) {
// High falling speeds may pass.
tags.add(tag + "grace");
return 0.0;
}
tags.add(tag);
return sc0 - (sc1 - 3.0 * minAmount);
}
}
}

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.locations;
import org.bukkit.Location;
import org.bukkit.World;

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.locations;
import java.util.Iterator;

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.locations;
import org.bukkit.Location;
import org.bukkit.entity.Player;

View File

@ -1,9 +1,10 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.locations;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.TeleportUtil;

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.model;
/**
* This is for tracking what medium a player has been in before lift-off.

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.model;
import org.bukkit.configuration.ConfigurationSection;

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.model;
import org.bukkit.Location;

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.util;
import org.bukkit.Chunk;
import org.bukkit.GameMode;
@ -11,6 +11,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.logging.StaticLog;

View File

@ -1,14 +1,16 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.velocity;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/**
* One entry of velocity for a player. Might be used per axis or for horizontal/vertical.
* One entry of velocity for a player, including fields for maintaining margins
* and effects per entry.
*
* @author mc_dev
*
*/
public class Velocity {
public class AccountEntry {
/** Tick at which velocity got added. */
public final int tick;
@ -16,17 +18,17 @@ public class Velocity {
/** The amount of velocity, decreasing with use. */
public double value;
/** "Some sum" for general purpose.
* <li> For vertical entries this is used to alter the allowed y-distance to the set-back point. </li>
/**
* "Some sum" for general purpose. <li>For vertical entries this is used to
* alter the allowed y-distance to the set-back point.</li>
*/
public double sum;
public double sum = 0.0;
///////////////////////////
// Activation conditions.
///////////////////////////
// TODO: Add more conditions (ticks, ?real time)
// TODO: Add more conditions (max tick, real time?)
/**
* Maximum count before activation.
@ -37,41 +39,29 @@ public class Velocity {
// Invalidation conditions.
///////////////////////////
// TODO: Add more conditions (ticks, ?real time)
// TODO: Add more conditions (max tick, real time?)
/**
* Count .
*/
public int valCount;
public Velocity(double value, int actCount, int valCount){
public AccountEntry(double value, int actCount, int valCount){
this.tick = TickTask.getTick();
this.value = value;
this.actCount = actCount;
this.valCount = valCount;
}
public Velocity(int tick, double value, int actCount, int valCount){
public AccountEntry(int tick, double value, int actCount, int valCount){
this.tick = tick;
this.value = value;
this.actCount = actCount;
this.valCount = valCount;
}
public String toString(){
return "Velocity(tick=" + tick + " sum=" + sum + " value=" + value + " valid=" + valCount + " activate=" + actCount + ")";
return "AccountEntry(tick=" + tick + " sum=" + sum + " value=" + value + " valid=" + valCount + " activate=" + actCount + ")";
}
}

View File

@ -1,25 +1,27 @@
package fr.neatmonster.nocheatplus.checks.moving;
package fr.neatmonster.nocheatplus.checks.moving.velocity;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
* Velocity accounting for one axis (positive + negative direction).
* Velocity accounting for one axis (positive + negative direction) with
* maintaining some kind of friction effects and maximum distance gained.
*
* @author dev1mc
*
*/
public class AxisVelocity {
public class FrictionAxisVelocity {
/** Velocity with a smaller absolute amount is removed. */
private static final double minValue = 0.001;
private static final double defaultFrictionFactor = 0.93;
private final List<Velocity> queued = new ArrayList<Velocity>();
private final List<Velocity> active = new ArrayList<Velocity>();
private final List<AccountEntry> queued = new LinkedList<AccountEntry>();
private final List<AccountEntry> active = new LinkedList<AccountEntry>();
public void add(Velocity vel) {
public void add(AccountEntry vel) {
// TODO: Merging behavior?
if (Math.abs(vel.value) != 0.0) {
queued.add(vel);
@ -62,14 +64,14 @@ public class AxisVelocity {
// TODO: Actual friction. Could pass as an argument (special value for not to be used).
// TODO: Consider removing already invalidated here.
// TODO: Consider working removeInvalid into this ?
for (final Velocity vel : active) {
for (final AccountEntry vel : active) {
vel.valCount --;
vel.sum += vel.value;
vel.value *= frictionFactor;
// (Altered entries should be kept, since they get used right away.)
}
// Decrease counts for queued.
final Iterator<Velocity> it = queued.iterator();
final Iterator<AccountEntry> it = queued.iterator();
while (it.hasNext()) {
it.next().actCount --;
}
@ -81,12 +83,13 @@ public class AxisVelocity {
* @param tick All velocity added before this tick gets removed.
*/
public void removeInvalid(final int tick) {
// Note: Adding unused entries to a collection should later be supported.
// TODO: Also merge entries here, or just on adding?
Iterator<Velocity> it;
Iterator<AccountEntry> it;
// Active.
it = active.iterator();
while (it.hasNext()) {
final Velocity vel = it.next();
final AccountEntry vel = it.next();
// TODO: 0.001 can be stretched somewhere else, most likely...
// TODO: Somehow use tick here too (actCount, valCount)?
if (vel.valCount <= 0 || Math.abs(vel.value) <= minValue) {
@ -98,7 +101,7 @@ public class AxisVelocity {
it = queued.iterator();
while (it.hasNext()) {
// TODO: Could check for alternating signum (error).
final Velocity vel = it.next();
final AccountEntry vel = it.next();
if (vel.actCount <= 0 || vel.tick < tick) {
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "Invalidate queued: " + vel);
it.remove();
@ -113,7 +116,7 @@ public class AxisVelocity {
public double getFreedom() {
// TODO: model/calculate it as accurate as possible...
double f = 0;
for (final Velocity vel : active) {
for (final AccountEntry vel : active) {
f += vel.value;
}
return f;
@ -134,10 +137,10 @@ public class AxisVelocity {
active.clear();
}
}
final Iterator<Velocity> it = queued.iterator();
final Iterator<AccountEntry> it = queued.iterator();
double used = 0;
while (it.hasNext()) {
final Velocity vel = it.next();
final AccountEntry vel = it.next();
if (vel.value * amount < 0.0) {
// Not aligned.
// TODO: This could be a problem with small amounts of velocity.
@ -189,8 +192,8 @@ public class AxisVelocity {
* @param builder
* @param entries
*/
private void addVeloctiy(final StringBuilder builder, final List<Velocity> entries) {
for (final Velocity vel: entries) {
private void addVeloctiy(final StringBuilder builder, final List<AccountEntry> entries) {
for (final AccountEntry vel: entries) {
builder.append(" ");
builder.append(vel);
}

View File

@ -0,0 +1,95 @@
package fr.neatmonster.nocheatplus.checks.moving.velocity;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
* Simple per-axis velocity (positive + negative), only accounting for queuing
* and invalidation. Since entries just store values for one time use, no extra
* ticking is done, invalidation mechanics and activation count decreasing takes
* place in removeInvalid.
*
* @author asofold
*
*/
public class SimpleAxisVelocity {
private final List<SimpleEntry> queued = new LinkedList<SimpleEntry>();
public void add(SimpleEntry entry) {
queued.add(entry);
}
public boolean hasQueued() {
return !queued.isEmpty();
}
/**
* The value of the first matching entry. Returns 0.0 if no entry
* is available. This will directly invalidate leading entries with the
* wrong sign.
*
* @param amount
* @return
*/
public double use(final double amount) {
final Iterator<SimpleEntry> it = queued.iterator();
final double absAmount = Math.abs(amount);
while (it.hasNext()) {
final SimpleEntry entry = it.next();
it.remove();
if (absAmount <= Math.abs(entry.value)) {
if (amount > 0.0 && entry.value > 0.0 || amount < 0.0 && entry.value < 0.0) {
// Success. Note that 0.0 Entries are ignored (should not exist anyway).
return entry.value;
} // else: Wrong sign.
} // else: Value too small.
// (Entry can not be used.)
// TODO: Note unused velocity.
}
// None found.
return 0.0;
}
/**
*
* @return The value of the first matching positive entry. Returns 0.0 if no
* entry is available. This will directly invalidate leading entries
* with the wrong sign.
*/
public double usePositive() {
return use(Double.MIN_VALUE);
}
/**
* Use any negative amount.
*
* @return The value of the first matching negative entry. Returns 0.0 if no
* entry is available. This will directly invalidate leading entries
* with the wrong sign.
*/
public double useNegative() {
return use(-Double.MIN_VALUE);
}
/**
* Remove all entries that have been added before the given tick, or for which the activation count has reached 0.
* @param tick
*/
public void removeInvalid(final int tick) {
final Iterator<SimpleEntry> it = queued.iterator();
while (it.hasNext()) {
final SimpleEntry entry = it.next();
entry.actCount --; // Let others optimize this.
if (entry.actCount <= 0 || entry.tick < tick) {
it.remove();
}
}
}
public void clear() {
queued.clear();
}
}

View File

@ -0,0 +1,39 @@
package fr.neatmonster.nocheatplus.checks.moving.velocity;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/**
* Simple check-once velocity.
* @author asofold
*
*/
public class SimpleEntry {
/** Tick at which velocity got added. */
public final int tick;
/** The amount of velocity. */
public final double value;
/** Count down for invalidation. */
public int actCount;
// TODO: Add more conditions (max tick, real time ?)
public SimpleEntry(double value, int actCount, int valCount){
this.tick = TickTask.getTick();
this.value = value;
this.actCount = actCount;
}
public SimpleEntry(int tick, double value, int actCount, int valCount){
this.tick = tick;
this.value = value;
this.actCount = actCount;
}
public String toString(){
return "SimpleEntry(tick=" + tick + " value=" + value + " activate=" + actCount + ")";
}
}

View File

@ -0,0 +1,22 @@
package fr.neatmonster.nocheatplus;
import static org.junit.Assert.fail;
import org.junit.Test;
public class NoobsTest {
@Test
public void testSmallDoubles() {
double x;
x = Double.MIN_VALUE;
if (x <= 0.0) {
fail("noob");
}
x = -Double.MIN_VALUE;
if (x >= 0.0) {
fail("noob");
}
}
}

View File

@ -7,9 +7,9 @@ import java.util.Random;
import org.junit.Test;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace.TraceIterator;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.locations.LocationTrace.TraceIterator;
public class TestLocationTrace {