Skip to content

optimize portal ticker loop and eliminate uninitialized reflection checks - #1

Open
Spagles wants to merge 1 commit into
EmilDeuOfficial:masterfrom
Spagles:master
Open

optimize portal ticker loop and eliminate uninitialized reflection checks#1
Spagles wants to merge 1 commit into
EmilDeuOfficial:masterfrom
Spagles:master

Conversation

@Spagles

@Spagles Spagles commented Aug 15, 2026

Copy link
Copy Markdown
  • Fixed cooldown bypass and eliminated reflection overhead: Swapped reflection-based portalCooldownField reading with native Player#getPortalCooldown(). In the previous implementation, hasPortalCooldown() was evaluated in the ticker before ensureReflection() had run inside acceleratePortal(), causing portalCooldownField to be null and returning false on initial entry. Utilizing the native Bukkit API resolves this uninitialized state bug, prevents cooldown bypasses, and removes per-tick reflective invocations.
  • Short-circuited block lookups and heap allocations: Reordered checks in startPortalTicker() to evaluate player.getPortalCooldown() > 0 before calling isInNetherPortal(player). isInNetherPortal() allocates a new Location object and executes two world chunk block lookups (feet and torso). Because players retain an active 300-tick (15-second) portal cooldown after teleporting while remaining inside the portal frame, checking the primitive integer first avoids thousands of redundant heap allocations and chunk queries.
  • Eliminated duplicate reflection calls in portal acceleration: Cached the result of getHandleMethod.invoke(player) in acceleratePortal(), checked for a null PortalProcessor instance early, and passed the resolved NMS handle directly into resolveMaxTime(nms). This avoids invoking getHandle via reflection multiple times per tick and skips max-time/config calculations when the game has not yet initialized the entity's portal process.
  • Removed dead event listener: Deleted the empty onPlayerTeleport(PlayerTeleportEvent) handler and its unused event imports. Because the method body was a no-op comment, removing it prevents Bukkit's event bus from dispatching every server-wide teleport event (commands, ender pearls, respawns) to an empty listener.

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