Optimize timer synchronization: pre-generation, performance improvements, and state validation#96
Conversation
Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
|
@copilot I want it to be more sync what if leave the active task to the SpawnerRangeChecker and the spawn loot to the SpawnerGuiViewManager |
…iggers spawn Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
Refactored the architecture as requested in commit e8f6938: SpawnerRangeChecker now only manages the active task timer (keeping track of when spawners are active based on player range). SpawnerGuiViewManager now triggers the actual loot spawn when it detects the timer has expired via This provides better synchronization and eliminates the circular dependency where |
|
@copilot Ok remove redundant code in SpawnerRangeChecker and make sure that they are sync like before the countdown start or restart check wether that spawner is active or not? and remove some plugin logger info in rangechecker since I used it for debug. Optimize for performance, and implement a feature that spawn loot generate and calculate all the things but not add to the real spawner before the timer countdown to 0s add it the spawner for better UX this way when spawnloot take long time to spawn it wont bypass the cycle time |
…spawner active state Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
Implemented all requested optimizations in commit 8e0a872: 1. Removed redundant code & debug logging:
2. Added spawner active state check:
3. Performance optimizations:
4. Pre-generation feature:
This ensures the spawn cycle time is preserved regardless of how long loot generation takes. |
|
@copilot /home/runner/work/smartspawner/smartspawner/core/src/main/java/github/nighter/smartspawner/spawner/lootgen/SpawnerLootGenerator.java:487: error: cannot find symbol
FAILURE: Build failed with an exception. Also SpawnerLootGenerator.java:
|
… thread-safety Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
Fixed all issues in commit 1be392e: Build Error Fixed:
Better Implementation:
Code Quality:
Thread Safety (Folia-compatible):
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot in calculateTimeUntilNextSpawn where is the check for spawner active before countdown or spawnloot? |
Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
Added spawner active checks in commit d1c79a0: Initial check (line 1335): Checks at the beginning and returns -1 if inactive Before pre-generation (lines 1325-1327): Checks Inside pre-generation task (lines 1333-1336): Re-checks active state when the scheduled task runs Before spawn loot (lines 1357-1360): Checks active state before spawning when timer expires Inside spawn task (lines 1366-1370): Re-checks active state when the scheduled loot spawn task runs This ensures spawner active state is validated at every critical point, preventing pre-generation or loot spawning if the spawner becomes inactive between checks. |
Pre-generation Refactor - Clean Code & Performance
Completely refactored the pre-generation implementation with better design, comprehensive documentation, and improved thread-safety.
Changes:
SpawnerData (Better Architecture):
SpawnerLootGenerator (Clean Code & Javadocs):
setSpawnerExp()instead of non-existentaddExperience()Scheduler.runLocationTask()SpawnerGuiViewManager (Simplified):
Thread Safety Improvements:
Scheduler.runLocationTask()Scheduler.runTaskAsync()Performance Benefits:
Code Quality:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.