ClicksPerSecond

Discussion in 'Spigot Plugin Development' started by bludsprae, May 20, 2016.

  1. Hello, I am making a macro detection for my server and there is one part im stuck on which is getting the players exact CPS(ClicksPerSecond). Here is some of the code.

    http://pastebin.com/Yi43zyQG
     
  2. First of all, why are you casting Player to a collection of players?
     
  3. I actually messed up and did that on accident lol I fixed it but im still wondering how to get a players CPS
     
  4. You'd probably have to track the PlayerInteractEvent and then calculate the cps.
     
    • Agree Agree x 1
  5. @VixaPvP is right. For every player, keep some kind of "interact history".

    However, now it gets a bit tricky. If you reset the interact history every second, getting the CPS will give you the amount of clicks the player has done that certain second. Which is often most likely to be 0. I have no idea what you need this for, but it seems more likely that you might need the following. Store the clicks a player has done and remember only the ones in the last 5 seconds (or more). When called, you return the amount of clicks over the last 5 seconds divided by 5. That would give you the average amount of clicks per second (over the last 5 seconds) as a decimal. It's the same with TPS, you might have seen Spigot's TPS command showing the TPS like this 20.0 (1 minute), 19.88 (5 minutes), 19.77 (15 minutes). The TPS might have dropped to below 10 for 1 second, however you don't care about that, as you only care about the average.

    Let us know if you have something new, good luck :)
     
    • Agree Agree x 1