Skip to content

perf & fix: performance optimizations + bug fixes#88

Open
mtynnn wants to merge 6 commits intomehboss:masterfrom
mtynnn:master
Open

perf & fix: performance optimizations + bug fixes#88
mtynnn wants to merge 6 commits intomehboss:masterfrom
mtynnn:master

Conversation

@mtynnn
Copy link
Copy Markdown

@mtynnn mtynnn commented Mar 12, 2026

Changes included

Performance (100 concurrent players)

  • getRecipeFromKey(): O(n) → O(1) with synchronized HashMap index
  • getRecipesFromType(): O(n) + new HashMap → O(1) with EnumMap index
  • isCustomItem(): for-loop → Set.of().contains()
  • EffectsManager: YAML disk read per-event → in-memory cache (critical for combat)
  • EffectsManager: triple getRecipeFromKey() per event → single lookup
  • Nexo/ExecutableItems cached items now return clone() to prevent shared mutation bug

Bug fixes

  • Typo CUSTOM_ITEM_IDENTIFER fixed in 4 files (effects and block placement never worked)
  • BlockManager/EffectsManager: stale RecipeUtil reference after /crecipe reload fixed
  • EffectsManager: ArrayIndexOutOfBoundsException in effects loop fixed
  • SmithingManager: setResult(null) on meta-check rejection (prevents re-use exploit)
  • SmithingManager: items lost when inventory is full on smithing craft fixed
  • CommandGive: negative/oversized amount exploit fixed (/crecipe give player item -1)
  • Cache invalidation on /crecipe reload via effectsManager.invalidateConfigCache()

mtynnn added 6 commits March 8, 2026 13:12
- Added UTF-8 encoding to maven-compiler-plugin
- Temporarily commented out HavenBags dependency (jitpack.io unreachable)
- Key findings: Spigot 1.21.5 requires Java 17+, no tests in project
Replace direct Main.getInstance().field access with proper getters/setters (e.g. getRecipeUtil(), getCooldownManager(), isDebug()/setCrafterDebug()) across multiple managers and command classes to improve encapsulation and prepare for API changes. Fix SmithingManager behavior: ensure meta-check failures null the result, copy persistent data container when copying enchants, handle leftover inventory items by dropping them, and clean up local variables/imports. Update Maven and shaded POMs (add item-nbt-api, register SCore as a system dependency, bump some dependency versions, set compiler encoding) and update resources/plugin.yml to api-version '1.21' and simplify softdepends. Add IDE settings (.classpath/.project/.settings), include SCore-5.26.3.2.jar and build_output.txt, and add a new .github agent markdown. These changes are aimed at modernization, encapsulation, and compatibility with newer Paper/Spigot API versions.
Add robust handling and detailed logging for crafting result clicks and item removals. Key changes:

- AmountManager: extended handling to InventoryClickEvent (result-slot tracing), dedupe rapid duplicate events, added handleResultClickInternal and traceResultSlotClicks, improved logic for computing craft counts and precise item removals, safer leftover/container handling, clamped cursor/result stack updates, and many targeted DEBUG-ITEMREMOVAL logs to diagnose removal issues.
- CraftManager: safer NBT reads with try/catch, additional debug logs for validation, and sanitizeCraftingMatrix() to clamp invalid stack sizes / remove zero-or-negative stacks before recipe matching.
- Main: register debug warnings about AmountManager listener and check CraftItemEvent listener counts on startup to help trace registration/dispatch issues.

These changes aim to prevent ghost/duplicate crafts, NBT-related exceptions, incorrect stack arithmetic, and to make it easier to trace and debug crafting/item-removal bugs.
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