Skip to content

refactor: replace PushbackManager scheduled task with event-driven CircularBoundingBox#30

Merged
TheBjoRedCraft merged 2 commits intotrello/tp-falsch-punch-sound-pushback-laggyfrom
copilot/add-bounding-box-to-executor
Mar 15, 2026
Merged

refactor: replace PushbackManager scheduled task with event-driven CircularBoundingBox#30
TheBjoRedCraft merged 2 commits intotrello/tp-falsch-punch-sound-pushback-laggyfrom
copilot/add-bounding-box-to-executor

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 15, 2026

Replace the polling-based runAtFixedRate pushback system with a PlayerMoveEvent-driven approach using per-executor circular bounding boxes.

Changes

  • CircularBoundingBox — new utility class for 2D circular containment checks using squared distance (no sqrt)
  • PushbackManager — remove scheduled task, maintain a Map<UUID, CircularBoundingBox> per executor instead of a Set<UUID>
    • updateExecutorPosition(player) — moves the box center on executor move
    • checkPushback(player) — non-executors check isInside() against all active boxes, with 1s cooldown
  • PlayerMoveListener — drives both methods on every position change
  • PaperMain — remove PushbackManager.startTask() call

How it works

// Executor moves → box follows
PushbackManager.updateExecutorPosition(player)  // O(1) map lookup + center update

// Any player moves → check all executor boxes
PushbackManager.checkPushback(player)  // early-out on permission/cooldown, then isInside() per box

Both paths bail out fast for the common case (non-executor with no nearby boxes). The isInside check is a simple dx² + dz² ≤ r² comparison rather than getNearbyPlayers() entity scanning every second.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • downloads.gradle.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Xmx64m -Xms64m -Dorg.gradle.appname=gradlew -jar /home/REDACTED/work/surf-lobby/surf-lobby/gradle/wrapper/gradle-wrapper.jar build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…gBox-based PlayerMoveEvent approach

Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add bounding box around executor for performance improvements refactor: replace PushbackManager scheduled task with event-driven CircularBoundingBox Mar 15, 2026
Copilot AI requested a review from TheBjoRedCraft March 15, 2026 14:21
@TheBjoRedCraft TheBjoRedCraft marked this pull request as ready for review March 15, 2026 14:44
@TheBjoRedCraft TheBjoRedCraft merged commit 813eb2b into trello/tp-falsch-punch-sound-pushback-laggy Mar 15, 2026
@TheBjoRedCraft TheBjoRedCraft deleted the copilot/add-bounding-box-to-executor branch March 15, 2026 14:44
@TheBjoRedCraft TheBjoRedCraft restored the copilot/add-bounding-box-to-executor branch March 15, 2026 14:54
@TheBjoRedCraft TheBjoRedCraft deleted the copilot/add-bounding-box-to-executor branch March 15, 2026 14: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.

2 participants