Commit Graph

176 Commits

Author SHA1 Message Date
laforetbrut
0c7026aa65 Fix stale effects persisting on server transfer
Effects from the local server .dat file persisted when the player had
no effects saved in the DB. removeAllEffects() was only called inside
the if-block that checks for saved effect data, so it was skipped when
effectData was null/empty. Now effects are ALWAYS cleared before
restoring from DB.

SOL Onion food diversity is already synced via the generic NeoForge
attachment system (FoodPlayerData is a NeoForge attachment).

Vyrriox
2026-03-26 15:11:38 +01:00
laforetbrut
2e0269ee62 Add Refined Storage 2 disk sync + Extra Disks support
- Sync RS2 disk storage contents between servers (storageReference UUID)
- Support both refinedstorage and extradisks namespaces
- Save: extract individual entries from StorageRepository SavedData
- Restore: decode via RS2 codec and inject into target server repository
- Skip restore if storage already exists on target server (no overwrite)
- Scan inventory + ender chest for disks

Vyrriox
2026-03-26 15:07:28 +01:00
laforetbrut
87d320c1f4 Fix excessive thread creation (issue #169) - bounded thread pool
Replace unbounded CachedThreadPool with bounded ThreadPoolExecutor.

Problem: CachedThreadPool creates unlimited threads. With many players
online and slow DB queries, thread count explodes (25000+ threads
observed in issue #169), causing memory leaks and server crashes.

Fix: ThreadPoolExecutor with 2 core / 8 max threads, 30s keepalive,
256-task bounded queue, and CallerRunsPolicy for backpressure.
When the queue is full, tasks execute on the calling thread instead
of creating more threads, providing natural flow control.

Closes mlus-asuka/PlayerSync#169

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:51:09 +01:00
laforetbrut
f37e58be53 Add generic NeoForge attachment sync for full mod compatibility
Adds a generic system that syncs ALL NeoForge player attachments,
covering per-player data from every mod in the modpack:

- Ars Nouveau: mana, glyph/spell knowledge
- Iron's Spellbooks: mana, learned spells, cooldowns
- Pehkui: player scale
- Spice of Life: Onion: food diversity history
- And ANY other mod using NeoForge's attachment system

Implementation:
- Save: extracts neoforge:attachments tag from player.saveWithoutId()
- Restore: uses reflection to call NeoForge's deserializeAttachments()
  which ensures exact same deserialization path as normal player load
- Stored as BNBT in mod_player_data table (mod_id=neoforge_attachments)

Also verified CosmeticArmours (mod id: cosmeticarmoursmod) and
CosmeticWeapons (mod id: cosmeticweaponsmod) are content-only mods
that add craftable items - no custom player storage, fully handled
by existing inventory sync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:43:42 +01:00
laforetbrut
5576d7f7e2 Add anti-duplication locks, shutdown save, and security hardening
- Per-player ReentrantLock prevents concurrent save/restore operations,
  eliminating race conditions that could cause item duplication
- Save ALL online players on ServerStoppingEvent (before disconnect) to
  prevent data loss from server shutdowns/restarts
- Lock acquired before restore on join, released in finally block
- Lock acquired before save on logout, cleaned up after completion
- Verified compatibility with 430-mod Arcadia V2 modpack:
  - All item DataComponents from all mods preserved via BNBT serialization
  - Curios items (Artifacts, Elytra Slot, Charm of Undying, etc.) synced
  - Accessories items (Aether, Deep Aether) synced
  - Server-specific data (FTB Quests/Chunks, Waystones, Lootr) correctly
    NOT synced as intended

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:39:44 +01:00
laforetbrut
c63d5849a3 Add mod compatibility: Accessories (Aether), Cosmetic Armor, Apotheosis
- Add Accessories API sync for Aether mod accessory slots (pendant, cape,
  gloves, rings, shield, misc). Uses same pattern as Curios: validate data
  before clearing slots, PreparedStatements for DB operations
- Add Cosmetic Armor Reworked sync for 4 cosmetic armor slots via
  InventoryManager/CosArmorAPI
- Add Apotheosis + Placebo as compileOnly deps. Apotheosis item data
  (affixes, gems, sockets, rarity) travels with items via DataComponents
  and is already synced by the inventory sync
- New generic mod_player_data DB table with composite key (uuid, mod_id)
  for extensible mod-specific data storage
- Integrated save/restore in join, logout, and auto-save pipelines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:21:09 +01:00
laforetbrut
03b57c3e6b Fix critical sync bugs, security, and add Sophisticated Storage support
- Fix advancements disappearing: use PreparedStatements for all SQL with
  user data (advancement JSON contains chars that broke string-concat SQL),
  add null safety for advancement file
- Fix multi-server kick: run doPlayerConnect synchronously instead of async
  (players could join before the duplicate check completed)
- Fix Curios disappearing: clear slots AFTER validating data exists (not
  before), use CuriosCache for dead players on logout instead of empty API
- Fix Sophisticated Storage items: add storeSophisticatedStorageItems() and
  restoreSophisticatedStorageItems() to sync packed barrels/shulkers/chests
- Anti-duplication: clear all inventories before restoring from DB on join
- Fix tick counter: remove LevelTickEvent (fired per dimension = 3x too
  fast), merge heartbeat into ServerTickEvent
- Fix connection leaks: use try-with-resources for all QueryResult
- Fix logout order: save data BEFORE marking player offline
- Skip auto-save for dead/unsynced players to prevent saving empty data

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:04:00 +01:00
mlus
148ac4db9b Revert "fallback BNBT, Compat with codec"
This reverts commit ce7004dba0.
2026-02-24 10:24:13 +08:00
mlus
ce7004dba0 fallback BNBT, Compat with codec 2026-02-24 10:20:27 +08:00
mlus
201e63a322 Fix SQL syntax by adding backticks around database and table names 2026-02-24 00:11:06 +08:00
mlus
4b39d52c12 Add binary NBT serialization and deserialization support to improve data handling 2026-02-23 23:53:41 +08:00
mlus
b6da709393 curios snbt clean 2026-02-23 22:33:13 +08:00
mlus
bc71c59a45
Change pokedex column type to MEDIUMBLOB 2026-02-21 16:14:56 +08:00
mlus
d0044fa824 snbt structure clean 2026-02-17 19:08:34 +08:00
mlus
d8c3bac31f new nbt serializer 2026-02-17 15:41:45 +08:00
mlus
0c51ad8eb7 try to fix component parse error 2026-02-17 14:27:45 +08:00
mlus
d4a2568f16 fix crash with too many cobblemon in pc 2026-02-08 22:21:37 +08:00
mlus
38c88a95f9 fix #151
fix #160
2026-01-14 20:26:26 +08:00
mlus
e373b8c226 add cobblemon support(in test) 2025-12-15 22:47:47 +08:00
mlus
72d0255d48 fix advancements sync 2025-11-30 01:57:26 +08:00
mlus
90742aafa0 fix backpack didn't sync 2025-11-30 00:50:55 +08:00
mlus
733f37cbb3 supplement 2025-11-28 22:15:29 +08:00
mlus
29da0f28ad recently commit port 2025-11-28 21:00:25 +08:00
mlus
b5e5f9fb65 line 155 make method return so curios data won't save at the first time 2025-10-14 16:56:47 +08:00
mlus
260b24975c heartbeat 2025-10-14 16:56:25 +08:00
mlus
62b0cf15bc chat sync reconnect system 2025-10-14 16:55:24 +08:00
dependabot[bot]
f06e6a6632 Bump gradle/actions from 4 to 5
Bumps [gradle/actions](https://github.com/gradle/actions) from 4 to 5.
- [Release notes](https://github.com/gradle/actions/releases)
- [Commits](https://github.com/gradle/actions/compare/v4...v5)

---
updated-dependencies:
- dependency-name: gradle/actions
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-14 16:55:21 +08:00
mlus
07709ad792 may fix #111 2025-09-25 23:03:17 +08:00
mlus
fc043e1e03 half done, noticed about advancement can't store normally 2025-06-07 00:55:30 +08:00
mlus
3b442fbee1 not done yet 2025-06-06 21:17:22 +08:00
mlus
79e0e2cbe4 Fix error when no player in server 2025-06-06 13:09:32 +08:00
mlus
0562b01138 Full tested ChatSync Feature 2025-06-05 12:43:41 +08:00
mlus
74451eecff
Merge pull request #65 from EoD/1.20.4-neoforge
Add support for 1.20.4 using NeoForge 20.4.248
2025-05-05 02:53:30 +08:00
EoD
22b628bdcb fix sophisticated backpack integration for 1.20.4 2025-05-04 18:43:11 +00:00
EoD
9eb8bdc4a0 add support for Minecraft 1.20.4 with ModDevGradle 2025-05-04 18:43:11 +00:00
EoD
bcb55c5a67 Revert "register JDBC driver to work around Forge bug"
This reverts commit ce0e173a9e.
2025-05-04 18:21:32 +00:00
mlus
606b9e1c1e
Merge pull request #62 from EoD/version-compat
encode unknown items using Paper
2025-05-05 02:03:03 +08:00
mlus
110a2baaa5
Merge pull request #64 from EoD/automatic-releases
Automatic Mod Releases
2025-05-05 01:37:18 +08:00
EoD
9ebcb65233 automatically release mod when pushing tags 2025-05-04 17:17:04 +00:00
EoD
0e8527a9f1 rename build-1.20.yml to build.yml 2025-05-04 16:54:17 +00:00
EoD
9f256df298 bump version to 2.1.0 2025-05-04 16:48:57 +00:00
EoD
6ac6f297af encode unknown items using Paper
This allows using PlayerSync with different minecraft versions and
even different sets of mods.

All unknown items are replaced by Paper with its original NBT data
encoded into the paper item.
2025-05-04 16:48:57 +00:00
mlus
ba879dabdb
Merge pull request #63 from EoD/disable-chat-sync-by-default
disable chat sync by default
2025-05-04 20:29:22 +08:00
mlus
39b69424e8 so it is 2.0.0 release 2025-05-04 18:40:39 +08:00
EoD
14ea54fcf3 disable chat sync by default 2025-05-03 21:50:17 +00:00
mlus
74f348c2c4
Merge pull request #61 from EoD/bump-version
bump mod version to 2.0.0
2025-05-04 00:34:54 +08:00
EoD
20e1759b46 bump mod version to 2.0.0 2025-05-03 16:30:01 +00:00
mlus
cfe6467b36
Merge pull request #60 from EoD/run-ci-on-all-1.x-branches
run build CI on all 1.xxx branches
2025-05-04 00:27:42 +08:00
EoD
09b33848e9 run build CI on all 1.xxx branches 2025-05-03 16:21:00 +00:00
mlus
d9ea1e97e2
Merge pull request #59 from EoD/fix-deprecated-ci
Update deprecated Gradle Actions
2025-05-04 00:16:00 +08:00