Skip to content

✨ feat(block-pdc): enhance persistent data container handling for blocks#343

Merged
twisti-dev merged 5 commits into
version/26.1from
fix/copy-to-in-block-pdc
May 11, 2026
Merged

✨ feat(block-pdc): enhance persistent data container handling for blocks#343
twisti-dev merged 5 commits into
version/26.1from
fix/copy-to-in-block-pdc

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and new features related to block persistent data containers (PDC) in the Surf API for Paper, enhances test plugin capabilities, and includes various utility and maintenance updates. The most significant changes are the addition of a comprehensive test command for block PDC operations, refactoring and optimization of PDC handling, and improved configuration for test environments.

Block Persistent Data Container (PDC) Improvements

  • Added the BlockPdcContainerTest command, providing a suite of subcommands (set, get, list, clear, copy-near, copy-far) for testing block-level PDC operations, including advanced copy tests across regions. ([[1]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-6eca36e8879fd97e968cdaf866674f54512159e4417e9611a69a121fef4a2e13R1-R228), [[2]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-55d4e84be3738641b06fcd462c85e60b18dbbfc2c25ed5658d6fc7a9d990e98eL33-R34))
  • Refactored piston event PDC handling to use CustomBlockPersistentDataContainer directly, optimizing copy and clear operations and improving type safety. ([[1]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-c1342adc8a4d6812c2defe7fe1db698801a091094cd750e855fd284cdd0d7c02R25-L27), [[2]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-c1342adc8a4d6812c2defe7fe1db698801a091094cd750e855fd284cdd0d7c02L38-L39), [[3]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-c1342adc8a4d6812c2defe7fe1db698801a091094cd750e855fd284cdd0d7c02L167-R185))
  • Updated PDC provider implementation to enforce tick thread access for block PDCs, improving thread safety. ([surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/impl/pdc/block/BlockPdcProviderImpl.ktR6-R12](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-63c0fd1d516396e4883ece70e58acbf5741dd18c95ee8766c2476c3afa68b8d9R6-R12))
  • Improved CustomBlockData by using a weak reference for chunk storage, enhancing memory management, and refactored key generation for better reusability. ([[1]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-2c137158554c90de41417c6ff66790116a254111c96450ce45745e7a150f89b6R34-R39), [[2]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-2c137158554c90de41417c6ff66790116a254111c96450ce45745e7a150f89b6L62-R67), [[3]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-2c137158554c90de41417c6ff66790116a254111c96450ce45745e7a150f89b6L135-R144))

Test Plugin and Build System Enhancements

  • Added xyz.jpenilla.runpaper.task.RunServer and improved runServer/runPaper task configuration to support Folia and conditional plugin downloads, enhancing test automation and compatibility. ([[1]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-2c2926e89c5b22702585aa2b98aec2db9fbeff33cb0d2c944949b5f8b9301113R2), [[2]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-2c2926e89c5b22702585aa2b98aec2db9fbeff33cb0d2c944949b5f8b9301113R28), [[3]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-2c2926e89c5b22702585aa2b98aec2db9fbeff33cb0d2c944949b5f8b9301113L43-R45), [[4]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-2c2926e89c5b22702585aa2b98aec2db9fbeff33cb0d2c944949b5f8b9301113R54-R74))
  • Updated Minecraft version to 26.1.2 in gradle.properties. ([gradle.propertiesL8-R8](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-3d103fc7c312a3e136f88e81cef592424b8af2464c468116545c4d22d6edcf19L8-R8))

Utility and Documentation Improvements

  • Added utility functions and improved documentation for conversions between Bukkit and Sponge types, and for player/UUID mapping utilities. ([[1]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-28001ce9fe8aa3617c00b9e01bb8eebf891191e395cf19df72abb15f66fb6ff2R31), [[2]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-28001ce9fe8aa3617c00b9e01bb8eebf891191e395cf19df72abb15f66fb6ff2R143-R148), [[3]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-28001ce9fe8aa3617c00b9e01bb8eebf891191e395cf19df72abb15f66fb6ff2R165-R170), [[4]](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-28001ce9fe8aa3617c00b9e01bb8eebf891191e395cf19df72abb15f66fb6ff2R181-R186))

Minor Code Cleanups

  • Broadened import of dev.jorel.commandapi.* for improved code clarity. ([surf-api-paper/surf-api-paper-plugin-test/src/main/java/dev/slne/surf/api/paper/test/command/SurfApiTestCommand.javaL3-R3](https://github.com/SLNE-Development/surf-api/pull/343/files#diff-55d4e84be3738641b06fcd462c85e60b18dbbfc2c25ed5658d6fc7a9d990e98eL3-R3))

These changes collectively improve the reliability, testability, and maintainability of block PDC features in the Surf API.

- implement custom block persistent data container for improved data management
- update piston handling to utilize new persistent data structure
- add BlockPdcContainerTest for testing block persistent data commands
@twisti-dev twisti-dev self-assigned this May 11, 2026
Copilot AI review requested due to automatic review settings May 11, 2026 12:57
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ API/ABI changes detected!

This PR contains changes that modified the public API. To update the reference ABI dumps:

./gradlew updateKotlinAbi
git add **/api/**
git commit -m "Update ABI reference"
git push

After updating, the CI will pass. Make sure the changes are backward compatible.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances Surf API’s Paper block PersistentDataContainer (PDC) tooling and safety, primarily by improving block-PDC move/copy handling and adding a dedicated test command suite in the Paper test plugin.

Changes:

  • Added a comprehensive /surfapitest blockpdc test command for setting/getting/listing/clearing and copying block PDC across regions.
  • Refactored block PDC persistence/copy internals (including piston move handling) and added tick-thread enforcement when accessing block PDCs.
  • Improved Paper test runtime tasks (Folia support, conditional plugin downloads) and bumped Minecraft/version properties.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/util/bukkit-util.kt Adds utility conversions and async chunk helpers used by test tooling and async world access.
surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/impl/pdc/block/CustomBlockData.kt Refines CustomBlockData internals (weak chunk ref, key helpers) and changes copy semantics.
surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/impl/pdc/block/BlockPdcProviderImpl.kt Enforces tick-thread access when retrieving a block PDC.
surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/impl/pdc/block/BlockDataListener.kt Refactors piston PDC move handling to use CustomBlockPersistentDataContainer directly.
surf-api-paper/surf-api-paper-plugin-test/src/main/kotlin/dev/slne/surf/surfapi/bukkit/test/command/subcommands/BlockPdcContainerTest.kt New test subcommand implementing set/get/list/clear and near/far copy validation.
surf-api-paper/surf-api-paper-plugin-test/src/main/java/dev/slne/surf/api/paper/test/command/SurfApiTestCommand.java Registers the new blockpdc subcommand under the test command root.
surf-api-paper/surf-api-paper-plugin-test/build.gradle.kts Updates run tasks to support Folia and conditional plugin downloads for local testing.
gradle.properties Bumps mcVersion and project version.

…lock

- clear the persistent data container of the block before copying data from pdc
- ensure no residual data remains in the block's pdc after the copy operation
@twisti-dev twisti-dev merged commit 25df7bb into version/26.1 May 11, 2026
4 of 7 checks passed
@twisti-dev twisti-dev deleted the fix/copy-to-in-block-pdc branch May 11, 2026 18:39
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ API/ABI changes detected!

This PR contains changes that modified the public API. To update the reference ABI dumps:

./gradlew updateKotlinAbi
git add **/api/**
git commit -m "Update ABI reference"
git push

After updating, the CI will pass. Make sure the changes are backward compatible.

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.

2 participants