Add Container Lookup and Area Query Support#854
Open
Restitutor wants to merge 2 commits intoPlayPro:masterfrom
Open
Add Container Lookup and Area Query Support#854Restitutor wants to merge 2 commits intoPlayPro:masterfrom
Restitutor wants to merge 2 commits intoPlayPro:masterfrom
Conversation
Restitutor
commented
Feb 8, 2026
| import net.coreprotect.utility.WorldUtils; | ||
| import org.bukkit.Location; | ||
| import org.bukkit.block.Block; | ||
|
|
Author
There was a problem hiding this comment.
IDE moved imports let me know if you want me to revert this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
CoreProtect logs container transactions but doesn't expose dedicated lookup methods in the public API. Plugin developers must use the generic
performLookup()withaction=4and parseString[]arrays.Use case: Anti-theft plugins that detect when players take items from containers they didn't deposit. This requires querying container history by location. BoxAPI allows for region based searches to scan a player base in a single query.
Changes
1.
ContainerResult— Typed result objectNew:
api/result/ContainerResult.javaImmutable result class for container transactions with typed accessors:
getTimestamp(),getPlayer(),getX/Y/Z(),worldName()getType()(Material),getData(),getAmount(),getMetadata()getActionId()/getActionString()(0=remove, 1=add)isRolledBack()2. Single-location container lookup
New:
BlockAPI.performContainerLookup(Location, offset)Returns
List<ContainerResult>for all container transactions at a location within the time window.Refactored
BlockAPI.performLookup()to usePreparedStatementvia sharedcreateLocationQuery()helper. Both block and container lookups now use parameterized queries.3. Area-based queries
New:
api/BoxAPI.javaQuery containers and blocks across bounding boxes or radii:
Container methods:
performAreaContainerLookup(World, BoundingBox, offset)performCubicContainerLookup(World, x, y, z, radius, offset)— cubic areaperformSphericalContainerLookup(World, x, y, z, radius, offset)— spherical filteringBlock methods:
performAreaLookup(World, BoundingBox, offset)→List<String[]>performCubicLookup(...),performSphericalLookup(...)Safety features:
PreparedStatementwith parameterized queries4. Public API entry point
New:
CoreProtectAPI.containerLookup(Location, time)Convenience wrapper that calls
BlockAPI.performContainerLookup(). Follows the same pattern asblockLookup().Usage Example
No breaking changes: Existing
BlockAPI.performLookup()behavior is unchanged; internal refactor toPreparedStatementis transparent.We could add methods to the CoreProtectAPI instead of having clients use BlockAPI and BoxAPI directly. Let me know what you would prefer.