Tweaks, unlikely.

This commit is contained in:
asofold 2012-08-31 07:50:33 +02:00
parent a6e01c8b48
commit fd42826477
7 changed files with 36 additions and 19 deletions

View File

@ -35,17 +35,20 @@ public class InstantHeal extends Check {
* @return true, if successful
*/
public boolean check(final Player player) {
// Take time once.
final long time = System.currentTimeMillis();
final FightData data = FightData.getData(player);
boolean cancel = false;
// Security check if system time ran backwards.
if (data.instantHealLastTime > System.currentTimeMillis()) {
if (data.instantHealLastTime > time) {
data.instantHealLastTime = 0L;
return false;
}
final long delta = System.currentTimeMillis() - (data.instantHealLastTime + 3000L);
final long delta = time - (data.instantHealLastTime + 3000L);
data.instantHealBuffer += delta;
if (data.instantHealBuffer < 0) {
@ -69,7 +72,7 @@ public class InstantHeal extends Check {
if (!cancel)
// New reference time.
data.instantHealLastTime = System.currentTimeMillis();
data.instantHealLastTime = time;
return cancel;
}

View File

@ -35,20 +35,23 @@ public class Drop extends Check {
* @return true, if successful
*/
public boolean check(final Player player) {
// Take time once.
final long time = System.currentTimeMillis();
final InventoryConfig cc = InventoryConfig.getConfig(player);
final InventoryData data = InventoryData.getData(player);
boolean cancel = false;
// Has the configured time passed? If so, reset the counter.
if (data.dropLastTime + cc.dropTimeFrame <= System.currentTimeMillis()) {
data.dropLastTime = System.currentTimeMillis();
if (data.dropLastTime + cc.dropTimeFrame <= time) {
data.dropLastTime = time;
data.dropCount = 0;
data.dropVL = 0D;
}
// Security check, if the system time changes.
else if (data.dropLastTime > System.currentTimeMillis())
else if (data.dropLastTime > time)
data.dropLastTime = Integer.MIN_VALUE;
data.dropCount++;

View File

@ -34,16 +34,19 @@ public class FastClick extends Check {
* @return true, if successful
*/
public boolean check(final Player player) {
// Take time once.
final long time = System.currentTimeMillis();
final InventoryData data = InventoryData.getData(player);
boolean cancel = false;
// If the last inventory click has been made within 45 milliseconds.
if (System.currentTimeMillis() - data.fastClickLastTime < 45L) {
if (time - data.fastClickLastTime < 45L) {
if (data.fastClickLastCancelled) {
// Calculate the difference between the limit and the time elapsed.
final double difference = 45L - System.currentTimeMillis() + data.fastClickLastTime;
final double difference = 45L - time + data.fastClickLastTime;
// Increment the violation level.
data.fastClickVL += difference;
@ -61,7 +64,7 @@ public class FastClick extends Check {
}
// Remember the current time.s
data.fastClickLastTime = System.currentTimeMillis();
data.fastClickLastTime = time;
return cancel;
}

View File

@ -36,6 +36,9 @@ public class InstantBow extends Check {
* @return true, if successful
*/
public boolean check(final Player player, final float force) {
// Take time once.
final long time = System.currentTimeMillis();
final InventoryData data = InventoryData.getData(player);
boolean cancel = false;
@ -43,14 +46,14 @@ public class InstantBow extends Check {
// Rough estimation of how long pulling the string should've taken.
final long expectedTimeWhenStringDrawn = data.instantBowLastTime + (int) (force * force * 700F);
if (expectedTimeWhenStringDrawn < System.currentTimeMillis())
if (expectedTimeWhenStringDrawn < time)
// The player was slow enough, reward him by lowering his violation level.
data.instantBowVL *= 0.9D;
else if (data.instantBowLastTime > System.currentTimeMillis())
else if (data.instantBowLastTime > time)
// Security check if time ran backwards, reset
data.instantBowLastTime = 0L;
else {
final double difference = (expectedTimeWhenStringDrawn - System.currentTimeMillis()) / 100D;
final double difference = (expectedTimeWhenStringDrawn - time) / 100D;
// Player was too fast, increase his violation level.
data.instantBowVL += difference;

View File

@ -38,6 +38,9 @@ public class InstantEat extends Check {
* @return true, if successful
*/
public boolean check(final Player player, final int level) {
// Take time once.
final long time = System.currentTimeMillis();
final InventoryData data = InventoryData.getData(player);
boolean cancel = false;
@ -49,14 +52,14 @@ public class InstantEat extends Check {
// Rough estimation about how long it should take to eat
final long expectedTimeWhenEatingFinished = data.instantEatLastTime + 700L;
if (expectedTimeWhenEatingFinished < System.currentTimeMillis())
if (expectedTimeWhenEatingFinished < time)
// Acceptable, reduce VL to reward the player.
data.instantEatVL *= 0.6D;
else if (data.instantEatLastTime > System.currentTimeMillis())
else if (data.instantEatLastTime > time)
// Security test, if time ran backwards, reset.
data.instantEatLastTime = 0;
else {
final double difference = (expectedTimeWhenEatingFinished - System.currentTimeMillis()) / 100D;
final double difference = (expectedTimeWhenEatingFinished - time) / 100D;
// Player was too fast, increase his violation level.
data.instantEatVL += difference;

View File

@ -59,6 +59,9 @@ public class MorePackets extends Check {
* @return the location
*/
public Location check(final Player player, final PlayerLocation from, final PlayerLocation to) {
// Take time once, first:
final long time = System.currentTimeMillis();
final MovingData data = MovingData.getData(player);
Location newTo = null;
@ -66,8 +69,6 @@ public class MorePackets extends Check {
if (data.morePacketsSetback == null)
data.morePacketsSetback = from.getLocation();
final long time = System.currentTimeMillis();
// Take a packet from the buffer.
data.morePacketsBuffer--;

View File

@ -58,6 +58,9 @@ public class MorePacketsVehicle extends Check {
* @return the location
*/
public Location check(final Player player, final Location from, final Location to) {
// Take time once, first:
final long time = System.currentTimeMillis();
final MovingData data = MovingData.getData(player);
Location newTo = null;
@ -65,8 +68,6 @@ public class MorePacketsVehicle extends Check {
if (data.morePacketsVehicleSetback == null)
data.morePacketsVehicleSetback = from;
final long time = System.currentTimeMillis();
// Take a packet from the buffer.
data.morePacketsVehicleBuffer--;