So I have been on a server where you could run around the spawn in a circle and it counted how many times you ran around the spawn. The plugin counted up once I ran a whole circle. Now I want to make a similar plugin. But how so I track if a person ran a circle?
Are you sure the example you showed us isn't just counting the blocks travelled in general. If that's not the case I can think of many reasons on how to track blocks of a player running around a circle. The first idea that comes to my mind is making hidden waypoints and then calculating the blocks travelled from the last waypoint.
Here is how I would perhaps do it: For simplicity imagine your spawn being at (0,0). You will have a north-south and east-west axis. The signs of the coordinates in each quadrant are: north-east: (+,-) south-east: (+,+) south-west: (-,+) north-west: (-,-) Create an enum for each side: NORTH, EAST, SOUTH, WEST. Define the radius of your spawn which is the minimum distance that a player has to be away from the center for a lap to count. Also define its square: Code (Text): int radius = 10; int radiusSquared = radius * radius; Listen to PlayerMoveEvent and compare the signs for x and z of .from() and .to(). For example if the signs changed from (+,-) to (+,+) you know that the player just crossed the east-west axis on the east side. If the crossing happend while Code (Text): player.getLocation().distanceSquared(spawn) > radiusSquared was true, map the enum corresponding to the crossing to the player: Code (Text): Map<Player, Side> latestSideCrossed = new HashMap<>(); latestSideCrossed.put(player, Side.EAST); Now start two quadrant counters (clockwise and anti-clockwise). If the next crossing happens on the south/north side increase the corresponding counter by 1 and reset the other one. Also update the enum value in the HashMap. Once a counter hits 4 a lap just happened.
I also want to know about that. I am going to share this question https://www.spigotmc.org/threads/how-to-make-a-plugin-619 area code-that-counts-walkes-rounds.557083/#post-4411008 with my friends and brother. Hope so, he knows something about this. Please wait for my next reply with good answer as soon as possible.