Skip to content

fix: Moving from ticks to ms to better handle all server environments - #34

Merged
renvins merged 4 commits into
masterfrom
fix/ticks-ms
Nov 19, 2025
Merged

renvins merged 4 commits into
masterfrom
fix/ticks-ms

Conversation

@renvins

@renvins renvins commented Nov 19, 2025

Copy link
Copy Markdown
Owner

Description

This PR refactors the TaskScheduler abstraction to use milliseconds (long delayMs, long periodMs) instead of ticks across the entire project. This change addresses a critical bug in the Velocity implementation where tasks were running instantly due to integer division errors.

Key Changes

  • Fixed Velocity Scheduling Bug:

    • Problem: The Velocity scheduler previously converted ticks to seconds using integer division (ticks / 20). If a delay was less than 20 ticks (1 second), the result was 0, causing tasks to run immediately in a tight loop.
    • Solution: The scheduler now accepts milliseconds directly and passes them to the Velocity API using TimeUnit.MILLISECONDS.
  • Standardized Time Units:

    • The TaskScheduler interface now enforces milliseconds as the standard unit of time. This removes ambiguity between "game ticks" (20/sec) and real-time, which is crucial for proxy platforms (Velocity/BungeeCord) that do not operate on a standard game loop.
  • Platform Implementation Updates:

    • Velocity & BungeeCord: Now use their native millisecond/TimeUnit support without unnecessary conversions.
    • Bukkit & Fabric: Now accept milliseconds and convert them back to server ticks (ms / 50) for compatibility with their internal schedulers.
  • Service Updates:

    • DatabaseService now uses a clear RETRY_DELAY_MS = 30000L constant instead of calculating ticks, ensuring consistent retry behavior across all platforms.

@renvins
renvins merged commit 57379ef into master Nov 19, 2025
1 check passed
@renvins
renvins deleted the fix/ticks-ms branch February 27, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant