mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-19 14:01:20 +01:00
Set up structure for exact breaking times.
This commit is contained in:
parent
8d41378688
commit
120d17a23c
@ -106,7 +106,7 @@ public class BlockBreakConfig extends ACheckConfig {
|
||||
|
||||
fastBreakCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK);
|
||||
fastBreakContention = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION, 2000);
|
||||
fastBreakBucketDur = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_DUR, 1000);
|
||||
fastBreakBucketDur = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_DUR, 4000);
|
||||
fastBreakBuckets = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_N, 30);
|
||||
fastBreakBuffer = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUFFER);
|
||||
fastBreakInterval = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVAL);
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockUtils;
|
||||
|
||||
/*
|
||||
* MM""""""""`M dP M#"""""""'M dP
|
||||
@ -52,16 +53,12 @@ public class FastBreak extends Check {
|
||||
final BlockBreakData data = BlockBreakData.getData(player);
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
// First, check the game mode of the player and choose the right limit.
|
||||
long elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * SURVIVAL);
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * CREATIVE);
|
||||
|
||||
// TODO: Use exact time for block types with new method !
|
||||
|
||||
|
||||
if (cc.fastBreakOldCheck){
|
||||
// First, check the game mode of the player and choose the right limit.
|
||||
long elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * SURVIVAL);
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * CREATIVE);
|
||||
// The elapsed time is the difference between the last damage time and the last break time.
|
||||
final long elapsedTime = data.fastBreakDamageTime - data.fastBreakBreakTime;
|
||||
if (elapsedTime < elapsedTimeLimit && data.fastBreakBreakTime > 0L && data.fastBreakDamageTime > 0L
|
||||
@ -88,17 +85,23 @@ public class FastBreak extends Check {
|
||||
}
|
||||
}
|
||||
else{
|
||||
// First, check the game mode of the player and choose the right limit.
|
||||
long breakingTime = Math.round((double) cc.fastBreakInterval / 100D * (double) BlockUtils.getBreakingDuration(block.getTypeId(), player.getItemInHand()));
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
breakingTime = Math.round((double) cc.fastBreakInterval / 100D * (double) CREATIVE);
|
||||
|
||||
// fastBreakDamageTime is now first interact on block (!).
|
||||
if (now - data.fastBreakDamageTime < elapsedTimeLimit){
|
||||
if (now - data.fastBreakDamageTime < breakingTime){
|
||||
// lag or cheat or Minecraft.
|
||||
final long elapsedTime = now - data.fastBreakDamageTime;
|
||||
|
||||
final long missingTime = elapsedTimeLimit - elapsedTime;
|
||||
final long missingTime = breakingTime - elapsedTime;
|
||||
|
||||
// Add as penalty
|
||||
data.fastBreakPenalties.add(now, (float) missingTime);
|
||||
|
||||
if (data.fastBreakPenalties.getScore(1f) > cc.fastBreakContention){
|
||||
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
|
||||
data.fastBreakVL += missingTime;
|
||||
cancel = executeActions(player, data.fastBreakVL, missingTime, cc.fastBreakActions);
|
||||
}
|
||||
|
31
src/fr/neatmonster/nocheatplus/utilities/BlockUtils.java
Normal file
31
src/fr/neatmonster/nocheatplus/utilities/BlockUtils.java
Normal file
@ -0,0 +1,31 @@
|
||||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Poperties of blocks.
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class BlockUtils {
|
||||
/** Properties of a tool. */
|
||||
public static class ToolProps{
|
||||
|
||||
}
|
||||
/** Properties of a block. */
|
||||
public static class BlockProps{
|
||||
public float hardness = 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the normal breaking duration, including enchantments, and tool properties.
|
||||
* @param blockId
|
||||
* @param itemInHand
|
||||
* @return
|
||||
*/
|
||||
public static long getBreakingDuration(final int blockId, final ItemStack itemInHand){
|
||||
// TODO: GET EXACT BREAKING TIME !
|
||||
return 95;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user