-
Notifications
You must be signed in to change notification settings - Fork 0
Adicionado NPC ao desconectar em evento #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: SrBedrock <[email protected]>
Co-authored-by: SrBedrock <[email protected]>
Co-authored-by: SrBedrock <[email protected]>
…proxies Co-authored-by: SrBedrock <[email protected]>
…ySpawnEvent cancellable, fix formatting Co-authored-by: SrBedrock <[email protected]>
…I to false in VanillaProvider Co-authored-by: SrBedrock <[email protected]>
…nd timeouts Co-authored-by: SrBedrock <[email protected]>
Co-authored-by: SrBedrock <[email protected]>
…D import Co-authored-by: SrBedrock <[email protected]>
Updated test files to use 'final' for local variables and replaced wildcard static imports with explicit imports for assertion methods. These changes improve code readability and maintainability in unit tests for CombatLogService and DisconnectTrackingService.
Refactored NPC proxy handling, combat log, and disconnect tracking services for improved clarity and reliability. Updated event listeners and proxy restoration logic to use more consistent variable naming, final modifiers, and streamlined method calls. Removed unused imports and simplified internal data structures for combat and disconnect records.
Co-authored-by: SrBedrock <[email protected]>
…gn pattern for scheduler mocking Co-authored-by: SrBedrock <[email protected]>
…with Java 17 compatibility Co-authored-by: SrBedrock <[email protected]>
Co-authored-by: SrBedrock <[email protected]>
…testing with Java 17 compatibility" This reverts commit 4725ef4.
…ning NPC" This reverts commit 6f667f9.
Refactored NPC proxy cleanup in BaseGame to clear disconnect tracking for all participants at game end. Added debug logging in NpcProxyListener when a damaged entity is not an NPC proxy.
Changed NPC creation log message to include entity ID for better traceability. Updated DisconnectTrackingServiceTest to use @NotNull annotation and improved parameter naming for compatibility and clarity.
Updated isPlayerVersionBlocked to return false if blockedProtocols is null or empty, preventing potential NullPointerException. Also annotated getBlockedProtocols with @nullable for clarity.
Replaces String.toLowerCase() with toLowerCase(Locale.ROOT) when normalizing the provider config value to ensure consistent case conversion across different locales.
Deleted CombatLogServiceTest and DisconnectTrackingServiceTest from the test suite. This reduces test coverage for combat-related services and may be part of a refactor or cleanup.
Deleted CombatLogService and removed all references to it from TitansBattle, BaseGame, and NpcProxyListener. NPC proxy damage events are now cancelled directly in NpcProxyListener, simplifying proxy handling and eliminating combat log tracking for proxies.
Removed health management from NPC proxy logic and related classes, simplifying NpcHandle and NpcProvider interfaces. Deleted NpcProxyListener and updated event, provider, and handle implementations to no longer track or set NPC health. This streamlines proxy spawning and event handling, focusing on presence rather than health state.
The player's health is no longer restored from the NPC proxy when rejoining. This change simplifies the proxy restoration process and removes the health assignment, focusing on location teleportation, event firing, proxy despawn, and game reinstatement.
Renamed DISCONNECT_TRACKING_SUMMARY.md, IMPLEMENTATION_SUMMARY.md, MANUAL_TEST_SCENARIOS.md, and NPC_PROXY_SYSTEM.md to the .github/copilot directory for better organization. Also deleted the TitansBattle [install-simpleclans].run.xml Maven run configuration file.
Expanded .gitignore to cover Eclipse, Maven, Java, IntelliJ, and VS Code files for better IDE and build tool compatibility. Deleted ArmaBattle.iml to avoid tracking IDE-specific configuration.
Deleted NpcProxySpawnEvent, NpcProxyDespawnEvent, and NpcProxyDeathEvent classes. Removed all usages of these events in BaseGame and PlayerJoinListener, simplifying NPC proxy handling and eliminating custom event firing.
Made setKit method in BaseGame public to allow external calls. Simplified DisconnectTrackingService by removing unused fields and methods related to reconnected state. Updated PlayerJoinListener to restore player kit upon reinstatement after reconnecting.
Eliminated broadcast messages and language keys related to NPC proxy spawning and player elimination due to disconnect limits. Cleaned up config options and removed the unused language-en_US.yml file for consistency.
Changed NpcProvider and NpcHandle interfaces to sealed, restricting their implementations to known classes. Marked CitizensProvider, FancyNpcsProvider, and VanillaProvider as final. Refactored VanillaNpcHandle to be a record within VanillaProvider. This improves type safety and clarity of the NPC provider hierarchy.
Refactored multiple classes to use the 'final' keyword for method parameters, improving code readability and preventing accidental reassignment. No functional changes were made; this is a code style and maintainability update.
Relocated the inventory clearing logic for players using kits from the disconnect handler to ensure it only runs for non-combat situations. This improves clarity and correctness in handling player disconnect events.
Set PlayerJoinEvent handler priority to LOWEST and add @NotNull annotation for event parameter. Removed code that reinstated players in active games after NPC proxy restoration, simplifying the restoration logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds an NPC proxy system to replace players who disconnect during active events, plus reconnect/timeout handling and Java 17 compatibility updates.
- Introduces pluggable NPC providers (FancyNpcs, Citizens placeholder, Vanilla fallback) and a resolver.
- Adds DisconnectTrackingService to limit repeated disconnects and enforce timeouts; integrates with BaseGame and PlayerJoinListener.
- Drops Java target to 17 and replaces Java 21 APIs; various minor refactors.
Reviewed Changes
Copilot reviewed 35 out of 37 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/resources/plugin.yml | Adds FancyNpcs and Citizens as soft dependencies to support NPC providers. |
| src/main/resources/language-en_US.yml | Removes lone YAML header line; no functional code impact. |
| src/main/resources/config.yml | Adds battle.npcProxy configuration, provider selection, and limits. |
| src/main/java/me/roinujnosde/titansbattle/types/Kit.java | Refactors (finals), no behavior change. |
| src/main/java/me/roinujnosde/titansbattle/types/Event.java | Minor refactors. |
| src/main/java/me/roinujnosde/titansbattle/npc/VanillaProvider.java | New Vanilla NPC provider; spawns a fallback mob as proxy. |
| src/main/java/me/roinujnosde/titansbattle/npc/NpcProviderResolver.java | Selects best provider based on config/availability. |
| src/main/java/me/roinujnosde/titansbattle/npc/NpcProvider.java | Sealed provider interface. |
| src/main/java/me/roinujnosde/titansbattle/npc/NpcHandle.java | Sealed handle interface for NPC proxies. |
| src/main/java/me/roinujnosde/titansbattle/npc/FancyNpcsProvider.java | FancyNpcs-based provider implementation. |
| src/main/java/me/roinujnosde/titansbattle/npc/CitizensProvider.java | Placeholder Citizens provider. |
| src/main/java/me/roinujnosde/titansbattle/managers/ListenerManager.java | Minor refactors. |
| src/main/java/me/roinujnosde/titansbattle/managers/DatabaseManager.java | Minor refactors. |
| src/main/java/me/roinujnosde/titansbattle/managers/CommandManager.java | Replaces Locale.of with Java 17 compatible new Locale(...). |
| src/main/java/me/roinujnosde/titansbattle/listeners/SpectateListener.java | Removes unused imports. |
| src/main/java/me/roinujnosde/titansbattle/listeners/PlayerJoinListener.java | Handles restoring players from NPC proxy, applies disconnect-limit logic. |
| src/main/java/me/roinujnosde/titansbattle/hooks/viaversion/ViaVersionHook.java | Null/empty guard for blocked protocols. |
| src/main/java/me/roinujnosde/titansbattle/games/Sumo.java | Java 17 compatibility refactor. |
| src/main/java/me/roinujnosde/titansbattle/games/FreeForAllGame.java | Java 17 compatibility (getFirst -> get(0)). |
| src/main/java/me/roinujnosde/titansbattle/games/EliminationTournamentGame.java | Java 17 compatibility (getFirst -> get(0)). |
| src/main/java/me/roinujnosde/titansbattle/events/PlayerWinEvent.java | Java 17 compatibility (getFirst -> get(0)). |
| src/main/java/me/roinujnosde/titansbattle/events/LobbyStartEvent.java | Minor refactors. |
| src/main/java/me/roinujnosde/titansbattle/dao/ConfigurationDao.java | Minor refactors. |
| src/main/java/me/roinujnosde/titansbattle/commands/completions/PrizeCompletion.java | Minor refactors. |
| src/main/java/me/roinujnosde/titansbattle/combat/DisconnectTrackingService.java | New disconnect/timeout tracking service. |
| src/main/java/me/roinujnosde/titansbattle/TitansBattle.java | Wires NPC provider and disconnect tracking; exposes getters; cleanup on disable. |
| src/main/java/me/roinujnosde/titansbattle/BaseGameConfiguration.java | Marks getBlockedProtocols as @nullable. |
| src/main/java/me/roinujnosde/titansbattle/BaseGame.java | Integrates NPC proxy spawning on disconnect, elimination helper, cleanup on finish. |
| pom.xml | Changes compiler target/source to 17; adds FancyNpcs repo/dependency; changes SimpleClans to system scope. |
| .github/copilot/*.md | Adds documentation for NPC Proxy System and manual test scenarios. |
| ArmaBattle.iml, .run/* | Removes IDE-specific files. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
Deleted DISCONNECT_TRACKING_SUMMARY.md, IMPLEMENTATION_SUMMARY.md, MANUAL_TEST_SCENARIOS.md, and NPC_PROXY_SYSTEM.md from .github/copilot. These files contained implementation details, testing scenarios, and system documentation for the NPC proxy and disconnect tracking systems.
Updated method parameters to use 'final' for immutability and replaced usages of 'list.get(0)' with 'list.getFirst()' for clarity and modern Java practices. Also improved string and collection handling, and updated Maven compiler target/source to Java 21.
Introduces a 'bypass-reasons' config option to prevent NPC proxy creation for specific quit messages (e.g., 'banned'). Updates BaseGame and PlayerQuitListener to support passing the quit message and checking against the bypass list.
Enhanced the logic for determining NPC proxy bypass reasons by normalizing and matching quit messages more flexibly. The bypass check now strips color codes, trims, and compares lowercased messages, allowing partial matches and handling null values.
No description provided.