Skip to content

v1.4.0 — Minor Performance and Stability Issues Fixxed

Latest

Choose a tag to compare

@040Elias 040Elias released this 04 Apr 19:04

Spawn v1.4.0 — Minor Performance and Stability Issues Fixxed

Performance Improvements

Sound Caching

  • Sound lookups (Registry.SOUNDS + NamespacedKey parsing) are now cached in a
    ConcurrentHashMap<String, Optional<Sound>> via computeIfAbsent()
  • Previously, every countdown tick per player triggered a full Registry lookup
  • Invalid/empty sound names are also cached to avoid repeated parse attempts
  • Cache is automatically cleared on /spawnreload

Display Name Caching

  • Tab-completion display names are now cached in a volatile List<String>
    instead of re-sorting the entire map on every keystroke
  • Cache is invalidated automatically on setSpawn() / deleteSpawn()

Stability Improvements

Async DB Error Handling

  • dbExecutor.execute() tasks for save() and delete() are now wrapped in
    try-catch(Exception) with full stack trace logging via log.log(Level.SEVERE, ..., e)
  • Previously, any RuntimeException thrown in async DB tasks was silently
    swallowed by the ExecutorService

Memory Leak Fixes

UpdateChecker Lifecycle Management

  • HttpClient and ExecutorService converted from static fields to instance
    fields with proper shutdown() method
  • shutdown() is called from SpawnPlugin.onDisable() before SpawnManager shutdown
  • Fixes: ClassLoader/thread leak on plugin reload — static threads and
    HttpClient previously survived class unloading

Sound Cache Cleanup

  • SoundUtil.clearCache() called on both /spawnreload and plugin disable

Code Safety

Abstract Read Methods in AbstractLocationManager

  • exists(), getNames(), getDisplayNames(), getLocation(), getDisplayName()
    are now abstract instead of concrete DB-query implementations
  • Forces subclasses to provide cache-backed implementations
  • Prevents: Accidental synchronous DB access on main/region thread
    (MSPT spikes, Folia threading violations)

Files Changed

File Change
SoundUtil.java Added ConcurrentHashMap sound cache + clearCache()
UpdateChecker.java Static → instance fields, added shutdown()
SpawnPlugin.java Lifecycle management for UpdateChecker + SoundUtil
AbstractLocationManager.java Read methods → abstract
SpawnManager.java Async error handling + displayNames caching
ReloadCommand.java Call SoundUtil.clearCache() on reload

Compatibility

  • Folia-safe: All changes maintain thread safety
  • Config: No config format changes — drop-in upgrade from v1.3.0