Adjust how first damage time for block break is updated.

This commit is contained in:
asofold 2012-09-19 13:33:48 +02:00
parent 764376f41d
commit 36b834df99
2 changed files with 11 additions and 4 deletions

View File

@ -78,6 +78,9 @@ public class BlockBreakData extends ACheckData {
public int clickedX;
public int clickedY;
public int clickedZ;
public int clickedTick;
// TODO: use tick here too ?
public long wasInstaBreak;
public final Stats stats;

View File

@ -12,6 +12,8 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/*
* M#"""""""'M dP dP M#"""""""'M dP
* ## mmmm. `M 88 88 ## mmmm. `M 88
@ -219,10 +221,11 @@ public class BlockBreakListener implements Listener {
if (block == null)
return;
// Skip if already set to the same block without breaking.
// TODO: should probably always set or depending on configuration.
if (data.fastBreakBreakTime < data.fastBreakfirstDamage && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY())
return;
final int tick = TickTask.getTick();
// Skip if already set to the same block without breaking within one tick difference.
if (data.fastBreakBreakTime < data.fastBreakfirstDamage && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()){
if (tick - data.clickedTick <= 1 ) return;
}
// (Always set, the interact event only fires once: the first time.)
// Only record first damage:
@ -231,6 +234,7 @@ public class BlockBreakListener implements Listener {
data.clickedX = block.getX();
data.clickedY = block.getY();
data.clickedZ = block.getZ();
data.clickedTick = tick;
}
}