Skip to content

Add nullability annotations to getChannel methods in player manager classes#1

Closed
3add wants to merge 1 commit into
2.0from
fix-nullability
Closed

Add nullability annotations to getChannel methods in player manager classes#1
3add wants to merge 1 commit into
2.0from
fix-nullability

Conversation

@3add

@3add 3add commented May 15, 2026

Copy link
Copy Markdown
Owner

This PR aims to add the @Nullable annotation to the ProtocolManager.java and PlayerManager.java. It is annoying having the IDE say that the value is never null when in reality it is. This could avoid a lot of bugs for users.

Summary by CodeRabbit

  • Refactor
    • Enhanced null-safety across all platform implementations (Spigot, Fabric, Velocity, Sponge, BungeeCord) with explicit nullability annotations for channel and user resolution methods that may return null values
    • Improves IDE support and null-checking tooling for developers, enabling better static code analysis
    • Reduces potential null-pointer exceptions and provides clearer guidance on method behavior

Review Change Stack

Copilot AI review requested due to automatic review settings May 15, 2026 18:36
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 36a8b65c-ee0f-4cee-acdd-d452fe893509

📥 Commits

Reviewing files that changed from the base of the PR and between 2fccee7 and 8de8330.

📒 Files selected for processing (11)
  • api/src/main/java/com/github/retrooper/packetevents/manager/player/PlayerManager.java
  • api/src/main/java/com/github/retrooper/packetevents/manager/protocol/ProtocolManager.java
  • bungeecord/src/main/java/io/github/retrooper/packetevents/bungee/factory/BungeePacketEventsBuilder.java
  • fabric-intermediary/src/client/java/io/github/retrooper/packetevents/factory/fabric/FabricClientPlayerManager.java
  • fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPlayerManager.java
  • fabric-official/src/client/java/io/github/retrooper/packetevents/factory/fabric/FabricClientPlayerManager.java
  • fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPlayerManager.java
  • netty-common/src/main/java/io/github/retrooper/packetevents/impl/netty/manager/player/PlayerManagerAbstract.java
  • spigot/src/main/java/io/github/retrooper/packetevents/manager/player/PlayerManagerImpl.java
  • sponge/src/main/java/io/github/retrooper/packetevents/sponge/manager/player/PlayerManagerImpl.java
  • velocity/src/main/java/io/github/retrooper/packetevents/manager/PlayerManagerImpl.java

📝 Walkthrough

Walkthrough

The pull request adds JetBrains @Nullable annotations to method return types across the player manager and protocol manager APIs and their implementations. The changes explicitly mark getChannel and getUser methods that may return null, making nullability part of the method contracts without altering runtime behavior.

Changes

Nullability annotations for player and protocol manager APIs

Layer / File(s) Summary
Core API interfaces: PlayerManager and ProtocolManager
api/src/main/java/com/github/retrooper/packetevents/manager/player/PlayerManager.java, api/src/main/java/com/github/retrooper/packetevents/manager/protocol/ProtocolManager.java
PlayerManager and ProtocolManager interfaces import org.jetbrains.annotations.Nullable and annotate getChannel and getUser return types as nullable with updated Javadoc describing null conditions.
Abstract base implementation: PlayerManagerAbstract
netty-common/src/main/java/io/github/retrooper/packetevents/impl/netty/manager/player/PlayerManagerAbstract.java
The abstract base class adds @Nullable annotations to getChannel and getUser method declarations to align with the interface contracts defined above.
Platform-specific implementations with nullable contracts
bungeecord/src/main/java/io/github/retrooper/packetevents/bungee/factory/BungeePacketEventsBuilder.java, spigot/src/main/java/io/github/retrooper/packetevents/manager/player/PlayerManagerImpl.java, sponge/src/main/java/io/github/retrooper/packetevents/sponge/manager/player/PlayerManagerImpl.java, velocity/src/main/java/io/github/retrooper/packetevents/manager/PlayerManagerImpl.java, fabric-intermediary/src/client/java/io/github/retrooper/packetevents/factory/fabric/FabricClientPlayerManager.java, fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPlayerManager.java, fabric-official/src/client/java/io/github/retrooper/packetevents/factory/fabric/FabricClientPlayerManager.java, fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPlayerManager.java
All platform-specific implementations consistently add org.jetbrains.annotations.Nullable imports and apply @Nullable annotations to getChannel and getUser method return types to reflect that these methods can return null when channels or users are unavailable.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 Hopping through the code with glee,
Adding @Nullable for all to see,
Contracts are clearer, nulls marked with care,
No more surprises lurking there!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-nullability

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@3add 3add closed this May 15, 2026
@3add 3add removed the request for review from Copilot May 15, 2026 18:59
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