Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces error handling across several core services in the Neptune Minecraft plugin. It adds a centralized errored flag on the Neptune plugin instance, wraps arena/kit loading and player profile creation in try-catch blocks, and skips the onDisable shutdown sequence when a load-time error is detected.
Changes:
- Adds
erroredflag andsetErrored()toNeptune.java, withonDisableguarded by this flag - Wraps arena and kit loading loops in try-catch blocks that log the error, set the
erroredflag, and rethrow - Adds error handling for player profile creation in
ProfileService, including kicking the player
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
Neptune.java |
Adds errored boolean flag + setErrored() method; guards onDisable cleanup |
ArenaService.java |
Wraps arena loading in try-catch with logging, errored flag, and rethrow |
KitService.java |
Wraps kit loading in try-catch with logging, errored flag, and rethrow |
ProfileService.java |
Wraps async profile creation with a try-catch to log and kick the player |
PotionEffectUtils.java |
Adds unused import dev.lrxh.neptune.Neptune |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Plugin/src/main/java/dev/lrxh/neptune/profile/ProfileService.java
Outdated
Show resolved
Hide resolved
| @Setter | ||
| private boolean allowMatches; | ||
|
|
||
| private boolean errored; |
There was a problem hiding this comment.
The errored field is a plain boolean without the volatile keyword. When setErrored() is called, it could theoretically be called from a thread other than the main server thread (e.g., if an error were to occur in a background task that triggers this). The onDisable() method reads errored on the main server thread. Without volatile, there is no guarantee that the write from one thread is visible to the read on another thread. Consider declaring errored as volatile boolean errored or using AtomicBoolean to ensure safe cross-thread visibility.
| private boolean errored; | |
| private volatile boolean errored; |
Plugin/src/main/java/dev/lrxh/neptune/game/arena/ArenaService.java
Outdated
Show resolved
Hide resolved
| @@ -1,5 +1,6 @@ | |||
| package dev.lrxh.neptune.utils; | |||
|
|
|||
| import dev.lrxh.neptune.Neptune; | |||
There was a problem hiding this comment.
The import dev.lrxh.neptune.Neptune added in this file is unused. The PotionEffectUtils class only contains serialize and deserialize methods, neither of which references Neptune. This import should be removed to avoid confusion.
| import dev.lrxh.neptune.Neptune; |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.