Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bleeding] Add interact.speed check.
- Loading branch information
Showing
9 changed files
with
98 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/Speed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package fr.neatmonster.nocheatplus.checks.blockinteract; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
import fr.neatmonster.nocheatplus.checks.Check; | ||
import fr.neatmonster.nocheatplus.checks.CheckType; | ||
import fr.neatmonster.nocheatplus.permissions.Permissions; | ||
import fr.neatmonster.nocheatplus.utilities.TickTask; | ||
|
||
public class Speed extends Check { | ||
|
||
public Speed() { | ||
super(CheckType.BLOCKINTERACT_SPEED); | ||
} | ||
|
||
public boolean check(final Player player, final BlockInteractData data, final BlockInteractConfig cc){ | ||
|
||
final long time = System.currentTimeMillis(); | ||
|
||
if (time < data.speedTime || time > data.speedTime + cc.speedInterval){ | ||
data.speedTime = time; | ||
data.speedCount = 0; | ||
} | ||
|
||
// Increase count. | ||
data.speedCount ++; | ||
|
||
boolean cancel = false; | ||
|
||
if (data.speedCount > cc.speedLimit){ | ||
// Lag correction | ||
final int correctedCount = (int) ((double) data.speedCount / TickTask.getLag(time - data.speedTime)); | ||
if (correctedCount > cc.speedLimit){ | ||
if (executeActions(player, data.speedVL, 1, cc.speedActions)){ | ||
cancel = true; | ||
} | ||
} | ||
// else: keep vl. | ||
} | ||
else{ | ||
data.speedVL *= 0.99; | ||
} | ||
|
||
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ | ||
player.sendMessage("Interact speed: " + data.speedCount); | ||
} | ||
|
||
return cancel; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters